hinterface-2.0.1: Haskell / Erlang interoperability library
Safe HaskellNone
LanguageHaskell2010

Util.IOExtra

Synopsis

Documentation

tryAndLogAll :: forall a m. (HasCallStack, MonadCatch m, MonadLogger m) => m a -> m (Maybe a) Source #

catchAndLogIO :: (HasCallStack, MonadCatch m, MonadLogger m) => m a -> (IOError -> m a) -> m a Source #

onExceptionLog :: (HasCallStack, MonadCatch m, MonadLogger m) => m a -> m b -> m a Source #

bracketOnErrorLog :: (HasCallStack, MonadMask m, MonadLogger m) => m a -> (a -> m b) -> (a -> m c) -> m c Source #

catchAndLog :: (HasCallStack, MonadCatch m, MonadLogger m, Exception e) => m a -> (e -> m a) -> m a Source #

handleAndLog :: (HasCallStack, MonadCatch m, MonadLogger m, Exception e) => (e -> m a) -> m a -> m a Source #

data ErrMsg a Source #

Constructors

ErrMsg String a 

Instances

Instances details
Show a => Show (ErrMsg a) Source # 
Instance details

Defined in Util.IOExtra

Methods

showsPrec :: Int -> ErrMsg a -> ShowS #

show :: ErrMsg a -> String #

showList :: [ErrMsg a] -> ShowS #

Exception a => Exception (ErrMsg a) Source # 
Instance details

Defined in Util.IOExtra

data ThreadId #

A ThreadId is an abstract type representing a handle to a thread. ThreadId is an instance of Eq, Ord and Show, where the Ord instance implements an arbitrary total ordering over ThreadIds. The Show instance lets you convert an arbitrary-valued ThreadId to string form; showing a ThreadId value is occasionally useful when debugging or diagnosing the behaviour of a concurrent program.

Note: in GHC, if you have a ThreadId, you essentially have a pointer to the thread itself. This means the thread itself can't be garbage collected until you drop the ThreadId. This misfeature will hopefully be corrected at a later date.

Instances

Instances details
Eq ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Ord ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

Show ThreadId

Since: base-4.2.0.0

Instance details

Defined in GHC.Conc.Sync

NFData ThreadId

Since: deepseq-1.4.0.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: ThreadId -> () #

Hashable ThreadId 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> ThreadId -> Int #

hash :: ThreadId -> Int #

waitBothSTM :: Async a -> Async b -> STM (a, b) #

A version of waitBoth that can be used inside an STM transaction.

Since: async-2.1.0

waitEitherSTM_ :: Async a -> Async b -> STM () #

A version of waitEither_ that can be used inside an STM transaction.

Since: async-2.1.0

waitEitherSTM :: Async a -> Async b -> STM (Either a b) #

A version of waitEither that can be used inside an STM transaction.

Since: async-2.1.0

waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b)) #

A version of waitEitherCatch that can be used inside an STM transaction.

Since: async-2.1.0

waitAnySTM :: [Async a] -> STM (Async a, a) #

A version of waitAny that can be used inside an STM transaction.

Since: async-2.1.0

waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a) #

A version of waitAnyCatch that can be used inside an STM transaction.

Since: async-2.1.0

pollSTM :: Async a -> STM (Maybe (Either SomeException a)) #

A version of poll that can be used inside an STM transaction.

waitCatchSTM :: Async a -> STM (Either SomeException a) #

A version of waitCatch that can be used inside an STM transaction.

waitSTM :: Async a -> STM a #

A version of wait that can be used inside an STM transaction.

compareAsyncs :: Async a -> Async b -> Ordering #

Compare two Asyncs that may have different types by their ThreadId.

data Async a #

An asynchronous action spawned by async or withAsync. Asynchronous actions are executed in a separate thread, and operations are provided for waiting for asynchronous actions to complete and obtaining their results (see e.g. wait).

Instances

Instances details
Functor Async 
Instance details

Defined in Control.Concurrent.Async

Methods

fmap :: (a -> b) -> Async a -> Async b #

(<$) :: a -> Async b -> Async a #

Eq (Async a) 
Instance details

Defined in Control.Concurrent.Async

Methods

(==) :: Async a -> Async a -> Bool #

(/=) :: Async a -> Async a -> Bool #

Ord (Async a) 
Instance details

Defined in Control.Concurrent.Async

Methods

compare :: Async a -> Async a -> Ordering #

(<) :: Async a -> Async a -> Bool #

(<=) :: Async a -> Async a -> Bool #

(>) :: Async a -> Async a -> Bool #

(>=) :: Async a -> Async a -> Bool #

max :: Async a -> Async a -> Async a #

min :: Async a -> Async a -> Async a #

Hashable (Async a) 
Instance details

Defined in Control.Concurrent.Async

Methods

hashWithSalt :: Int -> Async a -> Int #

hash :: Async a -> Int #

data AsyncCancelled #

The exception thrown by cancel to terminate a thread.

Constructors

AsyncCancelled 

rtsSupportsBoundThreads :: Bool #

True if bound threads are supported. If rtsSupportsBoundThreads is False, isCurrentThreadBound will always return False and both forkOS and runInBoundThread will fail.

data Chan a #

Chan is an abstract type representing an unbounded FIFO channel.

Instances

Instances details
Eq (Chan a)

Since: base-4.4.0.0

Instance details

Defined in Control.Concurrent.Chan

Methods

(==) :: Chan a -> Chan a -> Bool #

(/=) :: Chan a -> Chan a -> Bool #

data QSem #

QSem is a quantity semaphore in which the resource is acquired and released in units of one. It provides guaranteed FIFO ordering for satisfying blocked waitQSem calls.

The pattern

  bracket_ waitQSem signalQSem (...)

is safe; it never loses a unit of the resource.

data QSemN #

QSemN is a quantity semaphore in which the resource is acquired and released in units of one. It provides guaranteed FIFO ordering for satisfying blocked waitQSemN calls.

The pattern

  bracket_ (waitQSemN n) (signalQSemN n) (...)

is safe; it never loses any of the resource.

class Monad m => MonadIO (m :: Type -> Type) where #

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Methods

liftIO :: IO a -> m a #

Lift a computation from the IO monad.

Instances

Instances details
MonadIO IO

Since: base-4.9.0.0

Instance details

Defined in Control.Monad.IO.Class

Methods

liftIO :: IO a -> IO a #

MonadIO Q 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

liftIO :: IO a -> Q a #

MonadIO m => MonadIO (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftIO :: IO a -> MaybeT m a #

MonadIO m => MonadIO (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftIO :: IO a -> ResourceT m a #

MonadIO m => MonadIO (ListT m) 
Instance details

Defined in Control.Monad.Trans.List

Methods

liftIO :: IO a -> ListT m a #

MonadIO m => MonadIO (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

liftIO :: IO a -> NoLoggingT m a #

MonadIO m => MonadIO (WriterLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

liftIO :: IO a -> WriterLoggingT m a #

MonadIO m => MonadIO (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

liftIO :: IO a -> LoggingT m a #

MonadIO m => MonadIO (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Methods

liftIO :: IO a -> NodeT m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Strict

Methods

liftIO :: IO a -> WriterT w m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Lazy

Methods

liftIO :: IO a -> WriterT w m a #

MonadIO m => MonadIO (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Strict

Methods

liftIO :: IO a -> StateT s m a #

MonadIO m => MonadIO (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

liftIO :: IO a -> StateT s m a #

MonadIO m => MonadIO (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

liftIO :: IO a -> ReaderT r m a #

MonadIO m => MonadIO (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftIO :: IO a -> ExceptT e m a #

(Error e, MonadIO m) => MonadIO (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

liftIO :: IO a -> ErrorT e m a #

MonadIO m => MonadIO (IdentityT m) 
Instance details

Defined in Control.Monad.Trans.Identity

Methods

liftIO :: IO a -> IdentityT m a #

(Monoid w, Functor m, MonadIO m) => MonadIO (AccumT w m) 
Instance details

Defined in Control.Monad.Trans.Accum

Methods

liftIO :: IO a -> AccumT w m a #

MonadIO m => MonadIO (SelectT r m) 
Instance details

Defined in Control.Monad.Trans.Select

Methods

liftIO :: IO a -> SelectT r m a #

MonadIO m => MonadIO (ConduitT i o m) 
Instance details

Defined in Data.Conduit.Internal.Conduit

Methods

liftIO :: IO a -> ConduitT i o m a #

MonadIO m => MonadIO (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

liftIO :: IO a -> ContT r m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.RWS.Strict

Methods

liftIO :: IO a -> RWST r w s m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.RWS.Lazy

Methods

liftIO :: IO a -> RWST r w s m a #

MonadIO m => MonadIO (Pipe l i o u m) 
Instance details

Defined in Data.Conduit.Internal.Pipe

Methods

liftIO :: IO a -> Pipe l i o u m a #

errorBadArgument :: a #

Calls perror to indicate that there is a type error or similar in the given argument.

Since: base-4.7.0.0

errorMissingArgument :: a #

Calls perror to indicate that there is a missing argument in the argument list.

Since: base-4.7.0.0

errorShortFormat :: a #

Calls perror to indicate that the format string ended early.

Since: base-4.7.0.0

errorBadFormat :: Char -> a #

Calls perror to indicate an unknown format letter for a given type.

Since: base-4.7.0.0

perror :: String -> a #

Raises an error with a printf-specific prefix on the message string.

Since: base-4.7.0.0

formatRealFloat :: RealFloat a => a -> FieldFormatter #

Formatter for RealFloat values.

Since: base-4.7.0.0

formatInteger :: Integer -> FieldFormatter #

Formatter for Integer values.

Since: base-4.7.0.0

formatInt :: (Integral a, Bounded a) => a -> FieldFormatter #

Formatter for Int values.

Since: base-4.7.0.0

formatString :: IsChar a => [a] -> FieldFormatter #

Formatter for String values.

Since: base-4.7.0.0

formatChar :: Char -> FieldFormatter #

Formatter for Char values.

Since: base-4.7.0.0

vFmt :: Char -> FieldFormat -> FieldFormat #

Substitute a 'v' format character with the given default format character in the FieldFormat. A convenience for user-implemented types, which should support "%v".

Since: base-4.7.0.0

hPrintf :: HPrintfType r => Handle -> String -> r #

Similar to printf, except that output is via the specified Handle. The return type is restricted to (IO a).

printf :: PrintfType r => String -> r #

Format a variable number of arguments with the C-style formatting string.

>>> printf "%s, %d, %.4f" "hello" 123 pi
hello, 123, 3.1416

The return value is either String or (IO a) (which should be (IO ()), but Haskell's type system makes this hard).

The format string consists of ordinary characters and conversion specifications, which specify how to format one of the arguments to printf in the output string. A format specification is introduced by the % character; this character can be self-escaped into the format string using %%. A format specification ends with a format character that provides the primary information about how to format the value. The rest of the conversion specification is optional. In order, one may have flag characters, a width specifier, a precision specifier, and type-specific modifier characters.

Unlike C printf(3), the formatting of this printf is driven by the argument type; formatting is type specific. The types formatted by printf "out of the box" are:

printf is also extensible to support other types: see below.

A conversion specification begins with the character %, followed by zero or more of the following flags:

-      left adjust (default is right adjust)
+      always use a sign (+ or -) for signed conversions
space  leading space for positive numbers in signed conversions
0      pad with zeros rather than spaces
#      use an \"alternate form\": see below

When both flags are given, - overrides 0 and + overrides space. A negative width specifier in a * conversion is treated as positive but implies the left adjust flag.

The "alternate form" for unsigned radix conversions is as in C printf(3):

%o           prefix with a leading 0 if needed
%x           prefix with a leading 0x if nonzero
%X           prefix with a leading 0X if nonzero
%b           prefix with a leading 0b if nonzero
%[eEfFgG]    ensure that the number contains a decimal point

Any flags are followed optionally by a field width:

num    field width
*      as num, but taken from argument list

The field width is a minimum, not a maximum: it will be expanded as needed to avoid mutilating a value.

Any field width is followed optionally by a precision:

.num   precision
.      same as .0
.*     as num, but taken from argument list

Negative precision is taken as 0. The meaning of the precision depends on the conversion type.

Integral    minimum number of digits to show
RealFloat   number of digits after the decimal point
String      maximum number of characters

The precision for Integral types is accomplished by zero-padding. If both precision and zero-pad are given for an Integral field, the zero-pad is ignored.

Any precision is followed optionally for Integral types by a width modifier; the only use of this modifier being to set the implicit size of the operand for conversion of a negative operand to unsigned:

hh     Int8
h      Int16
l      Int32
ll     Int64
L      Int64

The specification ends with a format character:

c      character               Integral
d      decimal                 Integral
o      octal                   Integral
x      hexadecimal             Integral
X      hexadecimal             Integral
b      binary                  Integral
u      unsigned decimal        Integral
f      floating point          RealFloat
F      floating point          RealFloat
g      general format float    RealFloat
G      general format float    RealFloat
e      exponent format float   RealFloat
E      exponent format float   RealFloat
s      string                  String
v      default format          any type

The "%v" specifier is provided for all built-in types, and should be provided for user-defined type formatters as well. It picks a "best" representation for the given type. For the built-in types the "%v" specifier is converted as follows:

c      Char
u      other unsigned Integral
d      other signed Integral
g      RealFloat
s      String

Mismatch between the argument types and the format string, as well as any other syntactic or semantic errors in the format string, will cause an exception to be thrown at runtime.

Note that the formatting for RealFloat types is currently a bit different from that of C printf(3), conforming instead to showEFloat, showFFloat and showGFloat (and their alternate versions showFFloatAlt and showGFloatAlt). This is hard to fix: the fixed versions would format in a backward-incompatible way. In any case the Haskell behavior is generally more sensible than the C behavior. A brief summary of some key differences:

  • Haskell printf never uses the default "6-digit" precision used by C printf.
  • Haskell printf treats the "precision" specifier as indicating the number of digits after the decimal point.
  • Haskell printf prints the exponent of e-format numbers without a gratuitous plus sign, and with the minimum possible number of digits.
  • Haskell printf will place a zero after a decimal point when possible.

class PrintfType t #

The PrintfType class provides the variable argument magic for printf. Its implementation is intentionally not visible from this module. If you attempt to pass an argument of a type which is not an instance of this class to printf or hPrintf, then the compiler will report it as a missing instance of PrintfArg.

Minimal complete definition

spr

Instances

Instances details
IsChar c => PrintfType [c]

Since: base-2.1

Instance details

Defined in Text.Printf

Methods

spr :: String -> [UPrintf] -> [c]

a ~ () => PrintfType (IO a)

Since: base-4.7.0.0

Instance details

Defined in Text.Printf

Methods

spr :: String -> [UPrintf] -> IO a

(PrintfArg a, PrintfType r) => PrintfType (a -> r)

Since: base-2.1

Instance details

Defined in Text.Printf

Methods

spr :: String -> [UPrintf] -> a -> r

class HPrintfType t #

The HPrintfType class provides the variable argument magic for hPrintf. Its implementation is intentionally not visible from this module.

Minimal complete definition

hspr

Instances

Instances details
a ~ () => HPrintfType (IO a)

Since: base-4.7.0.0

Instance details

Defined in Text.Printf

Methods

hspr :: Handle -> String -> [UPrintf] -> IO a

(PrintfArg a, HPrintfType r) => HPrintfType (a -> r)

Since: base-2.1

Instance details

Defined in Text.Printf

Methods

hspr :: Handle -> String -> [UPrintf] -> a -> r

class PrintfArg a where #

Typeclass of printf-formattable values. The formatArg method takes a value and a field format descriptor and either fails due to a bad descriptor or produces a ShowS as the result. The default parseFormat expects no modifiers: this is the normal case. Minimal instance: formatArg.

Minimal complete definition

formatArg

Methods

formatArg :: a -> FieldFormatter #

Since: base-4.7.0.0

parseFormat :: a -> ModifierParser #

Since: base-4.7.0.0

Instances

Instances details
PrintfArg Char

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Double

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Float

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Int

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Int8

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Int16

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Int32

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Int64

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Integer

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Natural

Since: base-4.8.0.0

Instance details

Defined in Text.Printf

PrintfArg Word

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Word8

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Word16

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Word32

Since: base-2.1

Instance details

Defined in Text.Printf

PrintfArg Word64

Since: base-2.1

Instance details

Defined in Text.Printf

IsChar c => PrintfArg [c]

Since: base-2.1

Instance details

Defined in Text.Printf

class IsChar c where #

This class, with only the one instance, is used as a workaround for the fact that String, as a concrete type, is not allowable as a typeclass instance. IsChar is exported for backward-compatibility.

Methods

toChar :: c -> Char #

Since: base-4.7.0.0

fromChar :: Char -> c #

Since: base-4.7.0.0

Instances

Instances details
IsChar Char

Since: base-2.1

Instance details

Defined in Text.Printf

Methods

toChar :: Char -> Char #

fromChar :: Char -> Char #

data FormatAdjustment #

Whether to left-adjust or zero-pad a field. These are mutually exclusive, with LeftAdjust taking precedence.

Since: base-4.7.0.0

Constructors

LeftAdjust 
ZeroPad 

data FormatSign #

How to handle the sign of a numeric field. These are mutually exclusive, with SignPlus taking precedence.

Since: base-4.7.0.0

Constructors

SignPlus 
SignSpace 

data FieldFormat #

Description of field formatting for formatArg. See UNIX printf(3) for a description of how field formatting works.

Since: base-4.7.0.0

Constructors

FieldFormat 

Fields

data FormatParse #

The "format parser" walks over argument-type-specific modifier characters to find the primary format character. This is the type of its result.

Since: base-4.7.0.0

Constructors

FormatParse 

Fields

type FieldFormatter = FieldFormat -> ShowS #

This is the type of a field formatter reified over its argument.

Since: base-4.7.0.0

type ModifierParser = String -> FormatParse #

Type of a function that will parse modifier characters from the format string.

Since: base-4.7.0.0

unless :: Applicative f => Bool -> f () -> f () #

The reverse of when.

newtype AssertionFailed #

assert was applied to False.

Constructors

AssertionFailed String 

Instances

Instances details
Show AssertionFailed

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception AssertionFailed

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

class (Typeable e, Show e) => Exception e where #

Any type that you wish to throw or catch as an exception must be an instance of the Exception class. The simplest case is a new exception type directly below the root:

data MyException = ThisException | ThatException
    deriving Show

instance Exception MyException

The default method definitions in the Exception class do what we need in this case. You can now throw and catch ThisException and ThatException as exceptions:

*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Caught ThisException

In more complicated examples, you may wish to define a whole hierarchy of exceptions:

---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler

data SomeCompilerException = forall e . Exception e => SomeCompilerException e

instance Show SomeCompilerException where
    show (SomeCompilerException e) = show e

instance Exception SomeCompilerException

compilerExceptionToException :: Exception e => e -> SomeException
compilerExceptionToException = toException . SomeCompilerException

compilerExceptionFromException :: Exception e => SomeException -> Maybe e
compilerExceptionFromException x = do
    SomeCompilerException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler

data SomeFrontendException = forall e . Exception e => SomeFrontendException e

instance Show SomeFrontendException where
    show (SomeFrontendException e) = show e

instance Exception SomeFrontendException where
    toException = compilerExceptionToException
    fromException = compilerExceptionFromException

frontendExceptionToException :: Exception e => e -> SomeException
frontendExceptionToException = toException . SomeFrontendException

frontendExceptionFromException :: Exception e => SomeException -> Maybe e
frontendExceptionFromException x = do
    SomeFrontendException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception

data MismatchedParentheses = MismatchedParentheses
    deriving Show

instance Exception MismatchedParentheses where
    toException   = frontendExceptionToException
    fromException = frontendExceptionFromException

We can now catch a MismatchedParentheses exception as MismatchedParentheses, SomeFrontendException or SomeCompilerException, but not other types, e.g. IOException:

*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
*** Exception: MismatchedParentheses

Minimal complete definition

Nothing

Methods

toException :: e -> SomeException #

fromException :: SomeException -> Maybe e #

displayException :: e -> String #

Render this exception value in a human-friendly manner.

Default implementation: show.

Since: base-4.8.0.0

Instances

Instances details
Exception AsyncCancelled 
Instance details

Defined in Control.Concurrent.Async

Exception ExceptionInLinkedThread 
Instance details

Defined in Control.Concurrent.Async

Exception Void

Since: base-4.8.0.0

Instance details

Defined in Data.Void

Exception BlockedIndefinitelyOnMVar

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception BlockedIndefinitelyOnSTM

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception Deadlock

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception AllocationLimitExceeded

Since: base-4.8.0.0

Instance details

Defined in GHC.IO.Exception

Exception CompactionFailed

Since: base-4.10.0.0

Instance details

Defined in GHC.IO.Exception

Exception AssertionFailed

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception SomeAsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception AsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception ArrayException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception FixIOException

Since: base-4.11.0.0

Instance details

Defined in GHC.IO.Exception

Exception ExitCode

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception IOException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception ArithException

Since: base-4.0.0.0

Instance details

Defined in GHC.Exception.Type

Exception SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception.Type

Exception ASCII7_Invalid 
Instance details

Defined in Basement.String.Encoding.ASCII7

Methods

toException :: ASCII7_Invalid -> SomeException #

fromException :: SomeException -> Maybe ASCII7_Invalid #

displayException :: ASCII7_Invalid -> String #

Exception ISO_8859_1_Invalid 
Instance details

Defined in Basement.String.Encoding.ISO_8859_1

Methods

toException :: ISO_8859_1_Invalid -> SomeException #

fromException :: SomeException -> Maybe ISO_8859_1_Invalid #

displayException :: ISO_8859_1_Invalid -> String #

Exception UTF16_Invalid 
Instance details

Defined in Basement.String.Encoding.UTF16

Methods

toException :: UTF16_Invalid -> SomeException #

fromException :: SomeException -> Maybe UTF16_Invalid #

displayException :: UTF16_Invalid -> String #

Exception UTF32_Invalid 
Instance details

Defined in Basement.String.Encoding.UTF32

Methods

toException :: UTF32_Invalid -> SomeException #

fromException :: SomeException -> Maybe UTF32_Invalid #

displayException :: UTF32_Invalid -> String #

Exception InvalidAccess 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Exception ResourceCleanupException 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Exception OneBillionDollarBug Source # 
Instance details

Defined in Util.IOExtra

Exception BinaryGetError Source # 
Instance details

Defined in Util.Binary

Exception a => Exception (ErrMsg a) Source # 
Instance details

Defined in Util.IOExtra

fromJust :: HasCallStack => Maybe a -> a #

The fromJust function extracts the element out of a Just and throws an error if its argument is Nothing.

Examples

Expand

Basic usage:

>>> fromJust (Just 1)
1
>>> 2 * (fromJust (Just 10))
20
>>> 2 * (fromJust Nothing)
*** Exception: Maybe.fromJust: Nothing

isJust :: Maybe a -> Bool #

The isJust function returns True iff its argument is of the form Just _.

Examples

Expand

Basic usage:

>>> isJust (Just 3)
True
>>> isJust (Just ())
True
>>> isJust Nothing
False

Only the outer constructor is taken into consideration:

>>> isJust (Just Nothing)
True

void :: Functor f => f a -> f () #

void value discards or ignores the result of evaluation, such as the return value of an IO action.

Using ApplicativeDo: 'void as' can be understood as the do expression

do as
   pure ()

with an inferred Functor constraint.

Examples

Expand

Replace the contents of a Maybe Int with unit:

>>> void Nothing
Nothing
>>> void (Just 3)
Just ()

Replace the contents of an Either Int Int with unit, resulting in an Either Int ():

>>> void (Left 8675309)
Left 8675309
>>> void (Right 8675309)
Right ()

Replace every element of a list with unit:

>>> void [1,2,3]
[(),(),()]

Replace the second element of a pair with unit:

>>> void (1,2)
(1,())

Discard the result of an IO action:

>>> mapM print [1,2]
1
2
[(),()]
>>> void $ mapM print [1,2]
1
2

data MVar a #

An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.

Instances

Instances details
NFData1 MVar

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> MVar a -> () #

Eq (MVar a)

Since: base-4.1.0.0

Instance details

Defined in GHC.MVar

Methods

(==) :: MVar a -> MVar a -> Bool #

(/=) :: MVar a -> MVar a -> Bool #

NFData (MVar a)

NOTE: Only strict in the reference and not the referenced value.

Since: deepseq-1.4.2.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: MVar a -> () #

when :: Applicative f => Bool -> f () -> f () #

Conditional execution of Applicative expressions. For example,

when debug (putStrLn "Debugging")

will output the string Debugging if the Boolean value debug is True, and otherwise do nothing.

data SomeException #

The SomeException type is the root of the exception type hierarchy. When an exception of type e is thrown, behind the scenes it is encapsulated in a SomeException.

Constructors

Exception e => SomeException e 

Instances

Instances details
Show SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception.Type

Exception SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception.Type

class MonadIO m => MonadUnliftIO (m :: Type -> Type) #

Monads which allow their actions to be run in IO.

While MonadIO allows an IO action to be lifted into another monad, this class captures the opposite concept: allowing you to capture the monadic context. Note that, in order to meet the laws given below, the intuition is that a monad must have no monadic state, but may have monadic context. This essentially limits MonadUnliftIO to ReaderT and IdentityT transformers on top of IO.

Laws. For any value u returned by askUnliftIO, it must meet the monad transformer laws as reformulated for MonadUnliftIO:

  • unliftIO u . return = return
  • unliftIO u (m >>= f) = unliftIO u m >>= unliftIO u . f

Instances of MonadUnliftIO must also satisfy the idempotency law:

  • askUnliftIO >>= \u -> (liftIO . unliftIO u) m = m

This law showcases two properties. First, askUnliftIO doesn't change the monadic context, and second, liftIO . unliftIO u is equivalent to id IF called in the same monadic context as askUnliftIO.

Since: unliftio-core-0.1.0.0

Minimal complete definition

withRunInIO

Instances

Instances details
MonadUnliftIO IO 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

withRunInIO :: ((forall a. IO a -> IO a) -> IO b) -> IO b #

MonadUnliftIO m => MonadUnliftIO (ResourceT m)

Since: resourcet-1.1.10

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

withRunInIO :: ((forall a. ResourceT m a -> IO a) -> IO b) -> ResourceT m b #

MonadUnliftIO m => MonadUnliftIO (NoLoggingT m)

Since: monad-logger-0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

withRunInIO :: ((forall a. NoLoggingT m a -> IO a) -> IO b) -> NoLoggingT m b #

MonadUnliftIO m => MonadUnliftIO (LoggingT m)

Since: monad-logger-0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

withRunInIO :: ((forall a. LoggingT m a -> IO a) -> IO b) -> LoggingT m b #

MonadUnliftIO m => MonadUnliftIO (ReaderT r m) 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

withRunInIO :: ((forall a. ReaderT r m a -> IO a) -> IO b) -> ReaderT r m b #

MonadUnliftIO m => MonadUnliftIO (IdentityT m) 
Instance details

Defined in Control.Monad.IO.Unlift

Methods

withRunInIO :: ((forall a. IdentityT m a -> IO a) -> IO b) -> IdentityT m b #

data ResourceT (m :: Type -> Type) a #

The Resource transformer. This transformer keeps track of all registered actions, and calls them upon exit (via runResourceT). Actions may be registered via register, or resources may be allocated atomically via allocate. allocate corresponds closely to bracket.

Releasing may be performed before exit via the release function. This is a highly recommended optimization, as it will ensure that scarce resources are freed early. Note that calling release will deregister the action, so that a release action will only ever be called once.

Since 0.3.0

Instances

Instances details
MonadTrans ResourceT 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

lift :: Monad m => m a -> ResourceT m a #

MonadRWS r w s m => MonadRWS r w s (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

MonadWriter w m => MonadWriter w (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

writer :: (a, w) -> ResourceT m a #

tell :: w -> ResourceT m () #

listen :: ResourceT m a -> ResourceT m (a, w) #

pass :: ResourceT m (a, w -> w) -> ResourceT m a #

MonadState s m => MonadState s (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

get :: ResourceT m s #

put :: s -> ResourceT m () #

state :: (s -> (a, s)) -> ResourceT m a #

MonadReader r m => MonadReader r (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

ask :: ResourceT m r #

local :: (r -> r) -> ResourceT m a -> ResourceT m a #

reader :: (r -> a) -> ResourceT m a #

MonadError e m => MonadError e (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

throwError :: e -> ResourceT m a #

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

Monad m => Monad (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

(>>=) :: ResourceT m a -> (a -> ResourceT m b) -> ResourceT m b #

(>>) :: ResourceT m a -> ResourceT m b -> ResourceT m b #

return :: a -> ResourceT m a #

Functor m => Functor (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

fmap :: (a -> b) -> ResourceT m a -> ResourceT m b #

(<$) :: a -> ResourceT m b -> ResourceT m a #

MonadFix m => MonadFix (ResourceT m)

Since: resourcet-1.1.8

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

mfix :: (a -> ResourceT m a) -> ResourceT m a #

MonadFail m => MonadFail (ResourceT m)

Since: resourcet-1.2.2

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

fail :: String -> ResourceT m a #

Applicative m => Applicative (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

pure :: a -> ResourceT m a #

(<*>) :: ResourceT m (a -> b) -> ResourceT m a -> ResourceT m b #

liftA2 :: (a -> b -> c) -> ResourceT m a -> ResourceT m b -> ResourceT m c #

(*>) :: ResourceT m a -> ResourceT m b -> ResourceT m b #

(<*) :: ResourceT m a -> ResourceT m b -> ResourceT m a #

Alternative m => Alternative (ResourceT m)

Since 1.1.5

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

empty :: ResourceT m a #

(<|>) :: ResourceT m a -> ResourceT m a -> ResourceT m a #

some :: ResourceT m a -> ResourceT m [a] #

many :: ResourceT m a -> ResourceT m [a] #

MonadPlus m => MonadPlus (ResourceT m)

Since 1.1.5

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

mzero :: ResourceT m a #

mplus :: ResourceT m a -> ResourceT m a -> ResourceT m a #

MonadIO m => MonadIO (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftIO :: IO a -> ResourceT m a #

MonadUnliftIO m => MonadUnliftIO (ResourceT m)

Since: resourcet-1.1.10

Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

withRunInIO :: ((forall a. ResourceT m a -> IO a) -> IO b) -> ResourceT m b #

MonadIO m => MonadResource (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> ResourceT m a #

PrimMonad m => PrimMonad (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Associated Types

type PrimState (ResourceT m) #

Methods

primitive :: (State# (PrimState (ResourceT m)) -> (# State# (PrimState (ResourceT m)), a #)) -> ResourceT m a #

MonadThrow m => MonadThrow (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

throwM :: Exception e => e -> ResourceT m a #

MonadCatch m => MonadCatch (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

catch :: Exception e => ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a #

MonadMask m => MonadMask (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

mask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b #

uninterruptibleMask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b #

generalBracket :: ResourceT m a -> (a -> ExitCase b -> ResourceT m c) -> (a -> ResourceT m b) -> ResourceT m (b, c) #

MonadLogger m => MonadLogger (ResourceT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ResourceT m () #

MonadLoggerIO m => MonadLoggerIO (ResourceT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ResourceT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadCont m => MonadCont (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

callCC :: ((a -> ResourceT m b) -> ResourceT m a) -> ResourceT m a #

type PrimState (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

class MonadIO m => MonadResource (m :: Type -> Type) where #

A Monad which allows for safe resource allocation. In theory, any monad transformer stack which includes a ResourceT can be an instance of MonadResource.

Note: runResourceT has a requirement for a MonadUnliftIO m monad, which allows control operations to be lifted. A MonadResource does not have this requirement. This means that transformers such as ContT can be an instance of MonadResource. However, the ContT wrapper will need to be unwrapped before calling runResourceT.

Since 0.3.0

Methods

liftResourceT :: ResourceT IO a -> m a #

Lift a ResourceT IO action into the current Monad.

Since 0.4.0

Instances

Instances details
MonadResource m => MonadResource (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> MaybeT m a #

MonadIO m => MonadResource (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> ResourceT m a #

MonadResource m => MonadResource (ListT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> ListT m a #

MonadResource m => MonadResource (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

MonadResource m => MonadResource (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

liftResourceT :: ResourceT IO a -> LoggingT m a #

(MonadBase IO (NodeT m), MonadResource m) => MonadResource (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Methods

liftResourceT :: ResourceT IO a -> NodeT m a #

(Monoid w, MonadResource m) => MonadResource (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> WriterT w m a #

(Monoid w, MonadResource m) => MonadResource (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> WriterT w m a #

MonadResource m => MonadResource (StateT s m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> StateT s m a #

MonadResource m => MonadResource (StateT s m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> StateT s m a #

MonadResource m => MonadResource (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> ReaderT r m a #

MonadResource m => MonadResource (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> ExceptT e m a #

MonadResource m => MonadResource (IdentityT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> IdentityT m a #

MonadResource m => MonadResource (ConduitT i o m) 
Instance details

Defined in Data.Conduit.Internal.Conduit

Methods

liftResourceT :: ResourceT IO a -> ConduitT i o m a #

MonadResource m => MonadResource (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> ContT r m a #

(Monoid w, MonadResource m) => MonadResource (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> RWST r w s m a #

(Monoid w, MonadResource m) => MonadResource (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftResourceT :: ResourceT IO a -> RWST r w s m a #

MonadResource m => MonadResource (Pipe l i o u m) 
Instance details

Defined in Data.Conduit.Internal.Pipe

Methods

liftResourceT :: ResourceT IO a -> Pipe l i o u m a #

runResourceT :: MonadUnliftIO m => ResourceT m a -> m a #

Unwrap a ResourceT transformer, and call all registered release actions.

Note that there is some reference counting involved due to resourceForkIO. If multiple threads are sharing the same collection of resources, only the last call to runResourceT will deallocate the resources.

NOTE Since version 1.2.0, this function will throw a ResourceCleanupException if any of the cleanup functions throw an exception.

Since: resourcet-0.3.0

class Monad m => MonadThrow (m :: Type -> Type) where #

A class for monads in which exceptions may be thrown.

Instances should obey the following law:

throwM e >> x = throwM e

In other words, throwing an exception short-circuits the rest of the monadic computation.

Methods

throwM :: Exception e => e -> m a #

Throw an exception. Note that this throws when this action is run in the monad m, not when it is applied. It is a generalization of Control.Exception's throwIO.

Should satisfy the law:

throwM e >> f = throwM e

Instances

Instances details
MonadThrow [] 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> [a] #

MonadThrow Maybe 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> Maybe a #

MonadThrow IO 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> IO a #

MonadThrow Q 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> Q a #

MonadThrow STM 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> STM a #

e ~ SomeException => MonadThrow (Either e) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e0 => e0 -> Either e a #

MonadThrow (ST s) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ST s a #

MonadThrow m => MonadThrow (MaybeT m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> MaybeT m a #

MonadThrow m => MonadThrow (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

throwM :: Exception e => e -> ResourceT m a #

MonadThrow m => MonadThrow (ListT m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ListT m a #

MonadThrow m => MonadThrow (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

throwM :: Exception e => e -> NoLoggingT m a #

MonadThrow m => MonadThrow (WriterLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

throwM :: Exception e => e -> WriterLoggingT m a #

MonadThrow m => MonadThrow (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

throwM :: Exception e => e -> LoggingT m a #

MonadThrow m => MonadThrow (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Methods

throwM :: Exception e => e -> NodeT m a #

(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> WriterT w m a #

(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> WriterT w m a #

MonadThrow m => MonadThrow (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> StateT s m a #

MonadThrow m => MonadThrow (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> StateT s m a #

MonadThrow m => MonadThrow (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ReaderT r m a #

MonadThrow m => MonadThrow (ExceptT e m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e0 => e0 -> ExceptT e m a #

(Error e, MonadThrow m) => MonadThrow (ErrorT e m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e0 => e0 -> ErrorT e m a #

MonadThrow m => MonadThrow (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> IdentityT m a #

MonadThrow m => MonadThrow (ConduitT i o m) 
Instance details

Defined in Data.Conduit.Internal.Conduit

Methods

throwM :: Exception e => e -> ConduitT i o m a #

MonadThrow m => MonadThrow (ContT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> ContT r m a #

(MonadThrow m, Monoid w) => MonadThrow (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> RWST r w s m a #

(MonadThrow m, Monoid w) => MonadThrow (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: Exception e => e -> RWST r w s m a #

MonadThrow m => MonadThrow (Pipe l i o u m) 
Instance details

Defined in Data.Conduit.Internal.Pipe

Methods

throwM :: Exception e => e -> Pipe l i o u m a #

bracketOnError :: MonadMask m => m a -> (a -> m c) -> (a -> m b) -> m b #

Like bracket, but only performs the final action if an error is thrown by the in-between computation.

finally :: MonadMask m => m a -> m b -> m a #

Perform an action with a finalizer action that is run, even if an error occurs.

bracket_ :: MonadMask m => m a -> m c -> m b -> m b #

Version of bracket without any value being passed to the second and third actions.

bracket :: MonadMask m => m a -> (a -> m c) -> (a -> m b) -> m b #

Generalized abstracted pattern of safe resource acquisition and release in the face of errors. The first action "acquires" some value, which is "released" by the second action at the end. The third action "uses" the value and its result is the result of the bracket.

If an error is thrown during the use, the release still happens before the error is rethrown.

Note that this is essentially a type-specialized version of generalBracket. This function has a more common signature (matching the signature from Control.Exception), and is often more convenient to use. By contrast, generalBracket is more expressive, allowing us to implement other functions like bracketOnError.

onError :: MonadMask m => m a -> m b -> m a #

Run an action only if an error is thrown in the main action. Unlike onException, this works with every kind of error, not just exceptions. For example, if f is an ExceptT computation which aborts with a Left, the computation onError f g will execute g, while onException f g will not.

This distinction is only meaningful for monads which have multiple exit points, such as Except and MaybeT. For monads that only have a single exit point, there is no difference between onException and onError, except that onError has a more constrained type.

Since: exceptions-0.10.0

onException :: MonadCatch m => m a -> m b -> m a #

Run an action only if an exception is thrown in the main action. The exception is not caught, simply rethrown.

NOTE The action is only run if an exception is thrown. If the monad supports other ways of aborting the computation, the action won't run if those other kinds of errors are thrown. See onError.

catches :: (Foldable f, MonadCatch m) => m a -> f (Handler m a) -> m a #

Catches different sorts of exceptions. See Control.Exception's catches

tryJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a) #

A variant of try that takes an exception predicate to select which exceptions are caught. See Control.Exception's tryJust

try :: (MonadCatch m, Exception e) => m a -> m (Either e a) #

Similar to catch, but returns an Either result. See Control.Exception's try.

handleJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a #

handleIf :: (MonadCatch m, Exception e) => (e -> Bool) -> (e -> m a) -> m a -> m a #

Flipped catchIf

handleAll :: MonadCatch m => (SomeException -> m a) -> m a -> m a #

Flipped catchAll

handleIOError :: MonadCatch m => (IOError -> m a) -> m a -> m a #

Flipped catchIOError

handle :: (MonadCatch m, Exception e) => (e -> m a) -> m a -> m a #

catchJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a #

A more generalized way of determining which exceptions to catch at run time.

catchIf :: (MonadCatch m, Exception e) => (e -> Bool) -> m a -> (e -> m a) -> m a #

Catch exceptions only if they pass some predicate. Often useful with the predicates for testing IOError values in System.IO.Error.

catchIOError :: MonadCatch m => m a -> (IOError -> m a) -> m a #

Catch all IOError (eqv. IOException) exceptions. Still somewhat too general, but better than using catchAll. See catchIf for an easy way of catching specific IOErrors based on the predicates in System.IO.Error.

catchAll :: MonadCatch m => m a -> (SomeException -> m a) -> m a #

Catches all exceptions, and somewhat defeats the purpose of the extensible exception system. Use sparingly.

NOTE This catches all exceptions, but if the monad supports other ways of aborting the computation, those other kinds of errors will not be caught.

uninterruptibleMask_ :: MonadMask m => m a -> m a #

Like uninterruptibleMask, but does not pass a restore action to the argument.

mask_ :: MonadMask m => m a -> m a #

Like mask, but does not pass a restore action to the argument.

class MonadThrow m => MonadCatch (m :: Type -> Type) where #

A class for monads which allow exceptions to be caught, in particular exceptions which were thrown by throwM.

Instances should obey the following law:

catch (throwM e) f = f e

Note that the ability to catch an exception does not guarantee that we can deal with all possible exit points from a computation. Some monads, such as continuation-based stacks, allow for more than just a success/failure strategy, and therefore catch cannot be used by those monads to properly implement a function such as finally. For more information, see MonadMask.

Methods

catch :: Exception e => m a -> (e -> m a) -> m a #

Provide a handler for exceptions thrown during execution of the first action. Note that type of the type of the argument to the handler will constrain which exceptions are caught. See Control.Exception's catch.

Instances

Instances details
MonadCatch IO 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => IO a -> (e -> IO a) -> IO a #

MonadCatch STM 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => STM a -> (e -> STM a) -> STM a #

e ~ SomeException => MonadCatch (Either e)

Since: exceptions-0.8.3

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => Either e a -> (e0 -> Either e a) -> Either e a #

MonadCatch m => MonadCatch (MaybeT m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

MonadCatch m => MonadCatch (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

catch :: Exception e => ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a #

MonadCatch m => MonadCatch (ListT m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => ListT m a -> (e -> ListT m a) -> ListT m a #

MonadCatch m => MonadCatch (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

catch :: Exception e => NoLoggingT m a -> (e -> NoLoggingT m a) -> NoLoggingT m a #

MonadCatch m => MonadCatch (WriterLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

catch :: Exception e => WriterLoggingT m a -> (e -> WriterLoggingT m a) -> WriterLoggingT m a #

MonadCatch m => MonadCatch (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

catch :: Exception e => LoggingT m a -> (e -> LoggingT m a) -> LoggingT m a #

MonadCatch m => MonadCatch (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Methods

catch :: Exception e => NodeT m a -> (e -> NodeT m a) -> NodeT m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadCatch m => MonadCatch (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

MonadCatch m => MonadCatch (ExceptT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => ExceptT e m a -> (e0 -> ExceptT e m a) -> ExceptT e m a #

(Error e, MonadCatch m) => MonadCatch (ErrorT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e0 => ErrorT e m a -> (e0 -> ErrorT e m a) -> ErrorT e m a #

MonadCatch m => MonadCatch (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a #

(MonadCatch m, Monoid w) => MonadCatch (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

(MonadCatch m, Monoid w) => MonadCatch (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: Exception e => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

class MonadCatch m => MonadMask (m :: Type -> Type) where #

A class for monads which provide for the ability to account for all possible exit points from a computation, and to mask asynchronous exceptions. Continuation-based monads are invalid instances of this class.

Instances should ensure that, in the following code:

fg = f `finally` g

The action g is called regardless of what occurs within f, including async exceptions. Some monads allow f to abort the computation via other effects than throwing an exception. For simplicity, we will consider aborting and throwing an exception to be two forms of "throwing an error".

If f and g both throw an error, the error thrown by fg depends on which errors we're talking about. In a monad transformer stack, the deeper layers override the effects of the inner layers; for example, ExceptT e1 (Except e2) a represents a value of type Either e2 (Either e1 a), so throwing both an e1 and an e2 will result in Left e2. If f and g both throw an error from the same layer, instances should ensure that the error from g wins.

Effects other than throwing an error are also overriden by the deeper layers. For example, StateT s Maybe a represents a value of type s -> Maybe (a, s), so if an error thrown from f causes this function to return Nothing, any changes to the state which f also performed will be erased. As a result, g will see the state as it was before f. Once g completes, f's error will be rethrown, so g' state changes will be erased as well. This is the normal interaction between effects in a monad transformer stack.

By contrast, lifted-base's version of finally always discards all of g's non-IO effects, and g never sees any of f's non-IO effects, regardless of the layer ordering and regardless of whether f throws an error. This is not the result of interacting effects, but a consequence of MonadBaseControl's approach.

Methods

mask :: ((forall a. m a -> m a) -> m b) -> m b #

Runs an action with asynchronous exceptions disabled. The action is provided a method for restoring the async. environment to what it was at the mask call. See Control.Exception's mask.

uninterruptibleMask :: ((forall a. m a -> m a) -> m b) -> m b #

Like mask, but the masked computation is not interruptible (see Control.Exception's uninterruptibleMask. WARNING: Only use if you need to mask exceptions around an interruptible operation AND you can guarantee the interruptible operation will only block for a short period of time. Otherwise you render the program/thread unresponsive and/or unkillable.

generalBracket #

Arguments

:: m a

acquire some resource

-> (a -> ExitCase b -> m c)

release the resource, observing the outcome of the inner action

-> (a -> m b)

inner action to perform with the resource

-> m (b, c) 

A generalized version of bracket which uses ExitCase to distinguish the different exit cases, and returns the values of both the use and release actions. In practice, this extra information is rarely needed, so it is often more convenient to use one of the simpler functions which are defined in terms of this one, such as bracket, finally, onError, and bracketOnError.

This function exists because in order to thread their effects through the execution of bracket, monad transformers need values to be threaded from use to release and from release to the output value.

NOTE This method was added in version 0.9.0 of this library. Previously, implementation of functions like bracket and finally in this module were based on the mask and uninterruptibleMask functions only, disallowing some classes of tranformers from having MonadMask instances (notably multi-exit-point transformers like ExceptT). If you are a library author, you'll now need to provide an implementation for this method. The StateT implementation demonstrates most of the subtleties:

generalBracket acquire release use = StateT $ s0 -> do
  ((b, _s2), (c, s3)) <- generalBracket
    (runStateT acquire s0)
    ((resource, s1) exitCase -> case exitCase of
      ExitCaseSuccess (b, s2) -> runStateT (release resource (ExitCaseSuccess b)) s2

      -- In the two other cases, the base monad overrides use's state
      -- changes and the state reverts to s1.
      ExitCaseException e     -> runStateT (release resource (ExitCaseException e)) s1
      ExitCaseAbort           -> runStateT (release resource ExitCaseAbort) s1
    )
    ((resource, s1) -> runStateT (use resource) s1)
  return ((b, c), s3)

The StateT s m implementation of generalBracket delegates to the m implementation of generalBracket. The acquire, use, and release arguments given to StateT's implementation produce actions of type StateT s m a, StateT s m b, and StateT s m c. In order to run those actions in the base monad, we need to call runStateT, from which we obtain actions of type m (a, s), m (b, s), and m (c, s). Since each action produces the next state, it is important to feed the state produced by the previous action to the next action.

In the ExitCaseSuccess case, the state starts at s0, flows through acquire to become s1, flows through use to become s2, and finally flows through release to become s3. In the other two cases, release does not receive the value s2, so its action cannot see the state changes performed by use. This is fine, because in those two cases, an error was thrown in the base monad, so as per the usual interaction between effects in a monad transformer stack, those state changes get reverted. So we start from s1 instead.

Finally, the m implementation of generalBracket returns the pairs (b, s) and (c, s). For monad transformers other than StateT, this will be some other type representing the effects and values performed and returned by the use and release actions. The effect part of the use result, in this case _s2, usually needs to be discarded, since those effects have already been incorporated in the release action.

The only effect which is intentionally not incorporated in the release action is the effect of throwing an error. In that case, the error must be re-thrown. One subtlety which is easy to miss is that in the case in which use and release both throw an error, the error from release should take priority. Here is an implementation for ExceptT which demonstrates how to do this.

generalBracket acquire release use = ExceptT $ do
  (eb, ec) <- generalBracket
    (runExceptT acquire)
    (eresource exitCase -> case eresource of
      Left e -> return (Left e) -- nothing to release, acquire didn't succeed
      Right resource -> case exitCase of
        ExitCaseSuccess (Right b) -> runExceptT (release resource (ExitCaseSuccess b))
        ExitCaseException e       -> runExceptT (release resource (ExitCaseException e))
        _                         -> runExceptT (release resource ExitCaseAbort))
    (either (return . Left) (runExceptT . use))
  return $ do
    -- The order in which we perform those two Either effects determines
    -- which error will win if they are both Lefts. We want the error from
    -- release to win.
    c <- ec
    b <- eb
    return (b, c)

Since: exceptions-0.9.0

Instances

Instances details
MonadMask IO 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b #

uninterruptibleMask :: ((forall a. IO a -> IO a) -> IO b) -> IO b #

generalBracket :: IO a -> (a -> ExitCase b -> IO c) -> (a -> IO b) -> IO (b, c) #

e ~ SomeException => MonadMask (Either e)

Since: exceptions-0.8.3

Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. Either e a -> Either e a) -> Either e b) -> Either e b #

uninterruptibleMask :: ((forall a. Either e a -> Either e a) -> Either e b) -> Either e b #

generalBracket :: Either e a -> (a -> ExitCase b -> Either e c) -> (a -> Either e b) -> Either e (b, c) #

MonadMask m => MonadMask (MaybeT m)

Since: exceptions-0.10.0

Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. MaybeT m a -> MaybeT m a) -> MaybeT m b) -> MaybeT m b #

uninterruptibleMask :: ((forall a. MaybeT m a -> MaybeT m a) -> MaybeT m b) -> MaybeT m b #

generalBracket :: MaybeT m a -> (a -> ExitCase b -> MaybeT m c) -> (a -> MaybeT m b) -> MaybeT m (b, c) #

MonadMask m => MonadMask (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

mask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b #

uninterruptibleMask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b #

generalBracket :: ResourceT m a -> (a -> ExitCase b -> ResourceT m c) -> (a -> ResourceT m b) -> ResourceT m (b, c) #

MonadMask m => MonadMask (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

mask :: ((forall a. NoLoggingT m a -> NoLoggingT m a) -> NoLoggingT m b) -> NoLoggingT m b #

uninterruptibleMask :: ((forall a. NoLoggingT m a -> NoLoggingT m a) -> NoLoggingT m b) -> NoLoggingT m b #

generalBracket :: NoLoggingT m a -> (a -> ExitCase b -> NoLoggingT m c) -> (a -> NoLoggingT m b) -> NoLoggingT m (b, c) #

MonadMask m => MonadMask (WriterLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

mask :: ((forall a. WriterLoggingT m a -> WriterLoggingT m a) -> WriterLoggingT m b) -> WriterLoggingT m b #

uninterruptibleMask :: ((forall a. WriterLoggingT m a -> WriterLoggingT m a) -> WriterLoggingT m b) -> WriterLoggingT m b #

generalBracket :: WriterLoggingT m a -> (a -> ExitCase b -> WriterLoggingT m c) -> (a -> WriterLoggingT m b) -> WriterLoggingT m (b, c) #

MonadMask m => MonadMask (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

mask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b #

uninterruptibleMask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b #

generalBracket :: LoggingT m a -> (a -> ExitCase b -> LoggingT m c) -> (a -> LoggingT m b) -> LoggingT m (b, c) #

MonadMask m => MonadMask (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Methods

mask :: ((forall a. NodeT m a -> NodeT m a) -> NodeT m b) -> NodeT m b #

uninterruptibleMask :: ((forall a. NodeT m a -> NodeT m a) -> NodeT m b) -> NodeT m b #

generalBracket :: NodeT m a -> (a -> ExitCase b -> NodeT m c) -> (a -> NodeT m b) -> NodeT m (b, c) #

(MonadMask m, Monoid w) => MonadMask (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b #

uninterruptibleMask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b #

generalBracket :: WriterT w m a -> (a -> ExitCase b -> WriterT w m c) -> (a -> WriterT w m b) -> WriterT w m (b, c) #

(MonadMask m, Monoid w) => MonadMask (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b #

uninterruptibleMask :: ((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b) -> WriterT w m b #

generalBracket :: WriterT w m a -> (a -> ExitCase b -> WriterT w m c) -> (a -> WriterT w m b) -> WriterT w m (b, c) #

MonadMask m => MonadMask (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b #

uninterruptibleMask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b #

generalBracket :: StateT s m a -> (a -> ExitCase b -> StateT s m c) -> (a -> StateT s m b) -> StateT s m (b, c) #

MonadMask m => MonadMask (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b #

uninterruptibleMask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b #

generalBracket :: StateT s m a -> (a -> ExitCase b -> StateT s m c) -> (a -> StateT s m b) -> StateT s m (b, c) #

MonadMask m => MonadMask (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. ReaderT r m a -> ReaderT r m a) -> ReaderT r m b) -> ReaderT r m b #

uninterruptibleMask :: ((forall a. ReaderT r m a -> ReaderT r m a) -> ReaderT r m b) -> ReaderT r m b #

generalBracket :: ReaderT r m a -> (a -> ExitCase b -> ReaderT r m c) -> (a -> ReaderT r m b) -> ReaderT r m (b, c) #

MonadMask m => MonadMask (ExceptT e m)

Since: exceptions-0.9.0

Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b) -> ExceptT e m b #

uninterruptibleMask :: ((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b) -> ExceptT e m b #

generalBracket :: ExceptT e m a -> (a -> ExitCase b -> ExceptT e m c) -> (a -> ExceptT e m b) -> ExceptT e m (b, c) #

(Error e, MonadMask m) => MonadMask (ErrorT e m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. ErrorT e m a -> ErrorT e m a) -> ErrorT e m b) -> ErrorT e m b #

uninterruptibleMask :: ((forall a. ErrorT e m a -> ErrorT e m a) -> ErrorT e m b) -> ErrorT e m b #

generalBracket :: ErrorT e m a -> (a -> ExitCase b -> ErrorT e m c) -> (a -> ErrorT e m b) -> ErrorT e m (b, c) #

MonadMask m => MonadMask (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. IdentityT m a -> IdentityT m a) -> IdentityT m b) -> IdentityT m b #

uninterruptibleMask :: ((forall a. IdentityT m a -> IdentityT m a) -> IdentityT m b) -> IdentityT m b #

generalBracket :: IdentityT m a -> (a -> ExitCase b -> IdentityT m c) -> (a -> IdentityT m b) -> IdentityT m (b, c) #

(MonadMask m, Monoid w) => MonadMask (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b #

uninterruptibleMask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b #

generalBracket :: RWST r w s m a -> (a -> ExitCase b -> RWST r w s m c) -> (a -> RWST r w s m b) -> RWST r w s m (b, c) #

(MonadMask m, Monoid w) => MonadMask (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

mask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b #

uninterruptibleMask :: ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b) -> RWST r w s m b #

generalBracket :: RWST r w s m a -> (a -> ExitCase b -> RWST r w s m c) -> (a -> RWST r w s m b) -> RWST r w s m (b, c) #

data ExitCase a #

A MonadMask computation may either succeed with a value, abort with an exception, or abort for some other reason. For example, in ExceptT e IO you can use throwM to abort with an exception (ExitCaseException) or throwE to abort with a value of type e (ExitCaseAbort).

Instances

Instances details
Show a => Show (ExitCase a) 
Instance details

Defined in Control.Monad.Catch

Methods

showsPrec :: Int -> ExitCase a -> ShowS #

show :: ExitCase a -> String #

showList :: [ExitCase a] -> ShowS #

data Handler (m :: Type -> Type) a #

Generalized version of Handler

Constructors

Exception e => Handler (e -> m a) 

Instances

Instances details
Monad m => Functor (Handler m) 
Instance details

Defined in Control.Monad.Catch

Methods

fmap :: (a -> b) -> Handler m a -> Handler m b #

(<$) :: a -> Handler m b -> Handler m a #

type family StM (m :: Type -> Type) a #

Monadic state that m adds to the base monad b.

For all base (non-transformed) monads, StM m a ~ a:

StM IO         a ~ a
StM Maybe      a ~ a
StM (Either e) a ~ a
StM []         a ~ a
StM ((->) r)   a ~ a
StM Identity   a ~ a
StM STM        a ~ a
StM (ST s)     a ~ a

If m is a transformed monad, m ~ t b, StM is the monadic state of the transformer t (given by its StT from MonadTransControl). For a transformer stack, StM is defined recursively:

StM (IdentityT  m) a ~ ComposeSt IdentityT m a ~ StM m a
StM (MaybeT     m) a ~ ComposeSt MaybeT    m a ~ StM m (Maybe a)
StM (ErrorT e   m) a ~ ComposeSt ErrorT    m a ~ Error e => StM m (Either e a)
StM (ExceptT e  m) a ~ ComposeSt ExceptT   m a ~ StM m (Either e a)
StM (ListT      m) a ~ ComposeSt ListT     m a ~ StM m [a]
StM (ReaderT r  m) a ~ ComposeSt ReaderT   m a ~ StM m a
StM (StateT s   m) a ~ ComposeSt StateT    m a ~ StM m (a, s)
StM (WriterT w  m) a ~ ComposeSt WriterT   m a ~ Monoid w => StM m (a, w)
StM (RWST r w s m) a ~ ComposeSt RWST      m a ~ Monoid w => StM m (a, s, w)

Instances

Instances details
type StM [] a 
Instance details

Defined in Control.Monad.Trans.Control

type StM [] a = a
type StM Maybe a 
Instance details

Defined in Control.Monad.Trans.Control

type StM Maybe a = a
type StM IO a 
Instance details

Defined in Control.Monad.Trans.Control

type StM IO a = a
type StM Identity a 
Instance details

Defined in Control.Monad.Trans.Control

type StM Identity a = a
type StM STM a 
Instance details

Defined in Control.Monad.Trans.Control

type StM STM a = a
type StM (Either e) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (Either e) a = a
type StM (ST s) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (ST s) a = a
type StM (ST s) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (ST s) a = a
type StM (MaybeT m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (MaybeT m) a = ComposeSt MaybeT m a
type StM (ListT m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (ListT m) a = ComposeSt ListT m a
type StM (NoLoggingT m) a 
Instance details

Defined in Control.Monad.Logger

type StM (NoLoggingT m) a = StM m a
type StM (WriterLoggingT m) a 
Instance details

Defined in Control.Monad.Logger

type StM (LoggingT m) a 
Instance details

Defined in Control.Monad.Logger

type StM (LoggingT m) a = StM m a
type StM (NodeT m) a Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

type StM (NodeT m) a = StM m a
type StM (WriterT w m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (WriterT w m) a = ComposeSt (WriterT w) m a
type StM (WriterT w m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (WriterT w m) a = ComposeSt (WriterT w) m a
type StM (StateT s m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (StateT s m) a = ComposeSt (StateT s) m a
type StM (StateT s m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (StateT s m) a = ComposeSt (StateT s) m a
type StM (ReaderT r m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (ReaderT r m) a = ComposeSt (ReaderT r) m a
type StM (ExceptT e m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (ExceptT e m) a = ComposeSt (ExceptT e) m a
type StM (ErrorT e m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (ErrorT e m) a = ComposeSt (ErrorT e) m a
type StM (IdentityT m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (IdentityT m) a = ComposeSt (IdentityT :: (Type -> Type) -> Type -> Type) m a
type StM ((->) r :: Type -> Type) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM ((->) r :: Type -> Type) a = a
type StM (RWST r w s m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (RWST r w s m) a = ComposeSt (RWST r w s) m a
type StM (RWST r w s m) a 
Instance details

Defined in Control.Monad.Trans.Control

type StM (RWST r w s m) a = ComposeSt (RWST r w s) m a

replicateConcurrently_ :: MonadBaseControl IO m => Int -> m a -> m () #

Generalized version of replicateConcurrently_.

replicateConcurrently :: MonadBaseControl IO m => Int -> m a -> m [a] #

Generalized version of replicateConcurrently.

forConcurrently_ :: (Foldable t, MonadBaseControl IO m) => t a -> (a -> m b) -> m () #

Generalized version of forConcurrently_.

forConcurrently :: (Traversable t, MonadBaseControl IO m) => t a -> (a -> m b) -> m (t b) #

Generalized version of forConcurrently.

mapConcurrently_ :: (Foldable t, MonadBaseControl IO m) => (a -> m b) -> t a -> m () #

Generalized version of mapConcurrently_.

mapConcurrently :: (Traversable t, MonadBaseControl IO m) => (a -> m b) -> t a -> m (t b) #

Generalized version of mapConcurrently.

concurrently_ :: MonadBaseControl IO m => m a -> m b -> m () #

Generalized version of concurrently_.

concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b) #

Generalized version of concurrently.

race_ :: MonadBaseControl IO m => m a -> m b -> m () #

Generalized version of race_.

NOTE: This function discards the monadic effects besides IO in the forked computation.

race :: MonadBaseControl IO m => m a -> m b -> m (Either a b) #

Generalized version of race.

link2 :: MonadBase IO m => Async a -> Async b -> m () #

Generalized version of link2.

link :: MonadBase IO m => Async a -> m () #

Generalized version of link.

waitBoth :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (a, b) #

Generalized version of waitBoth.

waitEither_ :: MonadBase IO m => Async a -> Async b -> m () #

Generalized version of waitEither_.

NOTE: This function discards the monadic effects besides IO in the forked computation.

waitEitherCancel :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b) #

Generalized version of waitEitherCancel.

waitEitherCatch :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either (Either SomeException a) (Either SomeException b)) #

Generalized version of waitEitherCatch.

waitEither :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b) #

Generalized version of waitEither.

waitAnyCatchCancel :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a) #

Generalized version of waitAnyCatchCancel.

waitAnyCancel :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), a) #

Generalized version of waitAnyCancel.

waitAnyCatch :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a) #

Generalized version of waitAnyCatch.

waitAny :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), a) #

Generalized version of waitAny.

waitCatch :: MonadBaseControl IO m => Async (StM m a) -> m (Either SomeException a) #

Generalized version of waitCatch.

uninterruptibleCancel :: MonadBase IO m => Async a -> m () #

Generalized version of uninterruptibleCancel.

cancelWith :: (MonadBase IO m, Exception e) => Async a -> e -> m () #

Generalized version of cancelWith.

cancel :: MonadBase IO m => Async a -> m () #

Generalized version of cancel.

poll :: MonadBaseControl IO m => Async (StM m a) -> m (Maybe (Either SomeException a)) #

Generalized version of poll.

wait :: MonadBaseControl IO m => Async (StM m a) -> m a #

Generalized version of wait.

withAsyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m b #

Generalized version of withAsyncOnWithUnmask.

withAsyncWithUnmask :: MonadBaseControl IO m => ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m b #

Generalized version of withAsyncWithUnmask.

withAsyncOn :: MonadBaseControl IO m => Int -> m a -> (Async (StM m a) -> m b) -> m b #

Generalized version of withAsyncOn.

withAsyncBound :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m b #

Generalized version of withAsyncBound.

withAsync :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m b #

Generalized version of withAsync.

asyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall b. m b -> m b) -> m a) -> m (Async (StM m a)) #

Generalized version of asyncOnWithUnmask.

asyncWithUnmask :: MonadBaseControl IO m => ((forall b. m b -> m b) -> m a) -> m (Async (StM m a)) #

Generalized version of asyncWithUnmask.

asyncOn :: MonadBaseControl IO m => Int -> m a -> m (Async (StM m a)) #

Generalized version of asyncOn.

asyncBound :: MonadBaseControl IO m => m a -> m (Async (StM m a)) #

Generalized version of asyncBound.

async :: MonadBaseControl IO m => m a -> m (Async (StM m a)) #

Generalized version of async.

newtype Concurrently (m :: Type -> Type) a #

Generalized version of Concurrently.

A value of type Concurrently m a is an IO-based operation that can be composed with other Concurrently values, using the Applicative and Alternative instances.

Calling runConcurrently on a value of type Concurrently m a will execute the IO-based lifted operations it contains concurrently, before delivering the result of type a.

For example

  (page1, page2, page3) <- runConcurrently $ (,,)
    <$> Concurrently (getURL "url1")
    <*> Concurrently (getURL "url2")
    <*> Concurrently (getURL "url3")

Constructors

Concurrently 

Fields

Instances

Instances details
Functor m => Functor (Concurrently m) 
Instance details

Defined in Control.Concurrent.Async.Lifted

Methods

fmap :: (a -> b) -> Concurrently m a -> Concurrently m b #

(<$) :: a -> Concurrently m b -> Concurrently m a #

MonadBaseControl IO m => Applicative (Concurrently m) 
Instance details

Defined in Control.Concurrent.Async.Lifted

Methods

pure :: a -> Concurrently m a #

(<*>) :: Concurrently m (a -> b) -> Concurrently m a -> Concurrently m b #

liftA2 :: (a -> b -> c) -> Concurrently m a -> Concurrently m b -> Concurrently m c #

(*>) :: Concurrently m a -> Concurrently m b -> Concurrently m b #

(<*) :: Concurrently m a -> Concurrently m b -> Concurrently m a #

MonadBaseControl IO m => Alternative (Concurrently m) 
Instance details

Defined in Control.Concurrent.Async.Lifted

Methods

empty :: Concurrently m a #

(<|>) :: Concurrently m a -> Concurrently m a -> Concurrently m a #

some :: Concurrently m a -> Concurrently m [a] #

many :: Concurrently m a -> Concurrently m [a] #

(MonadBaseControl IO m, Semigroup a) => Semigroup (Concurrently m a) 
Instance details

Defined in Control.Concurrent.Async.Lifted

Methods

(<>) :: Concurrently m a -> Concurrently m a -> Concurrently m a #

sconcat :: NonEmpty (Concurrently m a) -> Concurrently m a #

stimes :: Integral b => b -> Concurrently m a -> Concurrently m a #

(MonadBaseControl IO m, Semigroup a, Monoid a) => Monoid (Concurrently m a) 
Instance details

Defined in Control.Concurrent.Async.Lifted

liftBaseOp_ :: MonadBaseControl b m => (b (StM m a) -> b (StM m c)) -> m a -> m c #

liftBaseOp_ is a particular application of liftBaseWith that allows lifting control operations of type:

(b a -> b a)

to:

(MonadBaseControl b m => m a -> m a)

For example:

liftBaseOp_ mask_ :: MonadBaseControl IO m => m a -> m a

mkWeakThreadId :: MonadBase IO m => ThreadId -> m (Weak ThreadId) #

Generalized versio of mkWeakThreadId.

runInUnboundThread :: MonadBaseControl IO m => m a -> m a #

Generalized version of runInUnboundThread.

runInBoundThread :: MonadBaseControl IO m => m a -> m a #

Generalized version of runInBoundThread.

isCurrentThreadBound :: MonadBase IO m => m Bool #

Generalized version of isCurrentThreadBound.

forkOS :: MonadBaseControl IO m => m () -> m ThreadId #

Generalized version of forkOS.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

threadWaitWrite :: MonadBase IO m => Fd -> m () #

Generalized version of threadWaitWrite.

threadWaitRead :: MonadBase IO m => Fd -> m () #

Generalized version of threadWaitRead.

threadDelay :: MonadBase IO m => Int -> m () #

Generalized version of threadDelay.

yield :: MonadBase IO m => m () #

Generalized version of yield.

threadCapability :: MonadBase IO m => ThreadId -> m (Int, Bool) #

Generalized version of threadCapability.

setNumCapabilities :: MonadBase IO m => Int -> m () #

Generalized version of setNumCapabilities.

getNumCapabilities :: MonadBase IO m => m Int #

Generalized version of getNumCapabilities.

forkOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall a. m a -> m a) -> m ()) -> m ThreadId #

Generalized version of forkOnWithUnmask.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

forkOn :: MonadBaseControl IO m => Int -> m () -> m ThreadId #

Generalized version of forkOn.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

killThread :: MonadBase IO m => ThreadId -> m () #

Generalized version of killThread.

forkFinally :: MonadBaseControl IO m => m a -> (Either SomeException a -> m ()) -> m ThreadId #

Generalized version of forkFinally.

Note that in forkFinally action and_then, while the forked action and the and_then function have access to the captured state, all their side-effects in m are discarded. They're run only for their side-effects in IO.

forkWithUnmask :: MonadBaseControl IO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId #

Generalized version of forkIOWithUnmask.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

fork :: MonadBaseControl IO m => m () -> m ThreadId #

Generalized version of forkIO.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

myThreadId :: MonadBase IO m => m ThreadId #

Generalized version of myThreadId.

throwTo :: (MonadBase IO m, Exception e) => ThreadId -> e -> m () #

Generalized version of throwTo.

signalQSemN :: MonadBase IO m => QSemN -> Int -> m () #

Generalized version of signalQSemN.

waitQSemN :: MonadBase IO m => QSemN -> Int -> m () #

Generalized version of waitQSemN.

newQSemN :: MonadBase IO m => Int -> m QSemN #

Generalized version of newQSemN.

signalQSem :: MonadBase IO m => QSem -> m () #

Generalized version of signalQSem.

waitQSem :: MonadBase IO m => QSem -> m () #

Generalized version of waitQSem.

newQSem :: MonadBase IO m => Int -> m QSem #

Generalized version of newQSem.

tryReadMVar :: MonadBase IO m => MVar a -> m (Maybe a) #

Generalized version of tryReadMVar.

withMVarMasked :: MonadBaseControl IO m => MVar a -> (a -> m b) -> m b #

Generalized version of withMVarMasked.

mkWeakMVar :: MonadBaseControl IO m => MVar a -> m () -> m (Weak (MVar a)) #

Generalized version of mkWeakMVar.

Note any monadic side effects in m of the "finalizer" computation are discarded.

modifyMVarMasked :: MonadBaseControl IO m => MVar a -> (a -> m (a, b)) -> m b #

Generalized version of modifyMVarMasked.

modifyMVarMasked_ :: MonadBaseControl IO m => MVar a -> (a -> m a) -> m () #

Generalized version of modifyMVarMasked_.

modifyMVar :: MonadBaseControl IO m => MVar a -> (a -> m (a, b)) -> m b #

Generalized version of modifyMVar.

modifyMVar_ :: MonadBaseControl IO m => MVar a -> (a -> m a) -> m () #

Generalized version of modifyMVar_.

withMVar :: MonadBaseControl IO m => MVar a -> (a -> m b) -> m b #

Generalized version of withMVar.

isEmptyMVar :: MonadBase IO m => MVar a -> m Bool #

Generalized version of isEmptyMVar.

tryPutMVar :: MonadBase IO m => MVar a -> a -> m Bool #

Generalized version of tryPutMVar.

tryTakeMVar :: MonadBase IO m => MVar a -> m (Maybe a) #

Generalized version of tryTakeMVar.

swapMVar :: MonadBase IO m => MVar a -> a -> m a #

Generalized version of swapMVar.

readMVar :: MonadBase IO m => MVar a -> m a #

Generalized version of readMVar.

putMVar :: MonadBase IO m => MVar a -> a -> m () #

Generalized version of putMVar.

takeMVar :: MonadBase IO m => MVar a -> m a #

Generalized version of takeMVar.

newMVar :: MonadBase IO m => a -> m (MVar a) #

Generalized version of newMVar.

newEmptyMVar :: MonadBase IO m => m (MVar a) #

Generalized version of newEmptyMVar.

writeList2Chan :: MonadBase IO m => Chan a -> [a] -> m () #

Generalized version of writeList2Chan.

getChanContents :: MonadBase IO m => Chan a -> m [a] #

Generalized version of getChanContents.

dupChan :: MonadBase IO m => Chan a -> m (Chan a) #

Generalized version of dupChan.

readChan :: MonadBase IO m => Chan a -> m a #

Generalized version of readChan.

writeChan :: MonadBase IO m => Chan a -> a -> m () #

Generalized version of writeChan.

newChan :: MonadBase IO m => m (Chan a) #

Generalized version of newChan.

liftThrough #

Arguments

:: (MonadTransControl t, Monad (t m), Monad m) 
=> (m (StT t a) -> m (StT t b)) 
-> t m a 
-> t m b 

Transform an action in t m using a transformer that operates on the underlying monad m

liftBaseOpDiscard :: MonadBaseControl b m => ((a -> b ()) -> b c) -> (a -> m ()) -> m c #

liftBaseOpDiscard is a particular application of liftBaseWith that allows lifting control operations of type:

((a -> b ()) -> b c)

to:

(MonadBaseControl b m => (a -> m ()) -> m c)

Note that, while the argument computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in the base monad b.

For example:

liftBaseDiscard (runServer addr port) :: MonadBaseControl IO m => m () -> m ()

liftBaseDiscard :: MonadBaseControl b m => (b () -> b a) -> m () -> m a #

liftBaseDiscard is a particular application of liftBaseWith that allows lifting control operations of type:

(b () -> b a)

to:

(MonadBaseControl b m => m () -> m a)

Note that, while the argument computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in the base monad b.

For example:

liftBaseDiscard forkIO :: MonadBaseControl IO m => m () -> m ThreadId

liftBaseOp :: MonadBaseControl b m => ((a -> b (StM m c)) -> b (StM m d)) -> (a -> m c) -> m d #

liftBaseOp is a particular application of liftBaseWith that allows lifting control operations of type:

((a -> b c) -> b c)

to:

(MonadBaseControl b m => (a -> m c) -> m c)

For example:

liftBaseOp alloca :: (Storable a, MonadBaseControl IO m) => (Ptr a -> m c) -> m c

captureM :: forall (b :: Type -> Type) m. MonadBaseControl b m => m (StM m ()) #

Capture the current state above the base monad

captureT :: forall t (m :: Type -> Type). (MonadTransControl t, Monad (t m), Monad m) => t m (StT t ()) #

Capture the current state of a transformer

embed_ :: MonadBaseControl b m => (a -> m ()) -> m (a -> b ()) #

Performs the same function as embed, but discards transformer state from the embedded function.

embed :: MonadBaseControl b m => (a -> m c) -> m (a -> b (StM m c)) #

Embed a transformer function as an function in the base monad returning a mutated transformer state.

control :: MonadBaseControl b m => (RunInBase m b -> b (StM m a)) -> m a #

An often used composition: control f = liftBaseWith f >>= restoreM

Example:

liftedBracket :: MonadBaseControl IO m => m a -> (a -> m b) -> (a -> m c) -> m c
liftedBracket acquire release action = control $ \runInBase ->
    bracket (runInBase acquire)
            (\saved -> runInBase (restoreM saved >>= release))
            (\saved -> runInBase (restoreM saved >>= action))

defaultRestoreM :: forall t (b :: Type -> Type) (m :: Type -> Type) a. (MonadTransControl t, MonadBaseControl b m) => ComposeSt t m a -> t m a #

Default definition for the restoreM method.

Note that: defaultRestoreM = restoreT . restoreM

defaultLiftBaseWith :: forall t b (m :: Type -> Type) a. (MonadTransControl t, MonadBaseControl b m) => (RunInBaseDefault t m b -> b a) -> t m a #

Default definition for the liftBaseWith method.

Note that it composes a liftWith of t with a liftBaseWith of m to give a liftBaseWith of t m:

defaultLiftBaseWith = \f -> liftWith $ \run ->
                              liftBaseWith $ \runInBase ->
                                f $ runInBase . run

defaultRestoreT2 #

Arguments

:: forall m (n' :: (Type -> Type) -> Type -> Type) n a t. (Monad m, Monad (n' m), MonadTransControl n, MonadTransControl n') 
=> (n (n' m) a -> t m a)

Monad constructor

-> m (StT n' (StT n a)) 
-> t m a 

Default definition for the restoreT method for double MonadTransControl.

defaultLiftWith2 #

Arguments

:: forall m (n' :: (Type -> Type) -> Type -> Type) n t a. (Monad m, Monad (n' m), MonadTransControl n, MonadTransControl n') 
=> (forall b. n (n' m) b -> t m b)

Monad constructor

-> (forall (o :: Type -> Type) b. t o b -> n (n' o) b)

Monad deconstructor

-> (RunDefault2 t n n' -> m a) 
-> t m a 

Default definition for the liftWith method.

defaultRestoreT #

Arguments

:: (Monad m, MonadTransControl n) 
=> (n m a -> t m a)

Monad constructor

-> m (StT n a) 
-> t m a 

Default definition for the restoreT method.

defaultLiftWith #

Arguments

:: (Monad m, MonadTransControl n) 
=> (forall b. n m b -> t m b)

Monad constructor

-> (forall (o :: Type -> Type) b. t o b -> n o b)

Monad deconstructor

-> (RunDefault t n -> m a) 
-> t m a 

Default definition for the liftWith method.

type family StT (t :: (Type -> Type) -> Type -> Type) a #

Monadic state of t.

The monadic state of a monad transformer is the result type of its run function, e.g.:

runReaderT :: ReaderT r m a -> r -> m a
StT (ReaderT r) a ~ a

runStateT :: StateT s m a -> s -> m (a, s)
StT (StateT s) a ~ (a, s)

runMaybeT :: MaybeT m a -> m (Maybe a)
StT MaybeT a ~ Maybe a

Provided type instances:

StT IdentityT    a ~ a
StT MaybeT       a ~ Maybe a
StT (ErrorT e)   a ~ Error e => Either e a
StT (ExceptT e)  a ~ Either e a
StT ListT        a ~ [a]
StT (ReaderT r)  a ~ a
StT (StateT s)   a ~ (a, s)
StT (WriterT w)  a ~ Monoid w => (a, w)
StT (RWST r w s) a ~ Monoid w => (a, s, w)

Instances

Instances details
type StT MaybeT a 
Instance details

Defined in Control.Monad.Trans.Control

type StT MaybeT a = Maybe a
type StT ListT a 
Instance details

Defined in Control.Monad.Trans.Control

type StT ListT a = [a]
type StT NoLoggingT a 
Instance details

Defined in Control.Monad.Logger

type StT NoLoggingT a = a
type StT WriterLoggingT a 
Instance details

Defined in Control.Monad.Logger

type StT WriterLoggingT a = (a, DList LogLine)
type StT LoggingT a 
Instance details

Defined in Control.Monad.Logger

type StT LoggingT a = a
type StT (WriterT w) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (WriterT w) a = (a, w)
type StT (WriterT w) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (WriterT w) a = (a, w)
type StT (StateT s) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (StateT s) a = (a, s)
type StT (StateT s) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (StateT s) a = (a, s)
type StT (ReaderT r) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (ReaderT r) a = a
type StT (ExceptT e) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (ExceptT e) a = Either e a
type StT (ErrorT e) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (ErrorT e) a = Either e a
type StT (IdentityT :: (Type -> Type) -> Type -> Type) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (IdentityT :: (Type -> Type) -> Type -> Type) a = a
type StT (RWST r w s) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (RWST r w s) a = (a, s, w)
type StT (RWST r w s) a 
Instance details

Defined in Control.Monad.Trans.Control

type StT (RWST r w s) a = (a, s, w)

class MonadTrans t => MonadTransControl (t :: (Type -> Type) -> Type -> Type) where #

The MonadTransControl type class is a stronger version of MonadTrans:

Instances of MonadTrans know how to lift actions in the base monad to the transformed monad. These lifted actions, however, are completely unaware of the monadic state added by the transformer.

MonadTransControl instances are aware of the monadic state of the transformer and allow to save and restore this state.

This allows to lift functions that have a monad transformer in both positive and negative position. Take, for example, the function

withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r

MonadTrans instances can only lift the return type of the withFile function:

withFileLifted :: MonadTrans t => FilePath -> IOMode -> (Handle -> IO r) -> t IO r
withFileLifted file mode action = lift (withFile file mode action)

However, MonadTrans is not powerful enough to make withFileLifted accept a function that returns t IO. The reason is that we need to take away the transformer layer in order to pass the function to withFile. MonadTransControl allows us to do this:

withFileLifted' :: (Monad (t IO), MonadTransControl t) => FilePath -> IOMode -> (Handle -> t IO r) -> t IO r
withFileLifted' file mode action = liftWith (\run -> withFile file mode (run . action)) >>= restoreT . return

Associated Types

type StT (t :: (Type -> Type) -> Type -> Type) a #

Monadic state of t.

The monadic state of a monad transformer is the result type of its run function, e.g.:

runReaderT :: ReaderT r m a -> r -> m a
StT (ReaderT r) a ~ a

runStateT :: StateT s m a -> s -> m (a, s)
StT (StateT s) a ~ (a, s)

runMaybeT :: MaybeT m a -> m (Maybe a)
StT MaybeT a ~ Maybe a

Provided type instances:

StT IdentityT    a ~ a
StT MaybeT       a ~ Maybe a
StT (ErrorT e)   a ~ Error e => Either e a
StT (ExceptT e)  a ~ Either e a
StT ListT        a ~ [a]
StT (ReaderT r)  a ~ a
StT (StateT s)   a ~ (a, s)
StT (WriterT w)  a ~ Monoid w => (a, w)
StT (RWST r w s) a ~ Monoid w => (a, s, w)

Methods

liftWith :: Monad m => (Run t -> m a) -> t m a #

liftWith is similar to lift in that it lifts a computation from the argument monad to the constructed monad.

Instances should satisfy similar laws as the MonadTrans laws:

liftWith . const . return = return
liftWith (const (m >>= f)) = liftWith (const m) >>= liftWith . const . f

The difference with lift is that before lifting the m computation liftWith captures the state of t. It then provides the m computation with a Run function that allows running t n computations in n (for all n) on the captured state, e.g.

withFileLifted :: (Monad (t IO), MonadTransControl t) => FilePath -> IOMode -> (Handle -> t IO r) -> t IO r
withFileLifted file mode action = liftWith (\run -> withFile file mode (run . action)) >>= restoreT . return

If the Run function is ignored, liftWith coincides with lift:

lift f = liftWith (const f)

Implementations use the Run function associated with a transformer:

liftWith :: Monad m => ((Monad n => ReaderT r n b -> n b) -> m a) -> ReaderT r m a
liftWith f = ReaderT (r -> f (action -> runReaderT action r))

liftWith :: Monad m => ((Monad n => StateT s n b -> n (b, s)) -> m a) -> StateT s m a
liftWith f = StateT (s -> liftM (x -> (x, s)) (f (action -> runStateT action s)))

liftWith :: Monad m => ((Monad n => MaybeT n b -> n (Maybe b)) -> m a) -> MaybeT m a
liftWith f = MaybeT (liftM Just (f runMaybeT))

restoreT :: Monad m => m (StT t a) -> t m a #

Construct a t computation from the monadic state of t that is returned from a Run function.

Instances should satisfy:

liftWith (\run -> run t) >>= restoreT . return = t

restoreT is usually implemented through the constructor of the monad transformer:

ReaderT  :: (r -> m a) -> ReaderT r m a
restoreT ::       m a  -> ReaderT r m a
restoreT action = ReaderT { runReaderT = const action }

StateT   :: (s -> m (a, s)) -> StateT s m a
restoreT ::       m (a, s)  -> StateT s m a
restoreT action = StateT { runStateT = const action }

MaybeT   :: m (Maybe a) -> MaybeT m a
restoreT :: m (Maybe a) -> MaybeT m a
restoreT action = MaybeT action

Example type signatures:

restoreT :: Monad m             => m a            -> IdentityT m a
restoreT :: Monad m             => m (Maybe a)    -> MaybeT m a
restoreT :: (Monad m, Error e)  => m (Either e a) -> ErrorT e m a
restoreT :: Monad m             => m (Either e a) -> ExceptT e m a
restoreT :: Monad m             => m [a]          -> ListT m a
restoreT :: Monad m             => m a            -> ReaderT r m a
restoreT :: Monad m             => m (a, s)       -> StateT s m a
restoreT :: (Monad m, Monoid w) => m (a, w)       -> WriterT w m a
restoreT :: (Monad m, Monoid w) => m (a, s, w)    -> RWST r w s m a

Instances

Instances details
MonadTransControl MaybeT 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT MaybeT a #

Methods

liftWith :: Monad m => (Run MaybeT -> m a) -> MaybeT m a #

restoreT :: Monad m => m (StT MaybeT a) -> MaybeT m a #

MonadTransControl ListT 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT ListT a #

Methods

liftWith :: Monad m => (Run ListT -> m a) -> ListT m a #

restoreT :: Monad m => m (StT ListT a) -> ListT m a #

MonadTransControl NoLoggingT 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StT NoLoggingT a #

Methods

liftWith :: Monad m => (Run NoLoggingT -> m a) -> NoLoggingT m a #

restoreT :: Monad m => m (StT NoLoggingT a) -> NoLoggingT m a #

MonadTransControl WriterLoggingT 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StT WriterLoggingT a #

Methods

liftWith :: Monad m => (Run WriterLoggingT -> m a) -> WriterLoggingT m a #

restoreT :: Monad m => m (StT WriterLoggingT a) -> WriterLoggingT m a #

MonadTransControl LoggingT 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StT LoggingT a #

Methods

liftWith :: Monad m => (Run LoggingT -> m a) -> LoggingT m a #

restoreT :: Monad m => m (StT LoggingT a) -> LoggingT m a #

Monoid w => MonadTransControl (WriterT w) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (WriterT w) a #

Methods

liftWith :: Monad m => (Run (WriterT w) -> m a) -> WriterT w m a #

restoreT :: Monad m => m (StT (WriterT w) a) -> WriterT w m a #

Monoid w => MonadTransControl (WriterT w) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (WriterT w) a #

Methods

liftWith :: Monad m => (Run (WriterT w) -> m a) -> WriterT w m a #

restoreT :: Monad m => m (StT (WriterT w) a) -> WriterT w m a #

MonadTransControl (StateT s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (StateT s) a #

Methods

liftWith :: Monad m => (Run (StateT s) -> m a) -> StateT s m a #

restoreT :: Monad m => m (StT (StateT s) a) -> StateT s m a #

MonadTransControl (StateT s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (StateT s) a #

Methods

liftWith :: Monad m => (Run (StateT s) -> m a) -> StateT s m a #

restoreT :: Monad m => m (StT (StateT s) a) -> StateT s m a #

MonadTransControl (ReaderT r) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (ReaderT r) a #

Methods

liftWith :: Monad m => (Run (ReaderT r) -> m a) -> ReaderT r m a #

restoreT :: Monad m => m (StT (ReaderT r) a) -> ReaderT r m a #

MonadTransControl (ExceptT e) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (ExceptT e) a #

Methods

liftWith :: Monad m => (Run (ExceptT e) -> m a) -> ExceptT e m a #

restoreT :: Monad m => m (StT (ExceptT e) a) -> ExceptT e m a #

Error e => MonadTransControl (ErrorT e) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (ErrorT e) a #

Methods

liftWith :: Monad m => (Run (ErrorT e) -> m a) -> ErrorT e m a #

restoreT :: Monad m => m (StT (ErrorT e) a) -> ErrorT e m a #

MonadTransControl (IdentityT :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT IdentityT a #

Methods

liftWith :: Monad m => (Run IdentityT -> m a) -> IdentityT m a #

restoreT :: Monad m => m (StT IdentityT a) -> IdentityT m a #

Monoid w => MonadTransControl (RWST r w s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (RWST r w s) a #

Methods

liftWith :: Monad m => (Run (RWST r w s) -> m a) -> RWST r w s m a #

restoreT :: Monad m => m (StT (RWST r w s) a) -> RWST r w s m a #

Monoid w => MonadTransControl (RWST r w s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StT (RWST r w s) a #

Methods

liftWith :: Monad m => (Run (RWST r w s) -> m a) -> RWST r w s m a #

restoreT :: Monad m => m (StT (RWST r w s) a) -> RWST r w s m a #

type Run (t :: (Type -> Type) -> Type -> Type) = forall (n :: Type -> Type) b. Monad n => t n b -> n (StT t b) #

A function that runs a transformed monad t n on the monadic state that was captured by liftWith

A Run t function yields a computation in n that returns the monadic state of t. This state can later be used to restore a t computation using restoreT.

Example type equalities:

Run IdentityT    ~ forall n b. Monad n             => IdentityT  n b -> n b
Run MaybeT       ~ forall n b. Monad n             => MaybeT     n b -> n (Maybe b)
Run (ErrorT e)   ~ forall n b. (Monad n, Error e)  => ErrorT e   n b -> n (Either e b)
Run (ExceptT e)  ~ forall n b. Monad n             => ExceptT e  n b -> n (Either e b)
Run ListT        ~ forall n b. Monad n             => ListT      n b -> n [b]
Run (ReaderT r)  ~ forall n b. Monad n             => ReaderT r  n b -> n b
Run (StateT s)   ~ forall n b. Monad n             => StateT s   n b -> n (a, s)
Run (WriterT w)  ~ forall n b. (Monad n, Monoid w) => WriterT w  n b -> n (a, w)
Run (RWST r w s) ~ forall n b. (Monad n, Monoid w) => RWST r w s n b -> n (a, s, w)

This type is usually satisfied by the run function of a transformer:

flip runReaderT :: r -> Run (ReaderT r)
flip runStateT  :: s -> Run (StateT s)
runMaybeT       ::      Run MaybeT

type RunDefault (t :: (Type -> Type) -> Type -> Type) (t' :: (Type -> Type) -> Type -> Type) = forall (n :: Type -> Type) b. Monad n => t n b -> n (StT t' b) #

A function like Run that runs a monad transformer t which wraps the monad transformer t'. This is used in defaultLiftWith.

type RunDefault2 (t :: (Type -> Type) -> Type -> Type) (n :: (Type -> Type) -> Type -> Type) (n' :: (Type -> Type) -> Type -> Type) = forall (m :: Type -> Type) b. (Monad m, Monad (n' m)) => t m b -> m (StT n' (StT n b)) #

A function like Run that runs a monad transformer t which wraps the monad transformers n and n'. This is used in defaultLiftWith2.

class MonadBase b m => MonadBaseControl (b :: Type -> Type) (m :: Type -> Type) | m -> b where #

Writing instances

The usual way to write a MonadBaseControl instance for a transformer stack over a base monad B is to write an instance MonadBaseControl B B for the base monad, and MonadTransControl T instances for every transformer T. Instances for MonadBaseControl are then simply implemented using ComposeSt, defaultLiftBaseWith, defaultRestoreM.

Associated Types

type StM (m :: Type -> Type) a #

Monadic state that m adds to the base monad b.

For all base (non-transformed) monads, StM m a ~ a:

StM IO         a ~ a
StM Maybe      a ~ a
StM (Either e) a ~ a
StM []         a ~ a
StM ((->) r)   a ~ a
StM Identity   a ~ a
StM STM        a ~ a
StM (ST s)     a ~ a

If m is a transformed monad, m ~ t b, StM is the monadic state of the transformer t (given by its StT from MonadTransControl). For a transformer stack, StM is defined recursively:

StM (IdentityT  m) a ~ ComposeSt IdentityT m a ~ StM m a
StM (MaybeT     m) a ~ ComposeSt MaybeT    m a ~ StM m (Maybe a)
StM (ErrorT e   m) a ~ ComposeSt ErrorT    m a ~ Error e => StM m (Either e a)
StM (ExceptT e  m) a ~ ComposeSt ExceptT   m a ~ StM m (Either e a)
StM (ListT      m) a ~ ComposeSt ListT     m a ~ StM m [a]
StM (ReaderT r  m) a ~ ComposeSt ReaderT   m a ~ StM m a
StM (StateT s   m) a ~ ComposeSt StateT    m a ~ StM m (a, s)
StM (WriterT w  m) a ~ ComposeSt WriterT   m a ~ Monoid w => StM m (a, w)
StM (RWST r w s m) a ~ ComposeSt RWST      m a ~ Monoid w => StM m (a, s, w)

Methods

liftBaseWith :: (RunInBase m b -> b a) -> m a #

liftBaseWith is similar to liftIO and liftBase in that it lifts a base computation to the constructed monad.

Instances should satisfy similar laws as the MonadIO and MonadBase laws:

liftBaseWith . const . return = return
liftBaseWith (const (m >>= f)) = liftBaseWith (const m) >>= liftBaseWith . const . f

The difference with liftBase is that before lifting the base computation liftBaseWith captures the state of m. It then provides the base computation with a RunInBase function that allows running m computations in the base monad on the captured state:

withFileLifted :: MonadBaseControl IO m => FilePath -> IOMode -> (Handle -> m a) -> m a
withFileLifted file mode action = liftBaseWith (\runInBase -> withFile file mode (runInBase . action)) >>= restoreM
                             -- = control $ \runInBase -> withFile file mode (runInBase . action)
                             -- = liftBaseOp (withFile file mode) action

liftBaseWith is usually not implemented directly, but using defaultLiftBaseWith.

restoreM :: StM m a -> m a #

Construct a m computation from the monadic state of m that is returned from a RunInBase function.

Instances should satisfy:

liftBaseWith (\runInBase -> runInBase m) >>= restoreM = m

restoreM is usually not implemented directly, but using defaultRestoreM.

Instances

Instances details
MonadBaseControl [] [] 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM [] a #

Methods

liftBaseWith :: (RunInBase [] [] -> [a]) -> [a] #

restoreM :: StM [] a -> [a] #

MonadBaseControl Maybe Maybe 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM Maybe a #

MonadBaseControl IO IO 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM IO a #

Methods

liftBaseWith :: (RunInBase IO IO -> IO a) -> IO a #

restoreM :: StM IO a -> IO a #

MonadBaseControl Identity Identity 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM Identity a #

MonadBaseControl STM STM 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM STM a #

Methods

liftBaseWith :: (RunInBase STM STM -> STM a) -> STM a #

restoreM :: StM STM a -> STM a #

MonadBaseControl b m => MonadBaseControl b (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (MaybeT m) a #

Methods

liftBaseWith :: (RunInBase (MaybeT m) b -> b a) -> MaybeT m a #

restoreM :: StM (MaybeT m) a -> MaybeT m a #

MonadBaseControl b m => MonadBaseControl b (ListT m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ListT m) a #

Methods

liftBaseWith :: (RunInBase (ListT m) b -> b a) -> ListT m a #

restoreM :: StM (ListT m) a -> ListT m a #

MonadBaseControl b m => MonadBaseControl b (WriterLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StM (WriterLoggingT m) a #

MonadBaseControl b m => MonadBaseControl b (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StM (NoLoggingT m) a #

Methods

liftBaseWith :: (RunInBase (NoLoggingT m) b -> b a) -> NoLoggingT m a #

restoreM :: StM (NoLoggingT m) a -> NoLoggingT m a #

MonadBaseControl b m => MonadBaseControl b (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StM (LoggingT m) a #

Methods

liftBaseWith :: (RunInBase (LoggingT m) b -> b a) -> LoggingT m a #

restoreM :: StM (LoggingT m) a -> LoggingT m a #

MonadBaseControl b m => MonadBaseControl b (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Associated Types

type StM (NodeT m) a #

Methods

liftBaseWith :: (RunInBase (NodeT m) b -> b a) -> NodeT m a #

restoreM :: StM (NodeT m) a -> NodeT m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (WriterT w m) a #

Methods

liftBaseWith :: (RunInBase (WriterT w m) b -> b a) -> WriterT w m a #

restoreM :: StM (WriterT w m) a -> WriterT w m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (WriterT w m) a #

Methods

liftBaseWith :: (RunInBase (WriterT w m) b -> b a) -> WriterT w m a #

restoreM :: StM (WriterT w m) a -> WriterT w m a #

MonadBaseControl b m => MonadBaseControl b (StateT s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (StateT s m) a #

Methods

liftBaseWith :: (RunInBase (StateT s m) b -> b a) -> StateT s m a #

restoreM :: StM (StateT s m) a -> StateT s m a #

MonadBaseControl b m => MonadBaseControl b (StateT s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (StateT s m) a #

Methods

liftBaseWith :: (RunInBase (StateT s m) b -> b a) -> StateT s m a #

restoreM :: StM (StateT s m) a -> StateT s m a #

MonadBaseControl b m => MonadBaseControl b (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ReaderT r m) a #

Methods

liftBaseWith :: (RunInBase (ReaderT r m) b -> b a) -> ReaderT r m a #

restoreM :: StM (ReaderT r m) a -> ReaderT r m a #

MonadBaseControl b m => MonadBaseControl b (IdentityT m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (IdentityT m) a #

Methods

liftBaseWith :: (RunInBase (IdentityT m) b -> b a) -> IdentityT m a #

restoreM :: StM (IdentityT m) a -> IdentityT m a #

MonadBaseControl b m => MonadBaseControl b (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ExceptT e m) a #

Methods

liftBaseWith :: (RunInBase (ExceptT e m) b -> b a) -> ExceptT e m a #

restoreM :: StM (ExceptT e m) a -> ExceptT e m a #

(Error e, MonadBaseControl b m) => MonadBaseControl b (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ErrorT e m) a #

Methods

liftBaseWith :: (RunInBase (ErrorT e m) b -> b a) -> ErrorT e m a #

restoreM :: StM (ErrorT e m) a -> ErrorT e m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (RWST r w s m) a #

Methods

liftBaseWith :: (RunInBase (RWST r w s m) b -> b a) -> RWST r w s m a #

restoreM :: StM (RWST r w s m) a -> RWST r w s m a #

(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (RWST r w s m) a #

Methods

liftBaseWith :: (RunInBase (RWST r w s m) b -> b a) -> RWST r w s m a #

restoreM :: StM (RWST r w s m) a -> RWST r w s m a #

MonadBaseControl (Either e) (Either e) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (Either e) a #

Methods

liftBaseWith :: (RunInBase (Either e) (Either e) -> Either e a) -> Either e a #

restoreM :: StM (Either e) a -> Either e a #

MonadBaseControl (ST s) (ST s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ST s) a #

Methods

liftBaseWith :: (RunInBase (ST s) (ST s) -> ST s a) -> ST s a #

restoreM :: StM (ST s) a -> ST s a #

MonadBaseControl (ST s) (ST s) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM (ST s) a #

Methods

liftBaseWith :: (RunInBase (ST s) (ST s) -> ST s a) -> ST s a #

restoreM :: StM (ST s) a -> ST s a #

MonadBaseControl ((->) r :: Type -> Type) ((->) r :: Type -> Type) 
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM ((->) r) a #

Methods

liftBaseWith :: (RunInBase ((->) r) ((->) r) -> r -> a) -> r -> a #

restoreM :: StM ((->) r) a -> r -> a #

type RunInBase (m :: Type -> Type) (b :: Type -> Type) = forall a. m a -> b (StM m a) #

A function that runs a m computation on the monadic state that was captured by liftBaseWith

A RunInBase m function yields a computation in the base monad of m that returns the monadic state of m. This state can later be used to restore the m computation using restoreM.

Example type equalities:

RunInBase (IdentityT  m) b ~ forall a.             IdentityT  m a -> b (StM m a)
RunInBase (MaybeT     m) b ~ forall a.             MaybeT     m a -> b (StM m (Maybe a))
RunInBase (ErrorT e   m) b ~ forall a. Error e =>  ErrorT e   m a -> b (StM m (Either e a))
RunInBase (ExceptT e  m) b ~ forall a.             ExceptT e  m a -> b (StM m (Either e a))
RunInBase (ListT      m) b ~ forall a.             ListT      m a -> b (StM m [a])
RunInBase (ReaderT r  m) b ~ forall a.             ReaderT    m a -> b (StM m a)
RunInBase (StateT s   m) b ~ forall a.             StateT s   m a -> b (StM m (a, s))
RunInBase (WriterT w  m) b ~ forall a. Monoid w => WriterT w  m a -> b (StM m (a, w))
RunInBase (RWST r w s m) b ~ forall a. Monoid w => RWST r w s m a -> b (StM m (a, s, w))

For a transformed base monad m ~ t b, 'RunInBase m b' ~ Run t.

type ComposeSt (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a = StM m (StT t a) #

Handy type synonym that composes the monadic states of t and m.

It can be used to define the StM for new MonadBaseControl instances.

type RunInBaseDefault (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) (b :: Type -> Type) = forall a. t m a -> b (ComposeSt t m a) #

A function like RunInBase that runs a monad transformer t in its base monad b. It is used in defaultLiftBaseWith.

logError :: (HasCallStack, MonadLogger m) => Text -> m () #

See logDebug

Since: monad-logger-0.3.19

logInfo :: (HasCallStack, MonadLogger m) => Text -> m () #

See logDebug

Since: monad-logger-0.3.19

logErrorCS :: MonadLogger m => CallStack -> Text -> m () #

See logDebugCS

Since: monad-logger-0.3.19

logWarnCS :: MonadLogger m => CallStack -> Text -> m () #

See logDebugCS

Since: monad-logger-0.3.19

logInfoCS :: MonadLogger m => CallStack -> Text -> m () #

See logDebugCS

Since: monad-logger-0.3.19

class Monad m => MonadLogger (m :: Type -> Type) #

A Monad which has the ability to log messages in some manner.

Instances

Instances details
MonadLogger m => MonadLogger (MaybeT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> MaybeT m () #

MonadLogger m => MonadLogger (ResourceT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ResourceT m () #

MonadLogger m => MonadLogger (ListT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ListT m () #

Monad m => MonadLogger (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> NoLoggingT m () #

Monad m => MonadLogger (WriterLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WriterLoggingT m () #

MonadIO m => MonadLogger (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> LoggingT m () #

MonadLogger m => MonadLogger (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> NodeT m () #

(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WriterT w m () #

(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WriterT w m () #

MonadLogger m => MonadLogger (StateT s m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> StateT s m () #

MonadLogger m => MonadLogger (StateT s m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> StateT s m () #

MonadLogger m => MonadLogger (ReaderT r m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ReaderT r m () #

MonadLogger m => MonadLogger (ExceptT e m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ExceptT e m () #

(MonadLogger m, Error e) => MonadLogger (ErrorT e m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ErrorT e m () #

MonadLogger m => MonadLogger (IdentityT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> IdentityT m () #

MonadLogger m => MonadLogger (ConduitM i o m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ConduitM i o m () #

MonadLogger m => MonadLogger (ContT r m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ContT r m () #

(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> RWST r w s m () #

(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> RWST r w s m () #

MonadLogger m => MonadLogger (Pipe l i o u m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> Pipe l i o u m () #

class (MonadLogger m, MonadIO m) => MonadLoggerIO (m :: Type -> Type) #

An extension of MonadLogger for the common case where the logging action is a simple IO action. The advantage of using this typeclass is that the logging function itself can be extracted as a first-class value, which can make it easier to manipulate monad transformer stacks, as an example.

Since: monad-logger-0.3.10

Instances

Instances details
MonadLoggerIO m => MonadLoggerIO (MaybeT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: MaybeT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (ResourceT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ResourceT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (ListT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ListT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadIO m => MonadLoggerIO (NoLoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: NoLoggingT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadIO m => MonadLoggerIO (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: LoggingT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (NodeT m) Source # 
Instance details

Defined in Foreign.Erlang.LocalNode

Methods

askLoggerIO :: NodeT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

(MonadLoggerIO m, Monoid w) => MonadLoggerIO (WriterT w m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: WriterT w m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

(MonadLoggerIO m, Monoid w) => MonadLoggerIO (WriterT w m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: WriterT w m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (StateT s m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: StateT s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (StateT s m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: StateT s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (ReaderT r m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ReaderT r m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (ExceptT e m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ExceptT e m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

(MonadLoggerIO m, Error e) => MonadLoggerIO (ErrorT e m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ErrorT e m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (IdentityT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: IdentityT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (ConduitM i o m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ConduitM i o m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (ContT r m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: ContT r m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

(MonadLoggerIO m, Monoid w) => MonadLoggerIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: RWST r w s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

(MonadLoggerIO m, Monoid w) => MonadLoggerIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: RWST r w s m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadLoggerIO m => MonadLoggerIO (Pipe l i o u m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: Pipe l i o u m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

data LoggingT (m :: Type -> Type) a #

Monad transformer that adds a new logging function.

Since: monad-logger-0.2.2

Instances

Instances details
MonadTrans LoggingT 
Instance details

Defined in Control.Monad.Logger

Methods

lift :: Monad m => m a -> LoggingT m a #

MonadTransControl LoggingT 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StT LoggingT a #

Methods

liftWith :: Monad m => (Run LoggingT -> m a) -> LoggingT m a #

restoreT :: Monad m => m (StT LoggingT a) -> LoggingT m a #

MonadRWS r w s m => MonadRWS r w s (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

MonadBase b m => MonadBase b (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

liftBase :: b α -> LoggingT m α #

MonadBaseControl b m => MonadBaseControl b (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Associated Types

type StM (LoggingT m) a #

Methods

liftBaseWith :: (RunInBase (LoggingT m) b -> b a) -> LoggingT m a #

restoreM :: StM (LoggingT m) a -> LoggingT m a #

MonadWriter w m => MonadWriter w (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

writer :: (a, w) -> LoggingT m a #

tell :: w -> LoggingT m () #

listen :: LoggingT m a -> LoggingT m (a, w) #

pass :: LoggingT m (a, w -> w) -> LoggingT m a #

MonadState s m => MonadState s (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

get :: LoggingT m s #

put :: s -> LoggingT m () #

state :: (s -> (a, s)) -> LoggingT m a #

MonadReader r m => MonadReader r (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

ask :: LoggingT m r #

local :: (r -> r) -> LoggingT m a -> LoggingT m a #

reader :: (r -> a) -> LoggingT m a #

MonadError e m => MonadError e (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

throwError :: e -> LoggingT m a #

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

Monad m => Monad (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

(>>=) :: LoggingT m a -> (a -> LoggingT m b) -> LoggingT m b #

(>>) :: LoggingT m a -> LoggingT m b -> LoggingT m b #

return :: a -> LoggingT m a #

Functor m => Functor (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

fmap :: (a -> b) -> LoggingT m a -> LoggingT m b #

(<$) :: a -> LoggingT m b -> LoggingT m a #

MonadFail m => MonadFail (LoggingT m)

Since: monad-logger-0.3.30

Instance details

Defined in Control.Monad.Logger

Methods

fail :: String -> LoggingT m a #

Applicative m => Applicative (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

pure :: a -> LoggingT m a #

(<*>) :: LoggingT m (a -> b) -> LoggingT m a -> LoggingT m b #

liftA2 :: (a -> b -> c) -> LoggingT m a -> LoggingT m b -> LoggingT m c #

(*>) :: LoggingT m a -> LoggingT m b -> LoggingT m b #

(<*) :: LoggingT m a -> LoggingT m b -> LoggingT m a #

MonadIO m => MonadIO (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

liftIO :: IO a -> LoggingT m a #

MonadUnliftIO m => MonadUnliftIO (LoggingT m)

Since: monad-logger-0.3.26

Instance details

Defined in Control.Monad.Logger

Methods

withRunInIO :: ((forall a. LoggingT m a -> IO a) -> IO b) -> LoggingT m b #

MonadResource m => MonadResource (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

liftResourceT :: ResourceT IO a -> LoggingT m a #

MonadThrow m => MonadThrow (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

throwM :: Exception e => e -> LoggingT m a #

MonadActive m => MonadActive (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

MonadCatch m => MonadCatch (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

catch :: Exception e => LoggingT m a -> (e -> LoggingT m a) -> LoggingT m a #

MonadMask m => MonadMask (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

mask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b #

uninterruptibleMask :: ((forall a. LoggingT m a -> LoggingT m a) -> LoggingT m b) -> LoggingT m b #

generalBracket :: LoggingT m a -> (a -> ExitCase b -> LoggingT m c) -> (a -> LoggingT m b) -> LoggingT m (b, c) #

MonadIO m => MonadLogger (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> LoggingT m () #

MonadIO m => MonadLoggerIO (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

askLoggerIO :: LoggingT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

MonadCont m => MonadCont (LoggingT m) 
Instance details

Defined in Control.Monad.Logger

Methods

callCC :: ((a -> LoggingT m b) -> LoggingT m a) -> LoggingT m a #

type StT LoggingT a 
Instance details

Defined in Control.Monad.Logger

type StT LoggingT a = a
type StM (LoggingT m) a 
Instance details

Defined in Control.Monad.Logger

type StM (LoggingT m) a = StM m a

withInternalState :: (InternalState -> m a) -> ResourceT m a #

Run an action in the underlying monad, providing it the InternalState.

Since 0.4.6

runInternalState :: ResourceT m a -> InternalState -> m a #

Unwrap a ResourceT using the given InternalState.

Since 0.4.6

getInternalState :: forall (m :: Type -> Type). Monad m => ResourceT m InternalState #

Get the internal state of the current ResourceT.

Since 0.4.6

closeInternalState :: MonadIO m => InternalState -> m () #

Close an internal state created by createInternalState.

Since 0.4.9

createInternalState :: MonadIO m => m InternalState #

Create a new internal state. This state must be closed with closeInternalState. It is your responsibility to ensure exception safety. Caveat emptor!

Since 0.4.9

resourceForkIO :: forall (m :: Type -> Type). MonadUnliftIO m => ResourceT m () -> ResourceT m ThreadId #

Launch a new reference counted resource context using forkIO.

This is defined as resourceForkWith forkIO.

Note: Using regular forkIO inside of a ResourceT is inherently unsafe, since the forked thread may try access the resources of the parent after they are cleaned up. When you use resourceForkIO or resourceForkWith, ResourceT is made aware of the new thread, and will only cleanup resources when all threads finish. Other concurrency mechanisms, like concurrently or race, are safe to use.

If you encounter InvalidAccess exceptions ("The mutable state is being accessed after cleanup"), use of forkIO is a possible culprit.

Since: resourcet-0.3.0

resourceForkWith :: forall (m :: Type -> Type) a. MonadUnliftIO m => (IO () -> IO a) -> ResourceT m () -> ResourceT m a #

Introduce a reference-counting scheme to allow a resource context to be shared by multiple threads. Once the last thread exits, all remaining resources will be released.

The first parameter is a function which will be used to create the thread, such as forkIO or async.

Note that abuse of this function will greatly delay the deallocation of registered resources. This function should be used with care. A general guideline:

If you are allocating a resource that should be shared by multiple threads, and will be held for a long time, you should allocate it at the beginning of a new ResourceT block and then call resourceForkWith from there.

Since: resourcet-1.1.9

joinResourceT :: forall (m :: Type -> Type) a. ResourceT (ResourceT m) a -> ResourceT m a #

This function mirrors join at the transformer level: it will collapse two levels of ResourceT into a single ResourceT.

Since 0.4.6

runResourceTChecked :: MonadUnliftIO m => ResourceT m a -> m a #

Backwards compatible alias for runResourceT.

Since: resourcet-1.1.11

resourceMask :: MonadResource m => ((forall a. ResourceT IO a -> ResourceT IO a) -> ResourceT IO b) -> m b #

Perform asynchronous exception masking.

This is more general then Control.Exception.mask, yet more efficient than Control.Exception.Lifted.mask.

Since 0.3.0

allocate_ #

Arguments

:: MonadResource m 
=> IO a

allocate

-> IO ()

free resource

-> m ReleaseKey 

Perform some allocation where the return value is not required, and automatically register a cleanup action.

allocate_ is to allocate as bracket_ is to bracket

This is almost identical to calling the allocation and then registering the release action, but this properly handles masking of asynchronous exceptions.

Since: resourcet-1.2.4

allocate #

Arguments

:: MonadResource m 
=> IO a

allocate

-> (a -> IO ())

free resource

-> m (ReleaseKey, a) 

Perform some allocation, and automatically register a cleanup action.

This is almost identical to calling the allocation and then registering the release action, but this properly handles masking of asynchronous exceptions.

Since 0.3.0

unprotect :: MonadIO m => ReleaseKey -> m (Maybe (IO ())) #

Unprotect resource from cleanup actions; this allows you to send resource into another resourcet process and reregister it there. It returns a release action that should be run in order to clean resource or Nothing in case if resource is already freed.

Since 0.4.5

release :: MonadIO m => ReleaseKey -> m () #

Call a release action early, and deregister it from the list of cleanup actions to be performed.

Since 0.3.0

register :: MonadResource m => IO () -> m ReleaseKey #

Register some action that will be called precisely once, either when runResourceT is called, or when the ReleaseKey is passed to release.

Since 0.3.0

type MonadResourceBase = MonadUnliftIO #

Just use MonadUnliftIO directly now, legacy explanation continues:

A Monad which can be used as a base for a ResourceT.

A ResourceT has some restrictions on its base monad:

  • runResourceT requires an instance of MonadUnliftIO.
  • MonadResource requires an instance of MonadIO

Note that earlier versions of conduit had a typeclass ResourceIO. This fulfills much the same role.

Since 0.3.2

type InternalState = IORef ReleaseMap #

The internal state held by a ResourceT transformer.

Since 0.4.6

transResourceT :: (m a -> n b) -> ResourceT m a -> ResourceT n b #

Transform the monad a ResourceT lives in. This is most often used to strip or add new transformers to a stack, e.g. to run a ReaderT.

Note that this function is a slight generalization of hoist.

Since 0.3.0

data ReleaseKey #

A lookup key for a specific release action. This value is returned by register and allocate, and is passed to release.

Since 0.3.0

type ResIO = ResourceT IO #

Convenient alias for ResourceT IO.

data InvalidAccess #

Indicates either an error in the library, or misuse of it (e.g., a ResourceT's state is accessed after being released).

Since 0.3.0

Constructors

InvalidAccess 

Fields

data ResourceCleanupException #

Thrown when one or more cleanup functions themselves throw an exception during cleanup.

Since: resourcet-1.1.11

Constructors

ResourceCleanupException 

Fields