
19 Jul
2010
19 Jul
'10
2:59 p.m.
I would be inclined to add type annotations as an extra constructor of the expression representation type.
data Exp = IntExp Integer | VarExp Symbol | AssignExp Symbol Exp | IfExp Exp Exp (Maybe Exp) | CallExp Symbol [Exp] | LetExp [Dec] Exp
| Exp `HasType` Ty This is particularly useful if the source language allows arbitrary type annotations on expressions, because it can cover both the user- supplied annotations, and the compiler-inferred ones. Also, your type inference phase is free to add as many or as few annotations into the AST as it wishes - they are not required everywhere. Regards, Malcolm