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

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to