[GHC] #16146: Trivial partial type signature kills type inference in the presence of GADTs
GHC
ghc-devs at haskell.org
Wed Jan 9 15:53:41 UTC 2019
#16146: Trivial partial type signature kills type inference in the presence of
GADTs
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by goldfire):
Another interesting example has cropped up. Re-consider
{{{#!hs
wurble :: _
wurble x = x
}}}
This is accepted, because the type `_` allows for implicit generalization.
But what about
{{{#!hs
wurble2 :: forall. _
wurble2 x = x
}}}
To my surprise, this is accepted too, with `wurble2 :: forall a. a -> a`.
Yet, I would have expected my `forall.` to say that there are no
quantified variables in the type of `wurble2`.
So, maybe another design is this: `foo :: _` can be generalized. (This is
at odds with the fact that `foo` cannot have constraints.) But if there is
an explicit `forall` in type of `foo`, we appeal to the forall-or-nothing
rule and say that the variables quantified in the `forall` are precisely
the quantified variables; no more can be inferred. Then, we can suppress
quantification in `forall. _`. One advantage here is that this new design
is backward compatible (though I'm not terribly worried about that here).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16146#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list