Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Partial application and function composition are the meat-and-potatoes of functional programming.

Automatic currying is syntactic sugar that can make these two easier and clearer as it gets rid of a bunch of named arguments and lambdas. For example, I can write:

  foo a b c = a * b + c  
I can then apply this partially like this (foo2 just takes argument c):

  foo2 = foo 10 20  
and compose it with other functions, for example like this:

  composed = foo2 >> bar >> baz
Without currying, you'd have something like:

  foo (a, b, c) = a * b + c 

  foo2 (z) = foo (10, 20, z)

  composed (a) = (\b -> foo2 (b)) ((\c -> bar (c)) (baz (a)))


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: