[Haskell-cafe] Tiger compiler in Haskell: annotating abstract
José Pedro Magalhães
jpm at cs.uu.nl
Tue Jul 20 03:17:15 EDT 2010
2010/7/19 José Romildo Malaquias <j.romildo at gmail.com>
> 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.
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).
> Computer Science Department
> Universidade Federal de Ouro Preto, Brasil
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe