3 ms·
Which are? I've read somewhere they help improve the modularity of your code, is this what you're referring to?
by anonymousDan 17y ago
Which are? I've read somewhere they help improve the
modularity of your code, is this what you're referring to?
- chousuke 17y agoFunctional programming is very focused on composing operations. Function composition is an obvious example, but it is not the only one. As far as I understand monads, they allow you to write generic operations separate from the logic needed to compose those operations. Inspired by this article. and in a fit of temporary insanity, I implemented a simple monad protocol and the Maybe and List monads in Clojure. It's not fit for use, but it was fun to write. http://gist.github.com/312281 http://gist.github.com/312281 It may not be immediately evident what is being composed there, but if you look at lift, it breaks the multi-argument "+" operator into several partial applications and composes each of those under the given monad, giving interesting results. This was necessary to maintain support for a variable number of arguments. Note that the code uses features only available in the git master branch, so you will need a snapshot build to run it.