[Haskell-cafe] GHC 8 + ImpredictiveTypes + $

Edward Z. Yang ezyang at mit.edu
Fri Jun 10 15:12:52 UTC 2016


Excerpts from Brendan Hay's message of 2016-06-10 01:59:51 -0700:
> * How does the use of ($) vs (.) fix this particular issue? (I'd naively
> assume the usage here would be equivalent.) I recall reading about ($)'s
> magical type alias somewhere - is this related?

When you say f $ a, where a is a polymorphic variable, we need to
instantiate the type variables in ($) :: (a -> b) -> a -> b with
quantified types; i.e., do an impredicative instantiation.  GHC has
never been able to do this, so there's a hack for the typechecker
to treat 'f $ a' as if it were just 'f a' (no more impredicative
instantiation).

(.) is not special cased similarly, which is why it doesn't work.
I don't know if we could special case it to solve this problem.

Edward


More information about the Haskell-Cafe mailing list