marconi-core-1.2.0.0: Modular indexing for rewindable ledger
Safe HaskellSafe-Inferred
LanguageHaskell2010

Marconi.Core.Preprocessor

Description

Preprocessors are used to transform the incoming events of an indexer, generally in a Worker.

Preprocessors can carry an internal state, that can be updated on each incoming ProcessingInput.

Preprocessors are composable using Category and Arrow operators. (., >>> and <<<).

Synopsis

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