Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- gauss ∷ Floating a ⇒ a → a → a → a
- class (Eq x, Show x, Typeable x) ⇒ Adds x where
- zero ∷ x
- one ∷ x
- add ∷ x → x → x
- minus ∷ [String] → x → x → x
- increaseBy1 ∷ Int → Int
- decreaseBy1 ∷ Int → Int
- partition ∷ x → [String] → Int → x → Gen [x]
- genAdds ∷ [String] → AddsSpec x → Gen x
- fromI ∷ [String] → Int → x
- toI ∷ x → Int
- genSmall ∷ Gen Int
- runOrdCondition ∷ OrdCond → x → x → Bool
- supportsNegative ∷ x → Bool
- smallerOf ∷ x → x → x
- sumAdds ∷ (Foldable t, Adds c) ⇒ t c → c
- lensAdds ∷ (Foldable t, Adds b) ⇒ Lens' a b → t a → b
- genFromAddsSpec ∷ [String] → AddsSpec c → Gen Int
- genFromNonNegAddsSpec ∷ [String] → AddsSpec c → Gen Int
- class (Show x, Adds x) ⇒ Sums t x | t → x where
- genTxOutX ∷ Reflect era ⇒ Proof era → Coin → Gen (TxOutF era)
- genValueX ∷ Reflect era ⇒ Proof era → Coin → Gen (ValueF era)
- updateRew ∷ ∀ c. Coin → Reward c → Reward c
- class Show t ⇒ Sizeable t where
- class Count t where
- data TxAuxDataF era where
- TxAuxDataF ∷ Proof era → TxAuxData era → TxAuxDataF era
- hashTxAuxDataF ∷ Reflect era ⇒ TxAuxDataF era → AuxiliaryDataHash (EraCrypto era)
- unTxAuxData ∷ TxAuxDataF era → TxAuxData era
- pcAuxData ∷ Proof era → TxAuxData era → PDoc
- genTxAuxDataF ∷ Proof era → Gen (TxAuxDataF era)
- data TxF era where
- unTxF ∷ TxF era → Tx era
- data TxWitsF era where
- unTxWitsF ∷ TxWitsF era → TxWits era
- data TxBodyF era where
- unTxBodyF ∷ TxBodyF era → TxBody era
- data TxCertF era where
- unTxCertF ∷ TxCertF era → TxCert era
- data PlutusPurposeF era where
- PlutusPurposeF ∷ Proof era → PlutusPurpose AsIxItem era → PlutusPurposeF era
- unPlutusPurposeF ∷ PlutusPurposeF era → PlutusPurpose AsIxItem era
- data PlutusPointerF era where
- PlutusPointerF ∷ Proof era → PlutusPurpose AsIx era → PlutusPointerF era
- unPlutusPointerF ∷ PlutusPointerF era → PlutusPurpose AsIx era
- data TxOutF era where
- unTxOut ∷ TxOutF era → TxOut era
- data ValueF era where
- unValue ∷ ValueF era → Value era
- data PParamsF era where
- unPParams ∷ PParamsF era → PParams era
- pparamsWrapperL ∷ Lens' (PParamsF era) (PParams era)
- data PParamsUpdateF era where
- PParamsUpdateF ∷ Proof era → PParamsUpdate era → PParamsUpdateF era
- unPParamsUpdate ∷ PParamsUpdateF era → PParamsUpdate era
- pparamsUpdateWrapperL ∷ Lens' (PParamsUpdateF era) (PParamsUpdate era)
- data ProposedPPUpdatesF era where
- ProposedPPUpdatesF ∷ Proof era → ProposedPPUpdates era → ProposedPPUpdatesF era
- unProposedPPUpdates ∷ ProposedPPUpdatesF era → ProposedPPUpdates era
- proposedCoreL ∷ Lens' (ProposedPPUpdates era) (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era))
- proposedWrapperL ∷ Lens' (ProposedPPUpdatesF era) (ProposedPPUpdates era)
- coreMapL ∷ Proof era → Lens' (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)) (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdateF era))
- proposedMapL ∷ Lens' (ProposedPPUpdatesF era) (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdateF era))
- data GovState era = GovState (Proof era) (GovState era)
- unGovState ∷ GovState era → GovState era
- govProposedL ∷ Lens' (GovState era) (ShelleyGovState era)
- getPPUP ∷ ∀ era. Proof era → GovState era → ShelleyGovState era
- putPPUP ∷ ∀ era. Proof era → ShelleyGovState era → GovState era
- liftUTxO ∷ Map (TxIn (EraCrypto era)) (TxOutF era) → UTxO era
- genValue ∷ Proof era → Gen (ValueF era)
- genTxOut ∷ Proof era → Gen (TxOutF era)
- genPParams ∷ Proof era → Gen (PParamsF era)
- genFuturePParams ∷ Proof era → Gen (FuturePParams era)
- genPParamsUpdate ∷ Proof era → Gen (PParamsUpdateF era)
- genProposedPPUpdates ∷ Proof era → Gen (ProposedPPUpdatesF era)
- genGovState ∷ Proof era → Gen (GovState era)
- genUTxO ∷ Proof era → Gen (UTxO era)
- data ScriptsNeededF era where
- ScriptsNeededF ∷ Proof era → ScriptsNeeded era → ScriptsNeededF era
- unScriptsNeededF ∷ ScriptsNeededF era → ScriptsNeeded era
- data ScriptF era where
- unScriptF ∷ ScriptF era → Script era
- genScriptF ∷ Era era ⇒ Proof era → Gen (ScriptF era)
- zeroCount ∷ Show a ⇒ [Char] → a → [Char]
- legalCallPartition ∷ [String] → String → Integer → Int → Integer → Maybe [String]
- integerPartition ∷ [String] → String → Integer → Int → Integer → Gen [Integer]
- partitionRational ∷ Rational → [String] → Int → Rational → Gen [Rational]
- partitionCoin ∷ Coin → [String] → Int → Coin → Gen [Coin]
- partitionDeltaCoin ∷ DeltaCoin → [String] → Int → DeltaCoin → Gen [DeltaCoin]
- partitionInt ∷ Int → [String] → Int → Int → Gen [Int]
- partitionWord64 ∷ Word64 → [String] → Int → Word64 → Gen [Word64]
- partitionNatural ∷ Natural → [String] → Int → Natural → Gen [Natural]
- ordCondToSize ∷ ∀ a. Adds a ⇒ (String, OrdCond, a) → Size
- varOnLeft ∷ Adds a ⇒ String → OrdCond → a → AddsSpec c
- varOnLeftSize ∷ Adds a ⇒ String → OrdCond → a → Size
- varOnRight ∷ Adds a ⇒ [String] → a → OrdCond → a → String → AddsSpec c
- varOnRightSize ∷ Adds a ⇒ [String] → a → OrdCond → a → String → Size
- varOnLeftNeg ∷ Adds a ⇒ String → OrdCond → a → AddsSpec c
- varOnRightNeg ∷ Adds a ⇒ a → OrdCond → a → String → AddsSpec c
- reverseOrdCond ∷ OrdCond → OrdCond
- data OrdCond
- runOrdCond ∷ Ord c ⇒ OrdCond → c → c → Bool
- data AddsSpec c where
- AddsSpecSize ∷ String → Size → AddsSpec c
- AddsSpecAny ∷ AddsSpec c
- AddsSpecNever ∷ [String] → AddsSpec c
- showAddsSpec ∷ AddsSpec c → String
- mergeAddsSpec ∷ AddsSpec c → AddsSpec c → AddsSpec c
- vLeft ∷ String → OrdCond → Int → AddsSpec c
- vLeftSize ∷ String → OrdCond → Int → Size
- vRight ∷ Int → OrdCond → Int → String → AddsSpec c
- vRightSize ∷ Int → OrdCond → Int → String → Size
- vLeftNeg ∷ String → OrdCond → Int → AddsSpec c
- vRightNeg ∷ Int → OrdCond → Int → String → AddsSpec c
Documentation
class (Eq x, Show x, Typeable x) ⇒ Adds x where Source #
The Adds class
Some methods of Adds
like minus
, genAdds
, partition
and fromI
are partial.
That is they might not be defined on all inputs. The `[string]` is a representation
of a stack trace, that describes what the sytem was doing, so if the function is partial
it can raise an appropriate error. The function
Test.Cardano.Ledger.Constrained.Combinators(errorMess) is used to raise an error
and properly report the stack trace.
zero, one, add, minus, partition, genAdds, fromI, toI, genSmall, runOrdCondition, supportsNegative, smallerOf
Additive identity
Just the unit of increment.
Add two of these
minus ∷ [String] → x → x → x Source #
Subtract one from another
increaseBy1 ∷ Int → Int Source #
Increase by unit of increment
decreaseBy1 ∷ Int → Int Source #
Decrease by unit of increment
partition ∷ x → [String] → Int → x → Gen [x] Source #
Generate a list of values
partition 7 trace 4 235
generate a list of length 4 that
adds up t0 235, where the smallest number is >= 7
genAdds ∷ [String] → AddsSpec x → Gen x Source #
Generate a single value
genAdds trace spec
generates an x
in the range specified by spec
fromI ∷ [String] → Int → x Source #
Analogous to fromIntegral, translate an Int to an appropriate x
translate an x
Int to an appropriate Int
Used in testing to get appropriate smallest
values to test
'partition smallest trace count total'. The generator should choose from
several values appropriate for the type x
. choose [0,1,2] would be
appropriate for Natural, since there are no negative Natural numbers.
runOrdCondition ∷ OrdCond → x → x → Bool Source #
supportsNegative ∷ x → Bool Source #
Instances
class Show t ⇒ Sizeable t where Source #
Instances
Sizeable Word64 Source # | |
Sizeable Coin Source # | |
Sizeable EpochNo Source # | |
Sizeable SlotNo Source # | |
Sizeable Natural Source # | |
Sizeable Int Source # | |
EraPParams era ⇒ Sizeable (Proposals era) Source # | |
Sizeable (MultiAsset c) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes getSize ∷ MultiAsset c → Int Source # | |
Show t ⇒ Sizeable (Set t) Source # | |
Show t ⇒ Sizeable [t] Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes | |
(Show dom, Show rng) ⇒ Sizeable (Map dom rng) Source # | |
canFollow ∷ t → t → Bool Source #
'canFollow x y', is x
an appropriate successor to y
Generate the predecessor, given the successor
Generate the successor, given the predecessor
data TxAuxDataF era where Source #
TxAuxDataF ∷ Proof era → TxAuxData era → TxAuxDataF era |
Instances
Show (TxAuxDataF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes | |
Eq (TxAuxDataF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes (==) ∷ TxAuxDataF era → TxAuxDataF era → Bool Source # (/=) ∷ TxAuxDataF era → TxAuxDataF era → Bool Source # |
hashTxAuxDataF ∷ Reflect era ⇒ TxAuxDataF era → AuxiliaryDataHash (EraCrypto era) Source #
unTxAuxData ∷ TxAuxDataF era → TxAuxData era Source #
genTxAuxDataF ∷ Proof era → Gen (TxAuxDataF era) Source #
data PlutusPurposeF era where Source #
PlutusPurposeF ∷ Proof era → PlutusPurpose AsIxItem era → PlutusPurposeF era |
Instances
Show (PlutusPurposeF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes | |
Eq (PlutusPurposeF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes (==) ∷ PlutusPurposeF era → PlutusPurposeF era → Bool Source # (/=) ∷ PlutusPurposeF era → PlutusPurposeF era → Bool Source # |
unPlutusPurposeF ∷ PlutusPurposeF era → PlutusPurpose AsIxItem era Source #
data PlutusPointerF era where Source #
PlutusPointerF ∷ Proof era → PlutusPurpose AsIx era → PlutusPointerF era |
Instances
Show (PlutusPointerF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes | |
Eq (PlutusPointerF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes (==) ∷ PlutusPointerF era → PlutusPointerF era → Bool Source # (/=) ∷ PlutusPointerF era → PlutusPointerF era → Bool Source # | |
Ord (PlutusPointerF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes compare ∷ PlutusPointerF era → PlutusPointerF era → Ordering Source # (<) ∷ PlutusPointerF era → PlutusPointerF era → Bool Source # (<=) ∷ PlutusPointerF era → PlutusPointerF era → Bool Source # (>) ∷ PlutusPointerF era → PlutusPointerF era → Bool Source # (>=) ∷ PlutusPointerF era → PlutusPointerF era → Bool Source # max ∷ PlutusPointerF era → PlutusPointerF era → PlutusPointerF era Source # min ∷ PlutusPointerF era → PlutusPointerF era → PlutusPointerF era Source # |
unPlutusPointerF ∷ PlutusPointerF era → PlutusPurpose AsIx era Source #
data TxOutF era where Source #
Instances
Show (TxOutF era) Source # | |
PrettyA (TxOutF era) Source # | |
Eq (TxOutF era) Source # | |
Ord (TxOutF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes | |
Reflect era ⇒ Sums (TxOutF era) Coin Source # | |
data ValueF era where Source #
Instances
Show (ValueF era) Source # | |
PrettyA (ValueF era) Source # | |
Eq (ValueF era) Source # | |
Ord (ValueF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes | |
Reflect era ⇒ Sums (ValueF era) Coin Source # | |
data PParamsUpdateF era where Source #
PParamsUpdateF ∷ Proof era → PParamsUpdate era → PParamsUpdateF era |
Instances
Show (PParamsUpdateF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes |
unPParamsUpdate ∷ PParamsUpdateF era → PParamsUpdate era Source #
pparamsUpdateWrapperL ∷ Lens' (PParamsUpdateF era) (PParamsUpdate era) Source #
data ProposedPPUpdatesF era where Source #
ProposedPPUpdatesF ∷ Proof era → ProposedPPUpdates era → ProposedPPUpdatesF era |
Instances
Show (ProposedPPUpdatesF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes | |
PrettyA (PParamsUpdate e) ⇒ PrettyA (ProposedPPUpdatesF e) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes prettyA ∷ ProposedPPUpdatesF e → PDoc Source # |
unProposedPPUpdates ∷ ProposedPPUpdatesF era → ProposedPPUpdates era Source #
proposedCoreL ∷ Lens' (ProposedPPUpdates era) (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)) Source #
proposedWrapperL ∷ Lens' (ProposedPPUpdatesF era) (ProposedPPUpdates era) Source #
coreMapL ∷ Proof era → Lens' (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)) (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdateF era)) Source #
proposedMapL ∷ Lens' (ProposedPPUpdatesF era) (Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdateF era)) Source #
unGovState ∷ GovState era → GovState era Source #
govProposedL ∷ Lens' (GovState era) (ShelleyGovState era) Source #
genFuturePParams ∷ Proof era → Gen (FuturePParams era) Source #
genPParamsUpdate ∷ Proof era → Gen (PParamsUpdateF era) Source #
genProposedPPUpdates ∷ Proof era → Gen (ProposedPPUpdatesF era) Source #
data ScriptsNeededF era where Source #
ScriptsNeededF ∷ Proof era → ScriptsNeeded era → ScriptsNeededF era |
Instances
Show (ScriptsNeededF era) Source # | |
Defined in Test.Cardano.Ledger.Constrained.Classes |
unScriptsNeededF ∷ ScriptsNeededF era → ScriptsNeeded era Source #
integerPartition ∷ [String] → String → Integer → Int → Integer → Gen [Integer] Source #
Generate a list of length size
that sums to total
, where the minimum element is (>= smallest
)
ordCondToSize ∷ ∀ a. Adds a ⇒ (String, OrdCond, a) → Size Source #
Translate (s,cond,n), into a Size which specifies the Int range on which the OrdCond is True. The triple (s, EQL, 2) denotes s = 2 (s, LTH, 7) denotes s < 7 (s, GTH, 5) denotes s > 5 ...
reverseOrdCond ∷ OrdCond → OrdCond Source #
This function reverseOrdCond
has been defined to handle the Pred SumsTo when the
variable is on the right-hand-side (rhs) of the OrdCond operator. In order to do that
we must multiply both sides of the inequality by (-1). For example consider
[SumsTo (DeltaCoin 1) ▵₳ -2 > ∑ ▵₳ -1 + x]
Note variable x on the rhs ^
To solve we subtract x
from both sides, and add '▵₳ -2' from bothsides
getting (-x) > ∑ (▵₳ -1) + (▵₳ -2)
reduced to (-x) > ∑ (▵₳ -3)
to solve we must multiply both sides by (-1)
x ?? ∑ (▵₳ 3)
What operator do we replace ?? by to make the original (▵₳ -2 > ∑ ▵₳ -1 + x) True?
The change in the operator is called "reversing" the operator. See
https://www.mathsisfun.com/algebra/inequality-solving.html for one explantion.
First order representation of the Ord comparisons
data AddsSpec c where Source #
A specification of summation. like: lhs = ∑ rhs
The idea is that the rhs
can contain multiple terms: rhs = ∑ r1 + r2 + r3
Other example conditions: (lhs rhs), and (lhs= ∑ rhs)
The invariant is that only a single variable appears in the summation.
It can appear on either side. If it appears in the rhs
then there
may be other, constant terms, in the rhs: 7 = ∑ 3 + v + 9
We always do the sums and solving at type Int, and cast back and forth to
accommodate other types with (Adds c) instances, using the methods 'fromI" and toI
This allows the instance to deal with special conditions.
There are two (non-failure) possibilities 1) Var on the left, 2) Var on the right
We supply functions
varOnLeft :: String -> OrdCond -> Integer -> AddsSpec c
SumsTo _ x 4 + 6 + 9 === (varOnLeft x LTE 19) == (AddsSpecSize x (AtMost 19))
varOnRight :: Integer -> OrdCond -> Integer -> String -> AddsSpec c
SumsTo _ 8 + x + 3 === (varOnRight 8 LTH 5 x) == (AddsSpecSize x (AtLeast 4))
But internally we store the information as a String and a Size (I.e. a range of Int)
AddsSpecSize | |
AddsSpecAny ∷ AddsSpec c | |
AddsSpecNever ∷ [String] → AddsSpec c |
showAddsSpec ∷ AddsSpec c → String Source #
Orphan instances
Crypto c ⇒ Ord (MaryValue c) Source # | |
Crypto c ⇒ Ord (MultiAsset c) Source # | |
compare ∷ MultiAsset c → MultiAsset c → Ordering Source # (<) ∷ MultiAsset c → MultiAsset c → Bool Source # (<=) ∷ MultiAsset c → MultiAsset c → Bool Source # (>) ∷ MultiAsset c → MultiAsset c → Bool Source # (>=) ∷ MultiAsset c → MultiAsset c → Bool Source # max ∷ MultiAsset c → MultiAsset c → MultiAsset c Source # min ∷ MultiAsset c → MultiAsset c → MultiAsset c Source # |