Remove unused imports from base
[ghc-base.git] / Control / Category.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module      :  Control.Category
4 -- Copyright   :  (c) Ashley Yakeley 2007
5 -- License     :  BSD-style (see the LICENSE file in the distribution)
6 --
7 -- Maintainer  :  ashley@semantic.org
8 -- Stability   :  experimental
9 -- Portability :  portable
10
11 -- http://hackage.haskell.org/trac/ghc/ticket/1773
12
13 module Control.Category where
14
15 import qualified Prelude
16
17 infixr 9 .
18 infixr 1 >>>, <<<
19
20 -- | A class for categories.
21 --   id and (.) must form a monoid.
22 class Category cat where
23         -- | the identity morphism
24         id :: cat a a
25
26         -- | morphism composition
27         (.) :: cat b c -> cat a b -> cat a c
28
29 {-# RULES
30 "identity/left" forall p .
31                 id . p = p
32 "identity/right"        forall p .
33                 p . id = p
34 "association"   forall p q r .
35                 (p . q) . r = p . (q . r)
36  #-}
37
38 instance Category (->) where
39         id = Prelude.id
40 #ifndef __HADDOCK__
41 -- Haddock 1.x cannot parse this:
42         (.) = (Prelude..)
43 #endif
44
45 -- | Right-to-left composition
46 (<<<) :: Category cat => cat b c -> cat a b -> cat a c
47 (<<<) = (.)
48
49 -- | Left-to-right composition
50 (>>>) :: Category cat => cat a b -> cat b c -> cat a c
51 f >>> g = g . f