Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created January 13, 2010 01:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jutememo/275830 to your computer and use it in GitHub Desktop.
Save jutememo/275830 to your computer and use it in GitHub Desktop.
class Boolean b where
isTrue :: b -> Bool
instance Boolean Bool where
isTrue True = True
isTrue False = False
instance Boolean Integer where
isTrue 0 = False
isTrue _ = True
instance Boolean [a] where
isTrue [] = False
isTrue _ = True
if' x e1 e2 = if isTrue x then e1 else e2
(&&&) e1 e2 = if' e1 e2 e1
(|||) e1 e2 = if' e1 e1 e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment