Changes between Version 1 and Version 2 of TemplateHaskellRichKinds

Mar 20, 2012 1:46:48 PM (6 years ago)



  • TemplateHaskellRichKinds

    v1 v2  
    22== Changes to Template Haskell Library ==
     4Throughout this document, it is assumed that the current version of GHC is 7.4.1.
    46A proposed change will add the following constructors to TH's {{{Type}}} datatype...
    1921The final {{{Kind}}} constructor does not need any special binder construct because all kinds are of sort {{{BOX}}}.
     23TH will also need to support promoted constructors other than lists and tuples, but this is in fact already supported through the use of {{{ConT}}}. The namespace of defined types and of promoted types is already kept distinct. For example, if we have the definition {{{data Foo = Foo}}}, the results of {{{ [t| Foo |] }}} and {{{ [t| 'Foo |] }}} are distinct (as in, {{{==}}} returns {{{False}}}). However, applying {{{show}}} to these two results produces the same string.
     25The one place TH needs to be updated to handle promoted data constructors is in the naming quote syntax. Currently, writing {{{'Foo}}} in an expression context within a splice looks {{{Foo}}} up in the expression namespace; TH will find a data constructor named {{{Foo}}} and return its {{{Name}}}. Writing {{{''Foo}}} in an expression context within a splice looks {{{Foo}}} up in the type namespace; TH will find a type constructor named {{{Foo}}} and return its name. There is currently no way to look up a promoted data constructor. The update will include a third form of quote, {{{'''Foo}}}, which gets the name of a promoted data constructor {{{Foo}}}. Though having three quotes is somewhat regrettable, it dovetails nicely with the fact that {{{'Foo}}}, when used in a type context, refers to a promoted data constructor. If we think of the first two quotes as establishing a type context, the third quote flows naturally.