You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.
First let me give some context. I'm coding an application, and I'm trying to interpret within category theory. Thus, I've started by assuming that the programming code was in the category of sets, with types as sets, and programming functions as mathematical functions in set-theory.
From that, I've coded a free monad . Given a type , an element of is an expression tree where the leafs have values of type .
In my code, I have an special type called , which represents primitives. Given a type (set) , I wanted to assign a function , i.e. a function that receives a value of type and constructs an expression formed by primitives. After some discussion, some people pointed out that the whole thing could be seen as the slice category . Indeed, after inspection, they were right, and this interpretation fits nicely (I wanted the composition to work like it does in the Kleisli category).
Here is my new conundrum. I now want to use my monad to construct expression trees where the leafs have "type" , but is a category not a set. Hence, I can't just interpret it as a type. I was wondering if there is a way to interpret this category in programming. My first idea was to somehow represent as a set or perhaps as a subcategory within the category of sets. I thought of Yoneda lemma (which I am frankly still in the process of fully understanding).
I have a few thoughts/questions for you, as I'm trying to understand what you want to do:
This starts to remind me of composition in an operad, which looks like this:
composition in an operad
We could imagine the "wires" coming down the page as the different ingredients we need to build something, and each triangle as a process that uses a given recipe to build something new from these ingredients. (The image is from "Entropy and diversity" by Leinster).
I'm not sure how closely this relates to what you want to do.
For 1., the answer is that is the function that applies to each leaf of , turning it into a .
About 3., yeah, it does sounds like operads. But I never quite understood operads and how to use them in programming.
Thus I just went another route. I ended up with the idea of the free monad .
Thanks for clarifying!
I still don't think I quite understand what you want to do. Is a tree where the leaves are objects from the sort of thing you are looking for?
Yes. For example, in I have . Which is an expression that says "draw then then ". I want to have .
Which is an expression constructed using , but applying to the object in the slice category.
Note that this expression can be translated into by applying , e.g. gives me an expression of expressions i.e. . Since is a monad, I can simply use , thus, returns a .
This interests me because it means I can construct complex expressions in using the "encapsulations".
Makes sense?
This has be clumsly coded, but it works... I'm now trying to find a categorical justification
David Egolf said:
Thanks for clarifying!
I still don't think I quite understand what you want to do. Is a tree where the leaves are objects from the sort of thing you are looking for?
Perhaps my example clarified that the leafs have "types"that are objects in , they are not directly the objects.
I guess the idea is similar to saying that I want to use which should mean that I want to construct a tree where each leave is a monoid, but each monoid can be distinct (e.g. one can be a list of strings, the other can be the integers using sum, and so on).
Davi Sales Barreira said:
Yes. For example, in I have . Which is an expression that says "draw then then ". I want to have .
I'm still working on reading the rest of what you said, but these tuples remind me a lot of the "category of elements" construction. If we have a "forgetful" functor that sends to just , then an object in the category of elements for is a tuple , where .
Here's the definition, for convenience (from "Category theory in context"):
category of elements
If I understand what you are saying, you want to construct trees where the leaves are tuples of this kind. (These trees encode expressions combining these tuples). If so, I think you are looking for trees having leaves that are objects in the category of elements of .
Hmm, I'm not sure. I'll have to think about it.