HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
YOW! Lambda Jam 2019 - Ken Scambler - Applied Category Theory

YOW! Conferences · Youtube · 93 HN points · 0 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention YOW! Conferences's video "YOW! Lambda Jam 2019 - Ken Scambler - Applied Category Theory".
Youtube Summary
Applied Category Theory - The Emerging Science of Compositionality

What do programming, quantum physics, chemistry, neuroscience, systems biology, natural language parsing, causality, network theory, game theory, dynamical systems and database theory have in common?

As functional programmers, we know how useful category theory can be for our work - or perhaps how abstruse and distant it can seem. What is less well known is that applying category theory to the real world is an exciting field of study that has really taken off in just the last few years. It turns out that we share something big with other fields and industries - we want to make big things out of little things without everything going to hell! The key is compositionality, the central idea of category theory.

This talk will introduce the emerging field of applied category theory, with the aims of:

Giving attendees a broad overview of cutting-edge applications of category theory
Building an understanding of a small number of the most important core concepts
Getting attendees excited, inspired to learn more, and equipped to apply some basic concepts to their work

Ken is a Melbourne-based software developer, who keeps the 1s pointy, the 0s round, and the data structures immutable at MYOB. He is an outspoken advocate of functional programming, an FP community builder in Melbourne, a co-organiser of the Compose :: Melbourne FP Conference and Melbourne Scala User Group, and previously ran the weekly "FP Guild" at REA Group.

For more on YOW! Conference, visit http://www.yowconference.com.au
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
May 02, 2020 · 91 points, 20 comments · submitted by Kinrany
ssivark
The concepts are intuitive enough, and make sense. But I don’t see what non-trivial insights this gives us.

I found the talk frustratingly vague. After all the hard work of setting up categories/operads in an example, the talk moved on without using them to do anything interesting.

lidHanteyk
Here is one non-trivial insight: Every formal logic corresponds to a category.

When we do logical deduction, we have facts and rules. We can apply rules to facts to get more facts. More specifically, formal logic is built from situations where we have some fact P, some rule P => Q, and some conclusion Q.

In a category, we have objects and arrows. We can imagine arrows as mapping one object to another, or sending one object to another. We might have objects P and Q, and an arrow f : P -> Q relating them.

The connection continues. We can take multiple rules in logic and apply them sequentially, building a proof tree; we can take multiple arrows in a category and compose them sequentially, building a path. In some logics, there is an idea of ex falso quodlibet, or from the false fact, anything can be proven; similarly, in some categories, there are initial objects, which come with arrows from the initial object to every other object.

Just like how logical formalism eventually removed the possibility that logic is non-mathematical, category theory removes the possibility that logic is unstructured. Logic is actually incredibly highly structured, and those structures happen to coincide with structures in other parts of maths and physics.

jiggawatts
Again though, how do I use this to solve everyday problems?

I've seen some vaguely cool stuff done with Category theory in Haskell, e.g.: composable tree parsing and traversal, but I've never seen anyone actually use any of this stuff to make a deliverable piece of software that is notably better than what developers can readily produce using traditional procedural languages.

I mean sure, I suppose it would be nice if the C# team added some sort of category theoretically "pure" tree processing sub-language akin to some bastard child of LINQ and XSLT, but... meh. I don't think it would see a lot of use in practice.

roenxi
I suspect I share your frustration; the academics who teach math tend not to have a very good grasp on why it might be useful.

The point is (probably, maybe) that nothing in programming is intuitive; all the abstractions have to be learned for a first time somewhere. A lot of math education is about cataloguing common patterns, naming them and providing an environment where students can check if they have internalised the obvious pattern or not.

This allows incremental building of knowledge between different people. So for example if someone is trying to build a Something with [Property Z] and person B points out "this is a [mathematical object X] therefore [theory Y] says the Something won't have [Property Z]" then the builder can understand the implications immediately and abandon the effort, or identify what needs to change to make the Something not an [object X]. Saves a lot of discussion, enables a lot of coordinating. You can ask an expert to check your work for [Object X]s if you never quite got confident in the concept.

A bit like how an engineer might look over another's design and say "the tensile stresses on that beam will be huge!" and the designer will be able to make a lot of assessments in an instant that would need a good half hour if the concept of tensile stresses wasn't part of a common language and the mistake-finder had to explain stress & strain from first principles.

So yeah; a lot of it probably is trivial but it saves hours of discussion and explaining out in the real world. And there is benefit in moving the explaining up early where it is dealt with in a 30:1 classroom setting and it doesn't slow down design work.

Koshkin
My view on this is that Category Theory is more of a framework for your brain rather than for your computer. As the founders of the theory had noted, categories were introduced as a basis for explaining what a functor is, and functors were needed to explain the phenomenon of natural equivalence. It is indeed practically useful to program your brain in such a way that you could better discern common patterns and be able to see that what you are trying to do is equivalent to something you’ve done before; being able to express this directly in code when possible (depends on the language) comes as an added benefit.
wisnesky
We're using applied category theory quite heavily in the design and implementation of the categorical query language CQL: https://www.categoricaldata.net . There category theory gave us algorithms that are missing from SQL (such as for left Kan extensions) and the ability to do extended compile time checking of queries against data integrity constraints; for most of CQL internals, it's unclear how you could make it work without category theory.
auggierose
I have tried to learn category theory a few times, but it always quickly became mind-bogglingly boring with all the stuff that is trivial in any given setting, but which I find harder to digest in the general category-theoretic setting. I would say areas like logic have ample applications of category theory once you have truly digested its concepts. But it is such a boring way to get there :-)
vcxy
> Again

The GP asked for nontrivial insights from applied category theory, not a recipe for use in everyday problems. I do not think every insight immediately leads to basic recipes that are used in day to day tasks. I haven't digested enough if the papers in the field yet to have a good answer for the GP, but I think you are not asking a fair question of a field as young as ACT.

lidHanteyk
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

ssivark
Very 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
XML 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

auggierose
But 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
Better 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
Yes, 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.
iaml
Here's a practical example I've been thinking about a lot recently, in the context of frontend/react. You could create out of the building blocks today a very different kind of ide inside your browser. Imagine this: you are creating a component, you start with graphical part then in the browser you open a dev menu that is connected to redux or maybe just a list of api call functions or a bunch of hooks. You compose those to match with component props directly in browser and the hoc with required prop transformations is generated with appropriate typings and possibly test data ready. This covers a sizeable chunk of work I do everyday, and now even designers could do it. Especially if we hide git interactions from them too, which is also not very compicated.
ssivark
To clarify my above comment, since most responses are tangential... I’m comfortable with abstraction. I only want to see a hard/confusing solution become easy with category theoretic ideas. (Need not even be an “everyday” problem; all kinds of examples appreciated)

One possibility I can imagine is that in a highly compositional language like Haskell, where structural patterns could be factored out as libraries, identifying patterns in a new problem means that you can now just use the library to take care of the structural “boilerplate” when writing code to solve the new problem, and focus purely on the domain-specific tidbits... in a sense allowing maximal code-reuse and convenience. It’s not Luke one couldn’t have solved the problem without categories — it’s just that there’s less “design pattern” boilerplate and correctness guarantees. I guess this is what it means to “make the trivial into trivially trivial” :-)

Tho approach is then not very useful when you’re interested in solving only a single problem. But if you want to solve many problems, then this approach gives HUGE leverage towards reducing incidental complexity in code, and should be particularly useful when designing frameworks/libraries/DSLs/etc for maximal reuse.

mikorym
There are foundational problems that can be studied via category theory, such as the view-update problem [1]. So, if you want to design a database you are faced with the problem of two users trying to update the same data at the same time and you will have to make a design decision about how it should work.

I don't know if the video itself maybe fails to properly point out uses of category theory.

My opinion on the matter is that if you do want to use mathematics in your everyday work, the main applications will come from the mathematics you know the best. So, whether you are interested in category theory or not will also influence whether you use it. Many of the concepts in category theory can be done instead in algebra and analysis, but it is the spirit of unification that inspires people to study category theory. A lot of functional programmers are delighted when they learn about axioms such as associativity (since you can prove thing about your program) but the concept is much older than category theory. So you can just know associativity if you are not really interested in category theory and that will already take you far.

[1] M. Johnson and R. Rosebrugh, Fibrations and universal view updatability, Theoretical Computer Science 388.1, 2007, 109–129.

ssivark
This is a fascinating topic, which could definitely do with a couple of blog posts, sketching out ideas/examples at a high level.

I achingly keep track of all these beautiful lecture notes, each over 50 pages long, that I bookmark because I’d love to read them, but never get around to doing so...

dang
Url changed from http://lambda-the-ultimate.org/node/5581, which points to this.
Kinrany
I initially decided against posting the video because the thread has a small amount of discussion.

Mainly the link to related work: Seven Sketches in Compositionality, https://arxiv.org/abs/1803.05316

Edit: previously on HN: https://news.ycombinator.com/item?id=20376325

jmount
Unfortunately in mathematics "application" is often a synonym for "prove a lemma or theorem."

David Spivak told me Peter Freyd once said, “Perhaps the purpose of categorical algebra is to show that which is trivial is trivially trivial.”

This will only work for those who already find category theory trivial (a hard thing, as it is so general) and the target domain novel (so they are not yet confident what is trivial and non-trivial in that domain). If done wrong it can look like the art of making the easy hard.

One good use of category theory is: admitting there are composition patterns other than function composition. For example: in scikit learn the fit_transform interface has composition. When you wire up compatible classes in a pipeline they lash together the fit, transform, and fit_tranform methods in a simultaneously useful and consistent manner. With category theory you can say this is a nice form of composition, even though it is not mere composition of functions.

Another idea that can be made clearer is: separating a function's identity from its action. This lets us claim code optimizations are correct. That is f1 := x -> 2.0 x can be thought of as doubling every real number. Now for real numbers (unfortunately not for mere floating point numbers!) we have an inverse f2 := x -> x/2.0. Under a very narrow view of composition we might force f1(f2(x)) to be realized by code such as 2.0(x/2.0). If we think of composition as different than action, we might say f1(f2(x)) is just x (though again, this is true over the real numbers- not over the floating point numbers).

victorthehuman
This is a test comment pls ignore
Aug 05, 2019 · 2 points, 0 comments · submitted by furcyd
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.