Instantly share code, notes, and snippets.

What would you like to do?
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