3 ms·
Currying is essentially a trick to turn n-ary functions to unary functions so you can compose them. It also enables the creation of specific functions from gene
by pwm 9y ago
Currying is essentially a trick to turn n-ary functions to unary functions so you can compose them. It also enables the creation of specific functions from generic ones by supplying arguments. Also, as functions can have functions as arguments it is the ultimate dependency injection pattern, if you’re familiar with the oop lingo.
- megaman22 9y agoI get the whole hole-in-the-middle functional dependency injection idea... The problem I frequently run into with this class of things is that people preach an unreasonable purity of thought with regard to the application of the technique, rather than just recognizing places it is useful and applying it there. Either one curries nothing, or one curries all the things. Monads are the fundamental fabric of the universe, or they are eldritch monoliths to worship, but not understand. Rarely is there the pragmatism applied to use these concepts where they make sense, and forego them for the simple where they do not.
- morgancmartin 9y agoI think that Clojure takes a sane approach to topics such as this one. I believe the "data first" approach tends to breed a pragmatic outlook when writing code and leaves behind all the proselytizing. Plus currying is built into the language, so there isn't any need for importing any special purpose libraries :) edit: a word