Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class Typeable a ⇒ EncCBOR a where
- withWordSize ∷ (Integral s, Integral a) ⇒ s → a
- newtype PreEncoded = PreEncoded {}
- toByronCBOR ∷ EncCBOR a ⇒ a → Encoding
- data Range b = Range {}
- szEval ∷ (∀ t. EncCBOR t ⇒ (Proxy t → Size) → Proxy t → Range Natural) → Size → Range Natural
- type Size = Fix SizeF
- data Case t = Case Text t
- caseValue ∷ Case t → t
- newtype LengthOf xs = LengthOf xs
- data SizeOverride
- = SizeConstant Size
- | SizeExpression ((∀ a. EncCBOR a ⇒ Proxy a → Size) → Size)
- | SelectCases [Text]
- isTodo ∷ Size → Bool
- szCases ∷ [Case Size] → Size
- szLazy ∷ EncCBOR a ⇒ Proxy a → Size
- szGreedy ∷ EncCBOR a ⇒ Proxy a → Size
- szForce ∷ Size → Size
- szWithCtx ∷ EncCBOR a ⇒ Map TypeRep SizeOverride → Proxy a → Size
- szSimplify ∷ Size → Either Size (Range Natural)
- apMono ∷ Text → (Natural → Natural) → Size → Size
- szBounds ∷ EncCBOR a ⇒ a → Either Size (Range Natural)
- encodedVerKeyDSIGNSizeExpr ∷ ∀ v. DSIGNAlgorithm v ⇒ Proxy (VerKeyDSIGN v) → Size
- encodedSignKeyDSIGNSizeExpr ∷ ∀ v. DSIGNAlgorithm v ⇒ Proxy (SignKeyDSIGN v) → Size
- encodedSigDSIGNSizeExpr ∷ ∀ v. DSIGNAlgorithm v ⇒ Proxy (SigDSIGN v) → Size
- encodedSignedDSIGNSizeExpr ∷ ∀ v a. DSIGNAlgorithm v ⇒ Proxy (SignedDSIGN v a) → Size
- encodedVerKeyKESSizeExpr ∷ ∀ v. KESAlgorithm v ⇒ Proxy (VerKeyKES v) → Size
- encodedSignKeyKESSizeExpr ∷ ∀ v. KESAlgorithm v ⇒ Proxy (SignKeyKES v) → Size
- encodedSigKESSizeExpr ∷ ∀ v. KESAlgorithm v ⇒ Proxy (SigKES v) → Size
- encodedVerKeyVRFSizeExpr ∷ ∀ v. VRFAlgorithm v ⇒ Proxy (VerKeyVRF v) → Size
- encodedSignKeyVRFSizeExpr ∷ ∀ v. VRFAlgorithm v ⇒ Proxy (SignKeyVRF v) → Size
- encodedCertVRFSizeExpr ∷ ∀ v. VRFAlgorithm v ⇒ Proxy (CertVRF v) → Size
Documentation
class Typeable a ⇒ EncCBOR a where Source #
Nothing
encCBOR ∷ a → Encoding Source #
encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy a → Size Source #
encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [a] → Size Source #
Instances
withWordSize ∷ (Integral s, Integral a) ⇒ s → a Source #
Compute encoded size of an integer
newtype PreEncoded Source #
Instances
EncCBOR PreEncoded Source # | |
Defined in Cardano.Ledger.Binary.Encoding.EncCBOR encCBOR ∷ PreEncoded → Encoding Source # encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy PreEncoded → Size Source # encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [PreEncoded] → Size Source # |
toByronCBOR ∷ EncCBOR a ⇒ a → Encoding Source #
Size of expressions
A range of values. Should satisfy the invariant forall x. lo x <= hi x
.
Instances
(Ord b, Num b) ⇒ Num (Range b) Source # | The |
Defined in Cardano.Ledger.Binary.Encoding.EncCBOR | |
Buildable (Range Natural) Source # | |
szEval ∷ (∀ t. EncCBOR t ⇒ (Proxy t → Size) → Proxy t → Range Natural) → Size → Range Natural Source #
Fully evaluate a size expression by applying the given function to any
suspended computations. szEval g
effectively turns each "thunk"
of the form TodoF f x
into g x
, then evaluates the result.
type Size = Fix SizeF Source #
Expressions describing the statically-computed size bounds on a type's possible values.
An individual labeled case.
A type used to represent the length of a value in Size
computations.
LengthOf xs |
data SizeOverride Source #
Override mechanisms to be used with szWithCtx
.
SizeConstant Size | Replace with a fixed |
SizeExpression ((∀ a. EncCBOR a ⇒ Proxy a → Size) → Size) | Recursively compute the size. |
SelectCases [Text] | Select only a specific case from a |
szLazy ∷ EncCBOR a ⇒ Proxy a → Size Source #
Evaluate the expression lazily, by immediately creating a thunk that will evaluate its contents lazily.
ghci> putStrLn $ pretty $ szLazy (Proxy @TxAux) (_ :: TxAux)
szGreedy ∷ EncCBOR a ⇒ Proxy a → Size Source #
Evaluate an expression greedily. There may still be thunks in the
result, for types that did not provide a custom encodedSizeExpr
method
in their EncCBOR
instance.
ghci> putStrLn $ pretty $ szGreedy (Proxy @TxAux) (0 + { TxAux=(2 + ((0 + (((1 + (2 + ((_ :: LengthOf [TxIn]) * (2 + { TxInUtxo=(2 + ((1 + 34) + { minBound=1 maxBound=5 })) })))) + (2 + ((_ :: LengthOf [TxOut]) * (0 + { TxOut=(2 + ((0 + ((2 + ((2 + withWordSize((((1 + 30) + (_ :: Attributes AddrAttributes)) + 1))) + (((1 + 30) + (_ :: Attributes AddrAttributes)) + 1))) + { minBound=1 maxBound=5 })) + { minBound=1 maxBound=9 })) })))) + (_ :: Attributes ()))) + (_ :: Vector TxInWitness))) })
szForce ∷ Size → Size Source #
Force any thunks in the given Size
expression.
ghci> putStrLn $ pretty $ szForce $ szLazy (Proxy @TxAux) (0 + { TxAux=(2 + ((0 + (_ :: Tx)) + (_ :: Vector TxInWitness))) })
szWithCtx ∷ EncCBOR a ⇒ Map TypeRep SizeOverride → Proxy a → Size Source #
Greedily compute the size bounds for a type, using the given context to override sizes for specific types.
szSimplify ∷ Size → Either Size (Range Natural) Source #
Simplify the given Size
, resulting in either the simplified Size
or,
if it was fully simplified, an explicit upper and lower bound.
apMono ∷ Text → (Natural → Natural) → Size → Size Source #
Apply a monotonically increasing function to the expression.
There are three cases when applying f
to a Size
expression:
* When applied to a value x
, compute f x
.
* When applied to cases, apply to each case individually.
* In all other cases, create a deferred application of f
.
Crypto
encodedVerKeyDSIGNSizeExpr ∷ ∀ v. DSIGNAlgorithm v ⇒ Proxy (VerKeyDSIGN v) → Size Source #
Size
expression for VerKeyDSIGN
which is using sizeVerKeyDSIGN
encoded as Size
.
encodedSignKeyDSIGNSizeExpr ∷ ∀ v. DSIGNAlgorithm v ⇒ Proxy (SignKeyDSIGN v) → Size Source #
Size
expression for SignKeyDSIGN
which is using sizeSignKeyDSIGN
encoded as Size
.
encodedSigDSIGNSizeExpr ∷ ∀ v. DSIGNAlgorithm v ⇒ Proxy (SigDSIGN v) → Size Source #
Size
expression for SigDSIGN
which is using sizeSigDSIGN
encoded as
Size
.
encodedSignedDSIGNSizeExpr ∷ ∀ v a. DSIGNAlgorithm v ⇒ Proxy (SignedDSIGN v a) → Size Source #
Size
expression for SignedDSIGN
which uses encodedSigDSIGNSizeExpr
encodedVerKeyKESSizeExpr ∷ ∀ v. KESAlgorithm v ⇒ Proxy (VerKeyKES v) → Size Source #
Size
expression for VerKeyKES
which is using sizeVerKeyKES
encoded
as Size
.
encodedSignKeyKESSizeExpr ∷ ∀ v. KESAlgorithm v ⇒ Proxy (SignKeyKES v) → Size Source #
Size
expression for SignKeyKES
which is using sizeSignKeyKES
encoded
as Size
.
encodedSigKESSizeExpr ∷ ∀ v. KESAlgorithm v ⇒ Proxy (SigKES v) → Size Source #
Size
expression for SigKES
which is using sizeSigKES
encoded as
Size
.
encodedVerKeyVRFSizeExpr ∷ ∀ v. VRFAlgorithm v ⇒ Proxy (VerKeyVRF v) → Size Source #
Size
expression for VerKeyVRF
which is using sizeVerKeyVRF
encoded as
Size
.
encodedSignKeyVRFSizeExpr ∷ ∀ v. VRFAlgorithm v ⇒ Proxy (SignKeyVRF v) → Size Source #
Size
expression for SignKeyVRF
which is using sizeSignKeyVRF
encoded
as Size
encodedCertVRFSizeExpr ∷ ∀ v. VRFAlgorithm v ⇒ Proxy (CertVRF v) → Size Source #
Size
expression for CertVRF
which is using sizeCertVRF
encoded as
Size
.