Skip to content

Instantly share code, notes, and snippets.

@raek
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raek/be13f53d0292c4f0f3e5 to your computer and use it in GitHub Desktop.
Save raek/be13f53d0292c4f0f3e5 to your computer and use it in GitHub Desktop.
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