<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >Control.Monad.Identity</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_Control-Monad-Identity.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >mtl-1.1.0.2: Monad transformer library</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >Control.Monad.Identity</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >portable</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >experimental</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >libraries@haskell.org</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" ><DL ><DT >Computation type:</DT ><DD > Simple function application. </DD ><DT >Binding strategy:</DT ><DD > The bound function is applied to the input value. <TT ><TT ><A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TT > x >>= f == <TT ><A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TT > (f x)</TT > </DD ><DT >Useful for:</DT ><DD > Monads can be derived from monad transformers applied to the <TT ><A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TT > monad. </DD ><DT >Zero and plus:</DT ><DD > None. </DD ><DT >Example type:</DT ><DD > <TT ><TT ><A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TT > a</TT > </DD ></DL ><P >The <TT >Identity</TT > monad is a monad that does not embody any computational strategy. It simply applies the bound function to its input without any modification. Computationally, there is no reason to use the <TT >Identity</TT > monad instead of the much simpler act of simply applying functions to their arguments. The purpose of the <TT >Identity</TT > monad is its fundamental role in the theory of monad transformers. Any monad transformer applied to the <TT >Identity</TT > monad yields a non-transformer version of that monad. </P ><P >Inspired by the paper /Functional Programming with Overloading and Higher-Order Polymorphism/, Mark P Jones (<A HREF="http://web.cecs.pdx.edu/~mpj/" >http://web.cecs.pdx.edu/~mpj/</A >) Advanced School of Functional Programming, 1995. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >newtype</SPAN > <A HREF="#t%3AIdentity" >Identity</A > a = <A HREF="#v%3AIdentity" >Identity</A > {<TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="recfield" ><A HREF="#v%3ArunIdentity" >runIdentity</A > :: a</TD ></TR ></TABLE >}</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" >module <A HREF="../base/Control-Monad.html" >Control.Monad</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" >module <A HREF="../base/Control-Monad-Fix.html" >Control.Monad.Fix</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Documentation</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >newtype</SPAN > <A NAME="t:Identity" ><A NAME="t%3AIdentity" ></A ></A ><B >Identity</B > a </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" ><P >Identity wrapper. Abstraction for wrapping up a object. If you have an monadic function, say: </P ><PRE > example :: Int -> Identity Int example x = return (x*x) </PRE ><P >you can "run" it, using </P ><PRE > Main> runIdentity (example 42) 1764 :: Int </PRE ><P >A typical use of the Identity monad is to derive a monad from a monad transformer. </P ><PRE > -- derive the Control.Monad.State.State monad using the Control.Monad.State.StateT monad transformer type Control.Monad.State.State s a = Control.Monad.State.StateT s <TT ><A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TT > a </PRE ><P >The <TT ><TT ><A HREF="Control-Monad-Identity.html#v%3ArunIdentity" >runIdentity</A ></TT ></TT > label is used in the type definition because it follows a style of monad definition that explicitly represents monad values as computations. In this style, a monadic computation is built up using the monadic operators and then the value of the computation is extracted using the <TT >run******</TT > function. Because the <TT >Identity</TT > monad does not do any computation, its definition is trivial. For a better example of this style of monad, see the <TT >Control.Monad.State.State</TT > monad. </P ></TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="5" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:Identity" ><A NAME="v%3AIdentity" ></A ></A ><B >Identity</B ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="body" COLSPAN="2" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:runIdentity" ><A NAME="v%3ArunIdentity" ></A ></A ><B >runIdentity</B > :: a</TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Identity')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Identity" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="../base/Control-Monad.html#t%3AMonad" >Monad</A > <A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="../base/Control-Monad.html#t%3AFunctor" >Functor</A > <A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="../base/Control-Monad-Fix.html#t%3AMonadFix" >MonadFix</A > <A HREF="Control-Monad-Identity.html#t%3AIdentity" >Identity</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" >module <A HREF="../base/Control-Monad.html" >Control.Monad</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" >module <A HREF="../base/Control-Monad-Fix.html" >Control.Monad.Fix</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.4.2</TD ></TR ></TABLE ></BODY ></HTML >