What good is Control.Category?
Asked Answered
V

2

14

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

Valeriavalerian answered 19/10, 2011 at 7:44 Comment(1)
As with all abstractions, there's a tradeoff: either you can do a lot of things with them, or you find out lots of things are instances of them. Categories go as far as they can towards the "lots of things are instances of them" side of the tradeoff: damn near every mathematical idea has an underlying category. The price you pay for the common terminology between all these ideas is that merely calling something a category doesn't give you much information. If you want more, you've got to dangle adjectives on the word: "cartesion closed category", or "braided monoidal category", etc.Barytone
H
11

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

Hydromel answered 19/10, 2011 at 7:49 Comment(1)
Addendum: "Wikipedia says" that category theory was regarded as 'general abstract nonsense' (in a good way), because it is extremely abstract.Separation
D
7

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

Diabolize answered 19/10, 2011 at 8:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.