Skip to content

Instantly share code, notes, and snippets.

@bananaumai
Last active February 20, 2017 00:08
Show Gist options
  • Select an option

  • Save bananaumai/ebd896dc6c266080cb42ed7f701505b9 to your computer and use it in GitHub Desktop.

Select an option

Save bananaumai/ebd896dc6c266080cb42ed7f701505b9 to your computer and use it in GitHub Desktop.
module Main where
import Prelude (Unit, bind, unit, (+))
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE)
import Data.Maybe (Maybe(..))
import Data.Int (fromString)
import Web.Cookies (COOKIE, getCookie, setCookie)
main :: forall eff. Eff (console :: CONSOLE, cookie :: COOKIE | eff) Unit
main = do
ck <- getCookie "_bnn"
case ck of Just v -> case fromString v of Just n -> setCookie "_bnn" (n+1) unit
Nothing -> setCookie "_bnn" 1 unit
Nothing -> setCookie "_bnn" 1 unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment