Discusses the algebraic properties of types, different kinds of functions and the information that is preserved or lost, and Category Theory concepts that underpin and unify them.
Explains the basic concepts of Category Theory, useful terminology to help understand the literature, and why it's so relevant to software engineering.
Introduction to Category Theory for software engineersPranav Prakash
An Introduction to Category Theory for Software Engineers. By Dr Steve Easterbrook
Associate Professor,
Dept of Computer Science,
University of Toronto
sme@cs.toronto.edu
Discusses the algebraic properties of types, different kinds of functions and the information that is preserved or lost, and Category Theory concepts that underpin and unify them.
Explains the basic concepts of Category Theory, useful terminology to help understand the literature, and why it's so relevant to software engineering.
Introduction to Category Theory for software engineersPranav Prakash
An Introduction to Category Theory for Software Engineers. By Dr Steve Easterbrook
Associate Professor,
Dept of Computer Science,
University of Toronto
sme@cs.toronto.edu
Download for flawless quality (slides viewed online look a bit grainy and out of focus). A monad is an implementation of one of the minimal sets of monadic combinators, satisfying the laws of associativity and identity - see how compositional responsibilities are distributed in each combinator set
Function Programming in Scala.
A lot of my examples here comes from the book
Functional programming in Scala By Paul Chiusano and Rúnar Bjarnason, It is a good book, buy it.
Integral Calculus. - Differential Calculus - Integration as an Inverse Process of Differentiation - Methods of Integration - Integration using trigonometric identities - Integrals of Some Particular Functions - rational function - partial fraction - Integration by partial fractions - standard integrals - First and second fundamental theorem of integral calculus
Download for flawless quality (slides viewed online look a bit grainy and out of focus). A monad is an implementation of one of the minimal sets of monadic combinators, satisfying the laws of associativity and identity - see how compositional responsibilities are distributed in each combinator set
Function Programming in Scala.
A lot of my examples here comes from the book
Functional programming in Scala By Paul Chiusano and Rúnar Bjarnason, It is a good book, buy it.
Integral Calculus. - Differential Calculus - Integration as an Inverse Process of Differentiation - Methods of Integration - Integration using trigonometric identities - Integrals of Some Particular Functions - rational function - partial fraction - Integration by partial fractions - standard integrals - First and second fundamental theorem of integral calculus
The Yoneda lemma and string diagrams
When we study the categorical theory, to check the commutativity is a routine work.
Using a string diagrammatic notation, the commutativity is replaced by more intuitive gadgets, the elevator rules.
I choose the Yoneda lemma as a mile stone of categorical theory, and will explain the equation-based proof using the string diagrams.
reference:
1: Category theory: a programming language-oriented introduction (Pierre-Louis Curien)
(especially in section 2.6)
You can get the pdf file in the below link:
http://www.pps.univ-paris-diderot.fr/~mellies/mpri/mpri-ens/articles/curien-category-theory.pdf
2: The Joy of String Diagrams (Pierre-Louis Curien)
http://hal.archives-ouvertes.fr/docs/00/69/71/15/PDF/csl-2008.pdf
3: (in progress) Cat (Ray D. Sameshima)
4: Physics, Topology, Logic and Computation: A Rosetta Stone (John C. Baez, Mike Stay)
http://math.ucr.edu/home/baez/rosetta.pdf
If you are physicist, this is a good introduction to category theory and its application on physics.
His string diagrams, however, differ from our one little.
5: Category Theory Using String Diagrams (Dan Marsden)
http://jp.arxiv.org/abs/1401.7220
outlines
1 Category, functor, and natural transformation
2 Examples
3 String diagrams
4 Yoneda lemma and string diagrams
5 and more...
Notes on intersection theory written for a seminar in Bonn in 2010.
Following Fulton's book the following topics are covered:
- Motivation of intersection theory
- Cones and Segre Classes
- Chern Classes
- Gauss-Bonet Formula
- Segre classes under birational morphisms
- Flat pull back
Stochastic Control/Reinforcement Learning for Optimal Market MakingAshwin Rao
Optimal Market Making is the problem of dynamically adjusting bid and ask prices/sizes on the Limit Order Book so as to maximize Expected Utility of Gains. This is a stochastic control problem that can be tackled with classical Dynamic Programming techniques or with Reinforcement Learning (using a market-learnt simulator)
Understanding Dynamic Programming through Bellman OperatorsAshwin Rao
Policy Iteration and Value Iteration algorithms are best understood by viewing them from the lens of Bellman Policy Operator and Bellman Optimality Operator
A.I. for Dynamic Decisioning under Uncertainty (for real-world problems in Re...Ashwin Rao
Slides from the Research Seminar talk I gave at Nvidia. The topic was: A.I. for Dynamic Decisioning under Uncertainty (for Real-World problems in Retail and in Financial Trading)
Overview of Stochastic Calculus FoundationsAshwin Rao
This is a quick refresher/overview of Stochastic Calculus Foundations. This assumes you have done a Stochastic Calculus course previously and now want to review/revise the material to prepare for a course that lists Stochastic Calculus as a pre-req. In these 11 slides, I list the key content you must be familiar with within Stochastic Calculus.
Risk-Aversion, Risk-Premium and Utility TheoryAshwin Rao
This lecture helps understand the concepts of Risk-Aversion and Risk-Premium viewed from the lens of Utility Theory. These are foundational economic concepts used widely in Financial applications - Portfolio problems and Pricing problems, to name a couple.
To make Reinforcement Learning Algorithms work in the real-world, one has to get around (what Sutton calls) the "deadly triad": the combination of bootstrapping, function approximation and off-policy evaluation. The first step here is to understand Value Function Vector Space/Geometry and then make one's way into Gradient TD Algorithms (a big breakthrough to overcome the "deadly triad").
Stanford CME 241 - Reinforcement Learning for Stochastic Control Problems in ...Ashwin Rao
I am pleased to introduce a new and exciting course, as part of ICME at Stanford University. I will be teaching CME 241 (Reinforcement Learning for Stochastic Control Problems in Finance) in Winter 2019.
HJB Equation and Merton's Portfolio ProblemAshwin Rao
Deriving the solution to Merton's Portfolio Problem (Optimal Asset Allocation and Consumption) using the elegant formulation of Hamilton-Jacobi-Bellman equation.
A Quick and Terse Introduction to Efficient Frontier MathematicsAshwin Rao
A Quick and Terse Introduction to Efficient Frontier Mathematics. Only a basic background in Linear Algebra, Probability and Optimization is expected to cover this material and gain a reasonable understanding of this topic within one hour.
Recursive Formulation of Gradient in a Dense Feed-Forward Deep Neural NetworkAshwin Rao
Recursive Formulation of Gradient in a Dense Feed-Forward Deep Neural Network. Derived for a fairly general setting where the supervisory variable has a conditional probability density modeled as an arbitrary Generalized Linear Model's "normal-form" probability density, and whose output layer activation function is the GLM canonical link function.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
1. CATEGORY THEORY FOUNDATIONALS
MADE EASY WITH (UGLY) PICTURES
Ashwin Rao
This is a sequel to the 3-hour
course we did previously on
Abstract Algebra
2. WHY ARE WE DOING THIS?
• Well, some of us are trying to learn Haskell
• And there is a school of thought that says one must learn Category Theory (CT) first
• While I don’t quite agree with this, I do think a very basic intro to CT is essential
• First PreReq is the contents of Hammack’s Book of Proof – Sets, Logic, Functions etc.
• Second PreReq is the crash-course on Abstract Algebra I had done earlier:
https://www.slideshare.net/cover_drive/abstract-algebra-in-3-hours
• We will combine rigorous definitions with plenty of (ugly) pictures and intuition
• After this course, you will understand the “much ridiculed” but important statement: “A monad in C is
just a monoid in the category of endofunctors of C, with product ⨂ as composition of endofunctors and
unit as the identity endofunctor.”
• After this course, you will also be able to make more sense of wiki pages on CT topics
• For a more detailed (and very nice) coverage of CT, Bartosz Milewski e-book hits the spot!
• I’ve also found sigfpe (Dan Piponi)’s blog posts extremely valuable.
3. Definition of A Category
Category C consists of: Class
†
of objects Obj(C) and Class of arrows Arr(C)
where each arrow f has a source X in Obj(C) and a target Y in Obj(C) denoted f: X → Y
Arr(X,Y) denotes the class of arrows from source X to target Y (some authors use the term
“morphism“ instead of “arrow“).
Binary composition operation ∘ on arrows f and g denoted as g ∘ f
∘ : Arr(Y,Z) x Arr(X,Y) → Arr(X,Z)
∘ operation has two properties:
1. Associative: h ∘ (g ∘ f) = (h ∘ g) ∘ f
2. Identity: For all X in Obj(C), there exists an arrow 1X in Arr(X,X) such that for all f in Arr(X,Y),
1Y ∘ f = f ∘ 1X = f
The default intuition of a category should not be as nodes and edges.
Think of an object as a set, and of an arrow as a function, with special properties assigned to
the sets (objects) and functions (arrows). Rely on visuals and examples to develop intuition.
† Treat the technical term “Class” as “Set” (typically refering to “set of sets”) for the purpose of this class (no pun intended!). For a precise
understanding of Class versus Set, one has to refer to Zermelo-Frankel-Choice Theory which is beyond the scope of this class.
4.
5.
6.
7. Examples of Categories
• SET – Objects are Sets, and Arrows are Functions (across the Sets)
• GRP – Objects are Groups, and Arrows are Homomorphisms (across the
Groups)
• VEC– Objects are Vector Spaces, and Arrows are Linear Transformations
(across the Vector Spaces)
• POS – Objects are Elements of a Partially Ordered Set, and Arrows are ≤
(across the Elements)
• HASK – Objects are Haskell Types, and Arrows are Haskell Functions
8. WTF are Functors and Natural Transformations?
A Functor F is a “mapping” from objects and arrows of a Category C to objects and arrows of a
category D with the following properties:
A. For all X in Obj(C), F(X) is in Obj(D)
B. For all f : X → Y in Arr(C), F(f) : F(X) → F(Y) is in Arr(D) such that:
1. For all X in Obj(C), F(1X) = 1F(X)
2. For all f : X → Y and g : Y → Z in Arr(C), F(g ∘ f) = F(g) ∘ F(f)
So, a Functor is a “structure-preserving“ map from one category to another.
A Natural Transformation 𝜂 from Functor F to Functor G (𝜂 : F → G) associates to every X in Obj(C), an
arrow 𝜂(: F(X) → G(X) in Arr(D) such that for all arrows f : X → Y in Arr(C),
𝜂) ∘ 𝐹 𝑓 = 𝐺(𝑓) ∘ 𝜂(
Don‘t panic – some (helpful) “ugly“ pictures are coming up J
9.
10.
11.
12. The Functor Category
In the previous picture, collapse each of the two “objects arrays” (one for each of the two
functors F and G) into a single object.
Also collapse the “arrows array” (for the natural transformation 𝜂) into a single arrow.
So you can visualize each collapsed object corresponding to a Functor, and each collapsed
arrow corresponding to a natural transformation.
This “Collapsed Category” is called the Functor Category, where the objects are the
Functors and the arrows are the natural transforms.
The Functor Category will be very useful as we get into advanced topics.
13.
14.
15.
16.
17. The Hask Category
Hask is the Haskell category where each Haskell Type is an object in Hask and each Haskell
function f : X → Y (for Types X and Y) is an arrow in Hask.
Arr(X, Y) is the class of functions from X to Y. Arr(X,Y) is a Type and hence, an object in Hask.
The identity function for each Type X is in the class Arr(X, X).
Functor T : Hask → Hask generates higher-order Type T X from each Type X
(X-type-parametric polymorphism).
fmap generates structure-preserving functions T f : T X → T Y from f : X → Y
Functor Typeclass overloading of fmap (ad-hoc polymorphism) gives various functor instances
T1,T2, …. and their fmaps.
Natural Transformation 𝜂 between T1,T2, ... take you across these higher-order Types T1X, T2X, ...
18.
19. Hask examples of Functors and Natural Transformations
[a] and Maybe a are examples of Functors (type-parameterized by a)
Now consider the functions maybeToList and listToMaybe
λ> :t maybeToList
maybeToList :: Maybe a -> [a]
λ> :t listToMaybe
listToMaybe :: [a] -> Maybe a
As you can see, maybeToList and listToMaybe are Natural Transformations.
Connecting this example to some of the pictures we drew earlier is quite helpful, IMO J
20. Are we ready for the M word yet?
A Monad in a Category C consists of:
• Functor M : C → C
• Natural Transformation 𝜂 : 1C → M (1C is the C → C identity functor)
• Natural Transformation 𝜇 : M ∘ M → M (M ∘ M, abbreviated as M2, also a C → C functor)
Furthermore, we require the following so-called coherence conditions:
• 𝜇 ∘ 𝑀𝜇 = 𝜇 ∘ 𝜇𝑀 (as natural transformations M3 → M)
• 𝜇 ∘ 𝑀𝜂 = 𝜇 ∘ 𝜂𝑀 = 13 (as natural transformations M → M)
Practically, Monads let us compose f : X → M(Y) with g : Y → M(Z) into h : X → M(Z)
In Haskell, ≫= ∷ 𝑀 𝑎 → 𝑎 → 𝑀 𝑏 → 𝑀 𝑏 enables this monadic composition
𝜂 corresponds to 𝑟𝑒𝑡𝑢𝑟𝑛 ∷ 𝑎 → 𝑀 𝑎 and 𝜇 corresponds to joi𝑛 ∷ 𝑀 𝑀 𝑎 → 𝑀 𝑎
Also, the Monad Typeclass laws are simply the coherence conditions expressed in code J
21.
22. Coherence Condition 1 illustrated with the [a] Monad
λ> [join [[3,2,4], [9,2]], join [[3,4], [1], [9,0,8]], join [[1,3], [7]]] – This is 𝑀𝜇
[[3,2,4,9,2],[3,4,1,9,0,8],[1,3,7]]
λ> join [join [[3,2,4], [9,2]], join [[3,4], [1], [9,0,8]], join [[1,3], [7]]] – This is µ ∘ 𝑀𝜇
[3,2,4,9,2,3,4,1,9,0,8]
λ> join [[[3,2,4], [9,2]], [[3,4], [1], [9,0,8]]] – This is 𝜇𝑀
[[3,2,4],[9,2],[3,4],[1],[9,0,8]]
λ> join (join [[[3,2,4], [9,2]], [[3,4], [1], [9,0,8]]]) – This is µ ∘ 𝜇𝑀
[3,2,4,9,2,3,4,1,9,0,8]
So, 𝜇 ∘ 𝑀𝜇 = 𝜇 ∘ 𝜇𝑀 is same as the code: join . (fmap join) == join . join
23. Coherence Condition 2 illustrated with the [a] Monad
λ> let ret = return :: a -> [a]
λ> ret [4,8,1,2] – This is 𝜂𝑀
[[4,8,1,2]]
λ> join (ret [4,8,1,2]) – This is 𝜇 ∘ 𝜂𝑀
[4,8,1,2]
λ> [ret 4, ret 8, ret 1, ret 2] – This is 𝑀𝜂
[[4],[8],[1],[2]]
λ> join [ret 4, ret 8, ret 1, ret 2] – This is 𝜇 ∘ 𝑀𝜂
[4,8,1,2]
So, 𝜇 ∘ 𝜂𝑀 = 𝜇 ∘ 𝑀𝜂 = 13 is same as the code: join . return == join . (fmap return) == id
24.
25. Kleisli Category : A good way to conceptualize Monads
A Monad <𝑀, 𝜂, 𝜇> enables us to compose f : X → M(Y) with g : Y → M(Z) into h : X → M(Z)
To do this, we have to express h : X → M(Z) as a composition of the following 3 arrows
• f : X → M(Y) – This is the basic morphism we start with
• M(g) : M(Y) → M(M(Z)) – We need this “functored“ morphism M(g) to go forward from M(Y)
• 𝜇Z : M(M(Z) → M(Z) – We need this morphism 𝜇Z generated from the natural transformation 𝜇
to reduce the higher-order object M(M(Z)) to the desired object M(Z)
Now consider a Category CT (called the Kleisli Category) derived from the original Category C
• Each object of C is also an object of CT
• Each arrow X → M(Y) of C gives us the arrow X →T Y in CT (known as Kleisli arrows)
• Each composition 𝜇B ∘ 𝑀 𝑔 ∘ 𝑓 in C gives us the composition 𝑔 ∘D 𝑓 in CT
Kleisli arrows compose naturally in the Kleisli Category (a good way to conceptualize Monads).
26. Monoidal Category
A Monoidal Category C involves :
• BiFunctor ⨂ ∶ 𝐶 × 𝐶 → 𝐶 (refered to as the monoidal product)
• Object I (refered to as identity object)
• Coherence conditions expressing ⨂ associativity and left/right identity laws
The idea is that ⨂ combines any two objects to yield an object (akin to Monoids).
Note that ⨂ will also apply (in a natural way) on the arrows across the objects of C.
Example 1: Hask is a Monoidal Category where ⨂ is simply the Cartesian Product of
Types (i.e., objects), which naturally produces a Cartesian Product on Functions (i.e., arrows)
across those Types. Any singleton Type will behave as I.
Example 2: Recall the Functor Category we covered earlier (objects are Functors and
arrows are Natural Transformations). This is a Monoidal Category where ⨂ (on objects) is
the composition of functors and ⨂ (on arrows) is the composition of natural transformations.
Identity Functor will behave as I.
27. Monoid Object
A Monoid Object M in a Monoidal Category < 𝐶, ⨂, 𝐼 > involves :
• Arrow 𝜂 ∶ 𝐼 → 𝑀 (akin to monoid unit, i.e., monoid identity element)
• Arrow µ ∶ 𝑀⨂𝑀 → 𝑀 (akin to monoid multiplication)
such that the following two coherence conditions apply:
• 𝜇 𝑀⨂𝜇 𝑀⨂𝑀 = 𝜇 𝜇 𝑀⨂𝑀 ⨂𝑀 = 𝑀 (akin to associativity in monoids)
• 𝜇 𝑀⨂𝜂 𝐼 = 𝜇 𝜂 𝐼 ⨂𝑀 = 𝑀 (akin to left/right identity laws in monoids)
The idea is that if we peer inside the object M, 𝜇 operates like closed monoid multiplication
on elements within M, and 𝜂𝑥 in M operates like monoid identity for any x in I.
28. Monoid Objects in the Functor Category
Now let us consider monoid objects in the Functor Category (viewed as a Monoidal Category)
If we squint hard at the coherence conditions for the monoid object (specialized to the Functor
Category), we see that they reduce to the coherence conditions we had stated for a Monad.
In other words, “A monad in C is just a monoid in the category of endofunctors of C, with
product ⨂ as composition of endofunctors and unit as the identity endofunctor.”
This provides an alternative mental model of monads – viewing them as monoids.
Let‘s use the [a] Monad in Hask to develop intuition.
λ> join [[2,3,7], [9,1], [8,6,3,9]] – Remember, join is same as 𝜇 (Monad View)
[2,3,7,9,1,8,6,3,9]
λ> mconcat [[2,3,7], [9,1], [8,6,3,9]] – mconcat “mappends” the lists (Monoid View)
[2,3,7,9,1,8,6,3,9]