Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created September 3, 2013 08:36
Show Gist options
  • Select an option

  • Save pasberth/6421190 to your computer and use it in GitHub Desktop.

Select an option

Save pasberth/6421190 to your computer and use it in GitHub Desktop.
つらぽよい Conditional
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