cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.MockChain.Staged

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

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

Instances details
MonadFail StagedMockChain Source # 
Instance details

Defined in Cooked.MockChain.Staged

Methods

fail :: String -> StagedMockChain a #

Alternative StagedMockChain Source # 
Instance details

Defined in Cooked.MockChain.Staged

MonadBlockChain StagedMockChain Source # 
Instance details

Defined in Cooked.MockChain.Staged

MonadBlockChainBalancing StagedMockChain Source # 
Instance details

Defined in Cooked.MockChain.Staged

MonadBlockChainWithoutValidation StagedMockChain Source # 
Instance details

Defined in Cooked.MockChain.Staged

MonadError MockChainError StagedMockChain Source # 
Instance details

Defined in Cooked.MockChain.Staged

InterpLtl (UntypedTweak InterpMockChain) MockChainBuiltin InterpMockChain Source # 
Instance details

Defined in Cooked.MockChain.Staged

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 #

Runs a Tweak from a given TxSkel within a mockchain

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 # 
Instance details

Methods

mzero :: MockChainT m a #

mplus :: MockChainT m a -> MockChainT m a -> MockChainT m a #