#5650: Type error when annotating a let binding with a forall type
-------------------------------+--------------------------------------------
Reporter: pelotom | Owner: simonpj
Type: bug | Status: closed
Priority: normal | Milestone: 7.4.1
Component: Compiler | Version: 7.2.1
Resolution: invalid | 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: => invalid
Comment:
It's quite right actually. The Haskell 2010 Report, in the section on
pattern bindings,
http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-880004.5,
defines the static semantics of
{{{
p = e
}}}
where pattern `p` binds variables `x1` .. `xn`, thus:
{{{
t = e
x1 = case t of p -> x1
...
xn = case t of p -> xn
}}}
So let's try that with your example, which is a (degenerate) pattern
binding:
{{{
t = id
x = case t of (x :: forall a. a->a) -> x
}}}
When you typecheck this, `t` gets type `forall a. a->a`, but the
''occurrence'' of `t` in the rhs of `x` is instantiated, of course, to
give type `b -> b`, where we don't yet know the type `b`. And that fails
to match the type of x in the pattern.
So I think GHC is following the specification.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5650#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