gabriele renzi | 20 Sep 2007 14:38
Picon
Favicon

Re: compose (o) for n-ary functions

On Thu, 20 Sep 2007 14:09:26 +0200, Andreas Rossberg wrote:

> gabriele renzi wrote:
<snip>

>> If compare was a single-valued function I'd do:
>>  Int.compare o look
>>
>> but since it takes 2 args I don't know how to handle it.
>>   
> 
> Pair.mapBoth may be what you want, so you can write
> 
>   List.sort (Int.compare o Pair.mapBoth look) aList

ah, I should think of the Pair class more often, thank you. 

>> Is it possible to define (or better, it is alread there) an n-compose
>> function that I could use in conjunction with Fn.curry ? 
>>
>> I am unable to find a type for it, but I have the feeling it is impossible
>> to define (I can't come up with a type for it) ?
>>   
> 
> There is no direct way of expressing what you intend in a more general 
> way. You can do so using a significant amount of type trickery for 
> encoding so-called type-indexed values, though, e.g. look here:
<snip>

thanks for the reference, it will be hard to digest but it seems quite
(Continue reading)


Gmane