Re:Admitting That Functional Programming Can Be Awkward (2007)
by tome on Saturday October 24, 2020 @03:53PM
(#24881531)
Huh, what do you mean by "modular" that isn't satisfied by the closures?
Re:Admitting That Functional Programming Can Be Awkward (2007)
by nendroid on Saturday October 24, 2020 @09:22PM
(#24883156)
Both examples have multiple functions defined as the definition of w.
But in one example f and g can be reused in other contexts, in the other example the two functions are tied together by free variables. Haskell heavily promotes the latter style with do notation. Any function written in the first style is decomposable into component combinators, any function written in the latter style cannot be decomposed.
FP is only modular when you use combinators. If you use closures then it's no longer modular.
g and f are combinators and modular and w is the composition of both of those combinators. In this case the above is not modular because it doesn't use combinators. The above style is actually kind of promoted by haskell when you need to do things with side effects. It actually makes FP more complex than it needs to be without improving modularity.