1 {-# OPTIONS_NHC98 --prelude #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 -----------------------------------------------------------------------------
5 -- Module : Control.Monad.Instances
6 -- Copyright : (c) The University of Glasgow 2001
7 -- License : BSD-style (see the file libraries/base/LICENSE)
9 -- Maintainer : libraries@haskell.org
10 -- Stability : provisional
11 -- Portability : portable
13 -- 'Functor' and 'Monad' instances for @(->) r@ and
14 -- 'Functor' instances for @(,) a@ and @'Either' a@.
16 module Control.Monad.Instances (Functor(..),Monad(..)) where
20 instance Functor ((->) r) where
23 instance Monad ((->) r) where
25 f >>= k = \ r -> k (f r) r
27 instance Functor ((,) a) where
28 fmap f (x,y) = (x, f y)
30 instance Functor (Either a) where
31 fmap _ (Left x) = Left x
32 fmap f (Right y) = Right (f y)