Conduit

conduit-1.3.6: Streaming data processing library.

Safe Haskell | None
Language | Haskell2010

Conduit

Contents

- Core conduit library
- Commonly used combinators
- Monadic lifting
- ResourceT
- Acquire
- Pure pipelines

Description

Your intended one-stop-shop for conduit functionality. This re-exports functions from many commonly used modules. When there is a conflict with standard functions, functions in this module are disambiguated by adding a trailing C (or for chunked functions, replacing a trailing E with CE). This means that the Conduit module can be imported unqualified without causing naming conflicts.

For more information on the naming scheme and intended usages of the combinators, please see the Data.Conduit.Combinators documentation.

Synopsis

- module Data.Conduit
- module Data.Conduit.Lift
- sourceFile :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitT i ByteString m ()
- sourceLazy :: forall (m :: Type -> Type) lazy strict i. (Monad m, LazySequence lazy strict) => lazy -> ConduitT i strict m ()
- yieldMany :: forall (m :: Type -> Type) mono i. (Monad m, MonoFoldable mono) => mono -> ConduitT i (Element mono) m ()
- sourceFileBS :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitT i ByteString m ()
- sourceHandle :: forall (m :: Type -> Type) i. MonadIO m => Handle -> ConduitT i ByteString m ()
- sourceHandleUnsafe :: forall (m :: Type -> Type) i. MonadIO m => Handle -> ConduitT i ByteString m ()
- sourceIOHandle :: forall (m :: Type -> Type) i. MonadResource m => IO Handle -> ConduitT i ByteString m ()
- withSourceFile :: forall m (n :: Type -> Type) i a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM i ByteString n () -> m a) -> m a
- sourceDirectory :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitT i FilePath m ()
- sourceDirectoryDeep :: forall (m :: Type -> Type) i. MonadResource m => Bool -> FilePath -> ConduitT i FilePath m ()
- sinkLazy :: forall (m :: Type -> Type) lazy strict o. (Monad m, LazySequence lazy strict) => ConduitT strict o m lazy
- sinkList :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m [a]
- sinkVector :: forall v a (m :: Type -> Type) o. (Vector v a, PrimMonad m) => ConduitT a o m (v a)
- sinkVectorN :: forall v a (m :: Type -> Type) o. (Vector v a, PrimMonad m) => Int -> ConduitT a o m (v a)
- sinkLazyBuilder :: forall (m :: Type -> Type) o. Monad m => ConduitT Builder o m ByteString
- sinkNull :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m ()
- awaitNonNull :: forall (m :: Type -> Type) a o. (Monad m, MonoFoldable a) => ConduitT a o m (Maybe (NonNull a))
- sinkFile :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitT ByteString o m ()
- sinkFileCautious :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitM ByteString o m ()
- sinkTempFile :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> String -> ConduitM ByteString o m FilePath
- sinkSystemTempFile :: forall (m :: Type -> Type) o. MonadResource m => String -> ConduitM ByteString o m FilePath
- sinkFileBS :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitT ByteString o m ()
- sinkHandle :: forall (m :: Type -> Type) o. MonadIO m => Handle -> ConduitT ByteString o m ()
- sinkIOHandle :: forall (m :: Type -> Type) o. MonadResource m => IO Handle -> ConduitT ByteString o m ()
- withSinkFile :: forall m (n :: Type -> Type) o a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM ByteString o n () -> m a) -> m a
- withSinkFileBuilder :: forall m (n :: Type -> Type) o a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM Builder o n () -> m a) -> m a
- withSinkFileCautious :: forall m (n :: Type -> Type) o a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM ByteString o n () -> m a) -> m a
- sinkHandleBuilder :: forall (m :: Type -> Type) o. MonadIO m => Handle -> ConduitM Builder o m ()
- sinkHandleFlush :: forall (m :: Type -> Type) o. MonadIO m => Handle -> ConduitM (Flush ByteString) o m ()
- conduitVector :: forall v a (m :: Type -> Type). (Vector v a, PrimMonad m) => Int -> ConduitT a (v a) m ()
- builderToByteString :: forall (m :: Type -> Type). PrimMonad m => ConduitT Builder ByteString m ()
- unsafeBuilderToByteString :: forall (m :: Type -> Type). PrimMonad m => ConduitT Builder ByteString m ()
- builderToByteStringWith :: forall (m :: Type -> Type). PrimMonad m => BufferAllocStrategy -> ConduitT Builder ByteString m ()
- builderToByteStringFlush :: forall (m :: Type -> Type). PrimMonad m => ConduitT (Flush Builder) (Flush ByteString) m ()
- builderToByteStringWithFlush :: forall (m :: Type -> Type). PrimMonad m => BufferAllocStrategy -> ConduitT (Flush Builder) (Flush ByteString) m ()
- type BufferAllocStrategy = (IO Buffer, Int -> Buffer -> IO (IO Buffer))
- allNewBuffersStrategy :: Int -> BufferAllocStrategy
- reuseBufferStrategy :: IO Buffer -> BufferAllocStrategy
- mapAccumS :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> ConduitT b Void m s) -> s -> ConduitT () b m () -> ConduitT a Void m s
- peekForever :: forall (m :: Type -> Type) i o. Monad m => ConduitT i o m () -> ConduitT i o m ()
- peekForeverE :: forall (m :: Type -> Type) i o. (Monad m, MonoFoldable i) => ConduitT i o m () -> ConduitT i o m ()
- unfoldC :: forall (m :: Type -> Type) b a i. Monad m => (b -> Maybe (a, b)) -> b -> ConduitT i a m ()
- enumFromToC :: forall (m :: Type -> Type) a i. (Monad m, Enum a, Ord a) => a -> a -> ConduitT i a m ()
- iterateC :: forall (m :: Type -> Type) a i. Monad m => (a -> a) -> a -> ConduitT i a m ()
- repeatC :: forall (m :: Type -> Type) a i. Monad m => a -> ConduitT i a m ()
- replicateC :: forall (m :: Type -> Type) a i. Monad m => Int -> a -> ConduitT i a m ()
- repeatMC :: Monad m => m a -> ConduitT i a m ()
- repeatWhileMC :: Monad m => m a -> (a -> Bool) -> ConduitT i a m ()
- replicateMC :: Monad m => Int -> m a -> ConduitT i a m ()
- stdinC :: forall (m :: Type -> Type) i. MonadIO m => ConduitT i ByteString m ()
- dropC :: forall (m :: Type -> Type) a o. Monad m => Int -> ConduitT a o m ()
- dropCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => Index seq -> ConduitT seq o m ()
- dropWhileC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m ()
- dropWhileCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => (Element seq -> Bool) -> ConduitT seq o m ()
- foldC :: forall (m :: Type -> Type) a o. (Monad m, Monoid a) => ConduitT a o m a
- foldCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Monoid (Element mono)) => ConduitT mono o m (Element mono)
- foldlC :: forall (m :: Type -> Type) a b o. Monad m => (a -> b -> a) -> a -> ConduitT b o m a
- foldlCE :: forall (m :: Type -> Type) mono a o. (Monad m, MonoFoldable mono) => (a -> Element mono -> a) -> a -> ConduitT mono o m a
- foldMapC :: forall (m :: Type -> Type) b a o. (Monad m, Monoid b) => (a -> b) -> ConduitT a o m b
- foldMapCE :: forall (m :: Type -> Type) mono w o. (Monad m, MonoFoldable mono, Monoid w) => (Element mono -> w) -> ConduitT mono o m w
- allC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m Bool
- allCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => (Element mono -> Bool) -> ConduitT mono o m Bool
- anyC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m Bool
- anyCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => (Element mono -> Bool) -> ConduitT mono o m Bool
- andC :: forall (m :: Type -> Type) o. Monad m => ConduitT Bool o m Bool
- andCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Element mono ~ Bool) => ConduitT mono o m Bool
- orC :: forall (m :: Type -> Type) o. Monad m => ConduitT Bool o m Bool
- orCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Element mono ~ Bool) => ConduitT mono o m Bool
- asumC :: forall (m :: Type -> Type) f a o. (Monad m, Alternative f) => ConduitT (f a) o m (f a)
- elemC :: forall (m :: Type -> Type) a o. (Monad m, Eq a) => a -> ConduitT a o m Bool
- elemCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Eq (Element seq)) => Element seq -> ConduitT seq o m Bool
- notElemC :: forall (m :: Type -> Type) a o. (Monad m, Eq a) => a -> ConduitT a o m Bool
- notElemCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Eq (Element seq)) => Element seq -> ConduitT seq o m Bool
- headC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m (Maybe a)
- headDefC :: forall (m :: Type -> Type) a o. Monad m => a -> ConduitT a o m a
- headCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => ConduitT seq o m (Maybe (Element seq))
- peekC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m (Maybe a)
- peekCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => ConduitT mono o m (Maybe (Element mono))
- lastC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m (Maybe a)
- lastDefC :: forall (m :: Type -> Type) a o. Monad m => a -> ConduitT a o m a
- lastCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => ConduitT seq o m (Maybe (Element seq))
- lengthC :: forall (m :: Type -> Type) len a o. (Monad m, Num len) => ConduitT a o m len
- lengthCE :: forall (m :: Type -> Type) len mono o. (Monad m, Num len, MonoFoldable mono) => ConduitT mono o m len
- lengthIfC :: forall (m :: Type -> Type) len a o. (Monad m, Num len) => (a -> Bool) -> ConduitT a o m len
- lengthIfCE :: forall (m :: Type -> Type) len mono o. (Monad m, Num len, MonoFoldable mono) => (Element mono -> Bool) -> ConduitT mono o m len
- maximumC :: forall (m :: Type -> Type) a o. (Monad m, Ord a) => ConduitT a o m (Maybe a)
- maximumCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Ord (Element seq)) => ConduitT seq o m (Maybe (Element seq))
- minimumC :: forall (m :: Type -> Type) a o. (Monad m, Ord a) => ConduitT a o m (Maybe a)
- minimumCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Ord (Element seq)) => ConduitT seq o m (Maybe (Element seq))
- nullC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m Bool
- nullCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => ConduitT mono o m Bool
- sumC :: forall (m :: Type -> Type) a o. (Monad m, Num a) => ConduitT a o m a
- sumCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Num (Element mono)) => ConduitT mono o m (Element mono)
- productC :: forall (m :: Type -> Type) a o. (Monad m, Num a) => ConduitT a o m a
- productCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Num (Element mono)) => ConduitT mono o m (Element mono)
- findC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m (Maybe a)
- mapM_C :: Monad m => (a -> m ()) -> ConduitT a o m ()
- mapM_CE :: (Monad m, MonoFoldable mono) => (Element mono -> m ()) -> ConduitT mono o m ()
- foldMC :: Monad m => (a -> b -> m a) -> a -> ConduitT b o m a
- foldMCE :: (Monad m, MonoFoldable mono) => (a -> Element mono -> m a) -> a -> ConduitT mono o m a
- foldMapMC :: (Monad m, Monoid w) => (a -> m w) -> ConduitT a o m w
- foldMapMCE :: (Monad m, MonoFoldable mono, Monoid w) => (Element mono -> m w) -> ConduitT mono o m w
- printC :: forall a (m :: Type -> Type) o. (Show a, MonadIO m) => ConduitT a o m ()
- stdoutC :: forall (m :: Type -> Type) o. MonadIO m => ConduitT ByteString o m ()
- stderrC :: forall (m :: Type -> Type) o. MonadIO m => ConduitT ByteString o m ()
- mapC :: forall (m :: Type -> Type) a b. Monad m => (a -> b) -> ConduitT a b m ()
- mapCE :: forall (m :: Type -> Type) f a b. (Monad m, Functor f) => (a -> b) -> ConduitT (f a) (f b) m ()
- omapCE :: forall (m :: Type -> Type) mono. (Monad m, MonoFunctor mono) => (Element mono -> Element mono) -> ConduitT mono mono m ()
- concatMapC :: forall (m :: Type -> Type) mono a. (Monad m, MonoFoldable mono) => (a -> mono) -> ConduitT a (Element mono) m ()
- concatMapCE :: forall (m :: Type -> Type) mono w. (Monad m, MonoFoldable mono, Monoid w) => (Element mono -> w) -> ConduitT mono w m ()
- takeC :: forall (m :: Type -> Type) a. Monad m => Int -> ConduitT a a m ()
- takeCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => Index seq -> ConduitT seq seq m ()
- takeWhileC :: forall (m :: Type -> Type) a. Monad m => (a -> Bool) -> ConduitT a a m ()
- takeWhileCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => (Element seq -> Bool) -> ConduitT seq seq m ()
- takeExactlyC :: forall (m :: Type -> Type) a b r. Monad m => Int -> ConduitT a b m r -> ConduitT a b m r
- takeExactlyCE :: forall (m :: Type -> Type) a b r. (Monad m, IsSequence a) => Index a -> ConduitT a b m r -> ConduitT a b m r
- concatC :: forall (m :: Type -> Type) mono. (Monad m, MonoFoldable mono) => ConduitT mono (Element mono) m ()
- filterC :: forall (m :: Type -> Type) a. Monad m => (a -> Bool) -> ConduitT a a m ()
- filterCE :: forall seq (m :: Type -> Type). (IsSequence seq, Monad m) => (Element seq -> Bool) -> ConduitT seq seq m ()
- mapWhileC :: forall (m :: Type -> Type) a b. Monad m => (a -> Maybe b) -> ConduitT a b m ()
- scanlC :: forall (m :: Type -> Type) a b. Monad m => (a -> b -> a) -> a -> ConduitT b a m ()
- mapAccumWhileC :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> Either s (s, b)) -> s -> ConduitT a b m s
- concatMapAccumC :: forall (m :: Type -> Type) a accum b. Monad m => (a -> accum -> (accum, [b])) -> accum -> ConduitT a b m ()
- intersperseC :: forall (m :: Type -> Type) a. Monad m => a -> ConduitT a a m ()
- slidingWindowC :: forall (m :: Type -> Type) seq a. (Monad m, IsSequence seq, Element seq ~ a) => Int -> ConduitT a seq m ()
- chunksOfCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => Index seq -> ConduitT seq seq m ()
- chunksOfExactlyCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => Index seq -> ConduitT seq seq m ()
- mapMC :: Monad m => (a -> m b) -> ConduitT a b m ()
- mapMCE :: (Monad m, Traversable f) => (a -> m b) -> ConduitT (f a) (f b) m ()
- omapMCE :: (Monad m, MonoTraversable mono) => (Element mono -> m (Element mono)) -> ConduitT mono mono m ()
- concatMapMC :: (Monad m, MonoFoldable mono) => (a -> m mono) -> ConduitT a (Element mono) m ()
- filterMC :: Monad m => (a -> m Bool) -> ConduitT a a m ()
- filterMCE :: (Monad m, IsSequence seq) => (Element seq -> m Bool) -> ConduitT seq seq m ()
- iterMC :: Monad m => (a -> m ()) -> ConduitT a a m ()
- scanlMC :: Monad m => (a -> b -> m a) -> a -> ConduitT b a m ()
- mapAccumWhileMC :: Monad m => (a -> s -> m (Either s (s, b))) -> s -> ConduitT a b m s
- concatMapAccumMC :: Monad m => (a -> accum -> m (accum, [b])) -> accum -> ConduitT a b m ()
- encodeUtf8C :: forall (m :: Type -> Type) text binary. (Monad m, Utf8 text binary) => ConduitT text binary m ()
- decodeUtf8C :: forall (m :: Type -> Type). MonadThrow m => ConduitT ByteString Text m ()
- decodeUtf8LenientC :: forall (m :: Type -> Type). Monad m => ConduitT ByteString Text m ()
- lineC :: forall (m :: Type -> Type) seq o r. (Monad m, IsSequence seq, Element seq ~ Char) => ConduitT seq o m r -> ConduitT seq o m r
- lineAsciiC :: forall (m :: Type -> Type) seq o r. (Monad m, IsSequence seq, Element seq ~ Word8) => ConduitT seq o m r -> ConduitT seq o m r
- unlinesC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Char) => ConduitT seq seq m ()
- unlinesAsciiC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Word8) => ConduitT seq seq m ()
- linesUnboundedC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Char) => ConduitT seq seq m ()
- linesUnboundedAsciiC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Word8) => ConduitT seq seq m ()
- vectorBuilderC :: forall (m :: Type -> Type) v e n i r. (PrimMonad m, Vector v e, PrimMonad n, PrimState m ~ PrimState n) => Int -> ((e -> n ()) -> ConduitT i Void m r) -> ConduitT i (v e) m r
- class Monad m => MonadIO (m :: Type -> Type) where
  - liftIO :: IO a -> m a
- class (forall (m :: Type -> Type). Monad m => Monad (t m)) => MonadTrans (t :: (Type -> Type) -> Type -> Type) where
  - lift :: Monad m => m a -> t m a
- class Monad m => MonadThrow (m :: Type -> Type) where
  - throwM :: (HasCallStack, Exception e) => e -> m a
- class MonadIO m => MonadUnliftIO (m :: Type -> Type) where
  - withRunInIO :: ((forall a. m a -> IO a) -> IO b) -> m b
- class Monad m => PrimMonad (m :: Type -> Type) where
  - type PrimState (m :: Type -> Type)
  - primitive :: (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
- class MonadIO m => MonadResource (m :: Type -> Type)
- data ResourceT (m :: Type -> Type) a
- runResourceT :: MonadUnliftIO m => ResourceT m a -> m a
- data Acquire a
- data ReleaseType where
  - ReleaseEarly
  - ReleaseNormal
  - ReleaseExceptionWith SomeException
  - pattern ReleaseException :: ReleaseType
- mkAcquire :: IO a -> (a -> IO ()) -> Acquire a
- mkAcquireType :: IO a -> (a -> ReleaseType -> IO ()) -> Acquire a
- allocateAcquire :: MonadResource m => Acquire a -> m (ReleaseKey, a)
- withAcquire :: MonadUnliftIO m => Acquire a -> (a -> m b) -> m b
- newtype Identity a = Identity {
  - runIdentity :: a
  }

# Core conduit library

module Data.Conduit

module Data.Conduit.Lift

# Commonly used combinators

sourceFile :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitT i ByteString m () #

Stream the contents of a file as binary data.

Since: 1.3.0

sourceLazy :: forall (m :: Type -> Type) lazy strict i. (Monad m, LazySequence lazy strict) => lazy -> ConduitT i strict m () #

Generate a producer by yielding each of the strict chunks in a `LazySequence`.

For more information, see `toChunks`.

Subject to fusion

Since: 1.3.0

yieldMany :: forall (m :: Type -> Type) mono i. (Monad m, MonoFoldable mono) => mono -> ConduitT i (Element mono) m () #

Yield each of the values contained by the given `MonoFoldable`.

This will work on many data structures, including lists, `ByteString`s, and `Vector`s.

Subject to fusion

Since: 1.3.0

sourceFileBS :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitT i ByteString m () #

Same as `sourceFile`. The alternate name is a holdover from an older version, when `sourceFile` was more polymorphic than it is today.

Since: 1.3.0

sourceHandle :: forall (m :: Type -> Type) i. MonadIO m => Handle -> ConduitT i ByteString m () #

Stream the contents of a `Handle` as binary data. Note that this function will not automatically close the `Handle` when processing completes, since it did not acquire the `Handle` in the first place.

Since: 1.3.0

sourceHandleUnsafe :: forall (m :: Type -> Type) i. MonadIO m => Handle -> ConduitT i ByteString m () #

Same as `sourceHandle`, but instead of allocating a new buffer for each incoming chunk of data, reuses the same buffer. Therefore, the `ByteString`s yielded by this function are not referentially transparent between two different `yield`s.

This function will be slightly more efficient than `sourceHandle` by avoiding allocations and reducing garbage collections, but should only be used if you can guarantee that you do not reuse a `ByteString` (or any slice thereof) between two calls to `await`.

Since: 1.3.0

sourceIOHandle :: forall (m :: Type -> Type) i. MonadResource m => IO Handle -> ConduitT i ByteString m () #

An alternative to `sourceHandle`. Instead of taking a pre-opened `Handle`, it takes an action that opens a `Handle` (in read mode), so that it can open it only when needed and close it as soon as possible.

Since: 1.3.0

withSourceFile :: forall m (n :: Type -> Type) i a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM i ByteString n () -> m a) -> m a #

Like `withBinaryFile`, but provides a source to read bytes from.

Since: 1.3.0

sourceDirectory :: forall (m :: Type -> Type) i. MonadResource m => FilePath -> ConduitT i FilePath m () #

Stream the contents of the given directory, without traversing deeply.

This function will return all of the contents of the directory, whether they be files, directories, etc.

Note that the generated filepaths will be the complete path, not just the filename. In other words, if you have a directory `foo` containing files `bar` and `baz`, and you use `sourceDirectory` on `foo`, the results will be `foo/bar` and `foo/baz`.

Since: 1.3.0

sourceDirectoryDeep #

Arguments

:: forall (m :: Type -> Type) i. MonadResource m |
=> Bool | Follow directory symlinks
-> FilePath | Root directory
-> ConduitT i FilePath m () |

Deeply stream the contents of the given directory.

This works the same as `sourceDirectory`, but will not return directories at all. This function also takes an extra parameter to indicate whether symlinks will be followed.

Since: 1.3.0

sinkLazy :: forall (m :: Type -> Type) lazy strict o. (Monad m, LazySequence lazy strict) => ConduitT strict o m lazy #

Consume all incoming strict chunks into a lazy sequence. Note that the entirety of the sequence will be resident at memory.

This can be used to consume a stream of strict ByteStrings into a lazy ByteString, for example.

Subject to fusion

Since: 1.3.0

sinkList :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m [a] #

Consume all values from the stream and return as a list. Note that this will pull all values into memory.

Subject to fusion

Since: 1.3.0

sinkVector :: forall v a (m :: Type -> Type) o. (Vector v a, PrimMonad m) => ConduitT a o m (v a) #

Sink incoming values into a vector, growing the vector as necessary to fit more elements.

Note that using this function is more memory efficient than `sinkList` and then converting to a `Vector`, as it avoids intermediate list constructors.

Subject to fusion

Since: 1.3.0

sinkVectorN #

Arguments

:: forall v a (m :: Type -> Type) o. (Vector v a, PrimMonad m) |
=> Int | maximum allowed size
-> ConduitT a o m (v a) |

Sink incoming values into a vector, up until size `maxSize`. Subsequent values will be left in the stream. If there are less than `maxSize` values present, returns a `Vector` of smaller size.

Note that using this function is more memory efficient than `sinkList` and then converting to a `Vector`, as it avoids intermediate list constructors.

Subject to fusion

Since: 1.3.0

sinkLazyBuilder :: forall (m :: Type -> Type) o. Monad m => ConduitT Builder o m ByteString #

Same as `sinkBuilder`, but afterwards convert the builder to its lazy representation.

Alternatively, this could be considered an alternative to `sinkLazy`, with the following differences:

- This function will allow multiple input types, not just the strict version of the lazy structure.
- Some buffer copying may occur in this version.

Subject to fusion

Since: 1.3.0

sinkNull :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m () #

Consume and discard all remaining values in the stream.

Subject to fusion

Since: 1.3.0

awaitNonNull :: forall (m :: Type -> Type) a o. (Monad m, MonoFoldable a) => ConduitT a o m (Maybe (NonNull a)) #

Same as `await`, but discards any leading `onull` values.

Since: 1.3.0

sinkFile :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitT ByteString o m () #

Stream all incoming data to the given file.

Since: 1.3.0

sinkFileCautious :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitM ByteString o m () #

Cautious version of `sinkFile`. The idea here is to stream the values to a temporary file in the same directory of the destination file, and only on successfully writing the entire file, moves it atomically to the destination path.

In the event of an exception occurring, the temporary file will be deleted and no move will be made. If the application shuts down without running exception handling (such as machine failure or a SIGKILL), the temporary file will remain and the destination file will be untouched.

Since: 1.3.0

sinkTempFile #

Arguments

:: forall (m :: Type -> Type) o. MonadResource m |
=> FilePath | temp directory
-> String | filename pattern
-> ConduitM ByteString o m FilePath |

Stream data into a temporary file in the given directory with the given filename pattern, and return the temporary filename. The temporary file will be automatically deleted when exiting the active `ResourceT` block, if it still exists.

Since: 1.3.0

sinkSystemTempFile #

Arguments

:: forall (m :: Type -> Type) o. MonadResource m |
=> String | filename pattern
-> ConduitM ByteString o m FilePath |

Same as `sinkTempFile`, but will use the default temp file directory for the system as the first argument.

Since: 1.3.0

sinkFileBS :: forall (m :: Type -> Type) o. MonadResource m => FilePath -> ConduitT ByteString o m () #

`sinkFile` specialized to `ByteString` to help with type inference.

Since: 1.3.0

sinkHandle :: forall (m :: Type -> Type) o. MonadIO m => Handle -> ConduitT ByteString o m () #

Stream all incoming data to the given `Handle`. Note that this function does not flush and will not close the `Handle` when processing completes.

Since: 1.3.0

sinkIOHandle :: forall (m :: Type -> Type) o. MonadResource m => IO Handle -> ConduitT ByteString o m () #

An alternative to `sinkHandle`. Instead of taking a pre-opened `Handle`, it takes an action that opens a `Handle` (in write mode), so that it can open it only when needed and close it as soon as possible.

Since: 1.3.0

withSinkFile :: forall m (n :: Type -> Type) o a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM ByteString o n () -> m a) -> m a #

Like `withBinaryFile`, but provides a sink to write bytes to.

Since: 1.3.0

withSinkFileBuilder :: forall m (n :: Type -> Type) o a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM Builder o n () -> m a) -> m a #

Same as `withSinkFile`, but lets you use a `Builder`.

Since: 1.3.0

withSinkFileCautious :: forall m (n :: Type -> Type) o a. (MonadUnliftIO m, MonadIO n) => FilePath -> (ConduitM ByteString o n () -> m a) -> m a #

Like `sinkFileCautious`, but uses the `with` pattern instead of `MonadResource`.

Since: 1.3.0

sinkHandleBuilder :: forall (m :: Type -> Type) o. MonadIO m => Handle -> ConduitM Builder o m () #

Stream incoming builders, executing them directly on the buffer of the given `Handle`. Note that this function does not automatically close the `Handle` when processing completes. Pass `flush` to flush the buffer.

Since: 1.3.0

sinkHandleFlush :: forall (m :: Type -> Type) o. MonadIO m => Handle -> ConduitM (Flush ByteString) o m () #

Stream incoming `Flush`es, executing them on `IO.Handle` Note that this function does not automatically close the `Handle` when processing completes

Since: 1.3.0

conduitVector #

Arguments

:: forall v a (m :: Type -> Type). (Vector v a, PrimMonad m) |
=> Int | maximum allowed size
-> ConduitT a (v a) m () |

Break up a stream of values into vectors of size n. The final vector may be smaller than n if the total number of values is not a strict multiple of n. No empty vectors will be yielded.

Since: 1.3.0

builderToByteString :: forall (m :: Type -> Type). PrimMonad m => ConduitT Builder ByteString m () #

Incrementally execute builders and pass on the filled chunks as bytestrings.

Since: 1.3.0

unsafeBuilderToByteString :: forall (m :: Type -> Type). PrimMonad m => ConduitT Builder ByteString m () #

Incrementally execute builders on the given buffer and pass on the filled chunks as bytestrings. Note that, if the given buffer is too small for the execution of a build step, a larger one will be allocated.

WARNING: This conduit yields bytestrings that are NOT referentially transparent. Their content will be overwritten as soon as control is returned from the inner sink!

Since: 1.3.0

builderToByteStringWith :: forall (m :: Type -> Type). PrimMonad m => BufferAllocStrategy -> ConduitT Builder ByteString m () #

A conduit that incrementally executes builders and passes on the filled chunks as bytestrings to an inner sink.

INV: All bytestrings passed to the inner sink are non-empty.

Since: 1.3.0

builderToByteStringFlush :: forall (m :: Type -> Type). PrimMonad m => ConduitT (Flush Builder) (Flush ByteString) m () #

Same as `builderToByteString`, but input and output are wrapped in `Flush`.

Since: 1.3.0

builderToByteStringWithFlush :: forall (m :: Type -> Type). PrimMonad m => BufferAllocStrategy -> ConduitT (Flush Builder) (Flush ByteString) m () #

Since: 1.3.0

type BufferAllocStrategy = (IO Buffer, Int -> Buffer -> IO (IO Buffer)) #

A buffer allocation strategy `(buf0, nextBuf)` specifies the initial buffer to use and how to compute a new buffer `nextBuf minSize buf` with at least size `minSize` from a filled buffer `buf`. The double nesting of the `IO` monad helps to ensure that the reference to the filled buffer `buf` is lost as soon as possible, but the new buffer doesn't have to be allocated too early.

Since: 1.3.0

allNewBuffersStrategy :: Int -> BufferAllocStrategy #

The simplest buffer allocation strategy: whenever a buffer is requested, allocate a new one that is big enough for the next build step to execute.

NOTE that this allocation strategy may spill quite some memory upon direct insertion of a bytestring by the builder. Thats no problem for garbage collection, but it may lead to unreasonably high memory consumption in special circumstances.

Since: 1.3.0

reuseBufferStrategy :: IO Buffer -> BufferAllocStrategy #

An unsafe, but possibly more efficient buffer allocation strategy: reuse the buffer, if it is big enough for the next build step to execute.

Since: 1.3.0

mapAccumS :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> ConduitT b Void m s) -> s -> ConduitT () b m () -> ConduitT a Void m s #

Consume a source with a strict accumulator, in a way piecewise defined by a controlling stream. The latter will be evaluated until it terminates.

    >>> let f a s = liftM (:s) $ mapC (*a) =$ CL.take a
    >>> reverse $ runIdentity $ yieldMany [0..3] $$ mapAccumS f [] (yieldMany [1..])
    [[],[1],[4,6],[12,15,18]] :: [[Int]]

peekForever :: forall (m :: Type -> Type) i o. Monad m => ConduitT i o m () -> ConduitT i o m () #

Run a consuming conduit repeatedly, only stopping when there is no more data available from upstream.

Since: 1.3.0

peekForeverE :: forall (m :: Type -> Type) i o. (Monad m, MonoFoldable i) => ConduitT i o m () -> ConduitT i o m () #

Run a consuming conduit repeatedly, only stopping when there is no more data available from upstream.

In contrast to `peekForever`, this function will ignore empty chunks of data. So for example, if a stream of data contains an empty `ByteString`, it is still treated as empty, and the consuming function is not called.

Since: 1.3.0

unfoldC :: forall (m :: Type -> Type) b a i. Monad m => (b -> Maybe (a, b)) -> b -> ConduitT i a m () #

Generate a producer from a seed value.

Since: 1.3.0

enumFromToC :: forall (m :: Type -> Type) a i. (Monad m, Enum a, Ord a) => a -> a -> ConduitT i a m () #

Enumerate from a value to a final value, inclusive, via `succ`.

This is generally more efficient than using `Prelude`'s `enumFromTo` and combining with `sourceList` since this avoids any intermediate data structures.

Since: 1.3.0

iterateC :: forall (m :: Type -> Type) a i. Monad m => (a -> a) -> a -> ConduitT i a m () #

Produces an infinite stream of repeated applications of f to x.

Since: 1.3.0

repeatC :: forall (m :: Type -> Type) a i. Monad m => a -> ConduitT i a m () #

Produce an infinite stream consisting entirely of the given value.

Since: 1.3.0

replicateC :: forall (m :: Type -> Type) a i. Monad m => Int -> a -> ConduitT i a m () #

Produce a finite stream consisting of n copies of the given value.

Since: 1.3.0

repeatMC :: Monad m => m a -> ConduitT i a m () #

Repeatedly run the given action and yield all values it produces.

Since: 1.3.0

repeatWhileMC :: Monad m => m a -> (a -> Bool) -> ConduitT i a m () #

Repeatedly run the given action and yield all values it produces, until the provided predicate returns `False`.

Since: 1.3.0

replicateMC :: Monad m => Int -> m a -> ConduitT i a m () #

Perform the given action n times, yielding each result.

Since: 1.3.0

stdinC :: forall (m :: Type -> Type) i. MonadIO m => ConduitT i ByteString m () #

`sourceHandle` applied to `stdin`.

Since: 1.3.0

dropC :: forall (m :: Type -> Type) a o. Monad m => Int -> ConduitT a o m () #

Ignore a certain number of values in the stream.

Note: since this function doesn't produce anything, you probably want to use it with (`>>`) instead of directly plugging it into a pipeline:

    >>> runConduit $ yieldMany [1..5] .| dropC 2 .| sinkList
    []
    >>> runConduit $ yieldMany [1..5] .| (dropC 2 >> sinkList)
    [3,4,5]

Since: 1.3.0

dropCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => Index seq -> ConduitT seq o m () #

Drop a certain number of elements from a chunked stream.

Note: you likely want to use it with monadic composition. See the docs for `dropC`.

Since: 1.3.0

dropWhileC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m () #

Drop all values which match the given predicate.

Note: you likely want to use it with monadic composition. See the docs for `dropC`.

Since: 1.3.0

dropWhileCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => (Element seq -> Bool) -> ConduitT seq o m () #

Drop all elements in the chunked stream which match the given predicate.

Note: you likely want to use it with monadic composition. See the docs for `dropC`.

Since: 1.3.0

foldC :: forall (m :: Type -> Type) a o. (Monad m, Monoid a) => ConduitT a o m a #

Monoidally combine all values in the stream.

Since: 1.3.0

foldCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Monoid (Element mono)) => ConduitT mono o m (Element mono) #

Monoidally combine all elements in the chunked stream.

Since: 1.3.0

foldlC :: forall (m :: Type -> Type) a b o. Monad m => (a -> b -> a) -> a -> ConduitT b o m a #

A strict left fold.

Since: 1.3.0

foldlCE :: forall (m :: Type -> Type) mono a o. (Monad m, MonoFoldable mono) => (a -> Element mono -> a) -> a -> ConduitT mono o m a #

A strict left fold on a chunked stream.

Since: 1.3.0

foldMapC :: forall (m :: Type -> Type) b a o. (Monad m, Monoid b) => (a -> b) -> ConduitT a o m b #

Apply the provided mapping function and monoidal combine all values.

Since: 1.3.0

foldMapCE :: forall (m :: Type -> Type) mono w o. (Monad m, MonoFoldable mono, Monoid w) => (Element mono -> w) -> ConduitT mono o m w #

Apply the provided mapping function and monoidal combine all elements of the chunked stream.

Since: 1.3.0

allC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m Bool #

Check that all values in the stream return True.

Subject to shortcut logic: at the first False, consumption of the stream will stop.

Since: 1.3.0

allCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => (Element mono -> Bool) -> ConduitT mono o m Bool #

Check that all elements in the chunked stream return True.

Subject to shortcut logic: at the first False, consumption of the stream will stop.

Since: 1.3.0

anyC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m Bool #

Check that at least one value in the stream returns True.

Subject to shortcut logic: at the first True, consumption of the stream will stop.

Since: 1.3.0

anyCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => (Element mono -> Bool) -> ConduitT mono o m Bool #

Check that at least one element in the chunked stream returns True.

Subject to shortcut logic: at the first True, consumption of the stream will stop.

Since: 1.3.0

andC :: forall (m :: Type -> Type) o. Monad m => ConduitT Bool o m Bool #

Are all values in the stream True?

Consumption stops once the first False is encountered.

Since: 1.3.0

andCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Element mono ~ Bool) => ConduitT mono o m Bool #

Are all elements in the chunked stream True?

Consumption stops once the first False is encountered.

Since: 1.3.0

orC :: forall (m :: Type -> Type) o. Monad m => ConduitT Bool o m Bool #

Are any values in the stream True?

Consumption stops once the first True is encountered.

Since: 1.3.0

orCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Element mono ~ Bool) => ConduitT mono o m Bool #

Are any elements in the chunked stream True?

Consumption stops once the first True is encountered.

Since: 1.3.0

asumC :: forall (m :: Type -> Type) f a o. (Monad m, Alternative f) => ConduitT (f a) o m (f a) #

`Alternative`ly combine all values in the stream.

Since: 1.3.0

elemC :: forall (m :: Type -> Type) a o. (Monad m, Eq a) => a -> ConduitT a o m Bool #

Are any values in the stream equal to the given value?

Stops consuming as soon as a match is found.

Since: 1.3.0

elemCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Eq (Element seq)) => Element seq -> ConduitT seq o m Bool #

Are any elements in the chunked stream equal to the given element?

Stops consuming as soon as a match is found.

Since: 1.3.0

notElemC :: forall (m :: Type -> Type) a o. (Monad m, Eq a) => a -> ConduitT a o m Bool #

Are no values in the stream equal to the given value?

Stops consuming as soon as a match is found.

Since: 1.3.0

notElemCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Eq (Element seq)) => Element seq -> ConduitT seq o m Bool #

Are no elements in the chunked stream equal to the given element?

Stops consuming as soon as a match is found.

Since: 1.3.0

headC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m (Maybe a) #

Take a single value from the stream, if available.

Since: 1.3.0

headDefC :: forall (m :: Type -> Type) a o. Monad m => a -> ConduitT a o m a #

Same as `headC`, but returns a default value if none are available from the stream.

Since: 1.3.0

headCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => ConduitT seq o m (Maybe (Element seq)) #

Get the next element in the chunked stream.

Since: 1.3.0

peekC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m (Maybe a) #

View the next value in the stream without consuming it.

Since: 1.3.0

peekCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => ConduitT mono o m (Maybe (Element mono)) #

View the next element in the chunked stream without consuming it.

Since: 1.3.0

lastC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m (Maybe a) #

Retrieve the last value in the stream, if present.

Since: 1.3.0

lastDefC :: forall (m :: Type -> Type) a o. Monad m => a -> ConduitT a o m a #

Same as `lastC`, but returns a default value if none are available from the stream.

Since: 1.3.0

lastCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq) => ConduitT seq o m (Maybe (Element seq)) #

Retrieve the last element in the chunked stream, if present.

Since: 1.3.0

lengthC :: forall (m :: Type -> Type) len a o. (Monad m, Num len) => ConduitT a o m len #

Count how many values are in the stream.

Since: 1.3.0

lengthCE :: forall (m :: Type -> Type) len mono o. (Monad m, Num len, MonoFoldable mono) => ConduitT mono o m len #

Count how many elements are in the chunked stream.

Since: 1.3.0

lengthIfC :: forall (m :: Type -> Type) len a o. (Monad m, Num len) => (a -> Bool) -> ConduitT a o m len #

Count how many values in the stream pass the given predicate.

Since: 1.3.0

lengthIfCE :: forall (m :: Type -> Type) len mono o. (Monad m, Num len, MonoFoldable mono) => (Element mono -> Bool) -> ConduitT mono o m len #

Count how many elements in the chunked stream pass the given predicate.

Since: 1.3.0

maximumC :: forall (m :: Type -> Type) a o. (Monad m, Ord a) => ConduitT a o m (Maybe a) #

Get the largest value in the stream, if present.

Since: 1.3.0

maximumCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Ord (Element seq)) => ConduitT seq o m (Maybe (Element seq)) #

Get the largest element in the chunked stream, if present.

Since: 1.3.0

minimumC :: forall (m :: Type -> Type) a o. (Monad m, Ord a) => ConduitT a o m (Maybe a) #

Get the smallest value in the stream, if present.

Since: 1.3.0

minimumCE :: forall (m :: Type -> Type) seq o. (Monad m, IsSequence seq, Ord (Element seq)) => ConduitT seq o m (Maybe (Element seq)) #

Get the smallest element in the chunked stream, if present.

Since: 1.3.0

nullC :: forall (m :: Type -> Type) a o. Monad m => ConduitT a o m Bool #

True if there are no values in the stream.

This function does not modify the stream.

Since: 1.3.0

nullCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono) => ConduitT mono o m Bool #

True if there are no elements in the chunked stream.

This function may remove empty leading chunks from the stream, but otherwise will not modify it.

Since: 1.3.0

sumC :: forall (m :: Type -> Type) a o. (Monad m, Num a) => ConduitT a o m a #

Get the sum of all values in the stream.

Since: 1.3.0

sumCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Num (Element mono)) => ConduitT mono o m (Element mono) #

Get the sum of all elements in the chunked stream.

Since: 1.3.0

productC :: forall (m :: Type -> Type) a o. (Monad m, Num a) => ConduitT a o m a #

Get the product of all values in the stream.

Since: 1.3.0

productCE :: forall (m :: Type -> Type) mono o. (Monad m, MonoFoldable mono, Num (Element mono)) => ConduitT mono o m (Element mono) #

Get the product of all elements in the chunked stream.

Since: 1.3.0

findC :: forall (m :: Type -> Type) a o. Monad m => (a -> Bool) -> ConduitT a o m (Maybe a) #

Find the first matching value.

Since: 1.3.0

mapM_C :: Monad m => (a -> m ()) -> ConduitT a o m () #

Apply the action to all values in the stream.

Note: if you want to pass the values instead of consuming them, use `iterM` instead.

Since: 1.3.0

mapM_CE :: (Monad m, MonoFoldable mono) => (Element mono -> m ()) -> ConduitT mono o m () #

Apply the action to all elements in the chunked stream.

Note: the same caveat as with `mapM_C` applies. If you don't want to consume the values, you can use `iterM`:

    iterM (omapM_ f)

Since: 1.3.0

foldMC :: Monad m => (a -> b -> m a) -> a -> ConduitT b o m a #

A monadic strict left fold.

Since: 1.3.0

foldMCE :: (Monad m, MonoFoldable mono) => (a -> Element mono -> m a) -> a -> ConduitT mono o m a #

A monadic strict left fold on a chunked stream.

Since: 1.3.0

foldMapMC :: (Monad m, Monoid w) => (a -> m w) -> ConduitT a o m w #

Apply the provided monadic mapping function and monoidal combine all values.

Since: 1.3.0

foldMapMCE :: (Monad m, MonoFoldable mono, Monoid w) => (Element mono -> m w) -> ConduitT mono o m w #

Apply the provided monadic mapping function and monoidal combine all elements in the chunked stream.

Since: 1.3.0

printC :: forall a (m :: Type -> Type) o. (Show a, MonadIO m) => ConduitT a o m () #

Print all incoming values to stdout.

Since: 1.3.0

stdoutC :: forall (m :: Type -> Type) o. MonadIO m => ConduitT ByteString o m () #

`sinkHandle` applied to `stdout`.

Since: 1.3.0

stderrC :: forall (m :: Type -> Type) o. MonadIO m => ConduitT ByteString o m () #

`sinkHandle` applied to `stderr`.

Since: 1.3.0

mapC :: forall (m :: Type -> Type) a b. Monad m => (a -> b) -> ConduitT a b m () #

Apply a transformation to all values in a stream.

Since: 1.3.0

mapCE :: forall (m :: Type -> Type) f a b. (Monad m, Functor f) => (a -> b) -> ConduitT (f a) (f b) m () #

Apply a transformation to all elements in a chunked stream.

Since: 1.3.0

omapCE :: forall (m :: Type -> Type) mono. (Monad m, MonoFunctor mono) => (Element mono -> Element mono) -> ConduitT mono mono m () #

Apply a monomorphic transformation to all elements in a chunked stream.

Unlike `mapE`, this will work on types like `ByteString` and `Text` which are `MonoFunctor` but not `Functor`.

Since: 1.3.0

concatMapC :: forall (m :: Type -> Type) mono a. (Monad m, MonoFoldable mono) => (a -> mono) -> ConduitT a (Element mono) m () #

Apply the function to each value in the stream, resulting in a foldable value (e.g., a list). Then yield each of the individual values in that foldable value separately.

Generalizes concatMap, mapMaybe, and mapFoldable.

Since: 1.3.0

concatMapCE :: forall (m :: Type -> Type) mono w. (Monad m, MonoFoldable mono, Monoid w) => (Element mono -> w) -> ConduitT mono w m () #

Apply the function to each element in the chunked stream, resulting in a foldable value (e.g., a list). Then yield each of the individual values in that foldable value separately.

Generalizes concatMap, mapMaybe, and mapFoldable.

Since: 1.3.0

takeC :: forall (m :: Type -> Type) a. Monad m => Int -> ConduitT a a m () #

Stream up to n number of values downstream.

Note that, if downstream terminates early, not all values will be consumed. If you want to force exactly the given number of values to be consumed, see `takeExactly`.

Since: 1.3.0

takeCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => Index seq -> ConduitT seq seq m () #

Stream up to n number of elements downstream in a chunked stream.

Note that, if downstream terminates early, not all values will be consumed. If you want to force exactly the given number of values to be consumed, see `takeExactlyE`.

Since: 1.3.0

takeWhileC :: forall (m :: Type -> Type) a. Monad m => (a -> Bool) -> ConduitT a a m () #

Stream all values downstream that match the given predicate.

Same caveats regarding downstream termination apply as with `take`.

Since: 1.3.0

takeWhileCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => (Element seq -> Bool) -> ConduitT seq seq m () #

Stream all elements downstream that match the given predicate in a chunked stream.

Same caveats regarding downstream termination apply as with `takeE`.

Since: 1.3.0

takeExactlyC :: forall (m :: Type -> Type) a b r. Monad m => Int -> ConduitT a b m r -> ConduitT a b m r #

Consume precisely the given number of values and feed them downstream.

This function is in contrast to `take`, which will only consume up to the given number of values, and will terminate early if downstream terminates early. This function will discard any additional values in the stream if they are unconsumed.

Note that this function takes a downstream `ConduitT` as a parameter, as opposed to working with normal fusion. For more information, see http://www.yesodweb.com/blog/2013/10/core-flaw-pipes-conduit, the section titled "pipes and conduit: isolate".

Since: 1.3.0

takeExactlyCE :: forall (m :: Type -> Type) a b r. (Monad m, IsSequence a) => Index a -> ConduitT a b m r -> ConduitT a b m r #

Same as `takeExactly`, but for chunked streams.

Since: 1.3.0

concatC :: forall (m :: Type -> Type) mono. (Monad m, MonoFoldable mono) => ConduitT mono (Element mono) m () #

Flatten out a stream by yielding the values contained in an incoming `MonoFoldable` as individually yielded values.

Since: 1.3.0

filterC :: forall (m :: Type -> Type) a. Monad m => (a -> Bool) -> ConduitT a a m () #

Keep only values in the stream passing a given predicate.

Since: 1.3.0

filterCE :: forall seq (m :: Type -> Type). (IsSequence seq, Monad m) => (Element seq -> Bool) -> ConduitT seq seq m () #

Keep only elements in the chunked stream passing a given predicate.

Since: 1.3.0

mapWhileC :: forall (m :: Type -> Type) a b. Monad m => (a -> Maybe b) -> ConduitT a b m () #

Map values as long as the result is `Just`.

Since: 1.3.0

scanlC :: forall (m :: Type -> Type) a b. Monad m => (a -> b -> a) -> a -> ConduitT b a m () #

Analog of `scanl` for lists.

Since: 1.3.0

mapAccumWhileC :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> Either s (s, b)) -> s -> ConduitT a b m s #

`mapWhileC` with a break condition dependent on a strict accumulator. Equivalently, `mapAccum` as long as the result is `Right`. Instead of producing a leftover, the breaking input determines the resulting accumulator via `Left`.

concatMapAccumC :: forall (m :: Type -> Type) a accum b. Monad m => (a -> accum -> (accum, [b])) -> accum -> ConduitT a b m () #

`concatMap` with an accumulator.

Since: 1.3.0

intersperseC :: forall (m :: Type -> Type) a. Monad m => a -> ConduitT a a m () #

Insert the given value between each two values in the stream.

Since: 1.3.0

slidingWindowC :: forall (m :: Type -> Type) seq a. (Monad m, IsSequence seq, Element seq ~ a) => Int -> ConduitT a seq m () #

Sliding window of values 1,2,3,4,5 with window size 2 gives [1,2],[2,3],[3,4],[4,5]

Best used with structures that support O(1) snoc.

Since: 1.3.0

chunksOfCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => Index seq -> ConduitT seq seq m () #

Split input into chunk of size `chunkSize`

The last element may be smaller than the `chunkSize` (see also `chunksOfExactlyE` which will not yield this last element)

Since: 1.3.0

chunksOfExactlyCE :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq) => Index seq -> ConduitT seq seq m () #

Split input into chunk of size `chunkSize`

If the input does not split into chunks exactly, the remainder will be leftover (see also `chunksOfE`)

Since: 1.3.0

mapMC :: Monad m => (a -> m b) -> ConduitT a b m () #

Apply a monadic transformation to all values in a stream.

If you do not need the transformed values, and instead just want the monadic side-effects of running the action, see `mapM_`.

Since: 1.3.0

mapMCE :: (Monad m, Traversable f) => (a -> m b) -> ConduitT (f a) (f b) m () #

Apply a monadic transformation to all elements in a chunked stream.

Since: 1.3.0

omapMCE :: (Monad m, MonoTraversable mono) => (Element mono -> m (Element mono)) -> ConduitT mono mono m () #

Apply a monadic monomorphic transformation to all elements in a chunked stream.

Unlike `mapME`, this will work on types like `ByteString` and `Text` which are `MonoFunctor` but not `Functor`.

Since: 1.3.0

concatMapMC :: (Monad m, MonoFoldable mono) => (a -> m mono) -> ConduitT a (Element mono) m () #

Apply the monadic function to each value in the stream, resulting in a foldable value (e.g., a list). Then yield each of the individual values in that foldable value separately.

Generalizes concatMapM, mapMaybeM, and mapFoldableM.

Since: 1.3.0

filterMC :: Monad m => (a -> m Bool) -> ConduitT a a m () #

Keep only values in the stream passing a given monadic predicate.

Since: 1.3.0

filterMCE :: (Monad m, IsSequence seq) => (Element seq -> m Bool) -> ConduitT seq seq m () #

Keep only elements in the chunked stream passing a given monadic predicate.

Since: 1.3.0

iterMC :: Monad m => (a -> m ()) -> ConduitT a a m () #

Apply a monadic action on all values in a stream.

This `Conduit` can be used to perform a monadic side-effect for every value, whilst passing the value through the `Conduit` as-is.

    iterM f = mapM (\a -> f a >>= \() -> return a)

Since: 1.3.0

scanlMC :: Monad m => (a -> b -> m a) -> a -> ConduitT b a m () #

Analog of `scanl` for lists, monadic.

Since: 1.3.0

mapAccumWhileMC :: Monad m => (a -> s -> m (Either s (s, b))) -> s -> ConduitT a b m s #

Monadic `mapAccumWhileC`.

concatMapAccumMC :: Monad m => (a -> accum -> m (accum, [b])) -> accum -> ConduitT a b m () #

`concatMapM` with an accumulator.

Since: 1.3.0

encodeUtf8C :: forall (m :: Type -> Type) text binary. (Monad m, Utf8 text binary) => ConduitT text binary m () #

Encode a stream of text as UTF8.

Since: 1.3.0

decodeUtf8C :: forall (m :: Type -> Type). MonadThrow m => ConduitT ByteString Text m () #

Decode a stream of binary data as UTF8.

Since: 1.3.0

decodeUtf8LenientC :: forall (m :: Type -> Type). Monad m => ConduitT ByteString Text m () #

Decode a stream of binary data as UTF8, replacing any invalid bytes with the Unicode replacement character.

Since: 1.3.0

lineC :: forall (m :: Type -> Type) seq o r. (Monad m, IsSequence seq, Element seq ~ Char) => ConduitT seq o m r -> ConduitT seq o m r #

Stream in the entirety of a single line.

Like `takeExactly`, this will consume the entirety of the line regardless of the behavior of the inner Conduit.

Since: 1.3.0

lineAsciiC :: forall (m :: Type -> Type) seq o r. (Monad m, IsSequence seq, Element seq ~ Word8) => ConduitT seq o m r -> ConduitT seq o m r #

Same as `line`, but operates on ASCII/binary data.

Since: 1.3.0

unlinesC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Char) => ConduitT seq seq m () #

Insert a newline character after each incoming chunk of data.

Since: 1.3.0

unlinesAsciiC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Word8) => ConduitT seq seq m () #

Same as `unlines`, but operates on ASCII/binary data.

Since: 1.3.0

linesUnboundedC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Char) => ConduitT seq seq m () #

Convert a stream of arbitrarily-chunked textual data into a stream of data where each chunk represents a single line. Note that, if you have unknownuntrusted input, this function is unsafe/, since it would allow an attacker to form lines of massive length and exhaust memory.

Since: 1.3.0

linesUnboundedAsciiC :: forall (m :: Type -> Type) seq. (Monad m, IsSequence seq, Element seq ~ Word8) => ConduitT seq seq m () #

Same as `linesUnbounded`, but for ASCII/binary data.

Since: 1.3.0

vectorBuilderC #

Arguments

:: forall (m :: Type -> Type) v e n i r. (PrimMonad m, Vector v e, PrimMonad n, PrimState m ~ PrimState n) |
=> Int | size
-> ((e -> n ()) -> ConduitT i Void m r) |
-> ConduitT i (v e) m r |

Generally speaking, yielding values from inside a Conduit requires some allocation for constructors. This can introduce an overhead, similar to the overhead needed to represent a list of values instead of a vector. This overhead is even more severe when talking about unboxed values.

This combinator allows you to overcome this overhead, and efficiently fill up vectors. It takes two parameters. The first is the size of each mutable vector to be allocated. The second is a function. The function takes an argument which will yield the next value into a mutable vector.

Under the surface, this function uses a number of tricks to get high performance. For more information on both usage and implementation, please see: https://www.fpcomplete.com/user/snoyberg/library-documentation/vectorbuilder

Since: 1.3.0

# Monadic lifting

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:

-     liftIO . return = return

-     liftIO (m >>= f) = liftIO m >>= (liftIO . f)

Methods

liftIO :: IO a -> m a #

Lift a computation from the `IO` monad. This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations (i.e. `IO` is the base monad for the stack).

### Example

Expand

    import Control.Monad.Trans.State -- from the "transformers" library

    printState :: Show s => StateT s IO ()
    printState = do
      state <- get
      liftIO $ print state

Had we omitted ``liftIO``, we would have ended up with this error:

    • Couldn't match type ‘IO’ with ‘StateT s IO’
     Expected type: StateT s IO ()
       Actual type: IO ()

The important part here is the mismatch between `StateT s IO ()` and ``IO` ()`.

Luckily, we know of a function that takes an ``IO` a` and returns an `(m a)`: ``liftIO``, enabling us to run the program and see the expected results:

    > evalStateT printState "hello"
    "hello"

    > evalStateT printState 3
    3

#### 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 Acquire |
Instance details Defined in Data.Acquire.Internal Methods liftIO :: IO a -> Acquire a #
MonadIO Q |
Instance details Defined in Language.Haskell.TH.Syntax Methods liftIO :: IO a -> Q a #
MonadIO m => MonadIO (CatchT m) |
Instance details Defined in Control.Monad.Catch.Pure Methods liftIO :: IO a -> CatchT 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 (MaybeT m) |
Instance details Defined in Control.Monad.Trans.Maybe Methods liftIO :: IO a -> MaybeT 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 (ExceptT e m) |
Instance details Defined in Control.Monad.Trans.Except Methods liftIO :: IO a -> ExceptT e m a #
MonadIO m => MonadIO (IdentityT m) |
Instance details Defined in Control.Monad.Trans.Identity Methods liftIO :: IO a -> IdentityT 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 (SelectT r m) |
Instance details Defined in Control.Monad.Trans.Select Methods liftIO :: IO a -> SelectT r 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 (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Strict Methods liftIO :: IO a -> StateT s m a #
MonadIO m => MonadIO (WriterT w m) |
Instance details Defined in Control.Monad.Trans.Writer.CPS 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 #
(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 #
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 #
MonadIO m => MonadIO (RWST r w s m) |
Instance details Defined in Control.Monad.Trans.RWS.CPS 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 #
(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 #
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 #

class (forall (m :: Type -> Type). Monad m => Monad (t m)) => MonadTrans (t :: (Type -> Type) -> Type -> Type) where #

The class of monad transformers. For any monad `m`, the result `t m` should also be a monad, and `lift` should be a monad transformation from `m` to `t m`, i.e. it should satisfy the following laws:

-     lift . return = return

-     lift (m >>= f) = lift m >>= (lift . f)

Since 0.6.0.0 and for GHC 8.6 and later, the requirement that `t m` be a `Monad` is enforced by the implication constraint `forall m. `Monad` m => `Monad` (t m)` enabled by the `QuantifiedConstraints` extension.

### Ambiguity error with GHC 9.0 to 9.2.2

Expand

These versions of GHC have a bug (https://gitlab.haskell.org/ghc/ghc/-/issues/20582) which causes constraints like

    (MonadTrans t, forall m. Monad m => Monad (t m)) => ...

to be reported as ambiguous. For transformers 0.6 and later, this can be fixed by removing the second constraint, which is implied by the first.

Methods

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

Lift a computation from the argument monad to the constructed monad.

#### Instances

Instances details

MonadTrans CatchT |
Instance details Defined in Control.Monad.Catch.Pure Methods lift :: Monad m => m a -> CatchT m a #
MonadTrans ResourceT |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods lift :: Monad m => m a -> ResourceT m a #
MonadTrans MaybeT |
Instance details Defined in Control.Monad.Trans.Maybe Methods lift :: Monad m => m a -> MaybeT m a #
Monoid w => MonadTrans (AccumT w) |
Instance details Defined in Control.Monad.Trans.Accum Methods lift :: Monad m => m a -> AccumT w m a #
MonadTrans (ExceptT e) |
Instance details Defined in Control.Monad.Trans.Except Methods lift :: Monad m => m a -> ExceptT e m a #
MonadTrans (IdentityT :: (Type -> Type) -> Type -> Type) |
Instance details Defined in Control.Monad.Trans.Identity Methods lift :: Monad m => m a -> IdentityT m a #
MonadTrans (ReaderT r) |
Instance details Defined in Control.Monad.Trans.Reader Methods lift :: Monad m => m a -> ReaderT r m a #
MonadTrans (SelectT r) |
Instance details Defined in Control.Monad.Trans.Select Methods lift :: Monad m => m a -> SelectT r m a #
MonadTrans (StateT s) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods lift :: Monad m => m a -> StateT s m a #
MonadTrans (StateT s) |
Instance details Defined in Control.Monad.Trans.State.Strict Methods lift :: Monad m => m a -> StateT s m a #
MonadTrans (WriterT w) |
Instance details Defined in Control.Monad.Trans.Writer.CPS Methods lift :: Monad m => m a -> WriterT w m a #
Monoid w => MonadTrans (WriterT w) |
Instance details Defined in Control.Monad.Trans.Writer.Lazy Methods lift :: Monad m => m a -> WriterT w m a #
Monoid w => MonadTrans (WriterT w) |
Instance details Defined in Control.Monad.Trans.Writer.Strict Methods lift :: Monad m => m a -> WriterT w m a #
MonadTrans (ConduitT i o) # |
Instance details Defined in Data.Conduit.Internal.Conduit Methods lift :: Monad m => m a -> ConduitT i o m a #
MonadTrans (ContT r) |
Instance details Defined in Control.Monad.Trans.Cont Methods lift :: Monad m => m a -> ContT r m a #
MonadTrans (RWST r w s) |
Instance details Defined in Control.Monad.Trans.RWS.CPS Methods lift :: Monad m => m a -> RWST r w s m a #
Monoid w => MonadTrans (RWST r w s) |
Instance details Defined in Control.Monad.Trans.RWS.Lazy Methods lift :: Monad m => m a -> RWST r w s m a #
Monoid w => MonadTrans (RWST r w s) |
Instance details Defined in Control.Monad.Trans.RWS.Strict Methods lift :: Monad m => m a -> RWST r w s m a #
MonadTrans (Pipe l i o u) # |
Instance details Defined in Data.Conduit.Internal.Pipe Methods lift :: Monad m => m a -> Pipe l i o u m a #

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 :: (HasCallStack, 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 STM |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> STM a #
MonadThrow IO |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> IO a #
MonadThrow Q |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> Q a #
MonadThrow Maybe |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> Maybe a #
MonadThrow [] |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> [a] #
Monad m => MonadThrow (CatchT m) |
Instance details Defined in Control.Monad.Catch.Pure Methods throwM :: (HasCallStack, Exception e) => e -> CatchT m a #
e ~ SomeException => MonadThrow (Either e) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e0) => e0 -> Either e a #
MonadThrow (ST s) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> ST s a #
MonadThrow m => MonadThrow (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods throwM :: (HasCallStack, Exception e) => e -> ResourceT m a #
MonadThrow m => MonadThrow (MaybeT m) | Throws exceptions into the base monad.
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> MaybeT m a #
MonadThrow m => MonadThrow (ExceptT e m) | Throws exceptions into the base monad.
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e0) => e0 -> ExceptT e m a #
MonadThrow m => MonadThrow (IdentityT m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> IdentityT m a #
MonadThrow m => MonadThrow (ReaderT r m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> ReaderT r m a #
MonadThrow m => MonadThrow (StateT s m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> StateT s m a #
MonadThrow m => MonadThrow (StateT s m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> StateT s m a #
(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> WriterT w m a #
(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> WriterT w m a #
MonadThrow m => MonadThrow (ConduitT i o m) # |
Instance details Defined in Data.Conduit.Internal.Conduit Methods throwM :: (HasCallStack, Exception e) => e -> ConduitT i o m a #
MonadThrow m => MonadThrow (ContT r m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, 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 :: (HasCallStack, 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 :: (HasCallStack, 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 :: (HasCallStack, Exception e) => e -> Pipe l i o u m a #

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

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 function `run` provided by `withRunInIO`, it must meet the monad transformer laws as reformulated for `MonadUnliftIO`:

-     run . return = return

-     run (m >>= f) = run m >>= run . f

Instances of `MonadUnliftIO` must also satisfy the following laws:

Identity law
  `withRunInIO (\run -> run m) = m`
Inverse law
  `withRunInIO (\_ -> m) = liftIO m`

As an example of an invalid instance, a naive implementation of `MonadUnliftIO (StateT s m)` might be

    withRunInIO inner =
      StateT $ \s ->
        withRunInIO $ \run ->
          inner (run . flip evalStateT s)

This breaks the identity law because the inner `run m` would throw away any state changes in `m`.

Since: unliftio-core-0.1.0.0

Methods

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

Convenience function for capturing the monadic context and running an `IO` action with a runner function. The runner function is used to run a monadic action `m` in `IO`.

Since: unliftio-core-0.1.0.0

#### 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 (IdentityT m) |
Instance details Defined in Control.Monad.IO.Unlift Methods withRunInIO :: ((forall a. IdentityT m a -> IO a) -> IO b) -> IdentityT 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 #

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

Class of monads which can perform primitive state-transformer actions.

Associated Types

type PrimState (m :: Type -> Type) #

State token type.

Methods

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

Execute a primitive operation.

#### Instances

Instances details

PrimMonad IO |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState IO |
Instance details Defined in Control.Monad.Primitive type PrimState IO = RealWorld
Methods primitive :: (State# (PrimState IO) -> (# State# (PrimState IO), a #)) -> IO a #
PrimMonad (ST s) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (ST s) |
Instance details Defined in Control.Monad.Primitive type PrimState (ST s) = s
Methods primitive :: (State# (PrimState (ST s)) -> (# State# (PrimState (ST s)), a #)) -> ST s a #
PrimMonad (ST s) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (ST s) |
Instance details Defined in Control.Monad.Primitive type PrimState (ST s) = s
Methods primitive :: (State# (PrimState (ST s)) -> (# State# (PrimState (ST s)), a #)) -> ST s a #
PrimMonad m => PrimMonad (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Associated Types
type PrimState (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal type PrimState (ResourceT m) = PrimState m
Methods primitive :: (State# (PrimState (ResourceT m)) -> (# State# (PrimState (ResourceT m)), a #)) -> ResourceT m a #
PrimMonad m => PrimMonad (MaybeT m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (MaybeT m) |
Instance details Defined in Control.Monad.Primitive type PrimState (MaybeT m) = PrimState m
Methods primitive :: (State# (PrimState (MaybeT m)) -> (# State# (PrimState (MaybeT m)), a #)) -> MaybeT m a #
(Monoid w, PrimMonad m) => PrimMonad (AccumT w m) | Since: primitive-0.6.3.0
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (AccumT w m) |
Instance details Defined in Control.Monad.Primitive type PrimState (AccumT w m) = PrimState m
Methods primitive :: (State# (PrimState (AccumT w m)) -> (# State# (PrimState (AccumT w m)), a #)) -> AccumT w m a #
PrimMonad m => PrimMonad (ExceptT e m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (ExceptT e m) |
Instance details Defined in Control.Monad.Primitive type PrimState (ExceptT e m) = PrimState m
Methods primitive :: (State# (PrimState (ExceptT e m)) -> (# State# (PrimState (ExceptT e m)), a #)) -> ExceptT e m a #
PrimMonad m => PrimMonad (IdentityT m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (IdentityT m) |
Instance details Defined in Control.Monad.Primitive type PrimState (IdentityT m) = PrimState m
Methods primitive :: (State# (PrimState (IdentityT m)) -> (# State# (PrimState (IdentityT m)), a #)) -> IdentityT m a #
PrimMonad m => PrimMonad (ReaderT r m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (ReaderT r m) |
Instance details Defined in Control.Monad.Primitive type PrimState (ReaderT r m) = PrimState m
Methods primitive :: (State# (PrimState (ReaderT r m)) -> (# State# (PrimState (ReaderT r m)), a #)) -> ReaderT r m a #
PrimMonad m => PrimMonad (SelectT r m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (SelectT r m) |
Instance details Defined in Control.Monad.Primitive type PrimState (SelectT r m) = PrimState m
Methods primitive :: (State# (PrimState (SelectT r m)) -> (# State# (PrimState (SelectT r m)), a #)) -> SelectT r m a #
PrimMonad m => PrimMonad (StateT s m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (StateT s m) |
Instance details Defined in Control.Monad.Primitive type PrimState (StateT s m) = PrimState m
Methods primitive :: (State# (PrimState (StateT s m)) -> (# State# (PrimState (StateT s m)), a #)) -> StateT s m a #
PrimMonad m => PrimMonad (StateT s m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (StateT s m) |
Instance details Defined in Control.Monad.Primitive type PrimState (StateT s m) = PrimState m
Methods primitive :: (State# (PrimState (StateT s m)) -> (# State# (PrimState (StateT s m)), a #)) -> StateT s m a #
(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (WriterT w m) |
Instance details Defined in Control.Monad.Primitive type PrimState (WriterT w m) = PrimState m
Methods primitive :: (State# (PrimState (WriterT w m)) -> (# State# (PrimState (WriterT w m)), a #)) -> WriterT w m a #
(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (WriterT w m) |
Instance details Defined in Control.Monad.Primitive type PrimState (WriterT w m) = PrimState m
Methods primitive :: (State# (PrimState (WriterT w m)) -> (# State# (PrimState (WriterT w m)), a #)) -> WriterT w m a #
(Monoid w, PrimMonad m) => PrimMonad (WriterT w m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (WriterT w m) |
Instance details Defined in Control.Monad.Primitive type PrimState (WriterT w m) = PrimState m
Methods primitive :: (State# (PrimState (WriterT w m)) -> (# State# (PrimState (WriterT w m)), a #)) -> WriterT w m a #
PrimMonad m => PrimMonad (ConduitT i o m) # |
Instance details Defined in Data.Conduit.Internal.Conduit Associated Types
type PrimState (ConduitT i o m) |
Instance details Defined in Data.Conduit.Internal.Conduit type PrimState (ConduitT i o m) = PrimState m
Methods primitive :: (State# (PrimState (ConduitT i o m)) -> (# State# (PrimState (ConduitT i o m)), a #)) -> ConduitT i o m a #
PrimMonad m => PrimMonad (ContT r m) | Since: primitive-0.6.3.0
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (ContT r m) |
Instance details Defined in Control.Monad.Primitive type PrimState (ContT r m) = PrimState m
Methods primitive :: (State# (PrimState (ContT r m)) -> (# State# (PrimState (ContT r m)), a #)) -> ContT r m a #
(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (RWST r w s m) |
Instance details Defined in Control.Monad.Primitive type PrimState (RWST r w s m) = PrimState m
Methods primitive :: (State# (PrimState (RWST r w s m)) -> (# State# (PrimState (RWST r w s m)), a #)) -> RWST r w s m a #
(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (RWST r w s m) |
Instance details Defined in Control.Monad.Primitive type PrimState (RWST r w s m) = PrimState m
Methods primitive :: (State# (PrimState (RWST r w s m)) -> (# State# (PrimState (RWST r w s m)), a #)) -> RWST r w s m a #
(Monoid w, PrimMonad m) => PrimMonad (RWST r w s m) |
Instance details Defined in Control.Monad.Primitive Associated Types
type PrimState (RWST r w s m) |
Instance details Defined in Control.Monad.Primitive type PrimState (RWST r w s m) = PrimState m
Methods primitive :: (State# (PrimState (RWST r w s m)) -> (# State# (PrimState (RWST r w s m)), a #)) -> RWST r w s m a #
PrimMonad m => PrimMonad (Pipe l i o u m) # |
Instance details Defined in Data.Conduit.Internal.Pipe Associated Types
type PrimState (Pipe l i o u m) |
Instance details Defined in Data.Conduit.Internal.Pipe type PrimState (Pipe l i o u m) = PrimState m
Methods primitive :: (State# (PrimState (Pipe l i o u m)) -> (# State# (PrimState (Pipe l i o u m)), a #)) -> Pipe l i o u m a #

# ResourceT

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

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

Minimal complete definition

liftResourceT

#### Instances

Instances details

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 (MaybeT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods liftResourceT :: ResourceT IO a -> MaybeT 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 (ReaderT r m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods liftResourceT :: ResourceT IO a -> ReaderT r 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 #
(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 (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 #

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
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 #
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 #
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 #
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 #
MonadIO m => MonadIO (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods liftIO :: IO a -> ResourceT m a #
MonadCatch m => MonadCatch (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods catch :: (HasCallStack, 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 :: HasCallStack => ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b # uninterruptibleMask :: HasCallStack => ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b # generalBracket :: HasCallStack => ResourceT m a -> (a -> ExitCase b -> ResourceT m c) -> (a -> ResourceT m b) -> ResourceT m (b, c) #
MonadThrow m => MonadThrow (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods throwM :: (HasCallStack, Exception e) => e -> 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] #
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 #
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 #
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 #
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 #
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 #
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 #
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 #
PrimMonad m => PrimMonad (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Associated Types
type PrimState (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal type PrimState (ResourceT m) = PrimState m
Methods primitive :: (State# (PrimState (ResourceT m)) -> (# State# (PrimState (ResourceT m)), a #)) -> ResourceT m a #
MonadIO m => MonadResource (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal Methods liftResourceT :: ResourceT 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 #
type PrimState (ResourceT m) |
Instance details Defined in Control.Monad.Trans.Resource.Internal type PrimState (ResourceT m) = PrimState m

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

# Acquire

data Acquire a #

A method for acquiring a scarce resource, providing the means of freeing it when no longer needed. This data type provides `Functor`/`Applicative`/`Monad` instances for composing different resources together. You can allocate these resources using either the `bracket` pattern (via `with`) or using `ResourceT` (via `allocateAcquire`).

This concept was originally introduced by Gabriel Gonzalez and described at: http://www.haskellforall.com/2013/06/the-resource-applicative.html. The implementation in this package is slightly different, due to taking a different approach to async exception safety.

Since: resourcet-1.1.0

#### Instances

Instances details

MonadIO Acquire |
Instance details Defined in Data.Acquire.Internal Methods liftIO :: IO a -> Acquire a #
Applicative Acquire |
Instance details Defined in Data.Acquire.Internal Methods pure :: a -> Acquire a # (<*>) :: Acquire (a -> b) -> Acquire a -> Acquire b # liftA2 :: (a -> b -> c) -> Acquire a -> Acquire b -> Acquire c # (*>) :: Acquire a -> Acquire b -> Acquire b # (<*) :: Acquire a -> Acquire b -> Acquire a #
Functor Acquire |
Instance details Defined in Data.Acquire.Internal Methods fmap :: (a -> b) -> Acquire a -> Acquire b # (<$) :: a -> Acquire b -> Acquire a #
Monad Acquire |
Instance details Defined in Data.Acquire.Internal Methods (>>=) :: Acquire a -> (a -> Acquire b) -> Acquire b # (>>) :: Acquire a -> Acquire b -> Acquire b # return :: a -> Acquire a #

data ReleaseType #

The way in which a release is called.

Since: resourcet-1.1.2

Constructors

ReleaseEarly |
ReleaseNormal |
ReleaseExceptionWith SomeException |

Bundled Patterns

pattern ReleaseException :: ReleaseType |

#### Instances

Instances details

Show ReleaseType |
Instance details Defined in Data.Acquire.Internal Methods showsPrec :: Int -> ReleaseType -> ShowS # show :: ReleaseType -> String # showList :: [ReleaseType] -> ShowS #

mkAcquire #

Arguments

:: IO a | acquire the resource
-> (a -> IO ()) | free the resource
-> Acquire a |

Create an `Acquire` value using the given allocate and free functions.

To acquire and free the resource in an arbitrary monad with `MonadUnliftIO`, do the following:

    acquire <- withRunInIO $ \runInIO ->
      return $ mkAcquire (runInIO create) (runInIO . free)

Note that this is only safe if the Acquire is run and freed within the same monadic scope it was created in.

Since: resourcet-1.1.0

mkAcquireType #

Arguments

:: IO a | acquire the resource
-> (a -> ReleaseType -> IO ()) | free the resource
-> Acquire a |

Same as `mkAcquire`, but the cleanup function will be informed of how cleanup was initiated. This allows you to distinguish, for example, between normal and exceptional exits.

To acquire and free the resource in an arbitrary monad with `MonadUnliftIO`, do the following:

    acquire <- withRunInIO $ \runInIO ->
      return $ mkAcquireType (runInIO create) (\a -> runInIO . free a)

Note that this is only safe if the Acquire is run and freed within the same monadic scope it was created in.

Since: resourcet-1.1.2

allocateAcquire :: MonadResource m => Acquire a -> m (ReleaseKey, a) #

Allocate a resource and register an action with the `MonadResource` to free the resource.

Since: resourcet-1.1.0

withAcquire :: MonadUnliftIO m => Acquire a -> (a -> m b) -> m b #

Longer name for `with`, in case `with` is not obvious enough in context.

Since: resourcet-1.2.0

# Pure pipelines

newtype Identity a #

Identity functor and monad. (a non-strict monad)

#### Examples

Expand

    >>> fmap (+1) (Identity 0)
    Identity 1

    >>> Identity [1, 2, 3] <> Identity [4, 5, 6]
    Identity [1,2,3,4,5,6]

    >>> do
          x <- Identity 10
          y <- Identity (x + 5)
          pure (x + y)
    Identity 25

@since base-4.8.0.0

Constructors

Identity |
Fields runIdentity :: a

#### Instances

Instances details

MonadZip Identity | Since: base-4.8.0.0
Instance details Defined in Control.Monad.Zip Methods mzip :: Identity a -> Identity b -> Identity (a, b) # mzipWith :: (a -> b -> c) -> Identity a -> Identity b -> Identity c # munzip :: Identity (a, b) -> (Identity a, Identity b) #
Foldable1 Identity | Since: base-4.18.0.0
Instance details Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Identity m -> m # foldMap1 :: Semigroup m => (a -> m) -> Identity a -> m # foldMap1' :: Semigroup m => (a -> m) -> Identity a -> m # toNonEmpty :: Identity a -> NonEmpty a # maximum :: Ord a => Identity a -> a # minimum :: Ord a => Identity a -> a # head :: Identity a -> a # last :: Identity a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Identity a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Identity a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Identity a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Identity a -> b #
Eq1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftEq :: (a -> b -> Bool) -> Identity a -> Identity b -> Bool #
Ord1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftCompare :: (a -> b -> Ordering) -> Identity a -> Identity b -> Ordering #
Read1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Identity a) # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Identity a] # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Identity a) # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Identity a] #
Show1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Identity a -> ShowS # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Identity a] -> ShowS #
NFData1 Identity | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> Identity a -> () #
Applicative Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods pure :: a -> Identity a # (<*>) :: Identity (a -> b) -> Identity a -> Identity b # liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c # (*>) :: Identity a -> Identity b -> Identity b # (<*) :: Identity a -> Identity b -> Identity a #
Functor Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods fmap :: (a -> b) -> Identity a -> Identity b # (<$) :: a -> Identity b -> Identity a #
Monad Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods (>>=) :: Identity a -> (a -> Identity b) -> Identity b # (>>) :: Identity a -> Identity b -> Identity b # return :: a -> Identity a #
MonadFix Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods mfix :: (a -> Identity a) -> Identity a #
Foldable Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods fold :: Monoid m => Identity m -> m # foldMap :: Monoid m => (a -> m) -> Identity a -> m # foldMap' :: Monoid m => (a -> m) -> Identity a -> m # foldr :: (a -> b -> b) -> b -> Identity a -> b # foldr' :: (a -> b -> b) -> b -> Identity a -> b # foldl :: (b -> a -> b) -> b -> Identity a -> b # foldl' :: (b -> a -> b) -> b -> Identity a -> b # foldr1 :: (a -> a -> a) -> Identity a -> a # foldl1 :: (a -> a -> a) -> Identity a -> a # toList :: Identity a -> [a] # null :: Identity a -> Bool # length :: Identity a -> Int # elem :: Eq a => a -> Identity a -> Bool # maximum :: Ord a => Identity a -> a # minimum :: Ord a => Identity a -> a # sum :: Num a => Identity a -> a # product :: Num a => Identity a -> a #
Traversable Identity | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Identity a -> f (Identity b) # sequenceA :: Applicative f => Identity (f a) -> f (Identity a) # mapM :: Monad m => (a -> m b) -> Identity a -> m (Identity b) # sequence :: Monad m => Identity (m a) -> m (Identity a) #
Hashable1 Identity |
Instance details Defined in Data.Hashable.Class Methods liftHashWithSalt :: (Int -> a -> Int) -> Int -> Identity a -> Int #
Generic1 Identity |
Instance details Defined in GHC.Internal.Data.Functor.Identity Associated Types
type Rep1 Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity type Rep1 Identity = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
Methods from1 :: Identity a -> Rep1 Identity a # to1 :: Rep1 Identity a -> Identity a #
Unbox a => Vector Vector (Identity a) |
Instance details Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: Mutable Vector s (Identity a) -> ST s (Vector (Identity a)) basicUnsafeThaw :: Vector (Identity a) -> ST s (Mutable Vector s (Identity a)) basicLength :: Vector (Identity a) -> Int basicUnsafeSlice :: Int -> Int -> Vector (Identity a) -> Vector (Identity a) basicUnsafeIndexM :: Vector (Identity a) -> Int -> Box (Identity a) basicUnsafeCopy :: Mutable Vector s (Identity a) -> Vector (Identity a) -> ST s () elemseq :: Vector (Identity a) -> Identity a -> b -> b
Unbox a => MVector MVector (Identity a) |
Instance details Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s (Identity a) -> Int basicUnsafeSlice :: Int -> Int -> MVector s (Identity a) -> MVector s (Identity a) basicOverlaps :: MVector s (Identity a) -> MVector s (Identity a) -> Bool basicUnsafeNew :: Int -> ST s (MVector s (Identity a)) basicInitialize :: MVector s (Identity a) -> ST s () basicUnsafeReplicate :: Int -> Identity a -> ST s (MVector s (Identity a)) basicUnsafeRead :: MVector s (Identity a) -> Int -> ST s (Identity a) basicUnsafeWrite :: MVector s (Identity a) -> Int -> Identity a -> ST s () basicClear :: MVector s (Identity a) -> ST s () basicSet :: MVector s (Identity a) -> Identity a -> ST s () basicUnsafeCopy :: MVector s (Identity a) -> MVector s (Identity a) -> ST s () basicUnsafeMove :: MVector s (Identity a) -> MVector s (Identity a) -> ST s () basicUnsafeGrow :: MVector s (Identity a) -> Int -> ST s (MVector s (Identity a))
Monoid w => MonadAccum w (AccumT w Identity) | Since: mtl-2.3
Instance details Defined in Control.Monad.Accum Methods look :: AccumT w Identity w # add :: w -> AccumT w Identity () # accum :: (w -> (a, w)) -> AccumT w Identity a #
MonadSelect r (SelectT r Identity) | Since: mtl-2.3
Instance details Defined in Control.Monad.Select Methods select :: ((a -> r) -> a) -> SelectT r Identity a #
NFData a => NFData (Identity a) | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: Identity a -> () #
Monoid a => Monoid (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods mempty :: Identity a # mappend :: Identity a -> Identity a -> Identity a # mconcat :: [Identity a] -> Identity a #
Semigroup a => Semigroup (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods (<>) :: Identity a -> Identity a -> Identity a # sconcat :: NonEmpty (Identity a) -> Identity a # stimes :: Integral b => b -> Identity a -> Identity a #
Bits a => Bits (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods (.&.) :: Identity a -> Identity a -> Identity a # (.|.) :: Identity a -> Identity a -> Identity a # xor :: Identity a -> Identity a -> Identity a # complement :: Identity a -> Identity a # shift :: Identity a -> Int -> Identity a # rotate :: Identity a -> Int -> Identity a # zeroBits :: Identity a # bit :: Int -> Identity a # setBit :: Identity a -> Int -> Identity a # clearBit :: Identity a -> Int -> Identity a # complementBit :: Identity a -> Int -> Identity a # testBit :: Identity a -> Int -> Bool # bitSizeMaybe :: Identity a -> Maybe Int # bitSize :: Identity a -> Int # isSigned :: Identity a -> Bool # shiftL :: Identity a -> Int -> Identity a # unsafeShiftL :: Identity a -> Int -> Identity a # shiftR :: Identity a -> Int -> Identity a # unsafeShiftR :: Identity a -> Int -> Identity a # rotateL :: Identity a -> Int -> Identity a # rotateR :: Identity a -> Int -> Identity a # popCount :: Identity a -> Int #
FiniteBits a => FiniteBits (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods finiteBitSize :: Identity a -> Int # countLeadingZeros :: Identity a -> Int # countTrailingZeros :: Identity a -> Int #
IsString a => IsString (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.String Methods fromString :: String -> Identity a #
Bounded a => Bounded (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods minBound :: Identity a # maxBound :: Identity a #
Enum a => Enum (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods succ :: Identity a -> Identity a # pred :: Identity a -> Identity a # toEnum :: Int -> Identity a # fromEnum :: Identity a -> Int # enumFrom :: Identity a -> [Identity a] # enumFromThen :: Identity a -> Identity a -> [Identity a] # enumFromTo :: Identity a -> Identity a -> [Identity a] # enumFromThenTo :: Identity a -> Identity a -> Identity a -> [Identity a] #
Floating a => Floating (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods pi :: Identity a # exp :: Identity a -> Identity a # log :: Identity a -> Identity a # sqrt :: Identity a -> Identity a # (**) :: Identity a -> Identity a -> Identity a # logBase :: Identity a -> Identity a -> Identity a # sin :: Identity a -> Identity a # cos :: Identity a -> Identity a # tan :: Identity a -> Identity a # asin :: Identity a -> Identity a # acos :: Identity a -> Identity a # atan :: Identity a -> Identity a # sinh :: Identity a -> Identity a # cosh :: Identity a -> Identity a # tanh :: Identity a -> Identity a # asinh :: Identity a -> Identity a # acosh :: Identity a -> Identity a # atanh :: Identity a -> Identity a # log1p :: Identity a -> Identity a # expm1 :: Identity a -> Identity a # log1pexp :: Identity a -> Identity a # log1mexp :: Identity a -> Identity a #
RealFloat a => RealFloat (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods floatRadix :: Identity a -> Integer # floatDigits :: Identity a -> Int # floatRange :: Identity a -> (Int, Int) # decodeFloat :: Identity a -> (Integer, Int) # encodeFloat :: Integer -> Int -> Identity a # exponent :: Identity a -> Int # significand :: Identity a -> Identity a # scaleFloat :: Int -> Identity a -> Identity a # isNaN :: Identity a -> Bool # isInfinite :: Identity a -> Bool # isDenormalized :: Identity a -> Bool # isNegativeZero :: Identity a -> Bool # isIEEE :: Identity a -> Bool # atan2 :: Identity a -> Identity a -> Identity a #
Storable a => Storable (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods sizeOf :: Identity a -> Int # alignment :: Identity a -> Int # peekElemOff :: Ptr (Identity a) -> Int -> IO (Identity a) # pokeElemOff :: Ptr (Identity a) -> Int -> Identity a -> IO () # peekByteOff :: Ptr b -> Int -> IO (Identity a) # pokeByteOff :: Ptr b -> Int -> Identity a -> IO () # peek :: Ptr (Identity a) -> IO (Identity a) # poke :: Ptr (Identity a) -> Identity a -> IO () #
Generic (Identity a) |
Instance details Defined in GHC.Internal.Data.Functor.Identity Associated Types
type Rep (Identity a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity type Rep (Identity a) = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
Methods from :: Identity a -> Rep (Identity a) x # to :: Rep (Identity a) x -> Identity a #
Ix a => Ix (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods range :: (Identity a, Identity a) -> [Identity a] # index :: (Identity a, Identity a) -> Identity a -> Int # unsafeIndex :: (Identity a, Identity a) -> Identity a -> Int # inRange :: (Identity a, Identity a) -> Identity a -> Bool # rangeSize :: (Identity a, Identity a) -> Int # unsafeRangeSize :: (Identity a, Identity a) -> Int #
Num a => Num (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods (+) :: Identity a -> Identity a -> Identity a # (-) :: Identity a -> Identity a -> Identity a # (*) :: Identity a -> Identity a -> Identity a # negate :: Identity a -> Identity a # abs :: Identity a -> Identity a # signum :: Identity a -> Identity a # fromInteger :: Integer -> Identity a #
Read a => Read (Identity a) | This instance would be equivalent to the derived instances of the `Identity` newtype if the `runIdentity` field were removed @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods readsPrec :: Int -> ReadS (Identity a) # readList :: ReadS [Identity a] # readPrec :: ReadPrec (Identity a) # readListPrec :: ReadPrec [Identity a] #
Fractional a => Fractional (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods (/) :: Identity a -> Identity a -> Identity a # recip :: Identity a -> Identity a # fromRational :: Rational -> Identity a #
Integral a => Integral (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods quot :: Identity a -> Identity a -> Identity a # rem :: Identity a -> Identity a -> Identity a # div :: Identity a -> Identity a -> Identity a # mod :: Identity a -> Identity a -> Identity a # quotRem :: Identity a -> Identity a -> (Identity a, Identity a) # divMod :: Identity a -> Identity a -> (Identity a, Identity a) # toInteger :: Identity a -> Integer #
Real a => Real (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods toRational :: Identity a -> Rational #
RealFrac a => RealFrac (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods properFraction :: Integral b => Identity a -> (b, Identity a) # truncate :: Integral b => Identity a -> b # round :: Integral b => Identity a -> b # ceiling :: Integral b => Identity a -> b # floor :: Integral b => Identity a -> b #
Show a => Show (Identity a) | This instance would be equivalent to the derived instances of the `Identity` newtype if the `runIdentity` field were removed @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods showsPrec :: Int -> Identity a -> ShowS # show :: Identity a -> String # showList :: [Identity a] -> ShowS #
Eq a => Eq (Identity a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods (==) :: Identity a -> Identity a -> Bool # (/=) :: Identity a -> Identity a -> Bool #
Ord a => Ord (Identity a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods compare :: Identity a -> Identity a -> Ordering # (<) :: Identity a -> Identity a -> Bool # (<=) :: Identity a -> Identity a -> Bool # (>) :: Identity a -> Identity a -> Bool # (>=) :: Identity a -> Identity a -> Bool # max :: Identity a -> Identity a -> Identity a # min :: Identity a -> Identity a -> Identity a #
Hashable a => Hashable (Identity a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Identity a -> Int # hash :: Identity a -> Int #
MonoFoldable (Identity a) |
Instance details Defined in Data.MonoTraversable Methods ofoldMap :: Monoid m => (Element (Identity a) -> m) -> Identity a -> m # ofoldr :: (Element (Identity a) -> b -> b) -> b -> Identity a -> b # ofoldl' :: (a0 -> Element (Identity a) -> a0) -> a0 -> Identity a -> a0 # otoList :: Identity a -> [Element (Identity a)] # oall :: (Element (Identity a) -> Bool) -> Identity a -> Bool # oany :: (Element (Identity a) -> Bool) -> Identity a -> Bool # onull :: Identity a -> Bool # olength :: Identity a -> Int # olength64 :: Identity a -> Int64 # ocompareLength :: Integral i => Identity a -> i -> Ordering # otraverse_ :: Applicative f => (Element (Identity a) -> f b) -> Identity a -> f () # ofor_ :: Applicative f => Identity a -> (Element (Identity a) -> f b) -> f () # omapM_ :: Applicative m => (Element (Identity a) -> m ()) -> Identity a -> m () # oforM_ :: Applicative m => Identity a -> (Element (Identity a) -> m ()) -> m () # ofoldlM :: Monad m => (a0 -> Element (Identity a) -> m a0) -> a0 -> Identity a -> m a0 # ofoldMap1Ex :: Semigroup m => (Element (Identity a) -> m) -> Identity a -> m # ofoldr1Ex :: (Element (Identity a) -> Element (Identity a) -> Element (Identity a)) -> Identity a -> Element (Identity a) # ofoldl1Ex' :: (Element (Identity a) -> Element (Identity a) -> Element (Identity a)) -> Identity a -> Element (Identity a) # headEx :: Identity a -> Element (Identity a) # lastEx :: Identity a -> Element (Identity a) # unsafeHead :: Identity a -> Element (Identity a) # unsafeLast :: Identity a -> Element (Identity a) # maximumByEx :: (Element (Identity a) -> Element (Identity a) -> Ordering) -> Identity a -> Element (Identity a) # minimumByEx :: (Element (Identity a) -> Element (Identity a) -> Ordering) -> Identity a -> Element (Identity a) # oelem :: Element (Identity a) -> Identity a -> Bool # onotElem :: Element (Identity a) -> Identity a -> Bool #
MonoFunctor (Identity a) |
Instance details Defined in Data.MonoTraversable Methods omap :: (Element (Identity a) -> Element (Identity a)) -> Identity a -> Identity a #
MonoPointed (Identity a) |
Instance details Defined in Data.MonoTraversable Methods opoint :: Element (Identity a) -> Identity a #
MonoTraversable (Identity a) |
Instance details Defined in Data.MonoTraversable Methods otraverse :: Applicative f => (Element (Identity a) -> f (Element (Identity a))) -> Identity a -> f (Identity a) # omapM :: Applicative m => (Element (Identity a) -> m (Element (Identity a))) -> Identity a -> m (Identity a) #
Prim a => Prim (Identity a) | Since: primitive-0.6.5.0
Instance details Defined in Data.Primitive.Types Methods sizeOfType# :: Proxy (Identity a) -> Int# # sizeOf# :: Identity a -> Int# # alignmentOfType# :: Proxy (Identity a) -> Int# # alignment# :: Identity a -> Int# # indexByteArray# :: ByteArray# -> Int# -> Identity a # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Identity a #) # writeByteArray# :: MutableByteArray# s -> Int# -> Identity a -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Identity a -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Identity a # readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Identity a #) # writeOffAddr# :: Addr# -> Int# -> Identity a -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Identity a -> State# s -> State# s #
Unbox a => Unbox (Identity a) |
Instance details Defined in Data.Vector.Unboxed.Base
type Rep1 Identity | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity type Rep1 Identity = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
newtype MVector s (Identity a) |
Instance details Defined in Data.Vector.Unboxed.Base newtype MVector s (Identity a) = MV_Identity (MVector s a)
type Rep (Identity a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity type Rep (Identity a) = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
type Element (Identity a) |
Instance details Defined in Data.MonoTraversable type Element (Identity a) = a
newtype Vector (Identity a) |
Instance details Defined in Data.Vector.Unboxed.Base newtype Vector (Identity a) = V_Identity (Vector a)