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 UtxoState]
- type StagedMockChain = Staged MockChainOp
- runTweakFrom :: InitialDistribution -> Tweak InterpMockChain a -> TxSkel -> [MockChainReturn a TxSkel]
- type MonadModalBlockChain m = (MonadBlockChain m, MonadModal m, Modification m ~ UntypedTweak InterpMockChain)
- somewhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> m a -> m a
- runTweak :: Tweak InterpMockChain a -> TxSkel -> [MockChainReturn a TxSkel]
- everywhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> 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
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 UtxoState] Source #
type StagedMockChain = Staged MockChainOp Source #
runTweakFrom :: InitialDistribution -> Tweak InterpMockChain a -> TxSkel -> [MockChainReturn a TxSkel] Source #
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 Tweak
s
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.
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.
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.
Orphan instances
MonadPlus m => MonadPlus (MockChainT m) Source # | |