߅      ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L MNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~portable experimentallibraries@haskell.orgIdentity wrapper. &Abstraction for wrapping up a object. &If you have an monadic function, say:  " example :: Int -> Identity Int  example x = return (x*x) you can "run" it, using   Main> runIdentity (example 42)  1764 :: Int 9A typical use of the Identity monad is to derive a monad from a monad transformer.   -- 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  a The 9 label is used in the type definition because it follows Ga style of monad definition that explicitly represents monad values as Qcomputations. In this style, a monadic computation is built up using the monadic =operators and then the value of the computation is extracted  using the  run****** function.  Because the Identity3 monad does not do any computation, its definition  is trivial. -For a better example of this style of monad, see the Control.Monad.State.State monad. /;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org+non-portable (multi-parameter type classes) experimentallibraries@haskell.org AThe strategy of combining computations that can throw exceptions by bypassing bound functions Gfrom the point an exception is thrown to the point that it is handled. 8Is parameterized over the type of error information and the monad type constructor. It is common to use  Data.Either String as the monad type constructor Ifor an error monad in which error descriptions take the form of strings. PIn that case and many other common cases the resulting monad is already defined as an instance of the   class. +You can also define your own error type and/ or use a monad type constructor  other than  Data.Either String or  Data.Either IOError. CIn these cases you will have to explicitly define instances of the   and/or   classes. DIs used within a monadic computation to begin exception processing. MA handler function to handle previous errors and return to normal execution.  A common idiom is:  7 do { action1; action2; action3 } `catchError` handler  where the action functions can call  .  Note that handler2 and the do-block must have the same return type. An exception to be thrown. + An instance must redefine at least one of  , . (Creates an exception without a message.  Default implementation is  "". %Creates an exception with a message.  Default implementation is  . $A string can be thrown as an error.        ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.orgget4 returns the state from the internals of the monad. put& replaces the state inside the monad. Monadic state transformer. 7Maps an old state to a new state inside a state monad. $ The old state is thrown away.  + Main> :t modify ((+1) :: Int -> Int) 1 modify (...) :: (MonadState Int a) => a () This says that  modify (+1) acts over any " Monad that is a member of the  MonadState class,  with an Int state. BGets specific component of the state, using a projection function  supplied. ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.orgSee examples in Control.Monad.Reader. *Note, the partially applied function type (->) r is a simple reader monad. See the instance declaration below. !Retrieves the monad environment. >Executes a computation in a modified environment. Parameters: ) The function to modify the environment.  Reader to run.  The resulting Reader. =Retrieves a function of the current environment. Parameters: 4 The selector function to apply to the environment. See an example in Control.Monad.Reader. ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.orgportable experimentallibraries@haskell.org+non-portable (multi-parameter type classes) experimentallibraries@haskell.orgcallCC" (call-with-current-continuation) D calls a function with the current continuation as its argument. P Provides an escape continuation mechanism for use with Continuation monads. K Escape continuations allow to abort the current computation and return  a value immediately. % They achieve a similar effect to Control.Monad.Error.throwError  and Control.Monad.Error.catchError  within an Control.Monad.Error.Error monad. , Advantage of this function over calling return is that it makes  the continuation explicit, 1 allowing more flexibility and better control  (see examples in Control.Monad.Cont). The standard idiom used with callCC# is to provide a lambda-expression K to name the continuation. Then calling the named continuation anywhere 7 within its scope will escape from the computation, ? even if it is many layers deep within nested computations.  ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org The reader monad transformer. FCan be used to add environment reading functionality to other monads. !""The parameterizable reader monad. The return function creates a Reader that ignores the environment, and produces the given value. The binding operator >>= produces a Reader that uses the environment )to extract the value its left-hand side, Kand then applies the bound function to that value in the same environment. #$Runs Reader' and extracts the final value from it.  To extract the value apply (runReader reader) to an environment value.  Parameters:  A Reader to run.  An initial environment. %&A more general version of . '(> !"#$%&'( "#$%& !'(  ! !"#$#$%&'( +non-portable (multi-parameter type classes) experimentallibraries@haskell.org)KThe error monad transformer. It can be used to add error handling to other monads. The ErrorT3 Monad structure is parameterized over two things:  e - The error type.  m - The inner monad. Here are some examples of use: . -- wraps IO action that can throw an error e & type ErrorWithIO e a = ErrorT e IO a  ==> ErrorT (IO (Either e a))  0 -- IO monad wrapped in StateT inside of ErrorT ; type ErrorAndStateWithIO e s a = ErrorT e (StateT s IO) a ' ==> ErrorT (StateT s IO (Either e a)) . ==> ErrorT (StateT (s -> IO (Either e a,s))) *+,0Note: this instance does not satisfy the second  law  v >> mzero = mzero : )*+,)*+,)*+*+, +non-portable (multi-parameter type classes) experimentallibraries@haskell.org-./01-./0-./0-././0 ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org123456789:;<=>j123456789:;<=>456789:123;<=>1232345656789:;<=>;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.orgj123456789:;<=> ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org?@ABCDEFGHIJKLj?@ABCDEFGHIJKLBCDEFGH?@AIJKL?@A@ABCDCDEFGHIJKL;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.orgM9A parameterizable state monad for encapsulating an inner  monad. =The StateT Monad structure is parameterized over two things:  s - The state.  m - The inner monad. Here are some examples of use: !(Parser from ParseLib with Hugs)  % type Parser a = StateT String [] a ) ==> StateT (String -> [(a,String)]) %For example, item can be written as:  item = do (x:xs) <- get  put xs  return x  / type BoringState s a = StateT s Indentity a ) ==> StateT (s -> Identity (a,s))  ( type StateWithIO s a = StateT s IO a # ==> StateT (s -> IO (a,s))  , type StateWithErr s a = StateT s Maybe a & ==> StateT (s -> Maybe (a,s)) NOP$A parameterizable state monad where s is the type of the state  to carry and a is the type of the  return value. QRS@Evaluate this state monad with the given initial state,throwing ' away the final state. Very much like fst composed with  runstate. The state to evaluate An initial value *The return value of the state application T?Execute this state and return the new state, throwing away the  return value. Very much like snd composed with  runstate. The state to evaluate An initial value The new state UBMap a stateful computation from one (return value, state) pair to D another. For instance, to convert numberTree from a function that C returns a tree to a function that returns the sum of the numbered D tree (see the Examples section for numberTree and sumTree) you may  write: < sumNumberedTree :: (Eq a) => Tree a -> State (Table a) Int K sumNumberedTree = mapState (\ (t, tab) -> (sumTree t, tab)) . numberTree VBApply this function to this state and return the resulting state. W Similar to S X Similar to T Y Similar to U Z Similar to V CMNOPQRSTUVWXYZPQRSTUVMNOWXYZMNONOPQRQRSTUVWXYZ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.orgCMNOPQRSTUVWXYZ;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org[9A parameterizable state monad for encapsulating an inner  monad. =The StateT Monad structure is parameterized over two things:  s - The state.  m - The inner monad. Here are some examples of use: !(Parser from ParseLib with Hugs)  % type Parser a = StateT String [] a ) ==> StateT (String -> [(a,String)]) %For example, item can be written as:  item = do (x:xs) <- get  put xs  return x  / type BoringState s a = StateT s Indentity a ) ==> StateT (s -> Identity (a,s))  ( type StateWithIO s a = StateT s IO a # ==> StateT (s -> IO (a,s))  , type StateWithErr s a = StateT s Maybe a & ==> StateT (s -> Maybe (a,s)) \]^$A parameterizable state monad where s is the type of the state  to carry and a is the type of the  return value. _`a@Evaluate this state monad with the given initial state,throwing ' away the final state. Very much like fst composed with  runstate. The state to evaluate An initial value *The return value of the state application b?Execute this state and return the new state, throwing away the  return value. Very much like snd composed with  runstate. The state to evaluate An initial value The new state cBMap a stateful computation from one (return value, state) pair to D another. For instance, to convert numberTree from a function that C returns a tree to a function that returns the sum of the numbered D tree (see the Examples section for numberTree and sumTree) you may  write: < sumNumberedTree :: (Eq a) => Tree a -> State (Table a) Int K sumNumberedTree = mapState (\ (t, tab) -> (sumTree t, tab)) . numberTree dBApply this function to this state and return the resulting state. e Similar to a f Similar to b g Similar to c h Similar to d C[\]^_`abcdefgh^_`abcd[\]efgh[\]\]^_`_`abcdefgh;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org ijklmnopqr\ijklmnopqr lmnopijkqr ijkjklmnmnopqr;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org\ijklmnopqr;non-portable (multi-param classes, functional dependencies) experimentallibraries@haskell.org stuvwxyz{|\stuvwxyz{| vwxyzstu{| stutuvwxwxyz{|+non-portable (multi-parameter type classes) experimentallibraries@haskell.org }$The continuation monad transformer. :Can be used to add continuation handling to other monads. ~Continuation monad. Cont r a; is a CPS computation that produces an intermediate result of type a5 within a CPS computation whose final result type is r. The returnC function simply creates a continuation which passes the value on. The >>=? operator adds the bound function into the continuation chain. :Runs a CPS computation, returns its result after applying " the final continuation to it.  Parameters:  a continuation computation (Cont). @ the final continuation, which produces the final result (often id). 9}~ }~ }~~ !"#$%&'()*+,-./0123 4 4 5 6 6 7 8 9 : ; < < = > ? ? @ A B B C D D E F G H I J K L M B B C D D E F G H I J K L MNNOPPQRSTUVWXYNNOPPQRSTUVWXYZZ[\\]^_`aZZ[\\]^_`abbcddefghijkljkmjknjkojpqjkrjksjptjuvjwxjuyjuzju{ju|ju}ju~jujujujujujujujujujujujujujujujujujujujujujujujujujujujk jjjjjjjjjjjjjjjjjjjjjjjjjjjj mtl-1.1.1.0Control.Monad.IdentityControl.Monad.Writer.ClassControl.Monad.Error.ClassControl.Monad.State.ClassControl.Monad.Reader.ClassControl.Monad.RWS.ClassControl.Monad.TransControl.Monad.Cont.ClassControl.Monad.ReaderControl.Monad.ErrorControl.Monad.ListControl.Monad.RWS.LazyControl.Monad.RWS.StrictControl.Monad.State.LazyControl.Monad.State.StrictControl.Monad.Writer.LazyControl.Monad.Writer.StrictControl.Monad.ContControl.Monad.RWSControl.Monad.StateControl.Monad.WriterIdentity runIdentity MonadWritertelllistenpasslistenscensor MonadError throwError catchErrorErrornoMsgstrMsg MonadStategetputmodifygets MonadReaderasklocalasksMonadRWSMonadIOliftIO MonadTranslift MonadContcallCCReaderT runReaderTReader runReader mapReader withReader mapReaderT withReaderTErrorT runErrorT mapErrorTListTrunListTmapListTRWSTrunRWSTRWSrunRWSevalRWSexecRWSmapRWSwithRWSevalRWSTexecRWSTmapRWSTwithRWSTStateT runStateTStaterunState evalState execStatemapState withState evalStateT execStateT mapStateT withStateTWriterT runWriterTWriter runWriter execWriter mapWriter execWriterT mapWriterTContTrunContTContrunContmapContwithContmapContT withContTbaseGHC.Basefail>>=>>returnControl.Monad.FixmfixMonadFunctorMonadFix Control.Monad MonadPlus Data.FunctionfixmfilterapliftM5liftM4liftM3liftM2liftMunlesswhen replicateM_ replicateMfoldM_foldM zipWithM_zipWithM mapAndUnzipMjoinvoidforever<=<>=>msumforM_forMfilterMguardmapM_mapM sequence_sequence=<<mplusmzerofmap $fError[] $fMonadPlusIO Data.MonoidmconcatmappendmemptyMonoidgetDualDualappEndoEndogetAllAllgetAnyAnygetSumSum getProductProductgetFirstFirstgetLastLast