| Copyright | (c) 2021 Juan Pablo Royo Sales |
|---|---|
| License | BSD3 |
| Maintainer | juanpablo.royo@gmail.com |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
DynamicPipeline.Stage
Description
Synopsis
- data DynamicPipeline dpDefinition filterState filterParam st
- data Filter dpDefinition filterState filterParam st
- data Actor dpDefinition filterState filterParam monadicAction
- data GeneratorStage dpDefinition filterState filterParam st
- data Stage a
- type family ValidDP (a :: Bool) :: Constraint where ...
- type family IsDP (dpDefinition :: k) :: Bool where ...
- data DP st a
- data UnFoldFilter dpDefinition readElem st filterState filterParam l
- withDP :: IO a -> DP s a
- mkGenerator :: Stage (WithGenerator dpDefinition (Filter dpDefinition filterState filterParam st) (DP st)) -> Filter dpDefinition filterState filterParam st -> GeneratorStage dpDefinition filterState filterParam st
- mkFilter :: forall dpDefinition filterState filterParam st. WithFilter dpDefinition filterParam (StateT filterState (DP st)) -> Filter dpDefinition filterState filterParam st
- single :: forall dpDefinition filterState filterParam st. WithFilter dpDefinition filterParam (StateT filterState (DP st)) -> NonEmpty (Actor dpDefinition filterState filterParam (StateT filterState (DP st)))
- actor :: forall dpDefinition filterState filterParam st. WithFilter dpDefinition filterParam (StateT filterState (DP st)) -> Actor dpDefinition filterState filterParam (StateT filterState (DP st))
- (|>>>) :: forall dpDefinition filterState filterParam st. Actor dpDefinition filterState filterParam (StateT filterState (DP st)) -> Filter dpDefinition filterState filterParam st -> Filter dpDefinition filterState filterParam st
- (|>>) :: forall dpDefinition filterState filterParam st. Actor dpDefinition filterState filterParam (StateT filterState (DP st)) -> Actor dpDefinition filterState filterParam (StateT filterState (DP st)) -> Filter dpDefinition filterState filterParam st
- withSource :: forall (dpDefinition :: Type) st. WithSource dpDefinition (DP st) -> Stage (WithSource dpDefinition (DP st))
- withGenerator :: forall (dpDefinition :: Type) (filter :: Type) st. WithGenerator dpDefinition filter (DP st) -> Stage (WithGenerator dpDefinition filter (DP st))
- withSink :: forall (dpDefinition :: Type) st. WithSink dpDefinition (DP st) -> Stage (WithSink dpDefinition (DP st))
- mkDP :: forall dpDefinition filterState st filterParam filter gparams slr slw glr glw silr silw iparams oparams ls lsi. DPConstraint dpDefinition filterState st filterParam filter gparams slr slw glr glw silr silw iparams oparams ls lsi => Stage (WithSource dpDefinition (DP st)) -> GeneratorStage dpDefinition filterState filterParam st -> Stage (WithSink dpDefinition (DP st)) -> DP st ()
- runDP :: (forall st. DP st a) -> IO a
- unfoldF :: forall dpDefinition readElem st filterState filterParam l l1 l2 l3 b2 b3 l4. SpawnFilterConstraint dpDefinition readElem st filterState filterParam l l1 l2 l3 b2 b3 l4 => UnFoldFilter dpDefinition readElem st filterState filterParam l -> DP st (HList l)
- mkUnfoldFilter :: (readElem -> Bool) -> (readElem -> DP st ()) -> Filter dpDefinition filterState filterParam st -> (readElem -> filterState) -> ReadChannel readElem -> HList l -> UnFoldFilter dpDefinition readElem st filterState filterParam l
- mkUnfoldFilter' :: (readElem -> Bool) -> Filter dpDefinition filterState filterParam st -> (readElem -> filterState) -> ReadChannel readElem -> HList l -> UnFoldFilter dpDefinition readElem st filterState filterParam l
- mkUnfoldFilterForAll :: Filter dpDefinition filterState filterParam st -> (readElem -> filterState) -> ReadChannel readElem -> HList l -> UnFoldFilter dpDefinition readElem st filterState filterParam l
- mkUnfoldFilterForAll' :: (readElem -> DP st ()) -> Filter dpDefinition filterState filterParam st -> (readElem -> filterState) -> ReadChannel readElem -> HList l -> UnFoldFilter dpDefinition readElem st filterState filterParam l
Documentation
data DynamicPipeline dpDefinition filterState filterParam st Source #
DynamicPipeline data type which contains all the three Stages definitions that have been generated by other combinators like withSource,
withGenerator and withSink.
dpDefinition ~Source(Channel..):=>Generator(Channel..):=>Sink- DP Type level Flow Definition
filterState- State of the
StateTMonadthat is the local State of the Filter execution filterParam- Type of the First Parameter that is pass to the Filter when it is created by the Generator Anamorphism. Generator can change the type received from the Reader Channels.
st- Existential Scope of
DPMonad.
data Filter dpDefinition filterState filterParam st Source #
Filter Is the template definition of the Filter that may be spawned when reading elements on the Stream.
Filteris aNonEmptyList ofActors.- Each
Actoris executed sequentially on the that List when an Element arrive to thatFilterinstance. - All the
Filterexecution (a.k.a.forM_ actors runStage) executes in aStateTMonadto share an internal state amongActors.
dpDefinition ~Source(Channel..):=>Generator(Channel..):=>Sink- DP Type level Flow Definition
filterState- State of the
StateTMonadthat is the local State of the Filter execution filterParam- Type of the First Parameter that is pass to the Filter when it is created by the Generator Anamorphism. Generator can change the type received from the Reader Channels.
st- Existential Scope of
DPMonad.
Instances
| Generic (Filter dpDefinition filterState filterParam st) Source # | |
Defined in DynamicPipeline.Stage | |
| Wrapped (Filter s' s a param) Source # | |
Defined in DynamicPipeline.Stage Associated Types type Unwrapped (Filter s' s a param) | |
| type Rep (Filter dpDefinition filterState filterParam st) Source # | |
Defined in DynamicPipeline.Stage type Rep (Filter dpDefinition filterState filterParam st) = D1 ('MetaData "Filter" "DynamicPipeline.Stage" "dynamic-pipeline-0.3.2.0-inplace" 'True) (C1 ('MetaCons "Filter" 'PrefixI 'True) (S1 ('MetaSel ('Just "unFilter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty (Actor dpDefinition filterState filterParam (StateT filterState (DP st))))))) | |
| type Unwrapped (Filter s' s a param) Source # | |
Defined in DynamicPipeline.Stage | |
data Actor dpDefinition filterState filterParam monadicAction Source #
Actor Is a particular Stage computation inside a Filter.
dpDefinition ~Source(Channel..):=>Generator(Channel..):=>Sink- DP Type level Flow Definition
filterState- State of the
StateTMonadthat is the local State of the Filter execution filterParam- Type of the First Parameter that is pass to the Filter when it is created by the Generator Anamorphism. Generator can change the type received from the Reader Channels.
monadicActionMonadWrapped inStateT.
data GeneratorStage dpDefinition filterState filterParam st Source #
GeneartorStage is a special Stage data type according to DPP Definition which contains a Filter template definition,
in orther to know how to spawn a new Filter if it is needed, and the Stage of the Generator to allow the user to perform some computation
in that case.
dpDefinition ~Source(Channel..):=>Generator(Channel..):=>Sink- DP Type level Flow Definition
filterState- State of the
StateTMonadthat is the local State of the Filter execution filterParam- Type of the First Parameter that is pass to the Filter when it is created by the Generator Anamorphism. Generator can change the type received from the Reader Channels.
st- Existential Scope of
DPMonad.
type family ValidDP (a :: Bool) :: Constraint where ... Source #
FCF - Type Level Defunctionalization
ValidDP Check if IsDP is True
aIsDP dpDefinition ~ 'True
Throw a TypeError if Grammar is not correct
Equations
| ValidDP 'True = () | |
| ValidDP 'False = TypeError ((((((('Text "Invalid Semantic for Building DP Program" :$$: 'Text "Language Grammar:") :$$: 'Text "DP -> Source CHANS :=> Generator CHANS :=> Sink") :$$: 'Text "DP -> Source CHANS :=> Generator CHANS :=> FEEDBACK :=> Sink") :$$: 'Text "CHANS -> Channel CH") :$$: 'Text "FEEDBACK -> FeedbackChannel CH") :$$: 'Text "CH -> Type :<+> CH | Eof") :$$: 'Text "Example: 'Source (Channel (Int :<+> Int)) :=> Generator (Channel (Int :<+> Int)) :=> Sink'") |
type family IsDP (dpDefinition :: k) :: Bool where ... Source #
FCF - Type Level Defunctionalization
IsDP Validates if DP Flow Type Level Definition is Correct according to the Grammar
Equations
| IsDP (Source (Channel inToGen) :=> (Generator (Channel genToOut) :=> Sink)) = And (IsDP (Source (Channel inToGen))) (IsDP (Generator (Channel genToOut))) | |
| IsDP (Source (Channel inToGen) :=> (Generator (Channel genToOut) :=> (FeedbackChannel toSource :=> Sink))) = And (IsDP (Source (Channel inToGen))) (IsDP (Generator (Channel genToOut))) | |
| IsDP (Source (Channel (a :<+> more))) = IsDP (Source (Channel more)) | |
| IsDP (Source (Channel Eof)) = 'True | |
| IsDP (Generator (Channel (a :<+> more))) = IsDP (Generator (Channel more)) | |
| IsDP (Generator (Channel a)) = 'True | |
| IsDP x = 'False |
DP is the only Monadic Action allowed to run a DP Defined Flow.
It is restricted on Scope by its Existential Type st in order to not escape out from this Monadic Context.
data UnFoldFilter dpDefinition readElem st filterState filterParam l Source #
UnFoldFilter is a wrapper Data Type that contains all the information needed to spawn Filter instances according to DPP.
The user will have the capability to select how those filters are going to be spawned, for example on each read element, how to setup
initial states of StateT Monad on Actor computations in filters, among others.
dpDefinition ~Source(Channel..):=>Generator(Channel..):=>Sink- DP Type level Flow Definition
readElem- Type of the element that is being read from the Selected Channel in the
GeneratorStage st- Existential Scope of
DPMonad. filterState- State of the
StateTMonadthat is the local State of the Filter execution filterParam- Type of the First Parameter that is pass to the Filter when it is created by the Generator Anamorphism. Generator can change the type received from the Reader Channels.
Arguments
| :: Stage (WithGenerator dpDefinition (Filter dpDefinition filterState filterParam st) (DP st)) | Generator |
| -> Filter dpDefinition filterState filterParam st |
|
| -> GeneratorStage dpDefinition filterState filterParam st |
Smart Constructor of GeneratorStage.
Arguments
| :: forall dpDefinition filterState filterParam st. WithFilter dpDefinition filterParam (StateT filterState (DP st)) | Associated type family to Generate Function Signature |
| -> Filter dpDefinition filterState filterParam st |
Smart Constructor of Filter.
Arguments
| :: forall dpDefinition filterState filterParam st. WithFilter dpDefinition filterParam (StateT filterState (DP st)) | Associated type family to Generate Function Signature |
| -> Actor dpDefinition filterState filterParam (StateT filterState (DP st)) |
Smart Constructor of Actor.
Arguments
| :: forall (dpDefinition :: Type) st. WithSource dpDefinition (DP st) | Associated type family to Generate Function Signature |
| -> Stage (WithSource dpDefinition (DP st)) |
Arguments
| :: forall (dpDefinition :: Type) (filter :: Type) st. WithGenerator dpDefinition filter (DP st) | Associated type family to Generate Function Signature |
| -> Stage (WithGenerator dpDefinition filter (DP st)) |
Arguments
| :: forall (dpDefinition :: Type) st. WithSink dpDefinition (DP st) | Associated type family to Generate Function Signature |
| -> Stage (WithSink dpDefinition (DP st)) |
Arguments
| :: forall dpDefinition filterState st filterParam filter gparams slr slw glr glw silr silw iparams oparams ls lsi. DPConstraint dpDefinition filterState st filterParam filter gparams slr slw glr glw silr silw iparams oparams ls lsi | |
| => Stage (WithSource dpDefinition (DP st)) |
|
| -> GeneratorStage dpDefinition filterState filterParam st |
|
| -> Stage (WithSink dpDefinition (DP st)) | |
| -> DP st () |
Smart constructor for DynamicPipeline Definition
Arguments
| :: forall dpDefinition readElem st filterState filterParam l l1 l2 l3 b2 b3 l4. SpawnFilterConstraint dpDefinition readElem st filterState filterParam l l1 l2 l3 b2 b3 l4 | |
| => UnFoldFilter dpDefinition readElem st filterState filterParam l | |
| -> DP st (HList l) | Return the list of |
Run UnFoldFilter
Arguments
| :: (readElem -> Bool) | Given a new Element determine if we need to interpose a new Filter or not |
| -> (readElem -> DP st ()) | For each element that the Filter is consuming allow to do something outside the filter with that element. For example trace or debug |
| -> Filter dpDefinition filterState filterParam st |
|
| -> (readElem -> filterState) | Given the First element in this Filter Instance how to Initiate Internal |
| -> ReadChannel readElem | Main |
| -> HList l |
|
| -> UnFoldFilter dpDefinition readElem st filterState filterParam l |
Smart Constructor for UnFoldFilter
Arguments
| :: (readElem -> Bool) | |
| -> Filter dpDefinition filterState filterParam st | |
| -> (readElem -> filterState) | |
| -> ReadChannel readElem | |
| -> HList l | |
| -> UnFoldFilter dpDefinition readElem st filterState filterParam l |
Smart Constructor for UnFoldFilter which bypass to do something externally on each read element
Arguments
| :: Filter dpDefinition filterState filterParam st | |
| -> (readElem -> filterState) | |
| -> ReadChannel readElem | |
| -> HList l | |
| -> UnFoldFilter dpDefinition readElem st filterState filterParam l |
Smart Constructor for UnFoldFilter That creates a Filter for each element on the Read Channel and interpose on Front of Generator Stage
and Last Filter
Source ---> Filter1 ---> Filter2 ... ---> FilterN ---> Generator ---> Sink
mkUnfoldFilterForAll' Source #
Arguments
| :: (readElem -> DP st ()) | |
| -> Filter dpDefinition filterState filterParam st | |
| -> (readElem -> filterState) | |
| -> ReadChannel readElem | |
| -> HList l | |
| -> UnFoldFilter dpDefinition readElem st filterState filterParam l |
Idem for mkUnfoldFilterForAll but do something on each Element externally