Created
November 2, 2015 13:22
-
-
Save lotz84/7024765e609b952bf2a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.Trans.Maybe | |
import Control.Monad.IO.Class | |
import Data.List | |
env :: [(String, Int)] | |
env = [("x", 1), ("y", 2), ("z", 3)] | |
main :: IO () | |
main = do | |
result <- runMaybeT $ do | |
n <- mb $ lookup "x" env | |
q <- liftIO $ getLine | |
mb $ if q /= "q" then Just q else Nothing | |
putStrLn $ maybe "quit!" id $ result | |
where | |
mb = MaybeT . pure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment