As its name suggests, a Maybe
is a type that may or may not hold a value. In JavaScript, we can use Maybe
s to check whether a value is undefined or null prior to passing it through to a transformer function and ultimately give us better control over the flow of our
In this lesson, we walk through the process of writing a factory function for creating objects that implement a Maybe
functor. The overall goal of the lesson is to become more comfortable working with the functor data type while learning about Maybe
, a widely-known implementation in the functional programming world
Hey Tre! Apologies for the late response. Thanks for the feedback though! It is really appreciated.
In regards to your question on Maybe
vs Either
, I believe that the difference is this:
Nothing
). You can think of it as the ADT for null
checks.null
or undefined
, Maybe(null)
will always return, therefore you can't get anything meaningful information.Left
), as it allows you to store information about the error, which you can then handle however you choose.I've adapted your code to gist - maybe-vs-either
Hope it helps!
Thanks very much!!!
I tend to use my own
Either
impl and I think I've been abusing it, like: ... https://github.com/elastic/kibana/blob/699959b484aad65366b73458d48a2df61a398b94/src/dev/code_coverage/ingest_coverage/transforms.js#L23I feel like that was my worst use of it. I'm trying to really get good at knowing when to use a Maybe vs an Either.
Anyway, thanks again for a great fp contrib!