Polymorphic Recursion / Rank-2 Confusion

Frank Atanassow franka at cs.uu.nl
Sat Sep 20 19:07:02 EDT 2003


On zaterdag, sep 20, 2003, at 13:01 Europe/Amsterdam, Dominic Steinitz 
wrote:

> Can anyone tell me why the following doesn't work (and what I have to 
> do to
> fix it)? I thought by specifying the type of coalw as rank-2 would 
> allow it
> to be used both at a and (a,b).

This will never work. A function expecting a value of type forall c d. 
c -> [d] needs to be passed a function which can turn an arbitrary 
value of an arbitrary type into a list of values of every other, 
arbitrary type; the only such (total) function I can think of is const 
[].

The type checker is complaining because the value you pass it is a 
function which only accepts tuple inputs; it has to work for _all_ 
inputs of any type.

If you explain what you're trying to do here, maybe someone can suggest 
a solution.

Regards,
Frank



More information about the Haskell mailing list