[Template-haskell] instance of Lift for Exp

Duncan Coutts duncan.coutts at worcester.oxford.ac.uk
Tue Jun 8 14:44:58 EDT 2004


Hi all,

the Exp type is not an instance of the Lift class. This is the sensible
thing most of the time so that you do not lift an expression when you
meant to splice it instead.

However in my experience it's sometimes useful (particularly when
writing code that generates code), so attached is a module which makes
it an instance. Like Text.Show.Functions, you should only import it if
you want it, not import it by default.

If people find this useful, I'd be quite happy to have it added to the
standard GHC TH libs. I've named it Language.Haskell.TH.LiftExp and
released it under GHC's BSD-style licence.

Issues:
      * At the moment it also exports instances for Ratio, Maybe,
        PackedString, (,) and (,,). In my opinion these instances should
        be exported from Language.Haskell.TH already in which case they
        could be deleted from this module. (Exporting the instance for
        PackedString and Ratio is not strictly necessary and perhaps not
        desirable.)
      * The encoding for unboxed integers is not pleasant. (Unboxed Ints
        are used in the definition of Name). If anyone can find a more
        straightforward encoding please tell me.

Duncan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LiftExp.hs
Type: text/x-haskell
Size: 6302 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/template-haskell/attachments/20040608/9358b205/LiftExp.bin


More information about the template-haskell mailing list