[GHC] #16146: Trivial partial type signature kills type inference in the presence of GADTs
GHC
ghc-devs at haskell.org
Tue Jan 8 00:13:22 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 simonpj):
It's not obvious what to do here. Consider
{{{
f :: Int -> Int -> Int
f x = (...blah...) :: forall a. a->a
}}}
Here the expression signature insists that `(..blah..)` has type `forall
a. a->a` which is ''more general than'' the `Int -> Int` imposed by the
signature for `f`.
Now imagine a partial version of this:
{{{
f :: Int -> Int -> Int
f x = (...blah...) :: forall a. a -> _
}}}
The same thing applies. Because the partial signature may be more general
than the expected type from "outside", it's hard to take advantage of the
latter until we've worked out what the fleshed-out partial signature is
(ie. in this case perhaps `forall a. a->a`). Only then can we instantiate
it to see if it is more general than `Int -> Int`.
So while `(e :: _)` may be a no-op, that is not true of other partial type
signatures. Short of making it a magic, ad-hoc special case, I'm not sure
how to do better. Perhaps one could make a special case when the partial
signature had no quantification. But it sounds smelly to me.
Why not just remove the `:: _`? It's not doing anything useful.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16146#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list