Closed wookieb closed 1 year ago
Hey @wookieb. Sounds nice, I like it. The only thing, the name is not eloquent. What do you think, what will be a better name for the function?
I really have no better idea for a name... Any suggestions?
mapBoth
?
https://www.npmjs.com/package/node-either-monad - uses fold
https://github.com/sniptt-official/monads - uses match
- which is also good
https://folktalegithubio.readthedocs.io/en/latest/api/data/either/Either.html#cata - uses cata
https://itnext.io/either-monad-a-functional-approach-to-error-handling-in-js-ffdc2917ab2 - uses matchWith
https://gcanti.github.io/fp-ts/modules/Either.ts.html#mapping - uses fold
I believe let's go with fold
since match
accepts object and we can introduce it later.
@JSMonk Do you agree to go with fold
?
I would like to name it match
with one a few variants
I prefer fold
personally as it's descriptive of doing away with the monad.
I agree with you, but, and I'm open to discussion. But, my point of view is that the fold
would confuse people from other non-pure-functional languages, because the fold
method commonly is a collection method to make folding of the collection to some value.
Yes but this is fold in collections, not in a Maybe monad. Therefore I would go with it.
I've encountered some issue with commiting and lint-staged
failing with some error about yarn.lock. Had to switch to yarn 1.22.1 but that created some files not available in the repository before. I did not committed them.
@JSMonk can You please fix configuration of yarn package or provide details regard contribution?
That's just bifoldMap
from Bifoldable
: https://hackage.haskell.org/package/base-4.18.0.0/docs/Prelude.html#v:bifoldMap
I would really like to see suport for catamorphism
Similar to: https://github.com/monet/monet.js/blob/master/docs/MAYBE.md#cata