Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If we have let's say:

    fa.then( f(ra) {
      return fb(ra);
    }).then( f(rb) {
      return fc(rb);
    })
rather than (if I understand the monadic way of doing things correctly)

    ra <- fa()
    rb <- fb(ra)
    rc <- fb(rb)
How is the scope of the short-circuiting limited? We will obtain a None result in case of error but we still do not know when the error occurred. Granted, we can add some guards but so can we with promises. Since the return statements are always at the end of each separate function the scope should not be a problem?

I am kind of new to this so please bear with me. Thanks.



Np!

The idea is that from "inside", as we are using do-notation, we merely think of working in an imperative language where failure might occur and short circuit things while from "outside" we see the type of this computation as Maybe and can examine whether or not it actually failed. The "inside"/"outside" dynamic is the scope delimitation.




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

Search: