[GHC] #7594: GHCi becomes confused about IO type
GHC
cvs-ghc at haskell.org
Wed Jan 16 14:58:40 CET 2013
#7594: GHCi becomes confused about IO type
-------------------------------+--------------------------------------------
Reporter: Khudyakov | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: GHCi | Version: 7.6.1
Resolution: worksforme | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
-------------------------------+--------------------------------------------
Changes (by simonpj):
* status: new => closed
* difficulty: => Unknown
* resolution: => worksforme
Comment:
Hmm. Absolutely right, and this happens for 7.6.2 too. However with HEAD
we get:
{{{
<interactive>:2:5:
Couldn't match type `b' with `IO ()'
`b' is untouchable
inside the constraints ((:&:) Show Real a)
bound by a type expected by the context:
(:&:) Show Real a => a -> b
at <interactive>:2:1-11
`b' is a rigid type variable bound by
the inferred type of it :: b at <interactive>:2:1
}}}
This is actually right, although the error message is not so easy. We
know that
{{{
print :: Show a => a -> IO ()
}}}
We also know (by way of the argument `q`, that `c = (Show :&: Real) a`.
So, to check that `print` is a valid argument to `app`, we must check that
{{{
From (Show :&: Real) a
prove that (Show a, beta ~ IO ())
}}}
where `beta` is a unification variable (as-yet-unknown type) obtained by
instantiating `app`.
Well, you say, we can choose `beta` to be `IO ()` and we are done. But
not so: in general the "`From`" constraints might include GADT-style
equalites, and GHC is careful NOT to unify under equality constraints.
(See the [http://haskell.org/haskellwiki/Simonpj/Talk:OutsideIn Modular
type inference with local assumptions] paper.) That's why `beta` is
"untouchable".
Easily fixed by saying `app print q :: IO ()`, and that works fine.
I am strongly dis-inclined to attempt to find out what's happening in 7.6!
So I propose just to close this. I might add a regression test though.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7594#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list