cardano-binary-1.7.1.0: Binary serialization for Cardano
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Binary

Synopsis

Documentation

class Typeable a ⇒ ToCBOR a where Source #

Minimal complete definition

toCBOR

Methods

toCBOR ∷ a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy a → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [a] → Size Source #

Instances

Instances details
ToCBOR Void Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORVoidEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy VoidSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Void] → Size Source #

ToCBOR Int32 Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORInt32Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy Int32Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Int32] → Size Source #

ToCBOR Int64 Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORInt64Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy Int64Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Int64] → Size Source #

ToCBOR Word16 Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORWord16Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy Word16Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Word16] → Size Source #

ToCBOR Word32 Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORWord32Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy Word32Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Word32] → Size Source #

ToCBOR Word64 Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORWord64Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy Word64Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Word64] → Size Source #

ToCBOR Word8 Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORWord8Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy Word8Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Word8] → Size Source #

ToCBOR ByteString Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORByteStringEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ByteStringSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ByteString] → Size Source #

ToCBOR ByteString Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORByteStringEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ByteStringSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ByteString] → Size Source #

ToCBOR ShortByteString Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

ToCBOR Encoding Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOREncodingEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy EncodingSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Encoding] → Size Source #

ToCBOR Term Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORTermEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy TermSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Term] → Size Source #

ToCBOR Text Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORTextEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy TextSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Text] → Size Source #

ToCBOR UTCTime Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORUTCTimeEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy UTCTimeSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [UTCTime] → Size Source #

ToCBOR Integer Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORIntegerEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy IntegerSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Integer] → Size Source #

ToCBOR Natural Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORNaturalEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy NaturalSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Natural] → Size Source #

ToCBOR () Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ () → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy () → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [()] → Size Source #

ToCBOR Bool Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORBoolEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy BoolSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Bool] → Size Source #

ToCBOR Double Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORDoubleEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy DoubleSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Double] → Size Source #

ToCBOR Float Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORFloatEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy FloatSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Float] → Size Source #

ToCBOR Int Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORIntEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy IntSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Int] → Size Source #

ToCBOR Word Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORWordEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy WordSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Word] → Size Source #

ToCBOR a ⇒ ToCBOR (Ratio a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORRatio a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Ratio a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Ratio a] → Size Source #

Typeable xs ⇒ ToCBOR (LengthOf xs) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORLengthOf xs → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (LengthOf xs) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [LengthOf xs] → Size Source #

ToCBOR a ⇒ ToCBOR (Seq a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORSeq a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Seq a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Seq a] → Size Source #

(Ord a, ToCBOR a) ⇒ ToCBOR (Set a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORSet a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Set a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Set a] → Size Source #

ToCBOR a ⇒ ToCBOR (Vector a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORVector a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Vector a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Vector a] → Size Source #

ToCBOR a ⇒ ToCBOR (NonEmpty a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORNonEmpty a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (NonEmpty a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [NonEmpty a] → Size Source #

ToCBOR a ⇒ ToCBOR (Maybe a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORMaybe a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Maybe a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Maybe a] → Size Source #

ToCBOR a ⇒ ToCBOR [a] Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ [a] → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [a] → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [[a]] → Size Source #

(ToCBOR a, ToCBOR b) ⇒ ToCBOR (Either a b) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOREither a b → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Either a b) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Either a b] → Size Source #

Typeable a ⇒ ToCBOR (Fixed a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORFixed a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Fixed a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Fixed a] → Size Source #

(Ord k, ToCBOR k, ToCBOR v) ⇒ ToCBOR (Map k v) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORMap k v → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Map k v) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Map k v] → Size Source #

ToCBOR (TokensTokens) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (TokensTokens) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (TokensTokens) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [TokensTokens] → Size Source #

(ToCBOR a, ToCBOR b) ⇒ ToCBOR (a, b) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (a, b) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (a, b) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [(a, b)] → Size Source #

(Typeable s, ToCBOR a) ⇒ ToCBOR (Tagged s a) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORTagged s a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Tagged s a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Tagged s a] → Size Source #

(ToCBOR a, ToCBOR b, ToCBOR c) ⇒ ToCBOR (a, b, c) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (a, b, c) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (a, b, c) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [(a, b, c)] → Size Source #

(ToCBOR a, ToCBOR b, ToCBOR c, ToCBOR d) ⇒ ToCBOR (a, b, c, d) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (a, b, c, d) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (a, b, c, d) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [(a, b, c, d)] → Size Source #

(ToCBOR a, ToCBOR b, ToCBOR c, ToCBOR d, ToCBOR e) ⇒ ToCBOR (a, b, c, d, e) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (a, b, c, d, e) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (a, b, c, d, e) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [(a, b, c, d, e)] → Size Source #

(ToCBOR a, ToCBOR b, ToCBOR c, ToCBOR d, ToCBOR e, ToCBOR f) ⇒ ToCBOR (a, b, c, d, e, f) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (a, b, c, d, e, f) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (a, b, c, d, e, f) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [(a, b, c, d, e, f)] → Size Source #

(ToCBOR a, ToCBOR b, ToCBOR c, ToCBOR d, ToCBOR e, ToCBOR f, ToCBOR g) ⇒ ToCBOR (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (a, b, c, d, e, f, g) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (a, b, c, d, e, f, g) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [(a, b, c, d, e, f, g)] → Size Source #

(ToCBOR a, ToCBOR b, ToCBOR c, ToCBOR d, ToCBOR e, ToCBOR f, ToCBOR g, ToCBOR h) ⇒ ToCBOR (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (a, b, c, d, e, f, g, h) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (a, b, c, d, e, f, g, h) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [(a, b, c, d, e, f, g, h)] → Size Source #

withWordSize ∷ (Integral s, Integral a) ⇒ s → a Source #

Compute encoded size of an integer

encodeMaybe ∷ (a → Encoding) → Maybe a → Encoding Source #

toCBORMaybe ∷ (a → Encoding) → Maybe a → Encoding Source #

Deprecated: In favor of encodeMaybe

encodeNullMaybe ∷ (a → Encoding) → Maybe a → Encoding Source #

Alternative way to encode a Maybe type.

Note - this is not the default method for encoding Maybe, use encodeMaybe instead

encodeSeq ∷ (a → Encoding) → Seq a → Encoding Source #

encodeNominalDiffTimeMicroNominalDiffTimeEncoding Source #

Same as encodeNominalDiffTime, except with loss of precision, because it encoded as Micro

Size of expressions

data Range b Source #

A range of values. Should satisfy the invariant forall x. lo x <= hi x.

Constructors

Range 

Fields

  • lo ∷ b
     
  • hi ∷ b
     

Instances

Instances details
(Ord b, Num b) ⇒ Num (Range b) Source #

The Num instance for Range uses interval arithmetic. Note that the signum method is not lawful: if the interval x includes 0 in its interior but is not symmetric about 0, then abs x * signum x /= x.

Instance details

Defined in Cardano.Binary.ToCBOR

Methods

(+)Range b → Range b → Range b Source #

(-)Range b → Range b → Range b Source #

(*)Range b → Range b → Range b Source #

negateRange b → Range b Source #

absRange b → Range b Source #

signumRange b → Range b Source #

fromIntegerIntegerRange b Source #

Buildable (Range Natural) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

szEval ∷ (∀ t. ToCBOR t ⇒ (Proxy t → Size) → Proxy t → Range Natural) → SizeRange 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.

data Case t Source #

An individual labeled case.

Constructors

Case Text t 

Instances

Instances details
Functor Case Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

fmap ∷ (a → b) → Case a → Case b Source #

(<$) ∷ a → Case b → Case a Source #

Buildable t ⇒ Buildable (Case t) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

buildCase t → Builder Source #

caseValueCase t → t Source #

Discard the label on a case.

newtype LengthOf xs Source #

A type used to represent the length of a value in Size computations.

Constructors

LengthOf xs 

Instances

Instances details
Typeable xs ⇒ ToCBOR (LengthOf xs) Source # 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBORLengthOf xs → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (LengthOf xs) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [LengthOf xs] → Size Source #

data SizeOverride Source #

Override mechanisms to be used with szWithCtx.

Constructors

SizeConstant Size

Replace with a fixed Size.

SizeExpression ((∀ a. ToCBOR a ⇒ Proxy a → Size) → Size)

Recursively compute the size.

SelectCases [Text]

Select only a specific case from a CasesF.

isTodoSizeBool Source #

Is this expression a thunk?

szCases ∷ [Case Size] → Size Source #

Create a case expression from individual cases.

szLazyToCBOR 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)

szGreedyToCBOR 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 ToCBOR 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))) })

szForceSizeSize Source #

Force any thunks in the given Size expression.

ghci> putStrLn $ pretty $ szForce $ szLazy (Proxy @TxAux)
(0 + { TxAux=(2 + ((0 + (_ :: Tx)) + (_ :: Vector TxInWitness))) })

szWithCtxToCBOR a ⇒ Map TypeRep SizeOverrideProxy a → Size Source #

Greedily compute the size bounds for a type, using the given context to override sizes for specific types.

szSimplifySizeEither 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.

apMonoText → (NaturalNatural) → SizeSize 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.

serializeToCBOR a ⇒ a → ByteString Source #

Serialize a Haskell value with a ToCBOR instance to an external binary representation.

The output is represented as a lazy LByteString and is constructed incrementally.

serialize'ToCBOR a ⇒ a → ByteString Source #

Serialize a Haskell value to an external binary representation.

The output is represented as a strict ByteString.

serializeBuilderToCBOR a ⇒ a → Builder Source #

Serialize into a Builder. Useful if you want to throw other ByteStrings around it.

serializeEncodingEncodingByteString Source #

Deprecated: Use serialize instead, since Encoding has ToCBOR instance

Serialize a Haskell value to an external binary representation using the provided CBOR Encoding

The output is represented as an LByteString and is constructed incrementally.

serializeEncoding'EncodingByteString Source #

Deprecated: Use serialize` instead, since Encoding has ToCBOR instance

A strict version of serializeEncoding

CBOR in CBOR

encodeNestedCborToCBOR a ⇒ a → Encoding Source #

Encode and serialise the given a and sorround it with the semantic tag 24 In CBOR diagnostic notation: >>> 24(hDEADBEEF)

encodeNestedCborBytesByteStringEncoding Source #

Like encodeNestedCbor, but assumes nothing about the shape of input object, so that it must be passed as a binary ByteString blob. It's the caller responsibility to ensure the input ByteString correspond indeed to valid, previously-serialised CBOR data.

class Typeable a ⇒ FromCBOR a where Source #

Minimal complete definition

fromCBOR

Methods

fromCBORDecoder s a Source #

labelProxy a → Text Source #

Instances

Instances details
FromCBOR Void Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Int32 Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Int64 Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Rational Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Word16 Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Word32 Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Word64 Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Word8 Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR ByteString Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR ByteString Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR ShortByteString Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR TermToken Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Term Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Text Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR UTCTime Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Integer Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Natural Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR () Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s () Source #

labelProxy () → Text Source #

FromCBOR Bool Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Double Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Float Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Int Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR Word Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR a ⇒ FromCBOR (Seq a) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (Seq a) Source #

labelProxy (Seq a) → Text Source #

(Ord a, FromCBOR a) ⇒ FromCBOR (Set a) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (Set a) Source #

labelProxy (Set a) → Text Source #

FromCBOR a ⇒ FromCBOR (Vector a) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (Vector a) Source #

labelProxy (Vector a) → Text Source #

FromCBOR a ⇒ FromCBOR (NonEmpty a) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

FromCBOR a ⇒ FromCBOR (Maybe a) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (Maybe a) Source #

labelProxy (Maybe a) → Text Source #

FromCBOR a ⇒ FromCBOR [a] Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s [a] Source #

labelProxy [a] → Text Source #

(FromCBOR a, FromCBOR b) ⇒ FromCBOR (Either a b) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (Either a b) Source #

labelProxy (Either a b) → Text Source #

Typeable a ⇒ FromCBOR (Fixed a) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (Fixed a) Source #

labelProxy (Fixed a) → Text Source #

(Ord k, FromCBOR k, FromCBOR v) ⇒ FromCBOR (Map k v) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (Map k v) Source #

labelProxy (Map k v) → Text Source #

(FromCBOR a, FromCBOR b) ⇒ FromCBOR (a, b) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (a, b) Source #

labelProxy (a, b) → Text Source #

(Typeable s, FromCBOR a) ⇒ FromCBOR (Tagged s a) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s0 (Tagged s a) Source #

labelProxy (Tagged s a) → Text Source #

(FromCBOR a, FromCBOR b, FromCBOR c) ⇒ FromCBOR (a, b, c) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (a, b, c) Source #

labelProxy (a, b, c) → Text Source #

(FromCBOR a, FromCBOR b, FromCBOR c, FromCBOR d) ⇒ FromCBOR (a, b, c, d) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (a, b, c, d) Source #

labelProxy (a, b, c, d) → Text Source #

(FromCBOR a, FromCBOR b, FromCBOR c, FromCBOR d, FromCBOR e) ⇒ FromCBOR (a, b, c, d, e) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (a, b, c, d, e) Source #

labelProxy (a, b, c, d, e) → Text Source #

(FromCBOR a, FromCBOR b, FromCBOR c, FromCBOR d, FromCBOR e, FromCBOR f) ⇒ FromCBOR (a, b, c, d, e, f) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (a, b, c, d, e, f) Source #

labelProxy (a, b, c, d, e, f) → Text Source #

(FromCBOR a, FromCBOR b, FromCBOR c, FromCBOR d, FromCBOR e, FromCBOR f, FromCBOR g) ⇒ FromCBOR (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (a, b, c, d, e, f, g) Source #

labelProxy (a, b, c, d, e, f, g) → Text Source #

(FromCBOR a, FromCBOR b, FromCBOR c, FromCBOR d, FromCBOR e, FromCBOR f, FromCBOR g, FromCBOR h) ⇒ FromCBOR (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Cardano.Binary.FromCBOR

Methods

fromCBORDecoder s (a, b, c, d, e, f, g, h) Source #

labelProxy (a, b, c, d, e, f, g, h) → Text Source #

enforceSizeTextIntDecoder s () Source #

Enforces that the input size is the same as the decoded one, failing in case it's not

matchSizeTextIntIntDecoder s () Source #

Compare two sizes, failing if they are not equal

fromCBORMaybeDecoder s a → Decoder s (Maybe a) Source #

Deprecated: In favor of decodeMaybe

decodeSeqDecoder s a → Decoder s (Seq a) Source #

decodeListWithDecoder s a → Decoder s [a] Source #

Decoder for list.

decodeNominalDiffTimeMicroDecoder s NominalDiffTime Source #

For backwards compatibility we round pico precision to micro

Helper tools to build instances

decodeMapSkel ∷ (Ord k, FromCBOR k, FromCBOR v) ⇒ ([(k, v)] → m) → Decoder s m Source #

Checks canonicity by comparing the new key being decoded with the previous one, to enfore these are sorted the correct way. See: https://tools.ietf.org/html/rfc7049#section-3.9 "[..]The keys in every map must be sorted lowest value to highest.[...]"

cborError ∷ (MonadFail m, Buildable e) ⇒ e → m a Source #

Convert a Buildable error message into a MonadFail failure.

toCborError ∷ (MonadFail m, Buildable e) ⇒ Either e a → m a Source #

Convert an Either-encoded failure to a MonadFail failure using the Buildable insatance

Unsafe deserialization

unsafeDeserializeFromCBOR a ⇒ ByteString → a Source #

Deserialize a Haskell value from the external binary representation (which must have been made using serialize or related function).

Throws: DeserialiseFailure if the given external representation is invalid or does not correspond to a value of the expected type.

unsafeDeserialize'FromCBOR a ⇒ ByteString → a Source #

Strict variant of deserialize.

toStrictByteString Source #

Arguments

Encoding

The Encoding of a CBOR value.

ByteString

The encoded value.

Turn an Encoding into a strict ByteString in CBOR binary format.

Since: cborg-0.2.0.0

Decoding

decodeFull ∷ ∀ a. FromCBOR a ⇒ ByteStringEither DecoderError a Source #

Deserialize a Haskell value from the external binary representation, failing if there are leftovers. In a nutshell, the full here implies the contract of this function is that what you feed as input needs to be consumed entirely.

decodeFullDecoder Source #

Arguments

Text

Label for error reporting

→ (∀ s. Decoder s a)

The parser for the ByteString to decode. It should decode the given ByteString into a value of type a

ByteString

The ByteString to decode

Either DecoderError a 

decodeFullDecoder' Source #

Arguments

Text

Label for error reporting

→ (∀ s. Decoder s a)

The parser for the ByteString to decode. It should decode the given ByteString into a value of type a

ByteString

The ByteString to decode

Either DecoderError a 

CBOR in CBOR

decodeNestedCborFromCBOR a ⇒ Decoder s a Source #

Remove the the semantic tag 24 from the enclosed CBOR data item, decoding back the inner ByteString as a proper Haskell type. Consume its input in full.

decodeNestedCborBytesDecoder s ByteString Source #

Like decodeKnownCborDataItem, but assumes nothing about the Haskell type we want to deserialise back, therefore it yields the ByteString Tag 24 surrounded (stripping such tag away).

In CBOR notation, if the data was serialised as:

>>> 24(h'DEADBEEF')

then decodeNestedCborBytes yields the inner DEADBEEF, unchanged.