[Haskell-cafe] type inference question

Jochem Berndsen jochem at functor.nl
Thu Oct 8 05:19:56 EDT 2009


minh thu wrote:
> Also, I'd like to know why
>
> id id True
>
> is permitted but not
>
> (\f -> f f True) id

If you want to do this, answer the question "what is the type of (\f ->
f f True)"?
You can do this, by the way, using rank-2 types:
> {-# LANGUAGE Rank2Types, PatternSignatures #-}
> thisIsAlwaysTrue = (\ (f :: forall a. a -> a) -> f f True) id

Cheers, Jochem
-- 
Jochem Berndsen | jochem at functor.nl | jochem@牛在田里.com


More information about the Haskell-Cafe mailing list