Re:Functional Programming with Bananas, Lenses, Envelopes an...
by siraben on Wednesday August 05, 2020 @08:41AM
(#24060150)
Also, these laws are immensely valuable to compilers. The Haskell foldr/build rewrite rule allows for intermediate lists to be eliminated altogether[0], so you can write
sum (map square [1..n])
and the compiler will remove the intermediate list altogether, putting a tail-recursive loop in the expression's place.[0] Paper on deforestation https://link.springer.com/content/pdf/10.1007%2F3-540-19027-...
I think what adds to the value of FP's abstractions is how they have mathematical (viz. categorical) laws in mind, which make them precise and elegant.
Anyone know if the same can be said for design patterns? It requires more classes to be added, more boilerplate, which definitely adds to the complexity.