Last active
June 13, 2019 08:14
-
-
Save kkirsanov/1447368 to your computer and use it in GitHub Desktop.
This file contains 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
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