Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I dont know is it real issue or not :) #169

Closed
ghost opened this issue Jun 15, 2018 · 3 comments
Closed

I dont know is it real issue or not :) #169

ghost opened this issue Jun 15, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 15, 2018

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

@tomecko
Copy link
Collaborator

tomecko commented Jun 15, 2018

@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));

@ghost
Copy link
Author

ghost commented Jun 15, 2018

oh thanks, and yes historyo is on purpose. I thought map will automaticlay returns Nothing but thanks i will use your example :)

@tomecko tomecko closed this as completed Jun 15, 2018
@ulfryk
Copy link
Member

ulfryk commented Jun 15, 2018

.map behaviour rationale can be found in this discussion #53 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants