#2418: desugaring type function application to constraint makes bug disappear
-------------------------------------+--------------------------------------
Reporter: claus | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 6.10.1
Component: Compiler (Type checker) | Version: 6.9
Severity: normal | Resolution: duplicate
Keywords: type families | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
-------------------------------------+--------------------------------------
Comment (by chak):
Replying to [comment:4 claus]:
> Replying to [comment:3 chak]:
> > This is actually a duplicate of #2146 (which more accurately pinpoints
the underlying problem).
>
> How so?
`T` is a unary type synonym family, so in
{{{
wrapper :: forall a f . (Blah f a) => a -> T f f a
}}}
you should read the result type as `(T f) f a`, where `T f` is the
''family application,'' whereas the application of `(T f)` to the second
`f` and to `a` are vanilla type applications. The bug is that GHC
mistakenly takes the whole of `T f f a` as tertiary family application.
(If it ''were'' a tertiary family application, the signature would be
ambiguous and the error message would be correct - but it's unary, so GHC
is wrong in rejecting the program.)
This also explains why what you call the desugared variant works:
{{{
wrapper :: forall a f tf . (Blah f a,T f~tf) => a -> tf f a
}}}
Here `tf f a` syntactically contains no type family. So, GHC correctly
takes this to be vanilla type applications.
The place in the type checker where things go wrong is in the
implementation of what we call the ''decomposition rule'' (see our
forthcoming ICFP'08 paper for details on the type checking algorithm).
That's exactly what #2146 is about. (In any case, I will also add the
example of the present ticket to the testsuite when I fix the bug.)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2418#comment:5>
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