{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $\\mathcal{C}$ be a category.\nA *monad* on $\\mathcal{C}$ is a triple $(T, \\eta, \\mu)$ made of these data.\n\n1. $T \\colon \\mathcal{C} \\to \\mathcal{C}$ is a [[functor|28NQ0KRHD3]].\n2. $\\eta \\colon \\mathrm{Id}_{\\mathcal{C}} \\Rightarrow T$ is a [[natural transformation|KYCPCC57FT]], the unit.\n3. $\\mu \\colon T \\circ T \\Rightarrow T$ is a natural transformation, the multiplication.\n\nThe data must satisfy two laws.\nThe associativity law is $\\mu \\circ T\\mu = \\mu \\circ \\mu T$ as natural transformations $T T T \\Rightarrow T$.\nThe unit laws are $\\mu \\circ T\\eta = \\id_T$ and $\\mu \\circ \\eta T = \\id_T$.\nHere $(T\\mu)_X = T(\\mu_X)$ and $(\\mu T)_X = \\mu_{T(X)}$, and similarly for $\\eta$.\n\n## Remarks\n\nExample: the power set monad on the category of sets.\nHere $T(X)$ is the power set of $X$, and $T(f)$ sends a subset $A$ to its image $f(A)$.\nThe unit is $\\eta_X(x) = \\set{x}$ and the multiplication is $\\mu_X(\\mathcal{S}) = \\bigcup \\mathcal{S}$.\nBoth sides of the associativity law send a set of sets of subsets to the union of all the subsets that occur in it.\nThe unit laws hold because $\\bigcup \\set{A} = A$ and $\\bigcup \\set{\\set{a} : a \\in A} = A$.\n\nNon-example: on the category of sets let $T(X) = X \\times X$, $\\eta_X(x) = (x, x)$ and $\\mu_X((a, b), (c, d)) = (a, c)$.\nThen $(\\mu \\circ \\eta T)_X$ sends $(x, y)$ to $\\mu_X((x, y), (x, y)) = (x, x)$.\nThis differs from $(x, y)$ when $x \\ne y$, so a unit law fails.\nWith $\\mu_X((a, b), (c, d)) = (a, d)$ instead, one gets a monad.\n\nA monad on $\\mathcal{C}$ is the same as a monoid object in the monoidal category of endofunctors of $\\mathcal{C}$, with composition as the product.\nThe dual notion is a comonad.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "FF6XXA6D1A",
    "kind": "definition",
    "msc": [
      "18C15"
    ],
    "name": "Monad",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Monad_(category_theory)"
      }
    ],
    "tag": "F426Q5R0RY",
    "uses": [
      "28NQ0KRHD3",
      "KYCPCC57FT"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/F426Q5R0RY/",
  "links": [
    {
      "field": "defines",
      "target": "FF6XXA6D1A"
    },
    {
      "field": "uses",
      "target": "28NQ0KRHD3"
    },
    {
      "field": "uses",
      "target": "KYCPCC57FT"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/F426Q5R0RY.md",
  "msc": [
    "18C15"
  ],
  "name": "Monad",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/F42/F426Q5R0RY.md",
  "status": null,
  "tag": "F426Q5R0RY",
  "uri": "m2://F426Q5R0RY",
  "url": "https://tamnd.github.io/math2/wiki/monad-definition/",
  "writing": {
    "tag": "F426Q5R0RY",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
