3 ms·
Suggestion for the author. Reformat the code of your translated example. I truly found it impenetrable until I formatted it more like idiomatic d3.js code. W
by rogerallen 13y ago
Suggestion for the author. Reformat the code of your translated example. I truly found it impenetrable until I formatted it more like idiomatic d3.js code. With this reformatting, I'll buy that it is less annoying and tedious than the original.
console.log(
Maybe(person)
.bind(function(p) { return p["address"]; })
.bind(function(a) { return a["state"]; })
.maybe("State unknown", function(s) { return s; })
);
And then I realized that d3.js code is monads! (shout it like Charlton Heston in Soylent Green)
- dllthomas 13y agoI'm not sure this is actually using the fact that maybe is monadic - I think this much can be done with applicative functors. In order to really be monadic, you'd need to run the next bind inside the function passed to the previous bind.