| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cooked.MockChain.Runnable
Contents
Description
This module exposes the infrastructure to execute mockchain runs. In particular:
- The notion of initial distribution (a list of payments)
- The return types of the runs (raw and refined)
- The initial configuration with which to execute a run
- The notion of
RunnableMockChainto actually execute computations
Synopsis
- type InitialDistribution = [TxSkelOut]
- initialDistributionTemplate :: InitialDistribution
- distributionFromList :: IsTxSkelOutAllowedOwner owner => [(owner, [Value])] -> InitialDistribution
- type RawMockChainReturn a = (MockChainJournal, (MockChainState, Either MockChainError a))
- data MockChainReturn a where
- MockChainReturn :: {..} -> MockChainReturn a
- type FunOnMockChainResult a b = RawMockChainReturn a -> b
- unRawMockChainReturn :: FunOnMockChainResult a (MockChainReturn a)
- data MockChainConf a b where
- MockChainConf :: {..} -> MockChainConf a b
- mockChainConfTemplate :: MockChainConf a (MockChainReturn a)
- class RunnableMockChain effs where
- runMockChain :: MockChainState -> Sem effs a -> [RawMockChainReturn a]
- runMockChainFromConf :: (RunnableMockChain effs, Member MockChainWrite effs) => MockChainConf a b -> Sem effs a -> [b]
- runMockChainFromInitDist :: (RunnableMockChain effs, Member MockChainWrite effs) => InitialDistribution -> Sem effs a -> [MockChainReturn a]
- runMockChainFromInitDistTemplate :: (RunnableMockChain effs, Member MockChainWrite effs) => Sem effs a -> [MockChainReturn a]
- runMockChainDef :: (RunnableMockChain effs, Member MockChainWrite effs) => Sem effs a -> [MockChainReturn a]
Initial distribution of funds
type InitialDistribution = [TxSkelOut] Source #
Describes the initial distribution of UTxOs per user.
The following specifies a starting state where wallet 1 owns two UTxOs,
one with 42 Ada and one with 2 Ada and one TOK token; wallet 2 owns a
single UTxO with 10 Ada and wallet 3 has 10 Ada and a permanent value
i0 = distributionFromList $
[ (wallet 1 , [ ada 42 , ada 2 <> quickValue "TOK" 1 ]
, (wallet 2 , [ ada 10 ])
, (wallet 3 , [ ada 10 <> permanentValue "XYZ" 10])
]Note that payment issued through an initial distribution will be attached enough ADA to sustain themselves unless a fixed value is explicitly required.
initialDistributionTemplate :: InitialDistribution Source #
4 UTxOs with 100 Ada each, for each of the first 4 knownWallets
distributionFromList :: IsTxSkelOutAllowedOwner owner => [(owner, [Value])] -> InitialDistribution Source #
Creating a initial distribution with simple values assigned to owners
type RawMockChainReturn a = (MockChainJournal, (MockChainState, Either MockChainError a)) Source #
Raw return type of running a mockchain
data MockChainReturn a where Source #
The returned type when running a mockchain. This is both a reorganizing and
filtering of the natural returned type RawMockChainReturn.
Constructors
| MockChainReturn | |
Fields
| |
Instances
| Functor MockChainReturn Source # | |
Defined in Cooked.MockChain.Runnable Methods fmap :: (a -> b) -> MockChainReturn a -> MockChainReturn b # (<$) :: a -> MockChainReturn b -> MockChainReturn a # | |
| Show a => PrettyCooked (MockChainReturn a) Source # | |
Defined in Cooked.Pretty.MockChain Methods prettyCookedOpt :: PrettyCookedOpts -> MockChainReturn a -> DocCooked Source # prettyCooked :: MockChainReturn a -> DocCooked Source # | |
| Show a => PrettyCooked [MockChainReturn a] Source # | |
Defined in Cooked.Pretty.MockChain Methods prettyCookedOpt :: PrettyCookedOpts -> [MockChainReturn a] -> DocCooked Source # prettyCooked :: [MockChainReturn a] -> DocCooked Source # | |
type FunOnMockChainResult a b = RawMockChainReturn a -> b Source #
The type of functions transforming an element of type RawMockChainReturn a
into an element of type b
unRawMockChainReturn :: FunOnMockChainResult a (MockChainReturn a) Source #
Building a MockChainReturn from a RawMockChainReturn
data MockChainConf a b where Source #
Configuration from which to run a mockchain
Constructors
| MockChainConf | |
Fields
| |
mockChainConfTemplate :: MockChainConf a (MockChainReturn a) Source #
The default MockChainConf, which uses the default initial state and
initial distribution, and returns a refined MockChainReturn
class RunnableMockChain effs where Source #
The class of effects that represent a mockchain run
Methods
runMockChain :: MockChainState -> Sem effs a -> [RawMockChainReturn a] Source #
Runs a computation from an initial MockChainState, while returning a
list of RawMockChainReturn
Instances
| RunnableMockChain DirectEffs Source # | |
Defined in Cooked.MockChain.Instances Methods runMockChain :: MockChainState -> Sem DirectEffs a -> [RawMockChainReturn a] Source # | |
| RunnableMockChain FullEffs Source # | |
Defined in Cooked.MockChain.Instances Methods runMockChain :: MockChainState -> Sem FullEffs a -> [RawMockChainReturn a] Source # | |
| InterpretAlone extraEff => RunnableMockChain (ExtendedStagedEffs extraEff) Source # | |
Defined in Cooked.MockChain.Instances Methods runMockChain :: MockChainState -> Sem (ExtendedStagedEffs extraEff) a -> [RawMockChainReturn a] Source # | |
runMockChainFromConf :: (RunnableMockChain effs, Member MockChainWrite effs) => MockChainConf a b -> Sem effs a -> [b] Source #
Runs a RunnableMockChain from an initial MockChainConf
runMockChainFromInitDist :: (RunnableMockChain effs, Member MockChainWrite effs) => InitialDistribution -> Sem effs a -> [MockChainReturn a] Source #
Runs a RunnableMockChain from an initial distribution
runMockChainFromInitDistTemplate :: (RunnableMockChain effs, Member MockChainWrite effs) => Sem effs a -> [MockChainReturn a] Source #
Same as runMockChainFromInitDist using the initialDistributionTemplate
runMockChainDef :: (RunnableMockChain effs, Member MockChainWrite effs) => Sem effs a -> [MockChainReturn a] Source #
Runs a RunnableMockChain from a default configuration