Converts an Result structure to a Maybe structure. Errors map to Nothings,
Oks map to Justs.
Converts an Result structure to a Maybe structure. Errors map to Nothings,
Oks map to Justs.
Not that Error values are lost in the conversion process, since failures
in Maybe (the Nothing tag) don't have a value.
const resultToMaybe = require('folktale/conversions/result-to-maybe');
const { Error, Ok } = require('folktale/result');
const { Just, Nothing } = require('folktale/maybe');
resultToMaybe(Error(1)); // ==> Nothing()
resultToMaybe(Ok(1)); // ==> Just(1)
(aResult) =>
aResult.matchWith({
Error: ({ value: _ }) => Nothing(),
Ok: ({ value }) => Just(value)
})