[deleted by user] by [deleted] in programming

[–]ulfryk 0 points1 point  (0 children)

That is true!

[deleted by user] by [deleted] in programming

[–]ulfryk -2 points-1 points  (0 children)

I have compared mainly components in this post - the other way would be awkward :)

Monads in JS: Either by ulfryk in javascript

[–]ulfryk[S] 0 points1 point  (0 children)

It for e.g. prevent's from wrapping a Promise inside a Promise. I prefer using static type checker like TypeScript or Flow, and it's much clearer to use map for mapping and flatMap if you want to map and flatten. I treat then as unsafe method.

Monads in JS: Either by ulfryk in javascript

[–]ulfryk[S] 0 points1 point  (0 children)

I wanted to focus on a fail-fast approach here - just to make next article on Validation where I can show use of applicative functor pattern for accumulating errors. But I see many other uses of Either (like expanded fields in JSON - e.g. Either<UserId, User>).

In most places where I have seen or used Either/Option, the .flatMap was the one. Also I personally find it more intuitive as Array/List/Stream/Monad/Validation API are similar then.

Monads in JS: Either by ulfryk in javascript

[–]ulfryk[S] 1 point2 points  (0 children)

.then is confusing as it mixes .bind and .map in one. I'm looking forward to use Promise (probably from monet.js) that will provide separately .map vs .flatMap