1 -----------------------------------------------------------------------------
3 -- Module : Control.Category
4 -- Copyright : (c) Ashley Yakeley 2007
5 -- License : BSD-style (see the LICENSE file in the distribution)
7 -- Maintainer : ashley@semantic.org
8 -- Stability : experimental
9 -- Portability : portable
11 -- http://hackage.haskell.org/trac/ghc/ticket/1773
13 module Control.Category where
15 import Prelude hiding (id,(.))
16 import qualified Prelude
21 -- | A class for categories.
22 -- id and (.) must form a monoid.
23 class Category cat where
24 -- | the identity morphism
27 -- | morphism composition
28 (.) :: cat b c -> cat a b -> cat a c
31 "identity/left" forall p .
33 "identity/right" forall p .
35 "association" forall p q r .
36 (p . q) . r = p . (q . r)
39 instance Category (->) where
42 -- Haddock 1.x cannot parse this:
46 -- | Right-to-left composition
47 (<<<) :: Category cat => cat b c -> cat a b -> cat a c
50 -- | Left-to-right composition
51 (>>>) :: Category cat => cat a b -> cat b c -> cat a c