[GHC] #9117: Coercible constraint solver misses one
GHC
ghc-devs at haskell.org
Tue May 20 13:39:15 UTC 2014
#9117: Coercible constraint solver misses one
-------------------------------------+------------------------------------
Reporter: goldfire | Owner: nomeata
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by nomeata):
In the paper comments you write
> Suppose module `A` uses `coerce` somewhere and contains a newtype whose
constructor is not imported. We now modify `A` to import the constructor.
Is it guaranteed that the use(s) of `coerce` will still work? We would
want to offer such a guarantee I think.
We are unable to give this guarantee with either of the two solving
strategies. Consider:
{{{#!haskell
module Foo where
newtype Rec a = Rec a
newtype Hide a = Hide (Rec a)
module Bar where
import Foo (Hide(Hide), Rec)
ex :: Rec Age -> Hide Int
ex = coerce
}}}
This works (`Hide` is unrolled, then we can lift through `Rec` and are
done). If we also import `Rec`, then `Coercible (Rec Age) (Hide Int)`
(where no lifting is possible yet, so the order does not matter) will
cause it to loop.
I couldn’t construct it with a less pathological newtype yet, though, as
these will cause a proper data tycon to appear, then the newtypes on the
RHS get unwrapped and eventually the terms on both sides match.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9117#comment:24>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list