monad-state-0.1.1.2: Utility library for monads, particularly those involving state

Control.Monad.Abort

Contents

Synopsis

Monads that can immediately return a result

class Monad m => MonadAbort m whereSource

Associated Types

type AbortResultType m Source

Methods

abort :: AbortResultType m -> m aSource

The Abort monad

type Abort r = AbortT r Identity

An abort monad, parametrized by the type r of the value to return.

runAbort

Arguments

:: Abort r r

the monadic computation to run

-> r

the result of the computation

Execute the abort monad computation and return the resulting value.

The AbortT monad transformer

newtype AbortT r m a

An abort monad transformer parametrized by

  • r - the value that will ultimately be returned; and
  • m - the inner monad.

The AbortT type wraps a monadic value that is either

  • Left r, which indicates that the monadic computation has terminated with result r and so all further steps in the computation should be ignored; or
  • Right a, which indicates that the computation is proceding normally and that its current value is a.

Constructors

AbortT 

Fields

unwrapAbortT :: m (Either r a)
 

runAbortT

Arguments

:: Monad m 
=> AbortT r m r

the monadic computation to run

-> m r

the (monadic) result of the computation

Execute the abort monad computation and return the resulting (monadic) value.

AbortT operations

mapAbortT :: (m (Either r a) -> n (Either r' b)) -> AbortT r m a -> AbortT r' n bSource