Hacker News new | past | comments | ask | show | jobs | submit login

At least I understand the metaphor as "being able to inject logic, depending on some context, between each operation in a sequence of operations". Alternatively, it could be thought as programmable function composition. So, for instance with the Either monad, instead of some code like

    var x = foo();
    var y = bar(x); 
    var z = baz(y);
you'd have

    var x = foo(); // returns an Either
    var y = x.flatMap(bar);
    var z = y.flatMap(baz);
where some extra computation happens in the flatMap calls that actually determines whether and/or how the function is called and what the actual return value is. In Either's case, if any of the chained operations returns an error, the subsequent operations are not executed and the error is propagated to the end of the sequence instead.



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: