haskellmathcategory-abstractions

What good is Control.Category?


If I find out that something is a Monoid or Monad, I get all to use all kinds of fun functions, like foldMap, sequence or even mapM. They make me happy.

What do I get if I find out that something is a Category? Do I get anything fun besides overloading id and (.) ?


Solution

  • Do I get anything fun besides overloading id and (.) ?

    Well, you also (should) get the laws associated with them:

    "identity/left" forall p .
                    id . p = p
    "identity/right"        forall p .
                    p . id = p
    "association"   forall p q r .
                    (p . q) . r = p . (q . r)
    

    As a side note: The reason that you don't get that many fun functions like mapM or foldMap is, that saying something is a category is actually saying very little about it. The most useful functions I guess are the ones defined in Control.Category, which sometimes make code easier to read: >>> and <<<