There are a lot of functional idioms: monads, applicatives, arrows, etc. They are documented in different articles but unfortunately I don't know any book or article where they're summarized in one place (there is Typeclassopedia but it has a lot of areas that aren't covered well). Can anyone recommend an article/book which covers them well in one place and which can be accessible to a programmer with intermediate skills in FP?
In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID. The functional programming community has design patterns and principles as well.
Closure is a language feature, not a design pattern.
Are the SOLID principles applicable to Functional Programming? Of course. Functional programmers want to separate their code to avoid crosstalk between responsibilities and users. They want to minimize the number of modules affected by a change.
My suggestion is, if you want to learn Scala, to read the book from Paul Chiusano and Runar Bjarnason:
http://manning.com/bjarnason/
Part II: Functional design and combinator libraries
Part III: Functional design patterns
Part IV: Breaking the rules: effects and I/O
I'm sorry I don't know of articles or books which cover in detail the different usages for all of those constructs, but I can give you a few links to individual resources.
A quite common pattern is to build monad transformers instead of simple monads (see also the link in the next paragraph). It basically means you build something that must be combined with other monads, resulting in a more complex one able to handle features of both of them.
In Real World Haskell there are a few chapters about monads. In Chapter 14. Monads the authors explain the basics and some common usages (maybe, list, state). Chapter 15. Programming with monads provides more explanations about how to effectively use them (it covers the reader monad as well). The following chapter explains how to use Parsec, but it may be more interesting to search for articles covering how it actually works: it should be a really good example of a well-organized use of monads for parsing. Fianlly, Chapter 18. Monad transformers introduces how monad transformers work and then shows how to build one, step by step. The considerations towards the final sections of the chapter are also interesting.
I read once a really interesting question on SO about creative uses of monads. The proposed links were awesome reads about the topic. With that spirit, I tried to ask the same for arrows: I definitely got less answers than the one on monads, but interesting ones nevertheless.
With respect to OOP patterns by the gang of four, there is a nice set of 3 articles by IBM about the topic in their series Functional thinking. The target functional language is Scala. They proceed by explaining usual design patterns in OOP and showing how they map into Scala.
The most relevant article w.r.t. your question is for sure the first one, but the other two may be interesting related readings nevertheless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With