Fiveable

🔢Category Theory Unit 10 Review

QR code for Category Theory practice questions

10.1 Definition and examples of monads

10.1 Definition and examples of monads

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
🔢Category Theory
Unit & Topic Study Guides

Monads are powerful tools in category theory that model computations with context or side effects. They consist of an endofunctor, unit, and multiplication, which work together to enable consistent and composable operations.

Common monads like Identity, Maybe, and List represent different computational contexts. Monad laws ensure predictable behavior, allowing monads to handle complex scenarios like failure, non-determinism, state changes, and I/O operations in a structured way.

Monads: Definition and Components

Components of a monad

  • Endofunctor TT maps objects and morphisms from category CC back to CC (SetSet\text{Set} \to \text{Set})
  • Natural transformation unit η\eta embeds objects from CC into the monad (XT(X)X \to T(X))
  • Natural transformation multiplication μ\mu composes monadic computations (T(T(X))T(X)T(T(X)) \to T(X))
  • Unit and multiplication satisfy coherence conditions enable composition of monadic computations
Components of a monad, Monadic Integration - Ascension Glossary

Examples of common monads

  • Identity monad represents plain values without any additional context or effects
    • Endofunctor: T(X)=XT(X) = X
    • Unit: ηX(x)=x\eta_X(x) = x
    • Multiplication: μX(x)=x\mu_X(x) = x
  • Maybe monad represents computations that may fail or produce no result
    • Endofunctor: T(X)=X+1T(X) = X + 1 (11 represents a singleton set)
    • Unit: ηX(x)=Just x\eta_X(x) = \text{Just } x
    • Multiplication: μX(Just x)=x\mu_X(\text{Just } x) = x, μX(Nothing)=Nothing\mu_X(\text{Nothing}) = \text{Nothing}
  • List monad represents non-deterministic computations or multiple results
    • Endofunctor: T(X)=XT(X) = X^* (free monoid on XX)
    • Unit: ηX(x)=[x]\eta_X(x) = [x] (singleton list)
    • Multiplication: μX(xss)=concat(xss)\mu_X(xss) = \text{concat}(xss) (list concatenation)
Components of a monad, Free monads in category theory (part 1)

Monad laws and consistency

  • Left identity: μ(Tη)=1T\mu \circ (T\eta) = 1_T composing unit and multiplication from left is identity
  • Right identity: μ(ηT)=1T\mu \circ (\eta T) = 1_T composing unit and multiplication from right is identity
  • Associativity: μ(Tμ)=μ(μT)\mu \circ (T\mu) = \mu \circ (\mu T) order of composing multiplications doesn't matter
  • Laws ensure monadic operations are consistent, well-behaved, and composable in a predictable way

Monads for contextual computations

  • Model computations with side effects (state changes, I/O, exceptions) or context (environment, config, logging)
  • Maybe monad for computations that may fail or produce no result (Just 42\text{Just } 42 or Nothing\text{Nothing})
  • List monad for non-deterministic computations or multiple results ([1,2,3][1, 2, 3] represents choosing 1, 2, or 3)
  • State monad for computations that modify a shared state (S(A,S)S \to (A, S) maps state to value and new state)
  • I/O monad for computations that interact with the outside world (reading/writing files)
Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly → and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc
report an error
description

screenshots help us find and fix the issue faster (optional)

add screenshot

2,589 studying →