#4863: TH crashes if you reify the Name of a dfun
---------------------------------+------------------------------------------
Reporter: guest | Owner: simonpj
Type: bug | Status: new
Priority: low | Milestone: _|_
Component: Template Haskell | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Linux | Blocking:
Architecture: x86_64 (amd64) | Failure: Compile-time crash
---------------------------------+------------------------------------------
Changes (by simonpj):
* priority: normal => low
* milestone: 7.0.3 => _|_
Comment:
Looking at this I realise that `TH.classInstances` has completely the
wrong type. It should be
{{{
classInstances :: Name -> [Type] -> Q [ClassInstance]
}}}
Before we were returning `[Name]` where the `Name` was the name of the
dictionary function of the instance.
I've fixed this. It's a API change, but `classInstances` is very new
anyway. Patch to HEAD:
{{{
Thu Jan 13 11:14:21 GMT 2011 [email protected]
* Make Template Haskell classInstances function return [ClassInstance]
This is a recently-introduce function, which was returning
a [Name], being the names of the dfuns. But what you really
want (obviously!) is the ClassInstances, and we have a TH type
for that.
This is an API change, so don't merge into GHC 7.0. But it's
a new part of TH which is still settling down.
Fixes Trac #4863.
M ./compiler/typecheck/TcSplice.lhs -3 +2
}}}
Patch to template-haskell library:
{{{
Thu Jan 13 11:54:37 GMT 2011 [email protected]
* Change type of TH.classInstances (and qClassInstances)
This patch accompanies the HEAD commit
Thu Jan 13 11:14:21 GMT 2011 [email protected]
* Make Template Haskell classInstances function return [ClassInstance]
It accomplishes the data type change
M ./Language/Haskell/TH.hs -1 +1
M ./Language/Haskell/TH/Syntax.hs -2 +2
}}}
There's still a residual problem, in that a `ClassInstance` still contains
the `Name` of the dfun, and you can't reify that; or at least doing so
gives the above crash. Why? Because `TH.Type` doesn't have a
representation for a type like
{{{
df :: forall a. Eq a => Eq [a]
}}}
I'm not sure of the best way to fix that. For example, reifying a dfun
could yield a `ClassInstance` rather than a `VarI`; but that would need a
new constructor in `TH.Info`. So I'm just going to leave it for now until
it becomes imporant to someone. Meanwhile I'll re-title and make low
priority.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4863#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs