CpsPreprocessor
cps.CpsPreprocessor
Typeclass for preprocessing expressions inside async blocks before CPS transformation occurs.
The preprocessor receives the body expression and the monad context. The context is passed explicitly because the body has type A (not a context function), so the context cannot be summoned inside the body.
Use cases:
- Durable monad: wrap vals with caching via ctx operations
- Tracing monad: add trace calls
- STM monad: add savepoints
Example implementation:
given CpsPreprocessor[Durable, DurableContext] with
inline def preprocess[A](inline body: A)(inline ctx: DurableContext): A =
${ DurablePreprocessMacro.impl[A]('body, 'ctx) }
The preprocessor macro can transform val definitions, control flow conditions, and other expressions as needed by the monad semantics, using ctx directly.
Type parameters
- C
-
The context type (subtype of CpsMonadContext[F])
- F
-
The monad type
Attributes
- Source
- CpsPreprocessor.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
In this article