On Wed, Sep 22, 2010 at 5:20 AM, Johannes Waldmann
<waldmann@imn.htwk-leipzig.de> wrote:
> - are there any prior art in documenting idioms and patterns in FP [...]
you got this backwards: what some folks call "idioms and (design) patterns"
actually *is* FP, because it is just this: higher order functions.
And it's been there some decades (lambda calculus).
That also explains the absence of any Design Patterns/Gang-of-Four
kind of book for Haskell - it's just not needed.
(as you say, map and fold are your patterns.)
Best - J.W.
Most developers misunderstand the Gang of Four design patterns, including the authors. For example, the GoF State Pattern is described synchronously, but anyone who has thought about this is in deep detail, e.g. actor theory, knows that asynchronous transitions are possible and that the target state can be decoupled from the source state. In mathematics, the most basic way to understand this is through finite state automata, since an automaton is only dependent on its current state and input to determine the next transition. GoF confuses the issue by insistenting on synchronous communication between classes that represent states. GoF has subpar explanations, but please separate the intellectual wheat from the chaff.
I have also heard some argue that GoF patterns all have the same structure. This is not true. I've heard confused programmers say that the Proxy pattern and the Decorator pattern "look the same". Decorators provide structural support of nesting and Proxies do not, but the key difference between the two is that a Decorator is about adding or removing properties *dynamically*, whereas a Proxy is about accessing existing properties through a known static structure. How does higher order (recursive) functions make such patterns obsolete?