Skip to content

Instantly share code, notes, and snippets.

@kkirsanov
Last active June 13, 2019 08:14
Show Gist options
  • Save kkirsanov/1447368 to your computer and use it in GitHub Desktop.
Save kkirsanov/1447368 to your computer and use it in GitHub Desktop.
data Logic a where
B :: Bool -> Logic Bool
And :: Logic Bool -> Logic Bool -> Logic Bool
Or :: Logic Bool -> Logic Bool -> Logic Bool
Imp :: Logic Bool -> Logic Bool -> Logic Bool
Not :: Logic Bool -> Logic Bool
imp :: Bool->Bool->Bool
imp False _ = True
imp True True = True
imp _ _ = False
eval :: Logic a -> a
eval (B a) = a
eval (And e1 e2) = (eval e1) && (eval e2)
eval (Or e1 e2) = (eval e1) || (eval e2)
eval (Imp e1 e2) = imp (eval e1) (eval e2)
eval (Not e) = not $ eval e
eval $ (B True) `And` (B False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment