[Haskell-cafe] supplying some of the arguments to a function

robert dockins robdockins at fastmail.fm
Fri May 6 12:31:14 EDT 2005


Mark Goldman wrote:
 > if I had a function f that took x y and z in that order, is there some
 > way that I can supply y and z and get back a function that takes x?
 > This question comes about after talking with a prof about currying and
 > wether it buys you anything.
 >
 > -mdg

let f = (\x y z -> ()) :: Bool -> Char -> Int -> ()

:t (\x -> f x 'a' 0)
  (\x -> f x 'a' 0) :: Bool -> ()

If you don't like lambdas you can do the same thing with combinators 
(eg, flip, (.), const, etc)

:t (flip . flip f) 'a' 0
  (flip . flip f) 'a' 0 :: Bool -> ()


Mostly, one should just try to write functions so that they take their 
parameters in the most convenient order for partial application.

Robert Dockins



More information about the Haskell-Cafe mailing list