dynamic-pipeline-0.3.1.0: Library Type Safe implementation of Dynamic Pipeline Paradigm (DPP).
Copyright(c) 2021 Juan Pablo Royo Sales
LicenseBSD3
Maintainerjuanpablo.royo@gmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

DynamicPipeline.Channel

Description

 
Synopsis

Documentation

data ReadChannel a Source #

ReadChannel can only read values of a previously written Channel. It is connected to a WriteChannel but hidden for the user

a
Type that this Channel can read

data WriteChannel a Source #

WriteChannel can only write values into some Channel Queue

a
Type that this Channel can write

(|=>) :: MonadIO m => ReadChannel a -> WriteChannel a -> m () infixl 5 Source #

Same as map_ but with id combinator

(|=>|) :: MonadIO m => ReadChannel a -> WriteChannel b -> (a -> b) -> m () infixl 5 Source #

Alias mapF_

(|>=>) :: MonadIO m => ReadChannel a -> WriteChannel b -> (a -> m (Maybe b)) -> m () infixr 5 Source #

Alias mapM_

(|>=>|) :: MonadIO m => ReadChannel a -> WriteChannel b -> (a -> m (Maybe b)) -> m () infixr 5 Source #

Alias mapMF_

mapF_ Source #

Arguments

:: MonadIO m 
=> ReadChannel a

ReadChannel

-> WriteChannel b

ReadChannel

-> (a -> b)

Monadic Transformation to do with read element

-> m () 

Same as map_ but mark Eof Channel after all processing

map_ Source #

Arguments

:: MonadIO m 
=> ReadChannel a

ReadChannel

-> WriteChannel b

ReadChannel

-> (a -> b)

Monadic Transformation to do with read element

-> m () 

map_ is a Natural Transformation from consumer ReadChannel to some producer WriteChannel applying a transformation with function f

mapM_ Source #

Arguments

:: MonadIO m 
=> ReadChannel a

ReadChannel

-> WriteChannel b

ReadChannel

-> (a -> m (Maybe b))

Monadic Transformation to do with read element

-> m () 

Same as map_ But applying a Monadic mapping

mapMF_ Source #

Arguments

:: MonadIO m 
=> ReadChannel a

ReadChannel

-> WriteChannel b

ReadChannel

-> (a -> m (Maybe b))

Monadic Transformation to do with read element

-> m () 

Same as mapM_ but mark Eof Channel after all processing

foldM_ Source #

Arguments

:: MonadIO m 
=> ReadChannel a

ReadChannel

-> (a -> m ())

Computation to do with read element

-> m () 

foldM_ is a Catamorphism for consuming a ReadChannel and do some Monadic m computation with each element

foldWithM_ Source #

Arguments

:: MonadIO m 
=> ReadChannel a

ReadChannel

-> m ()

Computation to do at the end of the channel

-> (a -> m ())

Computation to do with read element

-> m () 

Idem foldM_ but allows pass a monadic computation to perform at the end of the Channel

push :: MonadIO m => a -> WriteChannel a -> m () Source #

Push element a into WriteChannel

pull :: MonadIO m => ReadChannel a -> m (Maybe a) Source #

Pull element Maybe a from ReadChannel

unfoldM Source #

Arguments

:: forall m a b. MonadIO m 
=> m a

Monadic Seed

-> (a -> b)

Map input from seed to something to be written in Channel

-> m Bool

When stop unfolding

-> WriteChannel b

WriteChannel to write input seed elements

-> m () 

Coalgebra with Monadic computation to Feed some WriteChannel

m
Monadic computation wrapping Coalgebra
a
Element get from some Source and to be write in some Channel

| unfold from a Monadic seed m a to a WriteChannel

unfoldFile Source #

Arguments

:: MonadIO m 
=> FilePath

Seed FilePath to read from

-> WriteChannel b

WriteChannel to write File contents

-> (ByteString -> b)

Transform ByteString read from File to something meaningful for your App

-> m () 

Using unfoldM, unfold from file

unfoldT :: (MonadIO m, Foldable t) => t a -> WriteChannel b -> (a -> b) -> m () Source #

Idem unfoldM but for Foldable, for example a List [a]. Useful for testing purpose

newChannel :: forall a. IO (WriteChannel a, ReadChannel a) Source #

Warning: INTERNAL USE

end :: WriteChannel a -> IO () Source #

Warning: INTERNAL USE

finish :: MonadIO m => WriteChannel a -> m () Source #

Finalize Channel to indicate EOF mark and allow progress on following consumers