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

illegal state exception on Maybe.ap() invocation with null returning function #66

Closed
olivr70 opened this issue Jul 20, 2016 · 1 comment

Comments

@olivr70
Copy link

olivr70 commented Jul 20, 2016

hello

I am really new to the monad universe, and in fact using Monet.js to explore it.

I stumbled on an "Illegal state exception" while running

function nullFunc() { return null }
Some("a").ap(Some(nullFunc)); // throws "Illegal state exception" from Maybe.fn.Maybe.init

The problem seems to come from the fact that the map function listed hereafter composer _this.of_ with fn (my nullFunc).

Looking though the spec I did not see any requirement that ap() should be passed a non-null returning function. Did I miss something

Why use this.of and not this.fromNull in map ?

var map = function (fn) {
        return this.bind(this.of.compose(fn))
    }

Sorry I didn't proposed the PR, but I have miles to cover and the subject before

@ulfryk
Copy link
Member

ulfryk commented Jul 20, 2016

It is proper behaviour actually -- see discussion here: https://github.com/cwmyers/monet.js/issues/53

@ulfryk ulfryk closed this as completed Oct 25, 2016
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