1 {-# OPTIONS_NHC98 --prelude #-}
2 -- This module deliberately declares orphan instances:
3 {-# OPTIONS_GHC -fno-warn-orphans #-}
4 -----------------------------------------------------------------------------
6 -- Module : Control.Monad.Instances
7 -- Copyright : (c) The University of Glasgow 2001
8 -- License : BSD-style (see the file libraries/base/LICENSE)
10 -- Maintainer : libraries@haskell.org
11 -- Stability : provisional
12 -- Portability : portable
14 -- 'Functor' and 'Monad' instances for @(->) r@ and
15 -- 'Functor' instances for @(,) a@ and @'Either' a@.
17 module Control.Monad.Instances (Functor(..),Monad(..)) where
21 instance Functor ((->) r) where
24 instance Monad ((->) r) where
26 f >>= k = \ r -> k (f r) r
28 instance Functor ((,) a) where
29 fmap f (x,y) = (x, f y)
31 instance Functor (Either a) where
32 fmap _ (Left x) = Left x
33 fmap f (Right y) = Right (f y)
35 instance Monad (Either e) where