Some combinators to express breadth-first evaluation of catamorphisms, which allows you to stepwise evaluate the results of children. If, during the evaluation of an alternative, a choice needs to be made between taking the results of its children, with these combinators, you can stepwise evaluate the children in parallel, until a choice can be made. Until a choice is made, evaluation proceeds strictly; after a choice is made, evaluation proceeds lazily. What constitutes to be a step is determined by the callee.
- newtype Sem i n = Sem (Inh n -> Comp i n)
- data family Inh n
- data family Syn n
- data Comp i n
- invoke :: Sem i n -> Inh n -> Comp i n
- final :: Syn n -> Comp i n
- info :: i -> Comp i n -> Comp i n
- resume :: Comp i m -> (Syn m -> Comp i n) -> Comp i n
- inject :: i -> Comp i Inject
- sem_Inject :: Sem i Inject
- data Inject
- lazyEval :: Comp i a -> Syn a
- oneStep :: Comp i a -> Outcome i a
- data Outcome i a
Documentation
Semantics of a nonterminal of type n
as a function from inherited
attributes (Inh n
) to a computation Comp i n
of synthesized attributes (Syn n
).
Computation of synthesized attributes of nonterminal of type n
.
It is a trace of Info
-effects, that keeps track of the intermediate
states of the tree (using Pending
), ending ultimately in the
synthesized values (using Final
).
Operationally, we lift Info
-values over Pending
-values, thereby
gradually rewriting the latter, until it results in a Final
.
resume :: Comp i m -> (Syn m -> Comp i n) -> Comp i nSource
Create a |Pending| computation that waits for the given computation.
sem_Inject :: Sem i InjectSource
lazyEval :: Comp i a -> Syn aSource
Lazy evaluation of a computation. Note: we cannot inspect the effect-trace, as it would sequentialize the evaluation of children.