Last active
December 15, 2016 12:23
-
-
Save kseo/3a33d9b16565079fe409 to your computer and use it in GitHub Desktop.
GADT
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
{-# LANGUAGE GADTs #-} | |
data Expr a where | |
I :: Int -> Expr Int | |
B :: Bool -> Expr Bool | |
Add :: Expr Int -> Expr Int -> Expr Int | |
Mul :: Expr Int -> Expr Int -> Expr Int | |
Eq :: Expr Int -> Expr Int -> Expr Bool | |
eval :: Expr a -> a | |
eval (I n) = n | |
eval (B b) = b | |
eval (Add e1 e2) = eval e1 + eval e2 | |
eval (Mul e1 e2) = eval e1 * eval e2 | |
eval (Eq e1 e2) = eval e1 == eval e2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment