It's really cool to see a "real world" example of functional-lite in action. I think it's a great addition to the book.
At first, it was quite hard for me to understand, but I pulled the code, ran it, refactored around to get a better handle on it, and now I totally get it.
Mine's not to say what's idiomatic or correct since this is a pioneered paradigm; all I can offer is assistance with technical flaws, of which there are none, and maybe some comparisons to other fp flavors.
Compared to some other FP flavors:
Pure FP-style would have every thing composed from start to finish, probably using applicative functors for the 'zippiness', capturing side-effects in unevaluated observables, and merging them at the end for 1 subscribe call that happens outside the lib.
Ramda-style would probably wrap several functions, rearranging arg positions and currying everything to remove the reverseArgs, curry, and partial stuff from the application code. It might also replace some helper functions to be pointfree like:
var formatSign = R.ifElse(R.gt(0), R.concat('+'), R.identity)
var formatCurrency = R.concat('$')
var transformObservable = R.map
After reading the book and seeing the example, I'd feel I can now explain the FP-lite approach in a similar fashion: partial apply at the caller, clearly mark side effects, pipe where we can, take advantage of arrays etc.
It's really cool to see a "real world" example of functional-lite in action. I think it's a great addition to the book.
At first, it was quite hard for me to understand, but I pulled the code, ran it, refactored around to get a better handle on it, and now I totally get it.
Mine's not to say what's idiomatic or correct since this is a pioneered paradigm; all I can offer is assistance with technical flaws, of which there are none, and maybe some comparisons to other fp flavors.
Compared to some other FP flavors:
Pure FP-style would have every thing composed from start to finish, probably using applicative functors for the 'zippiness', capturing side-effects in unevaluated observables, and merging them at the end for 1 subscribe call that happens outside the lib.
Ramda-style would probably wrap several functions, rearranging arg positions and currying everything to remove the
reverseArgs
,curry
, andpartial
stuff from the application code. It might also replace some helper functions to be pointfree like: