そのようなモナドの例として maybe モナドについて簡単にまとめる.
$\mathbf{Set}_*$ を点付き集合 (pointed set) のなす圏とする.
忘却関手 (forgetful functor) $U : \mathbf{Set}_* \rightarrow \mathbf{Set}$ は左随伴
\begin{equation}
\DeclareMathOperator{\Aff}{Aff}
\DeclareMathOperator{\Ar}{Ar}
\DeclareMathOperator{\Arccos}{Arccos}
\DeclareMathOperator{\Arcsin}{Arcsin}
\DeclareMathOperator{\Arr}{Arr}
\DeclareMathOperator{\arr}{arr}
\DeclareMathOperator{\Aut}{Aut}
\DeclareMathOperator{\Auto}{Auto}
\DeclareMathOperator{\Axiom}{Axiom}
\DeclareMathOperator{\Bilin}{Bilin}
\DeclareMathOperator{\card}{card}
\DeclareMathOperator{\Catelem}{\int}
\DeclareMathOperator{\Cocone}{Cocone}
\DeclareMathOperator{\Cod}{cod}
\DeclareMathOperator{\Codomain}{cod}
\DeclareMathOperator{\Coin}{coin}
\DeclareMathOperator{\coker}{coker}
\DeclareMathOperator{\Colim}{colim}
\DeclareMathOperator{\comp}{comp}
\DeclareMathOperator{\Conf}{Conf}
\DeclareMathOperator{\Conj}{Conj}
\DeclareMathOperator{\Dom}{dom}
\DeclareMathOperator{\Domain}{dom}
\DeclareMathOperator{\Edge}{Edge}
\DeclareMathOperator{\Ev}{ev}
\DeclareMathOperator{\GCD}{gcd}
\DeclareMathOperator{\Gr}{Gr}
\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\Id}{id}
\DeclareMathOperator{\IM}{Im}
\DeclareMathOperator{\im}{im}
\DeclareMathOperator{\Ind}{ind}
\DeclareMathOperator{\INIT}{init}
\DeclareMathOperator{\iso}{iso}
\DeclareMathOperator{\LCM}{lcm}
\DeclareMathOperator{\Map}{Map}
\DeclareMathOperator{\mor}{arr}
\DeclareMathOperator{\Nat}{Nat}
\DeclareMathOperator{\Ob}{Ob}
\DeclareMathOperator{\ob}{ob}
\DeclareMathOperator{\ord}{ord}
\DeclareMathOperator{\Path}{Path}
\DeclareMathOperator{\PConf}{PConf}
\DeclareMathOperator{\Point}{Point}
\DeclareMathOperator{\Prob}{Prob}
\DeclareMathOperator{\RE}{Re}
\DeclareMathOperator{\Res}{res}
\DeclareMathOperator{\Sect}{Sect}
\DeclareMathOperator{\SF}{SF}
\DeclareMathOperator{\SkelCat}{sk}
\DeclareMathOperator{\Spec}{Spec}
\DeclareMathOperator{\Sq}{Sq}
\DeclareMathOperator{\Struct}{Struct}
\DeclareMathOperator{\Sub}{Sub}
\DeclareMathOperator{\Sym}{Sym}
\DeclareMathOperator{\TERM}{term}
\DeclareMathOperator{\Vertex}{Vert}
\newcommand{\Abs}[1]{\lvert{#1}\rvert}
\newcommand{\Bs}{\backslash}
\newcommand{\Cdot}{\,\cdot^{\mathrm{op}}}
\newcommand{\Comma}[2]{{{#1}\!\downarrow\!{#2}}}
\newcommand{\CommaCat}[2]{(#1/#2)}
\newcommand{\Complement}[1]{{\smash[t]{\mathstrut #1}}^{\mathrm{c}}}
\newcommand{\Emph}[1]{\textit{#1}}
\newcommand{\Eqclass}[4]{{#1#2#3}_{#4}}
\newcommand{\EqCls}[2]{{\left[#1\right]}_{#2}}
\newcommand{\Eqcls}[1]{\left[#1\right]}
\newcommand{\Expt}[2]{{\smash[t]{\mathstrut #1}}^{\mathstrut #2}}
\newcommand{\FnRest}[2]{{#1}|{#2}}
\newcommand{\Func}[2]{\mathrm{Func}(#1,#2)}
\newcommand{\g}{\varg}
\newcommand{\Inc}[2]{\mathrm{incl}\left(#1,#2\right)}
\newcommand{\Incl}[2]{\mathrm{incl}_{#1}^{#2}}
\newcommand{\InclArrow}[2]{\morphism(0,0)/>->/<450,0>[\Incl{#1}{#2} : {#1}\,\,`{#2};]}
\newcommand{\Ip}{\amalg}
\newcommand{\Lb}[1]{\mathrm{lb}(#1)}
\newcommand{\LH}{\mathrm{LH}}
\newcommand{\Lowerset}[1]{\downarrow\!\!{#1}}
\newcommand{\Leadsto}{\quad\leadsto\quad}
\newcommand{\Lrsquigarrow}{\quad\leftrightsquigarrow\quad}
\newcommand{\Mb}[1]{\mathbf{#1}}
\newcommand{\Mbb}[1]{\mathbb{#1}}
\newcommand{\Mi}[1]{\mathit{#1}}
\newcommand{\Mlb}[1]{\mathrm{mlb}(#1)}
\newcommand{\Mr}[1]{\mathrm{#1}}
\newcommand{\Ms}[1]{\mathscr{#1}}
\newcommand{\Mt}[1]{\mathtt{#1}}
\newcommand{\Mub}[1]{\mathrm{mub}(#1)}
\newcommand{\newinf}{\mathop{\mathrm{inf}\vphantom{\mathrm{sup}}}}
\newcommand{\newsup}{\mathop{\smash{\mathrm{sup}}}}
\newcommand{\Opp}[1]{#1^{\mathrm{op}}}
\newcommand{\Prj}[2]{\mathrm{proj}\left(#1,#2\right)}
\newcommand{\Proj}[2]{\mathrm{proj}^{#1}_{#2}}
\newcommand{\Pw}{\mathbf{P}}
\newcommand{\Rn}[1]{{\bmdefine{R}}^{#1}}
\newcommand{\q}{\hspace{1em}}
\newcommand{\qq}{\hspace{0.5em}}
\newcommand{\Rel}[1]{\langle{#1}\rangle}
\newcommand{\Rest}[2]{{#1}|{#2}}
\newcommand{\Slash}[1]{{\ooalign{\hfil/\hfil\crcr$#1$}}}
\newcommand{\SliCat}[2]{{#1}\,\big/\,{#2}}
\newcommand{\Src}{d^{0,\mathrm{op}}}
\newcommand{\ssqrt}[1]{\sqrt{\smash[b]{\mathstrut #1}}}
\newcommand{\Tgt}{d^{1,\mathrm{op}}}
\newcommand{\TwArCat}[1]{\mathrm{Tw}(#1)}
\newcommand{\Ub}[1]{\mathrm{ub}(#1)}
\newcommand{\Un}[1]{{1}_{#1}}
\newcommand{\Upperset}[1]{\uparrow\!\!{#1}}
\newcommand{\VectCat}[1]{#1 \mathchar`- \mathbf{Vect}}
\newcommand{\VS}{\vspace*{-1ex}}
\newcommand{\Wbar}[1]{\widebar{#1}}
\newcommand{\Ab}{\mathbf{Ab}}
\newcommand{\Adj}{\mathbf{Adj}}
\newcommand{\Affine}{\mathbf{Affine}}
\newcommand{\Ban}{\mathbf{Ban}}
\newcommand{\bbDelta}{\Delta\mkern-12mu\Delta}
\newcommand{\Card}{\mathbf{Card}}
\newcommand{\CAT}{\mathbf{CAT}}
\newcommand{\Cat}{\mathbf{Cat}}
\newcommand{\cgHaus}{\mathbf{cgHaus}}
\newcommand{\Ch}{\mathbf{Ch}}
\newcommand{\cHaus}{\mathbf{cHaus}}
\newcommand{\Cluster}{\mathbf{Cluster}}
\newcommand{\CMonoid}{\mathbf{CMonoid}}
\newcommand{\CRing}{\mathbf{CRing}}
\newcommand{\DirGraph}{\mathbf{DirGraph}}
\newcommand{\End}{\mathbf{End}}
\newcommand{\Euclid}{\mathbf{Euclid}}
\newcommand{\Field}{\mathbf{Field}}
\newcommand{\Fin}{\mathbf{Fin}}
\newcommand{\FinMetric}{\mathbf{FinMetric}}
\newcommand{\Four}{\mathbbm{4}}
\newcommand{\Graph}{\mathbf{Graph}}
\newcommand{\GrMod}{\mathbf{GrMod}}
\newcommand{\Grp}{\mathbf{Grp}}
\newcommand{\Group}{\mathbf{Group}}
\newcommand{\Groupoid}{\mathbf{Groupoid}}
\newcommand{\Haus}{\mathbf{Haus}}
\newcommand{\Htpy}{\mathbf{Htpy}}
\newcommand{\Man}{\mathbf{Man}}
\newcommand{\Mapsdown}{\rotatebox{270}{$\mapsto$}}
\newcommand{\Mapsup}{\rotatebox{90}{$\mapsto$}}
\newcommand{\Mat}{\mathbf{Mat}}
\newcommand{\Meas}{\mathbf{Meas}}
\newcommand{\Measure}{\mathbf{Measure}}
\newcommand{\Mod}{\mathbf{Mod}}
\newcommand{\Model}{\mathbf{Model}}
\newcommand{\Mon}{\mathbf{Mon}}
\newcommand{\Monoid}{\mathbf{Monoid}}
\newcommand{\oMega}{\bbomega}
\newcommand{\One}{\mymathbb{1}}
\newcommand{\Ord}{\mathrm{Ord}}
\newcommand{\PCluster}{\mathbf{PCluster}}
\newcommand{\POs}{\mathbf{Poset}}
\newcommand{\Poset}{\mathbf{Poset}}
\newcommand{\PROJ}{\mathbf{Proj}}
\newcommand{\Psh}{\mathbf{Psh}}
\newcommand{\Ring}{\mathbf{Ring}}
\newcommand{\Rng}{\mathbf{Rng}}
\newcommand{\SET}{\mathbf{SET}}
\newcommand{\Set}{\mathbf{Set}}
\newcommand{\setmid}{\mathrel{}\middle|\mathrel{}}
\newcommand{\Sh}{\mathbf{Sh}}
\newcommand{\Shv}{\mathbf{Shv}}
\newcommand{\Three}{\mymathbb{3}}
\renewcommand{\Top}{\mathbf{Top}}
\newcommand{\Two}{\mymathbb{2}}
\newcommand{\Vect}{\mathbf{Vect}}
\newcommand{\Zero}{\mymathbb{0}}
\newcommand{\sA}{\mathscr{A}}
\newcommand{\sB}{\mathscr{B}}
\newcommand{\sC}{\mathscr{C}}
\newcommand{\sD}{\mathscr{D}}
\newcommand{\sE}{\mathscr{E}}
\newcommand{\sF}{\mathscr{F}}
\newcommand{\sG}{\mathscr{G}}
\newcommand{\sH}{\mathscr{H}}
\newcommand{\sI}{\mathscr{I}}
\newcommand{\sJ}{\mathscr{J}}
\newcommand{\sK}{\mathscr{K}}
\newcommand{\sL}{\mathscr{L}}
\newcommand{\sM}{\mathscr{M}}
\newcommand{\sN}{\mathscr{N}}
\newcommand{\sO}{\mathscr{O}}
\newcommand{\sP}{\mathscr{P}}
\newcommand{\sQ}{\mathscr{Q}}
\newcommand{\sR}{\mathscr{R}}
\newcommand{\sS}{\mathscr{S}}
\newcommand{\sT}{\mathscr{T}}
\newcommand{\sU}{\mathscr{U}}
\newcommand{\sV}{\mathscr{V}}
\newcommand{\sW}{\mathscr{W}}
\newcommand{\sX}{\mathscr{X}}
\newcommand{\sY}{\mathscr{Y}}
\newcommand{\sZ}{\mathscr{Z}}
\newcommand{\bfA}{\mathbf{A}}
\newcommand{\bfB}{\mathbf{B}}
\newcommand{\bfC}{\mathbf{C}}
\newcommand{\bfD}{\mathbf{D}}
\newcommand{\bfE}{\mathbf{E}}
\newcommand{\bfF}{\mathbf{F}}
\newcommand{\bfG}{\mathbf{G}}
\newcommand{\bfH}{\mathbf{H}}
\newcommand{\bfI}{\mathbf{I}}
\newcommand{\bfJ}{\mathbf{J}}
\newcommand{\bfK}{\mathbf{K}}
\newcommand{\bfL}{\mathbf{L}}
\newcommand{\bfM}{\mathbf{M}}
\newcommand{\bfN}{\mathbf{N}}
\newcommand{\bfO}{\mathbf{O}}
\newcommand{\bfP}{\mathbf{P}}
\newcommand{\bfQ}{\mathbf{Q}}
\newcommand{\bfR}{\mathbf{R}}
\newcommand{\bfS}{\mathbf{S}}
\newcommand{\bfT}{\mathbf{T}}
\newcommand{\bfU}{\mathbf{U}}
\newcommand{\bfV}{\mathbf{V}}
\newcommand{\bfW}{\mathbf{W}}
\newcommand{\bfX}{\mathbf{X}}
\newcommand{\bfY}{\mathbf{Y}}
\newcommand{\bfZ}{\mathbf{Z}}
\newcommand{\bfa}{\mathbf{a}}
\newcommand{\bfb}{\mathbf{b}}
\newcommand{\bfc}{\mathbf{c}}
\newcommand{\bfd}{\mathbf{d}}
\newcommand{\bfe}{\mathbf{e}}
\newcommand{\bff}{\mathbf{f}}
\newcommand{\bfg}{\mathbf{g}}
\newcommand{\bfh}{\mathbf{h}}
\newcommand{\bfi}{\mathbf{i}}
\newcommand{\bfj}{\mathbf{j}}
\newcommand{\bfk}{\mathbf{k}}
\newcommand{\bfl}{\mathbf{l}}
\newcommand{\bfm}{\mathbf{m}}
\newcommand{\bfn}{\mathbf{n}}
\newcommand{\bfo}{\mathbf{o}}
\newcommand{\bfp}{\mathbf{p}}
\newcommand{\bfq}{\mathbf{q}}
\newcommand{\bfr}{\mathbf{r}}
\newcommand{\bfs}{\mathbf{s}}
\newcommand{\bft}{\mathbf{t}}
\newcommand{\bfu}{\mathbf{u}}
\newcommand{\bfv}{\mathbf{v}}
\newcommand{\bfw}{\mathbf{w}}
\newcommand{\bfx}{\mathbf{x}}
\newcommand{\bfy}{\mathbf{y}}
\newcommand{\bfz}{\mathbf{z}}
\newcommand{\frA}{\mathfrak{A}}
\newcommand{\frB}{\mathfrak{B}}
\newcommand{\frC}{\mathfrak{C}}
\newcommand{\frD}{\mathfrak{D}}
\newcommand{\frE}{\mathfrak{E}}
\newcommand{\frF}{\mathfrak{F}}
\newcommand{\frG}{\mathfrak{G}}
\newcommand{\frH}{\mathfrak{H}}
\newcommand{\frI}{\mathfrak{I}}
\newcommand{\frJ}{\mathfrak{J}}
\newcommand{\frK}{\mathfrak{K}}
\newcommand{\frL}{\mathfrak{L}}
\newcommand{\frM}{\mathfrak{M}}
\newcommand{\frN}{\mathfrak{N}}
\newcommand{\frO}{\mathfrak{O}}
\newcommand{\frP}{\mathfrak{P}}
\newcommand{\frQ}{\mathfrak{Q}}
\newcommand{\frR}{\mathfrak{R}}
\newcommand{\frS}{\mathfrak{S}}
\newcommand{\frT}{\mathfrak{T}}
\newcommand{\frU}{\mathfrak{U}}
\newcommand{\frV}{\mathfrak{V}}
\newcommand{\frW}{\mathfrak{W}}
\newcommand{\frX}{\mathfrak{X}}
\newcommand{\frY}{\mathfrak{Y}}
\newcommand{\frZ}{\mathfrak{Z}}
\newcommand{\Fra}{\mathfrak{a}}
\newcommand{\Frb}{\mathfrak{b}}
\newcommand{\Frc}{\mathfrak{c}}
\newcommand{\Frd}{\mathfrak{d}}
\newcommand{\Fre}{\mathfrak{e}}
\newcommand{\Frf}{\mathfrak{f}}
\newcommand{\Frg}{\mathfrak{g}}
\newcommand{\Frh}{\mathfrak{h}}
\newcommand{\Fri}{\mathfrak{i}}
\newcommand{\Frj}{\mathfrak{j}}
\newcommand{\Frk}{\mathfrak{k}}
\newcommand{\Frl}{\mathfrak{l}}
\newcommand{\Frm}{\mathfrak{m}}
\newcommand{\Frn}{\mathfrak{n}}
\newcommand{\Fro}{\mathfrak{o}}
\newcommand{\Frp}{\mathfrak{p}}
\newcommand{\Frq}{\mathfrak{q}}
\newcommand{\Frr}{\mathfrak{r}}
\newcommand{\Frs}{\mathfrak{s}}
\newcommand{\Frt}{\mathfrak{t}}
\newcommand{\Fru}{\mathfrak{u}}
\newcommand{\Frv}{\mathfrak{v}}
\newcommand{\Frw}{\mathfrak{w}}
\newcommand{\Frx}{\mathfrak{x}}
\newcommand{\Fry}{\mathfrak{y}}
\newcommand{\Frz}{\mathfrak{z}}
\newcommand{\rA}{\mathrm{A}}
\newcommand{\rB}{\mathrm{B}}
\newcommand{\rC}{\mathrm{C}}
\newcommand{\rD}{\mathrm{D}}
\newcommand{\rE}{\mathrm{E}}
\newcommand{\rF}{\mathrm{F}}
\newcommand{\rG}{\mathrm{G}}
\newcommand{\rH}{\mathrm{H}}
\newcommand{\rI}{\mathrm{I}}
\newcommand{\rJ}{\mathrm{J}}
\newcommand{\rK}{\mathrm{K}}
\newcommand{\rL}{\mathrm{L}}
\newcommand{\rM}{\mathrm{M}}
\newcommand{\rN}{\mathrm{N}}
\newcommand{\rO}{\mathrm{O}}
\newcommand{\rP}{\mathrm{P}}
\newcommand{\rQ}{\mathrm{Q}}
\newcommand{\rR}{\mathrm{R}}
\newcommand{\rS}{\mathrm{S}}
\newcommand{\rT}{\mathrm{T}}
\newcommand{\rU}{\mathrm{U}}
\newcommand{\rV}{\mathrm{V}}
\newcommand{\rW}{\mathrm{W}}
\newcommand{\rX}{\mathrm{X}}
\newcommand{\rY}{\mathrm{Y}}
\newcommand{\rZ}{\mathrm{Z}}
\newcommand{\sfA}{\mathsf{A}}
\newcommand{\sfB}{\mathsf{B}}
\newcommand{\sfC}{\mathsf{C}}
\newcommand{\sfD}{\mathsf{D}}
\newcommand{\sfE}{\mathsf{E}}
\newcommand{\sfF}{\mathsf{F}}
\newcommand{\sfG}{\mathsf{G}}
\newcommand{\sfH}{\mathsf{H}}
\newcommand{\sfI}{\mathsf{I}}
\newcommand{\sfJ}{\mathsf{J}}
\newcommand{\sfK}{\mathsf{K}}
\newcommand{\sfL}{\mathsf{L}}
\newcommand{\sfM}{\mathsf{M}}
\newcommand{\sfN}{\mathsf{N}}
\newcommand{\sfO}{\mathsf{O}}
\newcommand{\sfP}{\mathsf{P}}
\newcommand{\sfQ}{\mathsf{Q}}
\newcommand{\sfR}{\mathsf{R}}
\newcommand{\sfS}{\mathsf{S}}
\newcommand{\sfT}{\mathsf{T}}
\newcommand{\sfU}{\mathsf{U}}
\newcommand{\sfV}{\mathsf{V}}
\newcommand{\sfW}{\mathsf{W}}
\newcommand{\sfX}{\mathsf{X}}
\newcommand{\sfY}{\mathsf{Y}}
\newcommand{\sfZ}{\mathsf{Z}}
\newcommand{\bbA}{\mathbbm{A}}
\newcommand{\bbB}{\mathbbm{B}}
\newcommand{\bbC}{\mathbbm{C}}
\newcommand{\bbD}{\mathbbm{D}}
\newcommand{\bbE}{\mathbbm{E}}
\newcommand{\bbF}{\mathbbm{F}}
\newcommand{\bbG}{\mathbbm{G}}
\newcommand{\bbH}{\mathbbm{H}}
\newcommand{\bbI}{\mathbbm{I}}
\newcommand{\bbJ}{\mathbbm{J}}
\newcommand{\bbK}{\mathbbm{K}}
\newcommand{\bbL}{\mathbbm{L}}
\newcommand{\bbM}{\mathbbm{M}}
\newcommand{\bbN}{\mathbbm{N}}
\newcommand{\bbO}{\mathbbm{O}}
\newcommand{\bbP}{\mathbbm{P}}
\newcommand{\bbQ}{\mathbbm{Q}}
\newcommand{\bbR}{\mathbbm{R}}
\newcommand{\bbS}{\mathbbm{S}}
\newcommand{\bbT}{\mathbbm{T}}
\newcommand{\bbU}{\mathbbm{U}}
\newcommand{\bbV}{\mathbbm{V}}
\newcommand{\bbW}{\mathbbm{W}}
\newcommand{\bbX}{\mathbbm{X}}
\newcommand{\bbY}{\mathbbm{Y}}
\newcommand{\bbZ}{\mathbbm{Z}}
\newcommand{\bba}{\mathbbm{a}}
\newcommand{\bbb}{\mathbbm{b}}
\newcommand{\bbc}{\mathbbm{c}}
\newcommand{\bbd}{\mathbbm{d}}
\newcommand{\bbe}{\mathbbm{e}}
\newcommand{\bbf}{\mathbbm{f}}
\newcommand{\bbg}{\mathbbm{g}}
\newcommand{\bbh}{\mathbbm{h}}
\newcommand{\bbi}{\mathbbm{i}}
\newcommand{\bbj}{\mathbbm{j}}
\newcommand{\bbk}{\mathbbm{k}}
\newcommand{\bbl}{\mathbbm{l}}
\newcommand{\bbm}{\mathbbm{m}}
\newcommand{\bbn}{\mathbbm{n}}
\newcommand{\bbo}{\mathbbm{o}}
\newcommand{\bbp}{\mathbbm{p}}
\newcommand{\bbq}{\mathbbm{q}}
\newcommand{\bbr}{\mathbbm{r}}
\newcommand{\bbs}{\mathbbm{s}}
\newcommand{\bbt}{\mathbbm{t}}
\newcommand{\bbu}{\mathbbm{u}}
\newcommand{\bbv}{\mathbbm{v}}
\newcommand{\bbw}{\mathbbm{w}}
\newcommand{\bbx}{\mathbbm{x}}
\newcommand{\bby}{\mathbbm{y}}
\newcommand{\bbz}{\mathbbm{z}}
\newdir{ >}{{ }*!/-5pt/@{>}}
\begin{xy}
\xymatrix@=16pt {
(-)_+ \,:\, \mathbf{Set} \ar[r] & \mathbf{Set}_* \\
}
\end{xy}
\end{equation} を持つ.
関手 $(-)_+$ は各集合 $A$ に対して点付き集合
\begin{equation*}
A_+ = A \amalg \{ A \} = (A \amalg \{A\}, A)
\end{equation*} を対応させ, 関数 $f : A \rightarrow B$ に対して $f_+ : A_+ \rightarrow B_+$ を
\begin{equation*}
f_+(a) = \begin{cases}
f(a) & (a \in A) \\
B & (a = A)
\end{cases}
\end{equation*} として対応させる.
また, これに伴う単位 (unit) $\eta : \Un{\Set} \Rightarrow U(-)_+$ は, 各集合 $A$ に対して
\begin{equation*}
\begin{xy}
\xymatrix@=16pt@R=0pc {
\eta_A \,:\, A \ar[r] & A_+ \\
\hspace{2em}a \ar@{}[r]|(.6){\mapsto} & a
}
\end{xy}
\end{equation*} により, また余単位 (counit) $\epsilon : (-)_+ U \Rightarrow \Un{\Set_+}$ は, 各点付き集合 $(A,a_0)$ に対して
\begin{equation*}
\begin{xy}
\xymatrix@=16pt@R=0pc {
\epsilon_A \,:\, A_+ \ar[r] & (A,a_0) & \\
\hspace{1.6em}a \ar@{}[r]|(.6){\mapsto} & a & (a \in A) \\
\hspace{1.6em}A \ar@{}[r]|(.6){\mapsto} & a_0 & (a = A)
}
\end{xy}
\end{equation*} により与えられる.
この随伴
\begin{equation*}
\begin{xy}
\xymatrix@=32pt {
\Set_* \ar@<1ex>[r]^{(-)_+} \ar@{}[r]|{\bot} & \Set \ar@<1ex>[l]^{U}
}
\end{xy}
\end{equation*} から導かれるモナドを maybe モナドと呼ぶ.
maybe モナドを実際に構築してみる.
関手 $T : \Set \rightarrow \Set$ は $T=U(-)_+$ によって与えられる. 集合 $A$ に対して
\begin{equation*}
TA = A_+ = A \amalg \{A\}
\end{equation*} であり, 関数 $f : A \rightarrow B$ に対して
\begin{equation*}
Tf = f_+ : A_+ \rightarrow B_+
\end{equation*} である.
単位 (unit) は $\eta : \Un{\Set} \Rightarrow T$ で定まる.
積 (multiplication) は, 各集合 $A$ に対して
\begin{equation*}
(A_+)_+ = (A \amalg \{A\}) \amalg \{A \amalg \{A\}\} = (A \amalg \{A\}) \amalg \{A_+\}
\end{equation*} であるが
\begin{equation*} .
\begin{xy}
\xymatrix@=16pt@R=0pc {
\mu \,:\, (A_+)_+ \ar[r] & A_+ & \\
\hspace{2em}a \ar@{}[r]|(.6){\mapsto} & a & (a \in A) \\
\hspace{2em}A \ar@{}[r]|(.6){\mapsto} & A & (a = A) \\
\hspace{2em}A_+ \ar@{}[r]|(.6){\mapsto} & A & (a = A_+) \\
}
\end{xy}
\end{equation*} により定まる.
$(T,\eta,\mu)$ が実際にモナドになっていることを示す. 図式
\begin{equation*}
\begin{xy}
\xymatrix@=24pt {
T^3A \ar[r]^{T\mu_A} \ar[d]_{\mu_{TA}} & T^2A \ar[d]^{\mu} \\
T^2A \ar[r]_{\mu} & T
}
\qquad
\xymatrix {
TA \ar[r]^{\eta_{TA}} \ar[dr]_{\Un{TA}} & T^2A \ar[d]^{\mu} & TA \ar[l]_{T\eta_A} \ar[dl]^{\Un{TA}} \\
& TA &
}
\end{xy}
\end{equation*} を考える.
$a \in T^3A = ((A_+)_+)_+ = ((A \amalg \{A\}) \amalg \{A_+\}) \amalg \{(A_+)_+\}$ に対して
\begin{equation*}
T\mu_A(a) = \begin{cases}
a & (a \in (A_+)_+) \\
A_+ & (a = (A_+)_+),
\end{cases}
\end{equation*}
\begin{equation*}
\mu_{TA}(a) = \begin{cases}
a & (a \in A_+) \\
A_+ & (a = A_+, (A_+)_+),
\end{cases}
\end{equation*} だから
\begin{equation*}
\mu_A T\mu_A(a) = \begin{cases}
a & (a \in A) \\
A & (a=A, A_+, (A_+)_+)
\end{cases}
\end{equation*}
\begin{equation*}
\mu_A \mu_{TA}(a) = \begin{cases}
a & (a \in A) \\
A & (a=A, A_+, (A_+)_+)
\end{cases}
\end{equation*} となり, 左の図式は可換である.
また, $a \in TA$ に対して
\begin{equation*}
\eta_{TA}(a) = \begin{cases}
a & (a \in TA)
\end{cases}
\end{equation*}
\begin{equation*}
T\eta_A(a) = \begin{cases}
a & (a \in A) \\
A & (a = A)
\end{cases}
\end{equation*} だから
\begin{equation*}
\mu \eta_{TA}(a) = \begin{cases}
a & (a \in A) \\
A & (a = A)
\end{cases}
\end{equation*}
\begin{equation*}
\mu T\eta_A(a) = \begin{cases}
a & (a \in A) \\
A & (a = A)
\end{cases}
\end{equation*} となり, 右側の図式も可換である.
したがって maybe モナド $(T,\eta,\mu)$ は確かにモナドである.
プログラミングとの関係で言えば, 任意の関数 $f : A \rightarrow B$ を実装したプログラム $f_+ : A_+ \rightarrow B_+$ は, 入力 $a \in A$ に対しては出力として正常値 $f(a) \in B$ を返し, 予期せぬ入力 $a=A$ に対してはエラー値 $f_+(A) = B$ を返すということになる.
【このカテゴリーの最新記事】
- no image
- no image
- no image
- no image
- no image