move Monad and MonadFix instances for Either from mtl (proposal #4159)
[ghc-base.git] / Control / Monad / Instances.hs
index 6caf060..d41be4f 100644 (file)
@@ -31,3 +31,8 @@ instance Functor ((,) a) where
 instance Functor (Either a) where
         fmap _ (Left x) = Left x
         fmap f (Right y) = Right (f y)
+
+instance Monad (Either e) where
+        return = Right
+        Left  l >>= _ = Left l
+        Right r >>= k = k r