4 ms·
I dont disagree - where things like either, maybe or result really shine is when its baked into the stdlib _and_ there is machinery built into the language to m
by netcraft 7y ago
I dont disagree - where things like either, maybe or result really shine is when its baked into the stdlib _and_ there is machinery built into the language to make using them easy (like pattern matching, and them being in scope by default). I have used and written several libraries trying to make them work in js/ts and while they are beneficial around my custom domain specific code, you still spend a bunch of time wrapping things coming from libraries or other code you dont have control over.
But the benefit of them over a check against null is that you can write a pipeline of functions that dont have to handle those cases and you know that its always safe to do so. This other article by the same author as the OP I think illustrates it well https://jrsinclair.com/articles/2016/marvellously-mysterious-javascript-maybe-monad/ https://jrsinclair.com/articles/2016/marvellously-mysterious...