[GHC] #15639: Surprising failure combining QuantifiedConstraints with Coercible
GHC
ghc-devs at haskell.org
Tue Dec 4 20:34:36 UTC 2018
#15639: Surprising failure combining QuantifiedConstraints with Coercible
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler (Type | Version: 8.5
checker) | Keywords:
Resolution: | QuantifiedConstraints
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by dfeuer):
Replying to [comment:5 simonpj]:
> Can you explain more about this example? I think that it is important
that
>
> * You give a role signature for `Yeah`. (What is the inferred
signature?)
The inferred signature is `type role Yeah phantom`
> * You export the type constructor for `Yeah` but not the data
constructor.
Yes. The export isn't really as relevant as the import it enables; when a
newtype constructor is in scope that changes the coercion axioms the type
checker uses for the type.
> But I'm a bit lost about what you expect to happen. Can you amplify?
Why do you think it should typecheck? It'd probably help to give the
declaration for `Coercion` too, for those of us who do not use it daily.
The declaration of `Coercion` is
{{{#!hs
data Coercion a b where
Coercion :: Coercible a b => Coercion a b
}}}
The situation is
{{{#!hs
yeahCoercible :: ((forall a b. Coercible (Yeah a) (Yeah b)) => r) -> r
yeahCoercible r = r
-- Fishy2.hs
yeah :: Coercion [Yeah a] [Yeah b]
yeah = yeahCoercible Coercion
}}}
We call `yeahCoercible` with `Coercion`. For this to typecheck, we need
{{{#!hs
Coercion :: (forall a b. Coercible (Yeah a) (Yeah b)) => Coercion [Yeah a]
[Yeah b]
}}}
Put another way, we need `Coercible (Yeah a) (Yeah b)` to imply `Coercible
[Yeah a] [Yeah b]`. Under normal circumstances, that would follow from the
fact that `[]`'s parameter has a representational role. But the constraint
solver isn't figuring that out.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15639#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list