Question

In the error monad, the first failure halts any execution further just carrying the fault through any following binds.

What monad halts on success only carrying forward successes, and basically swallowing any faults and trying the next bind disregarding the failure of the previous one?

The error monad could maybe be used for this treating failure like success, but I'm curious if the default libraries have a monad for this specific purpose, almost like an Or monad in my mind "Do this, or that"

Edit:

Behaviour would be:

Left "fail" >>= (\x -> Right "win") >>= (\x -> Left "ahh neener") >>= (\x -> Right (x + " yay"))

In the error monad the first left value is just carried forward, so the result of that is Left "fail". The behaviour I want is where the above returns Right "win yay" it's a trivial monad to implement I could write myself, but figured something existed to do such (maybe not using Either, but that's the first thing that comes to mind for such behaviour).

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top