[Haskell-cafe] Haskell's "currying" versus Business Objects Gem Cutter's "burning"

Dougal Stanton ithika at gmail.com
Tue Jul 3 06:01:02 EDT 2007


On 03/07/07, peterv <bf3 at telenet.be> wrote:
>
>
>
>
> In Haskell, currying can only be done on the last (rightmost) function
> arguments.
>
>
>
> So
>
>
>
> foo x y
>
>
>
> can be curried as
>
>
>
> foo x
>
>
>
> but not as
>
>
>
> foo ? y
>
>
>
> where ? would be a "wilcard" for the x parameter.
>

The function flip can be used in two-argument functions, if you only
have second argument but not the first:

> function ??? arg2 -- this is what you mean
> flip function arg2 -- this is how you write it

So for example

> let nums = flip map [1..10]
> nums (*2)
[2,4,6,8,10,12,14,16,18,20]
> nums (subtract 1)
[0,1,2,3,4,5,6,7,8,9]

For the general situation of N arguments, I don't think there are any
predefined functions to help you. (After all, as N increases, the
number of variations of argument order gets rather silly.)

cheers
D.


More information about the Haskell-Cafe mailing list