Either.fromNullable(aValue, "An error has occurred")
.map(value => /* Do stuff to the object */),
.mapError(value => /* Do stuff to the string */)
or
Either.fromNullable(aValue, "An error has occurred")
.mapError(value => /* Do stuff to the string */)
But in cases where both .map and mapError are present we should be able to do
Either.fromNullable(aValue, "An error has occurred")
.map(
obj => /* Do stuff to the object */, // <-- Ok branch
str => /* Do stuff to the string */, // <-- Error branch
)
Currently we can do stuff like this
or
But in cases where both
.map
andmapError
are present we should be able to do