I dont know is it real issue or not :)
Opened this issue · 3 comments
Hello,
I dont know is it real issue or it has to work like that but i dont like it :)
Say i have a code like this:
const {Maybe} = require("monet");
const state = {
historyo: [
{
html: "test",
},
],
};
const MS = Maybe.fromNull(state);
console.log(MS);
const MS1 = MS.map(x => x.history);
console.log(MS1);
Does this code shouldnt return monadic state of nothing? i'm getting an error
monet.js:432 throw "Illegal state exception" ^ Illegal state exception
@poulius
Is historyo
typo made on purpose?
If yes, then you may want to change the last line:
const MS1 = MS.flatMap(x => Maybe.fromNull(x.history));
oh thanks, and yes historyo
is on purpose. I thought map
will automaticlay returns Nothing
but thanks i will use your example :)
.map
behaviour rationale can be found in this discussion #53 (comment)