[Haskell] Re: Type of y f = f . f

John Meacham john at repetae.net
Tue Mar 1 05:23:59 EST 2005


On Mon, Feb 28, 2005 at 11:10:40PM -0500, Jim Apple wrote:
> 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

Or one could do its dual (?).

> d :: (forall c . c -> b c) -> a -> b (b a)
> d f = f . f

rank-n polymorphism is fun :)

now, I guess the tricky thing is creating a function which will work as
d head 
and 
d (:[])
...
        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Haskell mailing list