8 ms·
A few months ago, while employed at a shop, I wrote about a hundred lines of Python which performed a basic katamorphism on some XML, outputting a PNG. Nobody e
by lidHanteyk 6y ago
A few months ago, while employed at a shop, I wrote about a hundred lines of Python which performed a basic katamorphism on some XML, outputting a PNG. Nobody else on my team could conceive of this, and were mystified by the fact that I could just sit down and do this. It wasn't too hard, though, because I could imagine the entire katamorphism in my mind.
The traditional approaches weren't just stymied by this problem, BTW; the other developers wanted to go shopping for off-the-shelf components which transform XML to PNG, as if that would get us the specific katamorphism we desired.
The nature of your everyday work will inform what you can do with category theory. I personally use category theory to design programming languages; it's something for which category theory gives a turn-the-key recipe:
* Pick some objects of interest
* Define a relatively free Cartesian closed category whose objects include your objects of interest
* Enrich the category with interesting arrows
* Extract a combinator basis
The MarshallB programming language [0] is a good example of this recipe in action.
[0] https://dl.acm.org/doi/10.1145/3341703 https://dl.acm.org/doi/10.1145/3341703
- auggierose 6y agoBut the real interesting part here is the use of exact real arithmetic, not the category theoretic part. Category theory is just used as scaffolding. I would also say it is dangerous to see things only through the category-theoretic lens, because no doubt, as with any generalisation, there will be plenty of situations where it does not provide the right generalisation.
- lidHanteyk 6y agoBetter scaffolding leads to bigger, better buildings. Don't knock the auxiliary and ancillary techniques; they're still necessary for this sort of work to be understandable. Also, from my perspective, the exact real arithmetic isn't super-interesting because it's not new; Turing was doing this sort of thing when he first got access to computers. Legend has that one of Turing's first recreational programs was computation of zeros of the Riemann zeta function, and ever since, there's been a tradition of exploring exact real arithmetic with computers and programming languages. MarshallB is one more incremental step forward in a big research programme of overcoming the inconvenient fact that we can't test real numbers for interesting properties with computers alone. At no point have I advocated only category theory. Categories are always composed of some collection of arrows (and objects, but I prefer object-free presentations!), and those arrows are always homogeneous, if not homoousios, composed of a single substance. We can study that substance on its own. Perhaps an analogy to materials science would be appropriate. We ought to study both each building material, be it sets, vector spaces, relations, graphs, or type theories; but also the architectural principles used to make buildings, like abstract algebra and category theory.
- auggierose 6y agoYes, nothing against better scaffolding, as long as you recognise it for what it is. Arguably exact real arithmetic is older than inexact real arithmetic ;-) But that's not the point, I think the point is that it becomes interesting now to actually do computations with it. It helped me program solid modelling operations for triangle meshes, when I was despairing doing it with normal floats. Switching to exact real arithmetic allowed me to see things clearer, and once I had what I wanted running with exact real arithmetic, I could switch back to floats to make it faster.
- ssivark 6y agoVery interesting. Could you describe 1. what was the problem you were trying to solve? 2. What a non cat. th. solution might have looked like 3. What a “katamorphism” enabled you to do?
- lidHanteyk 6y agoXML files have a tree structure. A katamorphism on a tree, often called a fold in functional programming, is simply a function which recurses through the tree and flattens its data into a single summary. I can't share the details of the program with you, but hopefully this helps. Wikipedia has more information and an example at [0]. [0] https://en.wikipedia.org/wiki/Catamorphism#Tree_fold https://en.wikipedia.org/wiki/Catamorphism#Tree_fold