Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Marconi.Core.Preprocessor
Description
Preprocessor
s are used to transform the incoming events of an indexer, generally in a Worker
.
Preprocessor
s can carry an internal state, that can be updated on each incoming ProcessingInput
.
Preprocessor
s are composable using Category
and Arrow
operators.
(.
, >>>
and <<<
).
Synopsis
- type Preprocessor m point a b = ScanM m [ProcessedInput point a] [ProcessedInput point b]
- runPreprocessor :: Monad m => Preprocessor m point a b -> [ProcessedInput point a] -> m ([ProcessedInput point b], Preprocessor m point a b)
- mapEvent :: Monad m => (a -> b) -> Preprocessor m point a b
- mapMaybeEvent :: forall m point a b. Monad m => (a -> Maybe b) -> Preprocessor m point a b
- traverseEvent :: Monad m => (a -> m b) -> Preprocessor m point a b
- traverseMaybeEvent :: Monad m => (a -> m (Maybe b)) -> Preprocessor m point a b
- scanEvent :: forall m s point a b. Monad m => (a -> State s b) -> s -> Preprocessor m point a b
- scanEventM :: forall m s point a b. Monad m => (a -> StateT s m b) -> m s -> Preprocessor m point a b
- scanMaybeEvent :: forall m s point a b. Monad m => (a -> State s (Maybe b)) -> s -> Preprocessor m point a b
- scanMaybeEventM :: forall m s point a b. Monad m => (a -> StateT s m (Maybe b)) -> m s -> Preprocessor m point a b
- preprocessor :: Monad m => (ProcessedInput point a -> State s [ProcessedInput point b]) -> s -> Preprocessor m point a b
- preprocessorM :: Monad m => (ProcessedInput point a -> StateT s m [ProcessedInput point b]) -> m s -> Preprocessor m point a b
Documentation
type Preprocessor m point a b = ScanM m [ProcessedInput point a] [ProcessedInput point b] #
Stateful tranformer. Map a list of preprocessor actions to a new lis of actions. Actions should be read from left to right element of the list
runPreprocessor :: Monad m => Preprocessor m point a b -> [ProcessedInput point a] -> m ([ProcessedInput point b], Preprocessor m point a b) #
Apply a preprocessor to an element and retrieve the updated transformer
Stateless preprocessors
mapEvent :: Monad m => (a -> b) -> Preprocessor m point a b #
Lift a function on events to a preprocessor
mapMaybeEvent :: forall m point a b. Monad m => (a -> Maybe b) -> Preprocessor m point a b #
Lift a function that may emit an event to a preprocessor.
traverseEvent :: Monad m => (a -> m b) -> Preprocessor m point a b #
Lift an effectful function on events to a preprocessor
traverseMaybeEvent :: Monad m => (a -> m (Maybe b)) -> Preprocessor m point a b #
Lift an effectful function that may emit an event to a preprocessor
Stateful preprocessors
scanEvent :: forall m s point a b. Monad m => (a -> State s b) -> s -> Preprocessor m point a b #
Create a tranformer from a strict stateful computation
scanEventM :: forall m s point a b. Monad m => (a -> StateT s m b) -> m s -> Preprocessor m point a b #
Create a tranformer from a strict stateful computation
scanMaybeEvent :: forall m s point a b. Monad m => (a -> State s (Maybe b)) -> s -> Preprocessor m point a b #
Create a tranformer from a strict stateful computation
scanMaybeEventM :: forall m s point a b. Monad m => (a -> StateT s m (Maybe b)) -> m s -> Preprocessor m point a b #
Create a tranformer from a strict stateful computation
Generic builder
preprocessor :: Monad m => (ProcessedInput point a -> State s [ProcessedInput point b]) -> s -> Preprocessor m point a b #
Lift a stateful function as a preprocessor
preprocessorM :: Monad m => (ProcessedInput point a -> StateT s m [ProcessedInput point b]) -> m s -> Preprocessor m point a b #
Lift a stateful and effectful function as a preprocessor