Last active
August 29, 2015 14:15
-
-
Save raek/be13f53d0292c4f0f3e5 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 Exp = Lit Integer | |
| Add Exp Exp | |
| Sub Exp Exp | |
| Mul Exp Exp | |
| Neg Exp | |
| Abs Exp | |
| Sgn Exp | |
| Var Var | |
deriving Show | |
type Var = String | |
instance Num Exp where | |
(+) = Add | |
(-) = Sub | |
(*) = Mul | |
negate = Neg | |
abs = Abs | |
signum = Sgn | |
fromInteger = Lit | |
-- subtract (Var "x") (Var "y") :: Exp | |
-- => Sub (Var "y") (Var "x") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment