[Template-haskell] instance of Lift for Exp

Simon Peyton-Jones simonpj at microsoft.com
Tue Jul 20 06:06:42 EDT 2004


Thanks for the offer.

Has anyone else encountered a need for this?  Duncan, would you like to
give some motivating examples?  For the present, I'm inclined to leave
it as a user library.

Simon

| -----Original Message-----
| From: template-haskell-bounces at haskell.org
[mailto:template-haskell-bounces at haskell.org] On
| Behalf Of Duncan Coutts
| Sent: 08 June 2004 19:45
| To: Template Haskell List
| Subject: [Template-haskell] instance of Lift for Exp
| 
| 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


More information about the template-haskell mailing list