Movatterモバイル変換


[0]ホーム

URL:


mtl-2.2.2: Monad classes, using functional dependencies
Copyright(c) Michael Weber <[email protected]> 2001
(c) Jeff Newbern 2003-2006
(c) Andriy Palamarchuk 2006
(c) Edward Kmett 2012
LicenseBSD-style (see the file LICENSE)
Maintainer[email protected]
Stabilityexperimental
Portabilitynon-portable (multi-parameter type classes)
Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Error.Class

Description

Computation type:
Computations which may fail or throw exceptions.
Binding strategy:
Failure records information about the cause/locationof the failure. Failure values bypass the bound function,other values are used as inputs to the bound function.
Useful for:
Building computations from sequences of functions that may failor using exception handling to structure error handling.
Zero and plus:
Zero is represented by an empty error and the plus operationexecutes its second argument if the first fails.
Example type:
EitherString a

The Error monad (also called the Exception monad).

Synopsis

Documentation

classError awhereSource#

An exception to be thrown.

Minimal complete definition:noMsg orstrMsg.

Minimal complete definition

Nothing

Methods

noMsg :: aSource#

Creates an exception without a message. The default implementation isstrMsg "".

strMsg ::String -> aSource#

Creates an exception with a message. The default implementation ofstrMsg s isnoMsg.

Instances

Instances details
ErrorIOException 
Instance details

Defined inControl.Monad.Trans.Error

ErrorList a =>Error [a]

A string can be thrown as an error.

Instance details

Defined inControl.Monad.Trans.Error

Methods

noMsg :: [a]Source#

strMsg ::String -> [a]Source#

classMonad m =>MonadError e m | m -> ewhereSource#

The strategy of combining computations that can throw exceptionsby bypassing bound functionsfrom the point an exception is thrown to the point that it is handled.

Is parameterized over the type of error information andthe monad type constructor.It is common to useEither String as the monad type constructorfor an error monad in which error descriptions take the form of strings.In that case and many other common cases the resulting monad is already definedas an instance of theMonadError class.You can also define your own error type and/or use a monad type constructorother thanEitherString orEitherIOError.In these cases you will have to explicitly define instances of theMonadErrorclass.(If you are using the deprecatedControl.Monad.Error orControl.Monad.Trans.Error, you may also have to define anError instance.)

Methods

throwError :: e -> m aSource#

Is used within a monadic computation to begin exception processing.

catchError :: m a -> (e -> m a) -> m aSource#

A handler function to handle previous errors and return to normal execution. A common idiom is:

do { action1; action2; action3 } `catchError` handler

where theaction functions can callthrowError. Note thathandler and the do-block must have the same return type.

Instances

Instances details
MonadError ()Maybe#

Since: mtl-2.2.2

Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: () ->Maybe aSource#

catchError ::Maybe a -> (() ->Maybe a) ->Maybe aSource#

MonadErrorIOExceptionIO# 
Instance details

Defined inControl.Monad.Error.Class

MonadError e m =>MonadError e (MaybeT m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->MaybeT m aSource#

catchError ::MaybeT m a -> (e ->MaybeT m a) ->MaybeT m aSource#

MonadError e m =>MonadError e (ListT m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->ListT m aSource#

catchError ::ListT m a -> (e ->ListT m a) ->ListT m aSource#

MonadError e (Either e)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->Either e aSource#

catchError ::Either e a -> (e ->Either e a) ->Either e aSource#

(Monoid w,MonadError e m) =>MonadError e (WriterT w m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->WriterT w m aSource#

catchError ::WriterT w m a -> (e ->WriterT w m a) ->WriterT w m aSource#

(Monoid w,MonadError e m) =>MonadError e (WriterT w m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->WriterT w m aSource#

catchError ::WriterT w m a -> (e ->WriterT w m a) ->WriterT w m aSource#

MonadError e m =>MonadError e (StateT s m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->StateT s m aSource#

catchError ::StateT s m a -> (e ->StateT s m a) ->StateT s m aSource#

MonadError e m =>MonadError e (StateT s m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->StateT s m aSource#

catchError ::StateT s m a -> (e ->StateT s m a) ->StateT s m aSource#

MonadError e m =>MonadError e (ReaderT r m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->ReaderT r m aSource#

catchError ::ReaderT r m a -> (e ->ReaderT r m a) ->ReaderT r m aSource#

MonadError e m =>MonadError e (IdentityT m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->IdentityT m aSource#

catchError ::IdentityT m a -> (e ->IdentityT m a) ->IdentityT m aSource#

Monad m =>MonadError e (ExceptT e m)#

Since: mtl-2.2

Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->ExceptT e m aSource#

catchError ::ExceptT e m a -> (e ->ExceptT e m a) ->ExceptT e m aSource#

(Monad m,Error e) =>MonadError e (ErrorT e m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->ErrorT e m aSource#

catchError ::ErrorT e m a -> (e ->ErrorT e m a) ->ErrorT e m aSource#

(Monoid w,MonadError e m) =>MonadError e (RWST r w s m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->RWST r w s m aSource#

catchError ::RWST r w s m a -> (e ->RWST r w s m a) ->RWST r w s m aSource#

(Monoid w,MonadError e m) =>MonadError e (RWST r w s m)# 
Instance details

Defined inControl.Monad.Error.Class

Methods

throwError :: e ->RWST r w s m aSource#

catchError ::RWST r w s m a -> (e ->RWST r w s m a) ->RWST r w s m aSource#

liftEither ::MonadError e m =>Either e a -> m aSource#

Lifts anEither e into anyMonadError e.

do { val <- liftEither =<< action1; action2 }

whereaction1 returns anEither to represent errors.

Since: mtl-2.2.2

Produced byHaddock version 2.23.0


[8]ページ先頭

©2009-2026 Movatter.jp