monad comprehensions: Group and Zip monad
[ghc-base.git] / Control / Monad / Instances.hs
index 63c943f..d41be4f 100644 (file)
@@ -1,4 +1,6 @@
 {-# OPTIONS_NHC98 --prelude #-}
+-- This module deliberately declares orphan instances:
+{-# OPTIONS_GHC -fno-warn-orphans #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Control.Monad.Instances
@@ -29,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