[Haskell] Re: Type of y f = f . f
Jim Apple
japple at freeshell.org
Tue Mar 1 19:07:12 EST 2005
Jon Fairbairn wrote:
>>>If you allow quantification over higher
>>>kinds, you can do something like this:
>>>
>>> d f = f . f
>>>
>>> d:: ∀a::*, b::*→*.(b a → a) → b (b a)→ a
>>>
>>
>>What's the problem with
>>
>>d :: (forall c . b c -> c) -> b (b a) -> a
>>d f = f . f
>>
>>to which ghci gives the type
>>
>>d :: forall a b. (forall c. b c -> c) -> b (b a) -> a
>
>
> It's too restrictive: it requires that the argument to d be
> polymorphic, so if f:: [Int]->[Int], d f won't typecheck.
Oh, that's bad.
> It
> also requires that the type of f have an application on the
> lhs, so f :: Int->Int won't allow d f to typecheck either.
This part I don't understand - isn't b anything in *->*? Can't b be the
identity functor?
Jim
More information about the Haskell
mailing list