| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cooked.MockChain.Staged
Contents
Description
This module provides a staged implementation of our MonadBlockChain. The
motivation behind this is to be able to modify traces using Ltl and
Tweak while they are interpreted.
Synopsis
- interpretAndRunWith :: (forall m. Monad m => MockChainT m a -> m res) -> StagedMockChain a -> [res]
- interpretAndRun :: StagedMockChain a -> [MockChainReturn a]
- type StagedMockChain = Staged (LtlOp (UntypedTweak InterpMockChain) MockChainBuiltin)
- data MockChainBuiltin a
- runTweakFrom :: InitialDistribution -> Tweak InterpMockChain a -> TxSkel -> [MockChainReturn (a, TxSkel)]
- type MonadModalBlockChain m = (MonadBlockChain m, MonadModal m, Modification m ~ UntypedTweak InterpMockChain)
- type InterpMockChain = MockChainT List
- somewhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> m a -> m a
- somewhere' :: MonadModal m => Ltl (Modification m) -> m a -> m a
- runTweak :: Tweak InterpMockChain a -> TxSkel -> [MockChainReturn (a, TxSkel)]
- everywhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> m a -> m a
- everywhere' :: MonadModal m => Ltl (Modification m) -> m a -> m a
- withTweak :: MonadModalBlockChain m => m x -> Tweak InterpMockChain a -> m x
- there :: MonadModalBlockChain m => Integer -> Tweak InterpMockChain b -> m a -> m a
- there' :: MonadModal m => Integer -> Ltl (Modification m) -> m a -> m a
Documentation
interpretAndRunWith :: (forall m. Monad m => MockChainT m a -> m res) -> StagedMockChain a -> [res] Source #
Interprets the staged mockchain then runs the resulting computation with a
custom function. This can be used, for example, to supply a custom
InitialDistribution by providing runMockChainTFrom.
interpretAndRun :: StagedMockChain a -> [MockChainReturn a] Source #
Same as interpretAndRunWith but using runMockChainT as the default way
to run the computation.
type StagedMockChain = Staged (LtlOp (UntypedTweak InterpMockChain) MockChainBuiltin) Source #
A StagedMockChain is a mockchain that can be modified using
Tweaks whenever a transaction is being sent for
validation. Selecting which transactions should be modified before going to
validations is done using Ltl formulas.
data MockChainBuiltin a Source #
Abstract representation of all the builtin functions of a MonadBlockChain
Instances
runTweakFrom :: InitialDistribution -> Tweak InterpMockChain a -> TxSkel -> [MockChainReturn (a, TxSkel)] Source #
Runs a Tweak from a given TxSkel and InitialDistribution within a
mockchain
type MonadModalBlockChain m = (MonadBlockChain m, MonadModal m, Modification m ~ UntypedTweak InterpMockChain) Source #
A modal mock chain is a mock chain that allows us to use LTL modifications
with Tweaks
type InterpMockChain = MockChainT List Source #
The semantic domain in which StagedMockChain gets interpreted
somewhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> m a -> m a Source #
Apply a Tweak to some transaction in the given Trace. The tweak must
apply at least once.
somewhere' :: MonadModal m => Ltl (Modification m) -> m a -> m a Source #
Apply an Ltl modification somewhere in the given Trace. The modification must apply at least once.
runTweak :: Tweak InterpMockChain a -> TxSkel -> [MockChainReturn (a, TxSkel)] Source #
everywhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> m a -> m a Source #
Apply a Tweak to every transaction in a given trace. This is also
successful if there are no transactions at all.
everywhere' :: MonadModal m => Ltl (Modification m) -> m a -> m a Source #
Apply an Ltl modification everywhere it can be (including nowhere if it does not apply). If the modification branches, this will branch at every location the modification can be applied.
withTweak :: MonadModalBlockChain m => m x -> Tweak InterpMockChain a -> m x Source #
Apply a Tweak to the next transaction in the given trace. The order of
arguments is reversed compared to somewhere and everywhere, because that
enables an idiom like
do ... endpoint arguments `withTweak` someModification ...
where endpoint builds and validates a single transaction depending on the
given arguments. Then withTweak says "I want to modify the transaction
returned by this endpoint in the following way".
there :: MonadModalBlockChain m => Integer -> Tweak InterpMockChain b -> m a -> m a Source #
Apply a Tweak to the (0-indexed) nth transaction in a given
trace. Successful when this transaction exists and can be modified.
there' :: MonadModal m => Integer -> Ltl (Modification m) -> m a -> m a Source #
Apply an Ltl modification to the (0-indexed) nth transaction in a given trace. Successful when this transaction exists and can be modified.
See also labelled' to select transactions based on
labels instead of their order.
Orphan instances
| MonadPlus m => MonadPlus (MockChainT m) Source # | |