3 from Data.Maybe import :: Maybe
4 from StdOverloaded import class toString
7 * Type errors can happen in either
8 * - variable declarations (x :: Int = True)
9 * - function declarations (f :: (Char -> Int) = (+)1)
10 * - Expressions (1 + 'a')
11 * So these are the items that will get position metadata
14 :: Pos = {line :: Int, col :: Int}
16 :: AST = AST [VarDecl] [FunDecl]
17 :: VarDecl = VarDecl Pos Type String Expr
19 = TupleType (Type, Type)
28 | Op2Expr Pos Expr Op2 Expr
29 | Op1Expr Pos Op1 Expr
35 | TupleExpr Pos (Expr, Expr)
36 :: VarDef = VarDef String [FieldSelector]
37 :: FieldSelector = FieldHd | FieldTl | FieldFst | FieldSnd
38 :: Op1 = UnNegation | UnMinus
39 :: Op2 = BiPlus | BiMinus | BiTimes | BiDivide | BiMod | BiEquals | BiLesser |
40 BiGreater | BiLesserEq | BiGreaterEq | BiUnEqual | BiAnd | BiOr | BiCons
42 :: FunDecl = FunDecl Pos String [String] (Maybe FunType) [VarDecl] [Stmt]
43 :: FunType = FunType [Type] (Maybe Type)
44 :: FunCall = FunCall String [Expr]
46 = IfStmt Expr [Stmt] [Stmt]
47 | WhileStmt Expr [Stmt]
50 | ReturnStmt (Maybe Expr)