deprecate unGetChan and isEmptyChan (see #4154)
[ghc-base.git] / Control / Monad / Instances.hs
index f53fac2..d41be4f 100644 (file)
@@ -1,4 +1,6 @@
-{-# OPTIONS_NHC98 -prelude #-}
+{-# OPTIONS_NHC98 --prelude #-}
+-- This module deliberately declares orphan instances:
+{-# OPTIONS_GHC -fno-warn-orphans #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Control.Monad.Instances
@@ -17,15 +19,20 @@ module Control.Monad.Instances (Functor(..),Monad(..)) where
 import Prelude
 
 instance Functor ((->) r) where
-       fmap = (.)
+        fmap = (.)
 
 instance Monad ((->) r) where
-       return = const
-       f >>= k = \ r -> k (f r) r
+        return = const
+        f >>= k = \ r -> k (f r) r
 
 instance Functor ((,) a) where
-       fmap f (x,y) = (x, f y)
+        fmap f (x,y) = (x, f y)
 
 instance Functor (Either a) where
-       fmap _ (Left x) = Left x
-       fmap f (Right y) = Right (f y)
+        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