Is there an inverse operation to >>= (kinda)

I think you’re looking for <|>. It “fails” at the first Just

Just 1 <|> Just 2 = Just 1

And it skips over Nothing as if it was a success:

Nothing <|> Just 1 = Just 1

It works out if you consistently think about Just as failure and Nothing as success, even in the final result.

See also this post of mine where I use the alternative instance of Maybe in this way:

3 Likes