\documentclass[12pt,titlepage]{article} \usepackage{amsmath} \usepackage{mathrsfs} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} \usepackage{mathtools} \usepackage{graphicx} \usepackage{color} \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{xparse} \usepackage{hyperref} %----Macros---------- % % Unresolved issues: % % \righttoleftarrow % \lefttorightarrow % % \color{} with HTML colorspec % \bgcolor % \array with options (without options, it's equivalent to the matrix environment) % Of the standard HTML named colors, white, black, red, green, blue and yellow % are predefined in the color package. Here are the rest. \definecolor{aqua}{rgb}{0, 1.0, 1.0} \definecolor{fuschia}{rgb}{1.0, 0, 1.0} \definecolor{gray}{rgb}{0.502, 0.502, 0.502} \definecolor{lime}{rgb}{0, 1.0, 0} \definecolor{maroon}{rgb}{0.502, 0, 0} \definecolor{navy}{rgb}{0, 0, 0.502} \definecolor{olive}{rgb}{0.502, 0.502, 0} \definecolor{purple}{rgb}{0.502, 0, 0.502} \definecolor{silver}{rgb}{0.753, 0.753, 0.753} \definecolor{teal}{rgb}{0, 0.502, 0.502} % Because of conflicts, \space and \mathop are converted to % \itexspace and \operatorname during preprocessing. % itex: \space{ht}{dp}{wd} % % Height and baseline depth measurements are in units of tenths of an ex while % the width is measured in tenths of an em. \makeatletter \newdimen\itex@wd% \newdimen\itex@dp% \newdimen\itex@thd% \def\itexspace#1#2#3{\itex@wd=#3em% \itex@wd=0.1\itex@wd% \itex@dp=#2ex% \itex@dp=0.1\itex@dp% \itex@thd=#1ex% \itex@thd=0.1\itex@thd% \advance\itex@thd\the\itex@dp% \makebox[\the\itex@wd]{\rule[-\the\itex@dp]{0cm}{\the\itex@thd}}} \makeatother % \tensor and \multiscript \makeatletter \newif\if@sup \newtoks\@sups \def\append@sup#1{\edef\act{\noexpand\@sups={\the\@sups #1}}\act}% \def\reset@sup{\@supfalse\@sups={}}% \def\mk@scripts#1#2{\if #2/ \if@sup ^{\the\@sups}\fi \else% \ifx #1_ \if@sup ^{\the\@sups}\reset@sup \fi {}_{#2}% \else \append@sup#2 \@suptrue \fi% \expandafter\mk@scripts\fi} \def\tensor#1#2{\reset@sup#1\mk@scripts#2_/} \def\multiscripts#1#2#3{\reset@sup{}\mk@scripts#1_/#2% \reset@sup\mk@scripts#3_/} \makeatother % \slash \makeatletter \newbox\slashbox \setbox\slashbox=\hbox{$/$} \def\itex@pslash#1{\setbox\@tempboxa=\hbox{$#1$} \@tempdima=0.5\wd\slashbox \advance\@tempdima 0.5\wd\@tempboxa \copy\slashbox \kern-\@tempdima \box\@tempboxa} \def\slash{\protect\itex@pslash} \makeatother % math-mode versions of \rlap, etc % from Alexander Perlis, "A complement to \smash, \llap, and lap" % http://math.arizona.edu/~aprl/publications/mathclap/ \def\clap#1{\hbox to 0pt{\hss#1\hss}} \def\mathllap{\mathpalette\mathllapinternal} \def\mathrlap{\mathpalette\mathrlapinternal} \def\mathclap{\mathpalette\mathclapinternal} \def\mathllapinternal#1#2{\llap{$\mathsurround=0pt#1{#2}$}} \def\mathrlapinternal#1#2{\rlap{$\mathsurround=0pt#1{#2}$}} \def\mathclapinternal#1#2{\clap{$\mathsurround=0pt#1{#2}$}} % Renames \sqrt as \oldsqrt and redefine root to result in \sqrt[#1]{#2} \let\oldroot\root \def\root#1#2{\oldroot #1 \of{#2}} \renewcommand{\sqrt}[2][]{\oldroot #1 \of{#2}} % Manually declare the txfonts symbolsC font \DeclareSymbolFont{symbolsC}{U}{txsyc}{m}{n} \SetSymbolFont{symbolsC}{bold}{U}{txsyc}{bx}{n} \DeclareFontSubstitution{U}{txsyc}{m}{n} % Manually declare the stmaryrd font \DeclareSymbolFont{stmry}{U}{stmry}{m}{n} \SetSymbolFont{stmry}{bold}{U}{stmry}{b}{n} % Manually declare the MnSymbolE font \DeclareFontFamily{OMX}{MnSymbolE}{} \DeclareSymbolFont{mnomx}{OMX}{MnSymbolE}{m}{n} \SetSymbolFont{mnomx}{bold}{OMX}{MnSymbolE}{b}{n} \DeclareFontShape{OMX}{MnSymbolE}{m}{n}{ <-6> MnSymbolE5 <6-7> MnSymbolE6 <7-8> MnSymbolE7 <8-9> MnSymbolE8 <9-10> MnSymbolE9 <10-12> MnSymbolE10 <12-> MnSymbolE12}{} % Declare specific arrows from txfonts without loading the full package \makeatletter \def\re@DeclareMathSymbol#1#2#3#4{% \let#1=\undefined \DeclareMathSymbol{#1}{#2}{#3}{#4}} \re@DeclareMathSymbol{\neArrow}{\mathrel}{symbolsC}{116} \re@DeclareMathSymbol{\neArr}{\mathrel}{symbolsC}{116} \re@DeclareMathSymbol{\seArrow}{\mathrel}{symbolsC}{117} \re@DeclareMathSymbol{\seArr}{\mathrel}{symbolsC}{117} \re@DeclareMathSymbol{\nwArrow}{\mathrel}{symbolsC}{118} \re@DeclareMathSymbol{\nwArr}{\mathrel}{symbolsC}{118} \re@DeclareMathSymbol{\swArrow}{\mathrel}{symbolsC}{119} \re@DeclareMathSymbol{\swArr}{\mathrel}{symbolsC}{119} \re@DeclareMathSymbol{\nequiv}{\mathrel}{symbolsC}{46} \re@DeclareMathSymbol{\Perp}{\mathrel}{symbolsC}{121} \re@DeclareMathSymbol{\Vbar}{\mathrel}{symbolsC}{121} \re@DeclareMathSymbol{\sslash}{\mathrel}{stmry}{12} \re@DeclareMathSymbol{\bigsqcap}{\mathop}{stmry}{"64} \re@DeclareMathSymbol{\biginterleave}{\mathop}{stmry}{"6} \re@DeclareMathSymbol{\invamp}{\mathrel}{symbolsC}{77} \re@DeclareMathSymbol{\parr}{\mathrel}{symbolsC}{77} \makeatother % \llangle, \rrangle, \lmoustache and \rmoustache from MnSymbolE \makeatletter \def\Decl@Mn@Delim#1#2#3#4{% \if\relax\noexpand#1% \let#1\undefined \fi \DeclareMathDelimiter{#1}{#2}{#3}{#4}{#3}{#4}} \def\Decl@Mn@Open#1#2#3{\Decl@Mn@Delim{#1}{\mathopen}{#2}{#3}} \def\Decl@Mn@Close#1#2#3{\Decl@Mn@Delim{#1}{\mathclose}{#2}{#3}} \Decl@Mn@Open{\llangle}{mnomx}{'164} \Decl@Mn@Close{\rrangle}{mnomx}{'171} \Decl@Mn@Open{\lmoustache}{mnomx}{'245} \Decl@Mn@Close{\rmoustache}{mnomx}{'244} \makeatother % Widecheck \makeatletter \DeclareRobustCommand\widecheck[1]{{\mathpalette\@widecheck{#1}}} \def\@widecheck#1#2{% \setbox\z@\hbox{\m@th$#1#2$}% \setbox\tw@\hbox{\m@th$#1% \widehat{% \vrule\@width\z@\@height\ht\z@ \vrule\@height\z@\@width\wd\z@}$}% \dp\tw@-\ht\z@ \@tempdima\ht\z@ \advance\@tempdima2\ht\tw@ \divide\@tempdima\thr@@ \setbox\tw@\hbox{% \raise\@tempdima\hbox{\scalebox{1}[-1]{\lower\@tempdima\box \tw@}}}% {\ooalign{\box\tw@ \cr \box\z@}}} \makeatother % \mathraisebox{voffset}[height][depth]{something} \makeatletter \NewDocumentCommand\mathraisebox{moom}{% \IfNoValueTF{#2}{\def\@temp##1##2{\raisebox{#1}{$\m@th##1##2$}}}{% \IfNoValueTF{#3}{\def\@temp##1##2{\raisebox{#1}[#2]{$\m@th##1##2$}}% }{\def\@temp##1##2{\raisebox{#1}[#2][#3]{$\m@th##1##2$}}}}% \mathpalette\@temp{#4}} \makeatletter % udots (taken from yhmath) \makeatletter \def\udots{\mathinner{\mkern2mu\raise\p@\hbox{.} \mkern2mu\raise4\p@\hbox{.}\mkern1mu \raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern1mu}} \makeatother %% Fix array \newcommand{\itexarray}[1]{\begin{matrix}#1\end{matrix}} %% \itexnum is a noop \newcommand{\itexnum}[1]{#1} %% Renaming existing commands \newcommand{\underoverset}[3]{\underset{#1}{\overset{#2}{#3}}} \newcommand{\widevec}{\overrightarrow} \newcommand{\darr}{\downarrow} \newcommand{\nearr}{\nearrow} \newcommand{\nwarr}{\nwarrow} \newcommand{\searr}{\searrow} \newcommand{\swarr}{\swarrow} \newcommand{\curvearrowbotright}{\curvearrowright} \newcommand{\uparr}{\uparrow} \newcommand{\downuparrow}{\updownarrow} \newcommand{\duparr}{\updownarrow} \newcommand{\updarr}{\updownarrow} \newcommand{\gt}{>} \newcommand{\lt}{<} \newcommand{\map}{\mapsto} \newcommand{\embedsin}{\hookrightarrow} \newcommand{\Alpha}{A} \newcommand{\Beta}{B} \newcommand{\Zeta}{Z} \newcommand{\Eta}{H} \newcommand{\Iota}{I} \newcommand{\Kappa}{K} \newcommand{\Mu}{M} \newcommand{\Nu}{N} \newcommand{\Rho}{P} \newcommand{\Tau}{T} \newcommand{\Upsi}{\Upsilon} \newcommand{\omicron}{o} \newcommand{\lang}{\langle} \newcommand{\rang}{\rangle} \newcommand{\Union}{\bigcup} \newcommand{\Intersection}{\bigcap} \newcommand{\Oplus}{\bigoplus} \newcommand{\Otimes}{\bigotimes} \newcommand{\Wedge}{\bigwedge} \newcommand{\Vee}{\bigvee} \newcommand{\coproduct}{\coprod} \newcommand{\product}{\prod} \newcommand{\closure}{\overline} \newcommand{\integral}{\int} \newcommand{\doubleintegral}{\iint} \newcommand{\tripleintegral}{\iiint} \newcommand{\quadrupleintegral}{\iiiint} \newcommand{\conint}{\oint} \newcommand{\contourintegral}{\oint} \newcommand{\infinity}{\infty} \newcommand{\bottom}{\bot} \newcommand{\minusb}{\boxminus} \newcommand{\plusb}{\boxplus} \newcommand{\timesb}{\boxtimes} \newcommand{\intersection}{\cap} \newcommand{\union}{\cup} \newcommand{\Del}{\nabla} \newcommand{\odash}{\circleddash} \newcommand{\negspace}{\!} \newcommand{\widebar}{\overline} \newcommand{\textsize}{\normalsize} \renewcommand{\scriptsize}{\scriptstyle} \newcommand{\scriptscriptsize}{\scriptscriptstyle} \newcommand{\mathfr}{\mathfrak} \newcommand{\statusline}[2]{#2} \newcommand{\tooltip}[2]{#2} \newcommand{\toggle}[2]{#2} % Theorem Environments \theoremstyle{plain} \newtheorem{theorem}{Theorem} \newtheorem{lemma}{Lemma} \newtheorem{prop}{Proposition} \newtheorem{cor}{Corollary} \newtheorem*{utheorem}{Theorem} \newtheorem*{ulemma}{Lemma} \newtheorem*{uprop}{Proposition} \newtheorem*{ucor}{Corollary} \theoremstyle{definition} \newtheorem{defn}{Definition} \newtheorem{example}{Example} \newtheorem*{udefn}{Definition} \newtheorem*{uexample}{Example} \theoremstyle{remark} \newtheorem{remark}{Remark} \newtheorem{note}{Note} \newtheorem*{uremark}{Remark} \newtheorem*{unote}{Note} %------------------------------------------------------------------- \begin{document} %------------------------------------------------------------------- \section*{monad (in computer science)} \hypertarget{context}{}\subsubsection*{{Context}}\label{context} \hypertarget{type_theory}{}\paragraph*{{Type theory}}\label{type_theory} [[!include type theory - contents]] \hypertarget{contents}{}\section*{{Contents}}\label{contents} \noindent\hyperlink{idea}{Idea}\dotfill \pageref*{idea} \linebreak \noindent\hyperlink{for_imperative_programs_in_functional_programming}{For imperative programs in functional programming}\dotfill \pageref*{for_imperative_programs_in_functional_programming} \linebreak \noindent\hyperlink{RelationToMonadsInCategoryTheory}{Relation to monads in category theory}\dotfill \pageref*{RelationToMonadsInCategoryTheory} \linebreak \noindent\hyperlink{Examples}{Examples}\dotfill \pageref*{Examples} \linebreak \noindent\hyperlink{related_concepts}{Related concepts}\dotfill \pageref*{related_concepts} \linebreak \noindent\hyperlink{references}{References}\dotfill \pageref*{references} \linebreak \noindent\hyperlink{general}{General}\dotfill \pageref*{general} \linebreak \noindent\hyperlink{in_quantum_computation}{In quantum computation}\dotfill \pageref*{in_quantum_computation} \linebreak \hypertarget{idea}{}\subsection*{{Idea}}\label{idea} In [[computer science]], a \emph{monad} describes a ``notion of computation''. Formally, it is a map that \begin{itemize}% \item sends every [[type]] $X$ of some given [[programming language]] to a new type $T(X)$ (called the ``type of $T$-computations with values in $X$''); \item is equipped with a rule for composing two [[functions]] of the form $f : X \to T(Y)$ (called \emph{[[Kleisli functions]]}) and $g : Y \to T(Z)$ to a function $g \circ f : X \to T (Z)$ (their [[Kleisli composition]]); \item is in a way that is [[associativity law|associative]] in the evident sense and [[unit law|unital]] with respect to a given unit function called $pure_X : X \to T(X)$, to be thought of as taking a value to the pure computation that simply returns that value. \end{itemize} This is essentially the same structure as a [[monad]] in [[category theory]], but presented differently; see below for the precise relationship. \hypertarget{for_imperative_programs_in_functional_programming}{}\subsubsection*{{For imperative programs in functional programming}}\label{for_imperative_programs_in_functional_programming} Monads provide one way to ``embed [[imperative programming]] in [[functional programming]]'', and are used that way notably in the [[programming language]] [[Haskell]]. But monads, as well as [[comonads]] and related structures, exist much more generally in programming languages; an exposition is in (\hyperlink{Harper}{Harper}). For an account of the use of monads in industry see \hyperlink{Benton15}{Benton15, pp. 11-12}. For instance when the monad $T(-)$ forms [[product types]] $T(X) \coloneqq X \times Q$ with some fixed type $Q$ that carries the structure of a [[monoid]], then a [[Kleisli function]] $f : X \to Y \times Q$ may be thought of as a function $X \to Y$ that produces a [[side effect]] output of type $Q$. The Kleisli composition of two functions $f \colon X \to Y \times Q$ and $g \colon Y \to Z \times Q$ then not only evaluates the two programs in sequence but also combines their $Q$-output using the monoid operation of $Q$; so if $f x = (y,q)$ and $g y = (z,q')$ then the final result of $(g \circ f)(x)$ will be $(z, q q')$. For example, $Q$ might be the set of strings of characters, and the monoid operation that of concatenation of strings (i.e. $Q$ is the [[free monoid]] on the type of characters). If the software is designed such that values of type $Q$ computed in this way appear on the user's screen or are written to memory, then this is a way to encode \emph{input/output} in [[functional programming]] (see the [[IO monad]] below). But monads have plenty of further uses. They are as ubiquituous (sometimes in disguise) in [[computer science]] as [[monad|monads in the sense of category theory]] are (sometimes in disguise) in [[category theory]]. This is no coincidence, see \emph{\hyperlink{RelationToMonadsInCategoryTheory}{Relation to monads in category theory}} below. \hypertarget{RelationToMonadsInCategoryTheory}{}\subsubsection*{{Relation to monads in category theory}}\label{RelationToMonadsInCategoryTheory} In [[computer science]], a [[programming language]] may be formalised or studied by means of a [[category]], called the \emph{[[syntactic category]]} $\mathcal{C}$, whose \begin{itemize}% \item [[objects]] $X \in \mathcal{C}$ are the [[types]] of the language, \item [[morphisms]] $X \to Y$ are the [[terms]] or [[programs]] (or an [[equivalence class]] of such) that takes a value of [[type]] $X$ as input and returns a value of type $Y$. \end{itemize} This point of view (see \emph{[[computational trinitarianism]]}) is particularly useful when studying purely [[functional programming|functional programming languages]]. Under this [[relation between type theory and category theory]] monads on the type system in the sense of computer science are [[monad|monads in the sense of category theory]], being certain [[endofunctors]] \begin{displaymath} T \colon \mathcal{C} \longrightarrow \mathcal{C} \end{displaymath} on the [[syntactic category]]. This [[functor]] \begin{enumerate}% \item sends each [[type]], hence [[object]] $X \in \mathcal{C}$ to another object $T(X)$; \item the unit [[natural transformation]] $\epsilon \colon Id_{\mathcal{C}} \Rightarrow T$ of the [[monad]] $T$ provides for each type $X$ a component [[morphism]] $pure_X : X \to T(X)$; \item the \emph{multiplication} [[natural transformation]] $\mu \colon T \circ T \Rightarrow T$ of the monad provides for each object $X$ a morphism $\mu_X : T(T(X)) \to T(X)$ which induces the [[Kleisli composition]] by the formula \end{enumerate} \begin{displaymath} \begin{aligned} (g \circ f) &\coloneqq (Y \stackrel{g}{\to} T(Z)) \circ_{Kleisli} (X \stackrel{f}{\to} T(Y)) \\ & \coloneqq X \stackrel{f}{\to} T(Y) \stackrel{T(g)}{\to} T(T(Z)) \stackrel{\mu(Z)}{\to} T Z \end{aligned} \,, \end{displaymath} Here the morphism $T(g)$ in the middle of the last line makes use of the fact that $T(-)$ is indeed a [[functor]] and hence may also be applied to morphisms / functions between types. The last morphism $\mu(Z)$ is the one that implements the ``$T$-computation''. The monads arising this way in computer science are usually required also to interact nicely with the structure of the programming language, as encoded in the structure of its syntactic category; in most cases, terms of the language will be allowed to take more than one input, so the category $\mathcal{C}$ will be at least [[monoidal category|monoidal]], and the corresponding kind of `nice' interaction corresponds to the monad's being a \emph{[[strong monad]]}. The `bind' operation is a means of describing multiplication on such a strong monad $M$. It is a term of the form $M A \to (M B)^A \to M B$, which is equivalent to a map of the form $M A \times M B^A \to M B$. It is the composite \begin{displaymath} M A \times M B^A \stackrel{strength}{\to} M(A \times M B^A) \stackrel{M eval_{A, M B}}{\to} M M B \stackrel{m B}{\to} M B \end{displaymath} where $m \colon M M \to M$ is the monad multiplication. When monads are defined in [[Haskell]], the Kleisli composition, `bind', is defined in Haskell. So monads in Haskell are always [[enriched monads]], according to the self-enrichment defined by the function type in Haskell. \hypertarget{Examples}{}\subsection*{{Examples}}\label{Examples} Various monads are \emph{definable} in terms of the the standard type-forming operations ([[product type]], [[function type]], etc.). These include the following. \begin{itemize}% \item A [[functional program]] with input of [[type]] $X$, output of [[type]] $Y$ and mutable state $S$ is a [[function]] ([[morphism]]) of [[type]] $X \times S \longrightarrow Y \times S$. Under the ([[Cartesian product]] $\dashv$ [[internal hom]])-[[adjunction]] this is equivalently given by its [[adjunct]], which is a function of type $X \longrightarrow [S, S \times Y ]$. Here the operation $[S, S\times (-)]$ is the [[monad]] induced by the above adjunction and this latter function is naturally regarded as a morphism in the [[Kleisli category]] of this monad. This monad $[S, S\times (-)]$ is called the \emph{[[state monad]]} for mutable states of type S. \item The [[maybe monad]] is the operation $X \mapsto X \coprod \ast$. The idea here is that a function $X \longrightarrow Y$ in its [[Kleisli category]] is in the original category a function of the form $X \longrightarrow Y \coprod \ast$ so either returns indeed a value in $Y$ or else returns the unique element of the [[unit type]]/[[terminal object]] $\ast$. This is then naturally interpreted as ``no value returned'', hence as indicating a ``failure in computation''. \item The [[continuation monad]] for a given type $S$ acts by $X \mapsto [[X,S],S]$. \item A number of further monads are similarly \emph{definable} in terms of standard type-forming operations, such as the [[reader monad]] and the [[writer comonad]]. Given a [[type]] $W$, then the [[reader monad]] is the operation of forming the [[function type]] $[W,-] = (W\to (-))$; the [[writer comonad]] is the operation of forming the [[product type]] $W\times (-)$ and the composite of writer followed by reader is the [[state monad]] $[W, W \times (-)]$. When $W$ carries the structure of a [[monoid object]] then writer also inherits the structure of a monad (on top of being a comonad) and converse for reader. \end{itemize} Other monads may be supplied ``axiomatically'' by the programming language, This includes \begin{itemize}% \item the [[IO monad]] in [[Haskell]]. \item The [[completion monad]] may be used, as in [[constructive analysis]], for dealing for instance with [[real numbers]]. \item Equipping [[homotopy type theory]] (say implemented as a programming language concretely in [[Coq]] or [[Agda]]) with two axiomatic [[idempotent monads]], denoted $\sharp$ and $\Pi$, with some additional data and relations, turns it into \emph{[[cohesive homotopy type theory]]}. See also \emph{[[modal type theory]]}. \end{itemize} \hypertarget{related_concepts}{}\subsection*{{Related concepts}}\label{related_concepts} Examples of (co)monads in ([[homotopy type theory|homotopy]]) [[type theory]] involve in particular \emph{[[modal operators]]} as they appear in \begin{itemize}% \item [[modal logic]]/[[modal type theory]]/[[computational type theory]]. \end{itemize} See also \begin{itemize}% \item [[adjoint modality]] \end{itemize} For an approach to composing monads, see \begin{itemize}% \item [[monad transformer]] \end{itemize} Another approach to modelling side effects in [[functional programming languages]] are \begin{itemize}% \item [[algebraic side effects]] \end{itemize} [[free monad|Free monads]] in computer science appear in the concepts of \begin{itemize}% \item [[initial algebra for an endofunctor]] \item [[terminal coalgebra for an endofunctor]] \end{itemize} Other generalizations are \begin{itemize}% \item [[arrow (in computer science)]] \item [[applicative functor]] \end{itemize} There is also \begin{itemize}% \item [[monad (in linguistics)]] \end{itemize} \hypertarget{references}{}\subsection*{{References}}\label{references} \hypertarget{general}{}\subsubsection*{{General}}\label{general} The original reference for monads as `notions of computation' is \begin{itemize}% \item [[Eugenio Moggi]], \emph{Notions of computation and monads}, Information and Computation, 93(1), 1991. (\href{http://www.disi.unige.it/person/MoggiE/ftp/ic91.pdf}{pdf}) \end{itemize} The impact of Moggi's work is assessed and a case for [[Lawvere theory|Lawvere theories]] is made in \begin{itemize}% \item [[Martin Hyland]], [[John Power]], \emph{The Category Theoretic Understanding of Universal Algebra: Lawvere Theories and Monads}, Electronic Notes in Theoretical Computer Science (ENTCS) archive Volume 172, April, 2007 Pages 437-458 (\href{https://www.dpmms.cam.ac.uk/~martin/Research/Publications/2007/hp07.pdf}{pdf}) \end{itemize} Effects treated this way are known as [[algebraic effects]]. Expositions of monads in computer science include \begin{itemize}% \item [[Philip Wadler]], \emph{Comprehending Monads}, in \emph{Conference on Lisp and functional programming}, ACM Press, 1990 ([[WadlerMonads.pdf:file]]) \item [[Philip Wadler]], \emph{Monads for functional programming} in \emph{Lecture notes for the Marktoberdorf Summer School on Program Design Calculi}, Springer Verlag 1992 \item [[Philip Mulry]], \emph{Monads in semantics} , ENTCS \textbf{14} (1998) pp.275-286. \item John Hughes, section 2 of \emph{Generalising Monads to Arrows}, Science of Computer Programming (Elsevier) 37 (1-3): 67--111. (2000) (\href{http://pdn.sciencedirect.com/science?_ob=MiamiImageURL&_cid=271600&_user=10&_pii=S0167642399000234&_check=y&_origin=search&_zone=rslt_list_item&_coverDate=2000-05-31&wchp=dGLzVlk-zSkWb&md5=fa91ab4ffc136b0cedc52318c7c249be&pid=1-s2.0-S0167642399000234-main.pdf}{pdf}) \item [[Robert Harper]], \emph{Of course ML Has Monads!} (2011) (\href{http://existentialtype.wordpress.com/2011/05/01/of-course-ml-has-monads/}{web}) \item [[Nick Benton]], \emph{Categorical Monads and Computer Programming}, (\href{https://www.lms.ac.uk/sites/lms.ac.uk/files/2.%20Benton%20-%20Categorical%20Monads%20and%20Computer%20Programming.pdf}{pdf}) \item [[Emily Riehl]], \emph{A categorical view of computational effects}, 2017 (\href{http://www.math.jhu.edu/~eriehl/compose.pdf}{pdf}) \end{itemize} The specification of monads in [[Haskell]] is at \begin{itemize}% \item \href{http://www.haskell.org/haskellwiki/Haskell}{The Haskell programming language}, \emph{\href{http://www.haskell.org/haskellwiki/Monad_laws}{Monad laws}} \end{itemize} and an exposition of [[category theory]] and monads in terms of Haskell is in \begin{itemize}% \item WikiBooks, \emph{\href{http://en.wikibooks.org/wiki/Haskell/Category_theory}{Haskell/Category}} \end{itemize} A comparison of monads with [[applicative functors]] (also known as idioms) and with [[arrows (in computer science)]] is in \begin{itemize}% \item [[Exequiel Rivas]], \emph{Relating Idioms, Arrows and Monads from Monoidal Adjunctions}, (\href{https://arxiv.org/abs/1807.04084}{arXiv:1807.04084}) \end{itemize} Generalization from [[monads]] to [[relative monads]] is discussed in \begin{itemize}% \item [[Thorsten Altenkirch]], James Chapman, Tarmo Uustalu, \emph{Monads need not be endofunctors} (\href{http://www.cs.nott.ac.uk/~txa/publ/jrelmon.pdf}{pdf}) \end{itemize} Discussion of [[comonads]] in this context includes \begin{itemize}% \item David Overton, \emph{Comonads in Haskell}, 2014 (\href{https://speakerdeck.com/dmoverton/comonads-in-haskell}{web}) \end{itemize} \hypertarget{in_quantum_computation}{}\subsubsection*{{In quantum computation}}\label{in_quantum_computation} Discussion of aspects of [[quantum computing]] in terms of monads in [[functional programming]] are in \begin{itemize}% \item [[Thorsten Altenkirch]], Alexander Green, \emph{The quantum IO monad}, in \emph{Semantic Techniques in Quantum Computation}, January 2009, appeared in 2010 (\href{http://www.cs.nott.ac.uk/~txa/publ/qio-chapter.pdf}{pdf}, \href{http://www.cs.nott.ac.uk/~txa/talks/qnet06.pdf}{talk slides}) \item J. K. Vizzotto, [[Thorsten Altenkirch]], A. Sabry, \emph{Structuring quantum effects: superoperators as arrows} (\href{http://arxiv.org/abs/quant-ph/0501151}{arXiv:quant-ph/0501151}) \end{itemize} [[!redirects monad (computer science)]] [[!redirects monads (computer science)]] [[!redirects monad (in computer science)]] [[!redirects monads (in computer science)]] [[!redirects monad (in programming theory)]] [[!redirects monads (in programming theory)]] [[!redirects monad in computer science]] [[!redirects monads in computer science]] \end{document}