2013/1/23 John Wiegley <johnw@fpcomplete.com>
>>>>> John Wiegley <johnw@fpcomplete.com> writes:

> Never mind, when/unless + left work just fine for this.

You know, it's been a humorous day. 
...

Don't take it so hard. Trying to reinvent something is always a great exercise and makes you really understand the problem. And it can have interesting results too. One of my university professors once heard about some concept, but didn't know the details. He tried to derive the concept himself, and he actually invented something different, new and very useful.

... 


    >>> let Left x |> y = y; x |> _ = x in Left 1 |> Right 2 |> Right 3
    Right 2            -- same functionality as my Or semigroup

This strongly reminds me of `mplus` of `Maybe`. The problem is we cannot define a generic instance `MonadPlus Either` because we cannot define `mzero` (but if we restrict the left type, we can achieve this, like in "instance Error e => MonadPlus (Either e)").

Another possibility how to capture this "Or" behavior is `MonadError`. You could define |> for any instance of `MonadError`, including Either (currently with some restrictions):

(|>) :: MonadError e m => m a -> m a -> m a
x |> y = x `catchError` (const y)

  Best regards,
  Petr Pudlak