Skip to content

Instantly share code, notes, and snippets.

@andyfriesen
Created July 6, 2012 14:14
Show Gist options
  • Save andyfriesen/3060411 to your computer and use it in GitHub Desktop.
Save andyfriesen/3060411 to your computer and use it in GitHub Desktop.
module Main (
main
) where
import Control.Monad.Trans.Either
import Data.List (stripPrefix)
import Data.Char(isUpper)
import System.Exit (exitFailure)
import Test.QuickCheck.All (quickCheckAll)
getName :: IO (Either Int String)
getName = do
putStr "Hurp: "
s <- getLine
return $ if isUpper (head s) then Right s
else Left 0
m :: IO (Either Int String)
m = runEitherT $ do
n1 <- EitherT getName
n2 <- EitherT getName
return (n2 ++ n1)
main = do
name <- m
case name of
Left n -> putStrLn $ "Left " ++ (show n)
Right n -> putStrLn n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment