Skip to content

Instantly share code, notes, and snippets.

@warpr
Created September 16, 2013 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warpr/6583496 to your computer and use it in GitHub Desktop.
Save warpr/6583496 to your computer and use it in GitHub Desktop.
import System.Exit( exitWith, ExitCode(..) )
exit = exitWith ExitSuccess
die = exitWith $ ExitFailure 1
readSomething :: String -> Either String String
readSomething s = Right (s ++ " -> 200 OK")
readSomethingElse :: String -> Either String String
readSomethingElse s = Left (s ++ " -> 404 NOT FOUND")
doStuff = readSomething "aap"
main = case doStuff of
Right something -> putStrLn something >> exit
Left errmsg -> putStrLn errmsg >> die
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment