Hi José,<br><br><div class="gmail_quote">2010/7/19 José Romildo Malaquias <span dir="ltr"><<a href="mailto:j.romildo@gmail.com">j.romildo@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
I am writing here to ask suggestions on how to annotate an ast with<br>
types (or any other information that would be relevant in a compiler<br>
phase) in Haskell.<br>
<br>
As an example, consider the simplified ast types:<br>
<br>
data Exp<br>
= IntExp Integer<br>
| VarExp Symbol<br>
| AssignExp Symbol Exp<br>
| IfExp Exp Exp (Maybe Exp)<br>
| CallExp Symbol [Exp]<br>
| LetExp [Dec] Exp<br>
<br>
data Dec<br>
= TypeDec Symbol Ty<br>
| FunctionDec Symbol [(Symbol,Symbol)] (Mybe Symbol) Exp<br>
| VarDec Symbol (Maybe Symbol) Exp<br>
<br>
Expressions can have type annotations, but declarations can not.<br>
<br>
Comments?<br></blockquote><div><br>Indeed I would suggest the method described in our paper:<br><br>Martijn van Steenbergen, José Pedro Magalhães, and
Johan Jeuring.
<span class="bold">Generic selections of subexpressions</span>.
<br>Paper link: <a href="http://dreixel.net/research/pdf/gss_draft.pdf">http://dreixel.net/research/pdf/gss_draft.pdf</a><br>Related hackage package: <a href="http://hackage.haskell.org/package/Annotations">http://hackage.haskell.org/package/Annotations</a><br>
<br>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).<br>
<br><br>Cheers,<br>Pedro<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
<br>
Regards,<br>
<br>
Romildo<br>
<font color="#888888">--<br>
Computer Science Department<br>
Universidade Federal de Ouro Preto, Brasil<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></blockquote></div><br>