Skip to content

Instantly share code, notes, and snippets.

@avh4
Last active June 12, 2016 19:43
Show Gist options
  • Save avh4/827b48ea529cfcf3b9973092a958c68d to your computer and use it in GitHub Desktop.
Save avh4/827b48ea529cfcf3b9973092a958c68d to your computer and use it in GitHub Desktop.
IO Either
import Control.Monad.Except (ExceptT, runExceptT)
import Data.Functor.Identity (Identity)
start :: ExceptT String IO String
start =
return "start"
next1 :: String -> String
next1 first = first ++ " next1"
next2 :: Monad m => String -> ExceptT String m String
next2 first =
return $ first ++ " next2"
next3 :: String -> ExceptT String IO String
next3 first =
return $ first ++ " next3"
main' :: ExceptT String IO String
main' =
do
a <- start
let b = next1 a
c <- next2 b
d <- next3 c
return d
main :: IO ()
main =
do
result <- runExceptT main'
putStrLn $ show result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment