#4008: type error trying to specialize polymorphic function
----------------------------------------+-----------------------------------
Reporter: nr | Owner: simonpj
Type: bug | Status: closed
Priority: normal | Milestone: 6.14.1
Component: Compiler (Type checker) | Version: 6.12.1
Resolution: invalid | Keywords:
Difficulty: | Os: Linux
Testcase: | Architecture: x86
Failure: GHC rejects valid program |
----------------------------------------+-----------------------------------
Changes (by simonpj):
* status: new => closed
* resolution: => invalid
Comment:
The program isn't well-typed, and is rightly rejected. Remember that type
checking proceeds as if type synonyms were expanded eagerly. So the type
signature for 'scalar' is identical to
{{{
scalar :: (forall e x . n e x -> Int)
-> (n C O -> Int, n O O -> Int, n O C -> Int)
}}}
Now when matching, say (`a C O ~ (n C O -> Int)`), the only solution is
that `a` is instantiate to `(->)`, and you can see how things go wrong.
In short, GHC does not do higher order unification. You could make htis
work by using a newtype for `Counter`.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4008#comment:2>
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