Re:Why Functional Programming Should Be the Future of Software
by mejutoco on Wednesday November 02, 2022 @08:19AM
(#33434525)
> I'd like to have a language that is imperative when written and functional when read :)
Depending on which language Monads give you exactly that bridge between imperative and functional.
In your example, you can always choose to have side effects in that deep call.
Personally, I like a type-driven approach. Then, I do not care so much where functions are (they will be grouped logically, but could be anywhere), as long as the type in and the type out matches.
Re:Why Functional Programming Should Be the Future of Software
by iterati on Wednesday November 02, 2022 @08:32AM
(#33434678)
I've handled this (in Clojure) either by passing a context map through the entire stack or binding some context atom at the top and using it lower down the stack. The binding is less obvious at first glance, so I prefer to pass the context, but both make testing quite easy and reduce the need for heavy refactoring.
Re:Why Functional Programming Should Be the Future of Software
by beders on Wednesday November 02, 2022 @11:59AM
(#33437948)
I like that aspect because it gives you a hint that your call tree is not how it should be.
Lifting out side-effects and passing the data back in is one approach, but not the only one.
Turning a deep call tree into a flat pipeline is a popular other approach and often leads to less complexity, better compos-ability.
It's incredibly frustrating when you work in a functional language, and yet it's the main benefit (no side effects).
I'd like to have a language that is imperative when written and functional when read :)