module Hajspy where data Expr = Var String | Expr :@: Expr -- function application | Neg Expr -- unary prefix - | Expr :*: Expr -- infix * | Expr :/: Expr -- infix / | Expr :+: Expr -- infix + | Expr :-: Expr -- infix - | Cond Expr Expr Expr -- "x if c else y" -> Cond c x y, note order change | Lambda String Expr deriving (Eq, Show) {- What does "Expr :@: Expr" mean? Answer: If you understand "App Expr Expr" as saying that App is a data constructor with two fields, then "Expr :@: Expr" means the same thing, except that the data constructor is :@: and uses infix syntax. This is in hope that f :@: x :@: y looks nicer than App (App f x) y Similarly for the others. See testParser.hs for usage examples. And below specifies their precedence and associativity. -} infixl 9 :@: infixl 7 :*:, :/: infixl 6 :+:, :-: