4 ms·
A certain portion of programmers seems convinced that currying offers a huge amount of power, and we just haven't unlocked it yet. But I don't think I understan
by draw_down 11y ago
A certain portion of programmers seems convinced that currying offers a huge amount of power, and we just haven't unlocked it yet. But I don't think I understand why they feel that way.
- darawk 11y agoIt mostly allows you to write extremely short code. E.g. `sumList = reduce(sum)` It has a variety of drawbacks though, like being harder to inspect at runtime, and arguably harder to read.
- tolmasky 11y agoYup, couldn't agree more and that's exactly one of the concerns I'm trying to address in the blog post ("All in all, the resulting effect in my exprience is that currying makes writing code far more pleasurable, but often makes reading code somewhat confusing."). I think the combination of named parameters actually makes it more readable.
- e_d_g_a_r 11y agoit offers some elegance, here's a timeout function blogpost. http://hyegar.com/2016/03/22/simple-timeouts/ http://hyegar.com/2016/03/22/simple-timeouts/ In it the timeout function only takes one arg for its timeout wrapped function, so how do we use functions with more than 1 arg? Via currying
- k__ 11y agoIt's just a different way of structuring. api = new Api('http://my.cool.api' http://my.cool.api') api.get('/it') api.post('/it') // connect = rootUrl => method => endpoint api = connect('http://my.cool.api' http://my.cool.api') get = api('GET') post = api('POST') get('/it') post('/it')
- pka 11y agoCurried: map (f . fst) Uncurried: \xs -> map (\x -> f (fst x)) xs Now comparing this to js would just be unfair (edit: ES6 lambdas are probably ok).