Monads ​Categories for the Working Programmers​(fully coded)​Part 1-α14.0
Dara O Shayda
dara@compclassnotes.com
In[]:=
DateObject[]
Out[]=
Mon 27 Oct 2025 18:57:04GMT
Abstract
This computational notebook, first of its kind, is an exercise to program the Natural Transformations η, μ in a Monad category
<X,,η,μ>
and its -algebra using a programming container called μονάς onas (/moˈnas/)[10]. In programming, Monads are cookie-cutter symbolic structures, structs or classes or templates or modules (parametric symbols), that construct new algebras out of mere Lists, and de-construct algebras back into Lists Borceux [8]. Main Results: 1)
μ:
2

⟶
as replacement for the Cartesian product of two sets
μ:M×M⟶M
is programmed into a monoidal symbolic structure that doubles the number of free variables of , with a proper subscript indexing algorithm, to obtain
2

as the core implement of the entire Monad algebras. 2) Lists are programmed to always be a monoidal product as opposed to data types. This treatise is a fully coded notebook developed for the working programmers to use Monad’s theoretical formal system to program and deploy new algebraic systems or even new algebraization(s) of existing structures e.g. Image Processing, Lie Matrix groups and group actions. We do that by coding symbolic scripts to get used to Monad’s innate structures [4], familiarize our minds with the Natural Transformations η, μ. In my case, the motivation was to follow the advice of Jose Meseguer [7] to advance his construction of monoidal Petri categories to more advanced algebraization(s) by breaking through the rudimentary monoid structures and explore new possibilities for more advanced monoidal Petri Nets. The foundations of this symbolic theoretical work, the categorical theories and Monads, are based upon the Saunders Mac Lane [6] and Francis Borceux [8]. Scanned pages from the chapter 4 volume 2 of Borceux [8] are annotated and coded in onas to match the Monad theory. Similar 3D categorical schematics introduced to support the Monad’s theoretical setting of Saunders Mac Lane [6] . All told, hopefully you will partly program several Monads and with ease to arrive at the categoricity of Monads.
​
Live Notebook:
https://www.wolframcloud.com/obj/ccn2/Published/Monad_Part1.nb
 In case of bugs in the code or mistakes in the theory please make contact to fix ASAP.
100% Fat Free Mathematics​​
Software
Release: α14.0
. To code these Monads to produce the final results is trivial for me but to get them to follow the theoretical apparatus of the categories and involved algebras and to produce actual familiar examples was dang hard! Finally to get the new products computed by the Monad algebras to Associate was painful. For that matter the number of alpha trials are much higher than usual .
Scripts: Symbolic computations performed in Wolfram Mathematica 14.3 .​​Notebook: https://www.wolframcloud.com/obj/ccn2/Published/Monad_Part1.nb ​​Support: Contact the author for additional code, bugs, correction in maths and algebraic/mathematical mistakes or invalid inferences.​​Nomenclature: Most functions and most identifiers start with lower case letters, all native vendor identifiers start with upper case. ​​No Packaging: There is no software engineering applied to the code here nor elsewhere in the author’s technical notes to reduce the difficulties and version mismatches in future. The eager readers can simply copy paste the code or download and run the notebook. ​​TODO: 1. Full JSON ASCII output support for third party Python, JS, C/C++/C# programs.2. Image processing Monads for 2D and 3D 3. Monads on Vector Bundles 4. Comonads and Jets5. String Rewriting Cats for Monads, I have some vague ideas but coding would focus the theory forward!6. Add as many group action matrix groups as possible specially for physics ​​TOLEARN:1. Kelisi categories 1. Monads on Vector Bundles and their cats and fibered manifolds and so on2. Comonad, Michael Marvan work3. Category of Differential Equations4. Explore Categorical Equational Proofs and possible deployments of Monads e.g. Ryerheard and Stell 1987​ Known Issues:​1. Consult with Wolfram support on how to consolidate the Unicode math symbols with their counterparts.2. Images to Symbols in Wolfram platform. 3. We need larger multi letter and possibly glyph Formalized symbols in Wolfram Mathematica. ​​
© 2012-Present CCN Studios​​Creative Commons Attribution-NonCommercial-ShareAlike 4.0​​​
​​
Initialization
In[]:=
Notation`AutoLoadNotationPalette=False;​​Needs["Notation`"];​​ClearNotations[];​​​​CloudGet["https://wolfr.am/1AkIFdB3H"];​​onasinit[];​​
onas-version: α14.0
1 Monad: Philosophy, Etymology and Programming
 What you read below by Saunders Mac Lane is the core concept for a programming technology to encapsulate all multiplicative products into a single programmable API to be able to program new multiplicative products. ​Imagine this as a Class in some object oriented programming language, which defines the blueprint for all binary or Listable products. ​Moreover, this de novo programmable structure is to extend the reach of the programming languages into non-Set-Theoretic mathematical formalism where the Sets and their Cartesian products are no longer viable or even extant. ​All that which I coded and present here is to this end to build new algebras out of Monads. ​​ Keep in mind that ; is a product, the elidable Text Concatenation is also a product, while { } or ( ) or [ ] are Lists! ​​elidable: (or elidible) is an adjective meaning “capable of being elided” (omitted or left out) without changing the fundamental meaning, often for style, fluency, or programming efficiency, describing things like syllables, words, or even code operations.

μ:
2

⟶
as replacement for the Cartesian products of two sets
μ:M×M⟶M
is programmed into symbolic structures which doubles the number of free variables of  to obtain
2

as the core implement of the entire Monad algebras:
Out[]=
The term Monad (from Ancient Greek μονάς (monas: /moˈnas/ [10]) ‘unity’ and μόνος (monos) ‘alone’) [1,2] is used in some cosmic philosophy and cosmogony to refer to a most basic or original substance. As originally conceived by the Pythagoreans, the Monad is therefore Supreme Being, divinity, or the totality of all things. According to some philosophers of the early modern period, most notably Gottfried Wilhelm Leibniz, there are infinite monads, which are the basic and immense forces, elementary particles, or simplest units, that make up the universe.
​
According to Hippolytus of Rome, the worldview was inspired by the Pythagoreans, who called the first thing that came into existence the “monad”, which begat (bore) the dyad (from the Greek word for two), which begat the numbers, which begat the point, begetting lines or finiteness, etc.
Out[]=
Monad in Ergo Proxy anime [3]
extant: 1540s, “standing out above a surface,” from Latin extantem (nominative extans), present participle of extare “stand out, be visible, exist,” from ex “out” (see ex-) + stare “to stand,” from PIE root *sta- “to stand, make or be firm.” Sense of “in existence” attested in English by 1560s. Related: Extance; extancy, both 17c., both obsolete. Still in existence; surviving e.g. “an extant letter”.
structure: that which can be subjected to similarity (measures).
Programming Container: is a collection of cloud objects that remotely construct and host to provide the functions and symbols of an entire software system for custom programming languages regardless of programming platforms.
1.1 Why code to study Monads?
● We will follow the advice of Jose Meseguer [7] to innovate new algebras for real applications, for example Petri Nets and their categories. He laid out some preliminary examples and I will code them a sequel soon.
... again one more time: What to code?
I follow the footsteps of the innovators of the Category theory and Monads, on programming Monads I follow the aim and purpose of the Functors by Saunders Mac Lane:
Let’s adumbrate these answers with brief examples. When it comes to Monads the devil is in the details!
​
​The devil is in the details: is an idiom alluding to a catch or mysterious element hidden in the details; it indicates that “something may seem simple, but in fact the details are complicated and likely to cause problems”.
● Monads are not monsters they can be anything you want them to be, since with their imbued categoricity, a Monad can easily shape-shift from one multiplicative product to another, shape shift from one algebra to another, and as a matter of fact you could discover new such products on your own during the interactive codexplanations below.
codexplain: code explain as in explain the formal system with its construction code.
1.2 onas[ ] Programming Strategy
● onas[ ] to follow the mathematical formal systems’ syntax and semantics as closely as possible.
● onas[ ] container’s general form is (x : y) with the assumption that the LHS “(“ is entrance into the container and the “)” RHS is the exit out of the container. This allows for surgical separation of the onas [ ] programming from Wolfram programming.
● onas[ ] container to contain solvers for all involved equational abstractions. The programmer must not waste time solving equations, that is what the inner machinations of Monads ought to do on their own.
● onas[ ] container is not the same as a programming language scope since the onas[ ] container might include asynchronous and parallel Sting and Term Rewriting elements as well as multitudes of functions and network IO.
● onas[ ] container includes quite a few groups and matrix groups e.g.  [n],  [n], [n], upper triangular matrices in [n] and diagonal matrices [n]:
or
● dom stands for Domain in functions and morphisms in category theory:
● These generated groups’s Automorphisms form their own group which is a Category with single object namely the group itself, and onas [ ] computes the actual morphisms:
and their inverses:
● onas[ ] programming phrases are to be as short as possible .
● onas[ ] programming phrases can be nested .
● onas[ ] programming phrases can be nested .
● onas[ ] programming relies on generators for most of the involved mathematical formal systems.
1.3 onas[ ] : Hello Lists!
● onas[ ] gives the programmer implicit and explicit access to the expressions in a Monad and its algebra.
● onas[ ] lists are always internal monoid products which almost always result into external monoid products.
● Following the denotations by Saunders Mac Lane [6], onas [ ] defines list by these angled brackets 〈 〉 , counterparts of Wolfram Mathematica’s curly brackets { } . You can use the { } in an expression and onas [ ] converts them to 〈 〉, start with a simple nested list :
The reverse:
Out[]//InputForm=
ζ ⋄ {x, ζ ⋄ {y, z}}
Or simply use the angled brackets 〈 〉 :
● onas[ ] allows all functions to be listable unless already barred:
● Nested lists:
● Replace functions by their symbols by simply placing this Sin→foo in the LHS of onas’ : Colon symbol:
● add a body to a function meaning define the function properly:
1.4 Monad programming Symbols
The following are the symbols for the programmers to code a Monad. As you can see the symbolics is glyph based in part with the purpose to shorthand the onas[ ] expressions. :
Note the empty String double quote, it is a specific font, please use only the fonts in the following:
Yep, no bugs here it works:
Use onas’ []: to format the matrices:
1.5 Why and What is ξ ?
● ξ (/saɪ/) [14] is a symbol or a token. In different evaluations in onas, per Monad’s category theory, ξ behaves certain ways apart from other symbols.
Remark: ⭑ symbol below is the arithmetic multiplication/product of Real numbers including all the * properties
● Reverse:
● Reverse:
List is the functional version of List[ ] in Wolfram Mathematica.
● Live dangerously:
-f breaks into a list both in Mathematica and onas[ ] :
​
2 onas[ ] coding Francis Borceux’s Monad
● In this case we call ξ a Symbol or Module which is a parametric symbol in this case the parameters are included in the list {a,b,c,d}. ξ is not a function nor an operator.
● Prof. Borceux used ξ as a variate map of some kind, ξ can be replaced by many Listable multiplicands or summands:
● Mix images into your onas[ ] lists:
2.1 ⧈ Image Assembly Product
● Current initial setup pads the images and rasterization of non-image list members to fixed width and heights similar to fixed length fonts:
● Spacings is an integer value that depicts the image riffle gap size, default is 2 but set it to 0 for a tight fit.
● ImageSize is an integer value that depicts the image width size or enter a list {width, height}.
2.2 Functional Image Processing
The elidable invisible String concatenation is modeled as Double quote , place at the LHS of symbol Colon : and accommodates for the empty string as the unity element:
elidable: (or elidible) is an adjective meaning “capable of being elided” (omitted or left out) without changing the fundamental meaning, often for style, fluency, or programming efficiency, describing things like syllables, words, or even code operations.
2.3 ξ as a multiplicand not as a function nor a Type, but why?
In onas the native lists are of the format 〈 . , . , ... 〉 :
Out[]//InputForm=
ζ ⋄ {a, b, c}
2.4 Nested Monad Lists ≡ Monoid
● Nested onas Lists are flattened by the list product the symbol ⦗⦘:
Out[]//InputForm=
ζ ⋄ {a, b, c, d}
● Nested and different onas containers:
η
Remark: ∈ in Borceux [8] is replaced by a more standard η symbol.
Out[]//InputForm=
ζ ⋄ {, abcd}
● Single symbols e.g. a is enclosed with ξ⋄{ } :
Out[]//InputForm=
ζ ⋄ {{}, a}
Out[]//InputForm=
ζ ⋄ {1, a}
Out[]//InputForm=
ζ ⋄ {1, a ⊗ b ⊗ c}
● { } curly brackets:
Out[]//InputForm=
ζ ⋄ {{}, {a, b, c}}
2.5 onas[ ] Inner Product
2.6 List[ ] ≡ Monad List
2.7 onas[ ] Array
2.8 onas[ ] Array
2.9 ✖ : onas[ ] Matrix Multiplication
3. onas[ ] Parametrized Matrix Groups
In mathematics, a matrix group is a group G consisting of invertible matrices over a specified field K, with the operation of matrix multiplication. A linear group is a group that is isomorphic to a matrix group (that is, admitting a faithful, finite-dimensional representation over K).
3.1  [n]
Test for the correctness of the basis:
Follow the example of SO[n] to see how Monad forms a product/monoid out of the rotation group and the same applies to the O[n].
3.2  [n]
3.3 [n]: General Linear Group over 
Det always non-zero:
This takes a bit of time to simplify to 0s:
3.4 [n]: Upper Triangular Reals Matrices
3.5 [n]: Diagonal Matrices
4.onads[ ] : Pictorial Categories
Monads[ ] function computes 3D pictorial rendering of important structures of the Monads and their algebras.
● Arrows: Functions are rendered as directional curved arrows as schematics
● Certain repeated appearances of patterns as we saw above, made the modern mathematicians to categorize mathematics per specific patterns later coined as the Category Theory.
● In the above matrix group structures let us consider the set Auto(G) where the G is a particular matrix group.
● Such patterns and structure of objects, morphisms, compositions and associativity culminate in formation of a Category.
● The above group G forms a single Object category, namely G itself and Auto(G) as arrows or morphisms.
4.4 Example: [3] group category
4.5 Definition Category
● O is the set of all objects
● A is the set of all morphisms
4.6 Morphisms between Categories: Functors
● We can define arrows or morphisms between both the objects and morphisms of two categories!
● These morphisms are called Functors and they plan an important role for probing categories for similarities.
Thinking Arrowy: This is a modality of mentation that you think of the complex system as an abstract graphVertices are objects in the world and they are connected, somehow, by arrows of some kind. We cannot understand how the objects in the universe are constructed, but can investigate something of the nature of arrows between them. What we measure as observables or what we pontificate in our equations of science are the arrows not the objects.
● A functor, like a category, can be described in the “arrows-only” fashion: It is a function-like T from arrows f of C to arrows T f of D, carrying each identity of C to an identity of D and each composable pair (g, f) in C to a composable pair (Tg, Tf) in D, with Tg ∘T f = T(g∘ f).
​
​function-like: something that behaves like a mathematical function but it might not be one.
● You can say that a Functor is an Arrowy Pattern Matcher between the morphisms/arrows of two categories.
4.8 Example: Power Set Functor
● The above graphics depicts red, green and orange 3D arrows leaving the category, stretching through another space or outside space and then target and object or morphism land back on the original category!
4.9 Definition Functor
● The object function T which assigns to each object X of C an object TX T(X) of D
5 ⇒ : Natural Transformations
● Imagine two functors from categories C to D, acting on an object a in C namely Fa and Ga (F(a) and G(a)) .
5.1 Example: Permutation Functor
● Think of morphisms between the sets as one-to-one functions when available.
● Construct the Permutation lists and let’s uncover the Natural Transformations between F and G from the diagram below. This Natural Transformation is induced by using the Set a as an indexer to both Fa and Ga sets : one-to-one homomorphisms which map each element of the set a to fixed elements in each tuple in the Permutations lists in Fa and nested Permutations lists in Ga.
3D figure above is interactive.
● Compute Fa:
● Compute Ga:
3D figure above is interactive.
● Compute Ga:
● Compute Gb:
6 ξ : The Structure Map of an algebra
onas’ core symbolic computing theory and code is based upon this example by Saunders Mac Lane, which served as the motivation for defining the Monad to begin with [6]. This class of Monads and their Monad Algebra is called Group Actions Monads and defined as follows:
To program and compute meaningful skill building algebraic structures, I decided to rely on the GL (invertible Real matrices) groups and later general Lie groups and their Lie algebras. My thoughts are that if we can come this far with matrix groups then we can surely graduate to Manifold theory and other finger licking abstract and intricate formal systems.
6.3 μ
6.4 μ is a Natural Transformation
6.5 Monad Algebra: where the rubber meets the road
where the rubber meets the road: The point at which someone’s or something’s efforts, resolve, or viability are put to the test; the point at which things become truly or meaningfully challenging.
● Monad begets all lists! Monad is the list maker! Monad does not understand anything else but how to fashion everything into Lists
● Monad Algebra begets all products, but exclusively from Monad’s lists!
6.6 Group Action Monad:  [3]
● ↦ not a function it is a symbol as a part of the definition of the . At lower levels it might be a function, or a part of a Term or Text Rewriting system. Best to understand ↦ as a part of a Rewriting System to be as general as possible.
● { } serve as bracketing operators for textual data and have no other meanings. They can be thought of as Lists or simply two symbols forming a grouping of other symbols.
6.7 μ
6.8 Group Action Monad: [n]
​
 TODO not sure how to identify which symbols can be re-indexed and which to remain constant:
References
1. https://en.wikipedia.org/wiki/Pythagoreanism
​
2. Monad Philosophy
https://en.wikipedia.org/wiki/Monad_(philosophy)
​
3. Monad anime
https://en.wikipedia.org/wiki/Ergo_Proxy
https://www.anime-planet.com/characters/monad-proxy (source image)
​
4. John von Neumann’s quotes
https://en.wikiquote.org/wiki/John_von_Neumann
​
5. Francis Borceux, Handbook of Categorical Algebra 2.
​
6. Saunders Mac Lane, Categories for the Working Mathematician
Second Edition
​
7. Jose Meseguer, Ugo Montarari, Petri Nets are Monoids. Information and Computation 88, 1990
​
8. Francis Borceux, Handbook of Categorical Algebra, volume 2.
​
9. Monad Idea
https://ncatlab.org/nlab/show/monad#Idea

10. μονάς onas[ ] (/moˈnas/)
https://ipa-reader.com/?text=moˈnas
​
11. https://en.wikipedia.org/wiki/Rewriting#Arithmetic
​
12. History of mathematical function: first formal definition
https://en.wikipedia.org/wiki/History_of_the_function_concept#Lobachevsky_and_Dirichlet

13. Inner Product
https://mathworld.wolfram.com/InnerProduct.html

14. ξ (/saɪ/)
https://ipa-reader.com/?text=sa%C9%AA

15. ∋ Peano symbol for suchthat, According to Julio González Cabillón, Peano introduced the backwards lower-case epsilon for “such that” in “Formulaire de Mathematiques vol. II, #2” (p. iv, 1898).
https://jeff560.tripod.com/set.html

16. Vect(X) Category of vector bundles over X​
​ https://ncatlab.org/nlab/show/Vect%28X%29

17. Grp
https://ncatlab.org/nlab/show/Grp
​
​
​