Skip to content

Instantly share code, notes, and snippets.

@virtualsafety
Last active December 23, 2015 11:59
Show Gist options
  • Save virtualsafety/6632668 to your computer and use it in GitHub Desktop.
Save virtualsafety/6632668 to your computer and use it in GitHub Desktop.
import Control.Monad.State
import Control.Monad.Identity
import Data.Char(toUpper)
test1 :: State Int (Int,Int)
test1 = do
a <- get
modify (+1)
b <- get
return (a,b)
test2 :: State [Char] ([Char],[Char])
test2 = do
a <- get
modify (++"1")
b <- get
return (a,b)
--let go1 = evalState test1 0
--let go2 = evalState test2 "0"
test3 :: StateT Int ( StateT [Char] Identity ) (Int, [Char])
test3 = do
modify (+1)
lift $ modify (++ "1")
a <- get
b <- lift get
return (a,b)
--let go3 = runIdentity $ evalStateT (evalStateT test3 0) "0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment