cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.MockChain.Tweak

Description

This module applies the Tweak effect for the purpose of modifying transaction skeleton before sending them for validation.

Synopsis

Modifying mockchain runs using tweaks

reinterpretMockChainWriteWithTweak :: forall tweakEffs effs a. (Members '[ModifyLocally (UntypedTweak tweakEffs), NonDet] effs, Subsume tweakEffs effs) => Sem (MockChainWrite : effs) a -> Sem (MockChainWrite : effs) a Source #

Reinterpretes MockChainWrite in itself, when the ModifyLocally effect exists in the stack, applying the relevant modifications in the process.

Typed and Untyped tweaks geared for TxSkel

type TypedTweak tweakEffs a = Sem (Tweak : (NonDet : tweakEffs)) a Source #

A stack of effects starting with Tweak and NonDet

data UntypedTweak tweakEffs where Source #

Wrapping up typed tweaks to existentially quantify on their return type

Constructors

UntypedTweak :: TypedTweak tweakEffs a -> UntypedTweak tweakEffs 

Instances

Instances details
RunnableMockChain FullEffs Source # 
Instance details

Defined in Cooked.MockChain.Instances

InterpretAlone extraEff => RunnableMockChain (ExtendedStagedEffs extraEff) Source # 
Instance details

Defined in Cooked.MockChain.Instances

Modalities to deploy UntypedTweaks on time

somewhere :: Members '[ModifyGlobally (UntypedTweak tweakEffs)] effs => TypedTweak tweakEffs b -> Sem effs a -> Sem effs a Source #

Applies a Tweak to every step in a trace where it is applicable, branching at any such locations. The tweak must apply at least once.

everywhere :: Members '[ModifyGlobally (UntypedTweak tweakEffs)] effs => TypedTweak tweakEffs b -> Sem effs a -> Sem effs a Source #

Applies a Tweak to every transaction in a given trace. Fails if the tweak fails anywhere in the trace.

nowhere :: Members '[ModifyGlobally (UntypedTweak tweakEffs)] effs => TypedTweak tweakEffs b -> Sem effs a -> Sem effs a Source #

Ensures a given Tweak can never successfully be applied in a computation, and leaves the computation unchanged.

whenAble :: Members '[ModifyGlobally (UntypedTweak tweakEffs)] effs => TypedTweak tweakEffs b -> Sem effs a -> Sem effs a Source #

Apply a given Tweak at every location in a computation where it does not fail, which might never occur.

there :: Members '[ModifyGlobally (UntypedTweak tweakEffs)] effs => Integer -> TypedTweak tweakEffs b -> Sem effs a -> Sem effs a Source #

Apply a Tweak 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 index.

withTweak :: Members '[ModifyGlobally (UntypedTweak tweakEffs)] effs => Sem effs a -> TypedTweak tweakEffs b -> Sem effs a Source #

Apply a Tweak to the next transaction in the given trace. The order of arguments 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".