The advantage of having formal laws is that functional programmers can reason mathematically about their design patterns.
This is completely different from the OOP case, where a "design pattern" is something someone found useful X number of times, with no rhyme or reason for structuring things this way. Which is why, in my opinion, it's so hard to talk about OOP design patterns beyond "it seems to fit".
This is completely unlike the OOP community, where a design pattern has a poor spec written in english.
In the FP community, the laws for folds/unfolds/functors etc. are sacred, which make for very robust programs and well-behaved libraries.
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.
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-...
And it is exactly the overuse of design patterns that is one of the reasons that OOP has become less popular over the years. I see a lot of similarities with FP there. Once you learn a new design pattern it opens your eyes to new and beautiful solutions for existing problems. And of course from then on you want to use it wherever you can. To repeat a cliché: If your latest tool is a hammer, every problem looks like a nail.
This overuse of abstractions leads to software that is hard to understand and because of that, it actually becomes harder to maintain or extend, while the whole point of design patterns was to make it easier. This doesn't mean that design patterns, either in OOP or FP, are bad, no they still are really powerful but only if used when they are strictly needed; they should most of the time not be used to introduce some opportunity for reusability if reusability is currently not needed.