The value contained in a Just instance of the Maybe structure.
The value contained in a Just instance of the Maybe structure.
This is usually used to destructure the instance in a .matchWith
call.
const Maybe = require('folktale/maybe');
Maybe.Just(1).matchWith({
Just: ({ value }) => value, // equivalent to (x) => x.value
Nothing: () => 'nothing'
});
// ==> 1
get value() {
throw new TypeError('`value` can’t be accessed in an abstract instance of Maybe.Just');
}