
Hi José,
2010/7/19 José Romildo Malaquias
I am writing here to ask suggestions on how to annotate an ast with types (or any other information that would be relevant in a compiler phase) in Haskell.
As an example, consider the simplified ast types:
data Exp = IntExp Integer | VarExp Symbol | AssignExp Symbol Exp | IfExp Exp Exp (Maybe Exp) | CallExp Symbol [Exp] | LetExp [Dec] Exp
data Dec = TypeDec Symbol Ty | FunctionDec Symbol [(Symbol,Symbol)] (Mybe Symbol) Exp | VarDec Symbol (Maybe Symbol) Exp
Expressions can have type annotations, but declarations can not.
Comments?
Indeed I would suggest the method described in our paper: Martijn van Steenbergen, José Pedro Magalhães, and Johan Jeuring. Generic selections of subexpressions. Paper link: http://dreixel.net/research/pdf/gss_draft.pdf Related hackage package: http://hackage.haskell.org/package/Annotations Something like what Malcolm proposed (adding one extra constructor) would also be possible generically, but it would be more similar to how we add meta-variables in our generic rewriting library (ask for more details if you're interested in this alternative). Cheers, Pedro
Regards,
Romildo -- Computer Science Department Universidade Federal de Ouro Preto, Brasil _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe