1641e03875b5fc3b05f56d2d7d93e40b7494a058
[haskell-directory.git] / Control / Monad / Instances.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module      :  Control.Monad.Instances
4 -- Copyright   :  (c) The University of Glasgow 2001
5 -- License     :  BSD-style (see the file libraries/base/LICENSE)
6 --
7 -- Maintainer  :  libraries@haskell.org
8 -- Stability   :  provisional
9 -- Portability :  portable
10 --
11 -- 'Functor' and 'Monad' instances for @(->) r@ and
12 -- 'Functor' instances for @(,) a@ and @'Either' a@.
13
14 module Control.Monad.Instances () where
15
16 import Prelude
17
18 instance Functor ((->) r) where
19         fmap = (.)
20
21 instance Monad ((->) r) where
22         return = const
23         f >>= k = \ r -> k (f r) r
24
25 instance Functor ((,) a) where
26         fmap f (x,y) = (x, f y)
27
28 instance Functor (Either a) where
29         fmap _ (Left x) = Left x
30         fmap f (Right y) = Right (f y)