What good is Control.Category?

777 views Asked by At

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 (.) ?

2

There are 2 answers

1
bzn On BEST ANSWER

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 <<<

0
Landei On

Control.Category is just the ground work for Control.Arrow, and that's where you get the fun functions from.