What `reify` sees in Template Haskell
Simon Peyton Jones
simonpj at microsoft.com
Fri Feb 13 17:12:47 UTC 2015
| 1. would it be possible to revert to the old behavior easily, or is
| doing that difficult or impossible now given the overall changes to
| the Template Haskell code?
I don’t think it would be difficult to recover the old behaviour, but it's not clear to me that it would be a Good Thing. A program that works today, and then does not work tomorrow because of some incidental change to the way type inference works, would not be a happy state of affairs.
Perhaps if 'x' had a type annotation that would be ok. Or maybe there is something else about your intended application that makes it solidly predictable.
By all means start a wiki page to sketch a design for what you think should happen, and why it should be predicable.
Meanwhile, if you would care to draft the bit of user-manual material that you wish had been there, I could review it and put it in.
Thanks!
Simon
| -----Original Message-----
| From: Francesco Mazzoli [mailto:f at mazzo.li]
| Sent: 13 February 2015 12:54
| To: ghc-devs at haskell.org
| Cc: Simon Peyton Jones
| Subject: What `reify` sees in Template Haskell
|
| Hi,
|
| I recently stumbled upon the issue of `reify` not being able to give
| information about local variables, as of GHC 7.8. For example, this
| won't work:
|
| foo x = $(do {xInfo <- reify 'x; ...})
|
| The motivation for this change is described here:
| <https://ghc.haskell.org/trac/ghc/wiki/TemplateHaskell/BlogPostChanges
| #PartC:Reificationandtypechecking>.
|
| While I agree that getting the type of local variables is going to be
| brittle, I also think that offering that functionality is extremely
| useful in certain cases, such as in the case of the language-c-inline
| library, that used this facility to avoid having to type verbose type
| annotations -- see <https://github.com/mchakravarty/language-c-
| inline/issues/25>.
|
| My two part question is:
|
| 1. would it be possible to revert to the old behavior easily, or is
| doing that difficult or impossible now given the overall changes to
| the Template Haskell code?
| 2. if 1, wouldn't it make more sense to allow reifying all names if
| the user really wants, maybe with a specific `unsafeReify` function or
| similar?
|
| It should be made clear in the docs that by using `unsafeReify` the
| user is relying on GHC internals (specifically the internals of type
| checking).
|
| Also, I think that post should at least be referenced in the manual,
| for lack of better documentation. This behavior is not mentioned
| anywhere else.
|
| Thanks,
| Francesco
More information about the ghc-devs
mailing list