[Haskell-cafe] Re: currying combinators

Yitzchak Gale gale at sefer.org
Wed May 26 07:35:01 EDT 2010


I wrote:
> keep :: (forall c . (t ->  c) ->  u ->  c) ->  ((t1 ->  t) ->  b) -> (t1 ->  u) -> b
> keep transform rec = \fn -> rec $ transform id . fn

Just to clarify - you don't really need the RankNTypes here, I just
wrote it that way so you could see what I had been thinking,
and to make it clear how the first parameter of keep
takes transformers like drop'. But you could write it as

keep :: ((t -> t) -> u -> t) -> ...

and it would work just fine, because transformers like drop'
would specialize nicely to what you need for keep.

If you let GHC deduce the type of keep from its definition,
GHC comes up with something else:

keep :: ((a -> a) -> u -> t) -> ((t1 -> t) -> b) -> (t1 -> u) -> b

That also works, but it's weird. It generalizes in a direction
that we don't really need here, and thus obscures the meaning
of what we're doing.

Regards,
Yitz


More information about the Haskell-Cafe mailing list