Created
September 3, 2013 08:36
-
-
Save pasberth/6421190 to your computer and use it in GitHub Desktop.
つらぽよい Conditional
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
| module Main | |
| class Conditional a where | |
| toBool : a -> Bool | |
| instance Conditional Bool where | |
| toBool = id | |
| instance Conditional String where | |
| toBool "" = False | |
| toBool _ = True | |
| (&&&&&) : (Monad m, Conditional a) => m a -> m a -> m a | |
| m &&&&& k = do { x <- m ; if toBool x then k else return x } | |
| main : IO () | |
| main = do | |
| x <- (&&&&&) getLine getLine | |
| putStr $ "\"" ++ x ++ "\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment