1 {-# OPTIONS_NHC98 -prelude #-}
2 -----------------------------------------------------------------------------
4 -- Module : Control.Monad.Instances
5 -- Copyright : (c) The University of Glasgow 2001
6 -- License : BSD-style (see the file libraries/base/LICENSE)
8 -- Maintainer : libraries@haskell.org
9 -- Stability : provisional
10 -- Portability : portable
12 -- 'Functor' and 'Monad' instances for @(->) r@ and
13 -- 'Functor' instances for @(,) a@ and @'Either' a@.
15 module Control.Monad.Instances (Functor(..),Monad(..)) where
19 instance Functor ((->) r) where
22 instance Monad ((->) r) where
24 f >>= k = \ r -> k (f r) r
26 instance Functor ((,) a) where
27 fmap f (x,y) = (x, f y)
29 instance Functor (Either a) where
30 fmap _ (Left x) = Left x
31 fmap f (Right y) = Right (f y)