<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=139.63.53.202</id>
	<title>formulasearchengine - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=139.63.53.202"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/wiki/Special:Contributions/139.63.53.202"/>
	<updated>2026-07-22T02:53:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.47.0-wmf.7</generator>
	<entry>
		<id>https://en.formulasearchengine.com/w/index.php?title=Similarities_between_Wiener_and_LMS&amp;diff=20873</id>
		<title>Similarities between Wiener and LMS</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Similarities_between_Wiener_and_LMS&amp;diff=20873"/>
		<updated>2014-01-15T14:56:08Z</updated>

		<summary type="html">&lt;p&gt;139.63.53.202: Undid revision 590792242 by ISHMAEL N MWANGANGI (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Wikibooks|Haskell|Monad transformers}}&lt;br /&gt;
In [[functional programming]], a &#039;&#039;&#039;monad transformer&#039;&#039;&#039; is a type constructor which takes a [[monads in functional programming|monad]] as an argument and returns a monad as a result.&lt;br /&gt;
&lt;br /&gt;
Monad transformers can be used to compose features encapsulated by monads - such as state, [[exception handling]], and I/O - in a modular way. Typically, a monad transformer is created by generalising an existing monad; applying the resulting monad transformer to the identity monad yields a monad which is equivalent to the original monad (ignoring any necessary boxing and unboxing).&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
A monad transformer consists of:&lt;br /&gt;
&lt;br /&gt;
# A type constructor &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; of [[kind (type theory)|kind]] &amp;lt;code&amp;gt;(* -&amp;gt; *) -&amp;gt; * -&amp;gt; *&amp;lt;/code&amp;gt;&lt;br /&gt;
# Monad operations &amp;lt;code&amp;gt;return&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bind&amp;lt;/code&amp;gt; (or an equivalent formulation) for all &amp;lt;code&amp;gt;t m&amp;lt;/code&amp;gt; where &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; is a monad, satisfying the monad laws&lt;br /&gt;
# An additional operation, &amp;lt;code&amp;gt;lift :: m a -&amp;gt; t m a&amp;lt;/code&amp;gt;, satisfying the following laws:&amp;lt;ref name=&amp;quot;modular-interpreters&amp;quot;&amp;gt;&lt;br /&gt;
{{cite conference&lt;br /&gt;
 | first = Sheng&lt;br /&gt;
 | last = Liang&lt;br /&gt;
 | coauthors = Hudak, Paul; Jones, Mark&lt;br /&gt;
 | title = Monad transformers and modular interpreters&lt;br /&gt;
 | booktitle = Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages&lt;br /&gt;
 | pages = 333&amp;amp;ndash;343&lt;br /&gt;
 | publisher = ACM&lt;br /&gt;
 | year = 1995&lt;br /&gt;
 | location = New York, NY&lt;br /&gt;
 | url = http://portal.acm.org/citation.cfm?id=199528&lt;br /&gt;
 | format = PDF&lt;br /&gt;
 | doi = 10.1145/199448.199528&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/ref&amp;gt; (the notation &amp;lt;code&amp;gt;`bind`&amp;lt;/code&amp;gt; below indicates infix application):&lt;br /&gt;
## &amp;lt;code&amp;gt;lift . return = return&amp;lt;/code&amp;gt;&lt;br /&gt;
## &amp;lt;code&amp;gt;lift (m `bind` k) = (lift m) `bind` (lift . k)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
=== The option monad transformer ===&lt;br /&gt;
Given any monad &amp;lt;math&amp;gt;\mathrm{M} \, A&amp;lt;/math&amp;gt;, the option monad transformer &amp;lt;math&amp;gt;\mathrm{M} \left( A^{?} \right)&amp;lt;/math&amp;gt; (where &amp;lt;math&amp;gt;A^{?}&amp;lt;/math&amp;gt; denotes the [[option type]]) is defined by:&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{return}: A \rarr \mathrm{M} \left( A^{?} \right) = a \mapsto \mathrm{return} (\mathrm{Just}\,a)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{bind}: \mathrm{M} \left( A^{?} \right) \rarr \left( A \rarr \mathrm{M} \left( B^{?} \right) \right) \rarr \mathrm{M} \left( B^{?} \right) = m \mapsto f \mapsto \mathrm{bind} \, m \, \left(a \mapsto \begin{cases} \mbox{return Nothing} &amp;amp; \mbox{if } a = \mathrm{Nothing}\\ f \, a&#039; &amp;amp; \mbox{if } a = \mathrm{Just} \, a&#039; \end{cases} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{lift}: \mathrm{M} (A) \rarr \mathrm{M} \left( A^{?} \right) = m \mapsto \mathrm{bind} \, m \, (a \mapsto \mathrm{return} (\mathrm{Just} \, a))&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The exception monad transformer ===&lt;br /&gt;
Given any monad &amp;lt;math&amp;gt;\mathrm{M} \, A&amp;lt;/math&amp;gt;, the exception monad transformer &amp;lt;math&amp;gt;\mathrm{M} (A + E)&amp;lt;/math&amp;gt; (where &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt; is the type of exceptions) is defined by:&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{return}: A \rarr \mathrm{M} (A + E) = a \mapsto \mathrm{return} (\mathrm{value}\,a)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{bind}: \mathrm{M} (A + E) \rarr (A \rarr \mathrm{M} (B + E)) \rarr \mathrm{M} (B + E) = m \mapsto f \mapsto \mathrm{bind} \, m \,\left( a \mapsto \begin{cases} \mbox{return err } e &amp;amp; \mbox{if } a = \mathrm{err} \, e\\ f \, a&#039; &amp;amp; \mbox{if } a = \mathrm{value} \, a&#039; \end{cases} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{lift}: \mathrm{M} \, A \rarr \mathrm{M} (A + E) = m \mapsto \mathrm{bind} \, m \, (a \mapsto \mathrm{return} (\mathrm{value} \, a))&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The reader monad transformer ===&lt;br /&gt;
Given any monad &amp;lt;math&amp;gt;\mathrm{M} \, A&amp;lt;/math&amp;gt;, the reader monad transformer &amp;lt;math&amp;gt;E \rarr \mathrm{M}\,A&amp;lt;/math&amp;gt; (where &amp;lt;math&amp;gt;E&amp;lt;/math&amp;gt; is the environment type) is defined by:&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{return}: A \rarr E \rarr \mathrm{M} \, A = a \mapsto e \mapsto \mathrm{return} \, a&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{bind}: (E \rarr \mathrm{M} \, A) \rarr (A \rarr E \rarr \mathrm{M}\,B) \rarr E \rarr \mathrm{M}\,B = m \mapsto k \mapsto e \mapsto \mathrm{bind} \, (m \, e) \,( a \mapsto k \, a \, e)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{lift}: \mathrm{M} \, A \rarr E \rarr \mathrm{M} \, A = a \mapsto e \mapsto a&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The state monad transformer ===&lt;br /&gt;
Given any monad &amp;lt;math&amp;gt;\mathrm{M} \, A&amp;lt;/math&amp;gt;, the state monad transformer &amp;lt;math&amp;gt;S \rarr \mathrm{M}(A \times S)&amp;lt;/math&amp;gt; (where &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is the state type) is defined by:&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{return}: A \rarr S \rarr \mathrm{M} (A \times S) = a \mapsto s \mapsto \mathrm{return} \, (a, s)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{bind}: (S \rarr \mathrm{M}(A \times S)) \rarr (A \rarr S \rarr \mathrm{M}(B \times S)) \rarr S \rarr \mathrm{M}(B \times S) = m \mapsto k \mapsto s \mapsto \mathrm{bind} \, (m \, s) \,((a, s&#039;) \mapsto k \, a \, s&#039;)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{lift}: \mathrm{M} \, A \rarr S \rarr \mathrm{M}(A \times S) = m \mapsto s \mapsto \mathrm{bind} \, m \, (a \mapsto \mathrm{return} \, (a, s))&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The writer monad transformer ===&lt;br /&gt;
Given any monad &amp;lt;math&amp;gt;\mathrm{M} \, A&amp;lt;/math&amp;gt;, the writer monad transformer &amp;lt;math&amp;gt;\mathrm{M}(W \times A)&amp;lt;/math&amp;gt; (where &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; is endowed with a [[monoid]] operation &amp;lt;math&amp;gt;*&amp;lt;/math&amp;gt; with identity element &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt;) is defined by:&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{return}: A \rarr \mathrm{M} (W \times A) = a \mapsto \mathrm{return} \, (\varepsilon, a)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{bind}: \mathrm{M}(W \times A) \rarr (A \rarr \mathrm{M}(W \times B)) \rarr \mathrm{M}(W \times B) = m \mapsto f \mapsto \mathrm{bind} \, m \,((w, a) \mapsto \mathrm{bind} \, (f \, a) \, ((w&#039;, b) \mapsto \mathrm{return} \, (w * w&#039;, b)))&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{lift}: \mathrm{M} \, A \rarr \mathrm{M}(W \times A) = m \mapsto \mathrm{bind} \, m \, (a \mapsto \mathrm{return} \, (\varepsilon, a))&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The continuation monad transformer ===&lt;br /&gt;
Given any monad &amp;lt;math&amp;gt;\mathrm{M} \, A&amp;lt;/math&amp;gt;, the continuation monad transformer maps an arbitrary type &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; into functions of type &amp;lt;math&amp;gt;(A \rarr \mathrm{M} \, R) \rarr \mathrm{M} \, R&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; is the result type of the continuation.  It is defined by:&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{return} \colon A \rarr \left( A \rarr \mathrm{M} \, R \right) \rarr \mathrm{M} \, R = a \mapsto k \mapsto k \, a&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{bind} \colon \left( \left( A \rarr \mathrm{M} \, R \right) \rarr \mathrm{M} \, R \right) \rarr \left( A \rarr \left( B \rarr \mathrm{M} \, R \right) \rarr \mathrm{M} \, R \right) \rarr \left( B \rarr \mathrm{M} \, R \right) \rarr \mathrm{M} \, R&amp;lt;/math&amp;gt;&amp;lt;math&amp;gt;= c \mapsto f \mapsto k \mapsto c \, \left( a \mapsto f \, a \, k \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
*&amp;lt;math&amp;gt;\mathrm{lift}: \mathrm{M} \, A \rarr (A \rarr \mathrm{M} \, R) \rarr \mathrm{M} \, R = \mathrm{bind}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that monad transformations are usually not [[commutative]]: for instance, applying the state transformer to the option monad yields a type &amp;lt;math&amp;gt;S \rarr \left(A \times S \right)^{?}&amp;lt;/math&amp;gt; (a computation which may fail and yield no final state), whereas the converse transformation has type &amp;lt;math&amp;gt;S \rarr \left(A^{?} \times S \right)&amp;lt;/math&amp;gt; (a computation which yields a final state and an optional return value).&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Monads in functional programming]]&lt;br /&gt;
* [[Natural transformation]] - a related concept in [[category theory]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Monad_transformers/] - a highly technical blog post briefly reviewing some of the literature on monad transformers and related concepts, with a focus on categorical-theoretic treatment&lt;br /&gt;
{{Expand section|date=May 2008}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Functional programming]]&lt;/div&gt;</summary>
		<author><name>139.63.53.202</name></author>
	</entry>
</feed>