[Template-haskell] Reification of local names

Simon Peyton-Jones simonpj at microsoft.com
Tue Jun 22 09:36:33 EDT 2004

| > One idea: add (Maybe Type) fields to many TH syntax forms, where the
| > type checker can record types.  That's simple and direct.
| This is actually the way how we implemented it in Nemerle. Our syntax
| has elements like E_typed { body : Typedtree.Expr } in Parsetree.Expr
| T_typed { body : Typedtree.Type } in Parsetree.Type, so we can store
| parts in our ASTs.
| Our quotations support this with
| <[  $(e : typed) ]>  where `e' is a variable holding typed tree of
| We can also build typed trees for types with quotation like
| <[ ttype: int ]>

Interesting ... but I'm afraid I don't understand what these notations

Suppose you want to build a data structure from the original
constructors, by hand as it were.  (Which Template Haskell certainly
allows you to do.)  You don't want to supply all the types!  If pattern
match over this structure, you aren't going to see types.  So the types
must somehow be optional.  I don't want to have two completely
different, but similar, data structures, one with types and one without.
Hence the 'Maybe' part.  Is that what you have?


More information about the template-haskell mailing list