{-# OPTIONS_GHC -fglasgow-exts #-}

-- factor out instances of standard classes for 
-- standard types, to allow conflict avoidance

module ControlMonadMatchInstances where

import Control.Monad

instance Monad (Either String) where
  fail   = Left
  return = Right
  (Left a)  >>= b = Left a
  (Right a) >>= b = b a

instance MonadPlus (Either String) where
  mzero = Left "mzero"
  (Left _)      `mplus` b = b 
  (a@(Right _)) `mplus` _ = a 


