cardano-ledger-core-1.19.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellNone
LanguageHaskell2010

Cardano.Ledger.MemoBytes.Internal

Description

Provides MemoBytes internals

Warning

This module is considered internal.

The contents of this module may change in any way whatsoever and without any warning between minor versions of this package.

Synopsis

Documentation

data MemoBytes t Source #

Pair together a type t and its serialization. Used to encode a type that is serialized over the network, and to remember the original bytes that were used to transmit it. Important since hashes are computed from the serialization of a type, and EncCBOR instances do not have unique serializations.

Constructors

MemoBytes 

Bundled Patterns

pattern Memo ∷ t → ShortByteStringMemoBytes t

Prevent coercion on MemoBytes because it does not preserve the invariants

Instances

Instances details
Typeable t ⇒ ToCBOR (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

toCBORMemoBytes t → Encoding Source #

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

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

(Typeable t, DecCBOR (Annotator t)) ⇒ DecCBOR (Annotator (MemoBytes t)) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

DecCBOR t ⇒ DecCBOR (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

EncCBOR (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

encCBORMemoBytes t → Encoding Source #

SafeToHash (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

NFData t ⇒ NFData (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

rnfMemoBytes t → () #

Generic (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Associated Types

type Rep (MemoBytes t) 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

type Rep (MemoBytes t) = D1 ('MetaData "MemoBytes" "Cardano.Ledger.MemoBytes.Internal" "cardano-ledger-core-1.19.0.0-inplace" 'False) (C1 ('MetaCons "MemoBytes" 'PrefixI 'True) (S1 ('MetaSel ('Just "mbRawType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t) :*: (S1 ('MetaSel ('Just "mbBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString) :*: S1 ('MetaSel ('Just "mbHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SafeHash (MemoHashIndex t))))))

Methods

fromMemoBytes t → Rep (MemoBytes t) x #

toRep (MemoBytes t) x → MemoBytes t #

Show t ⇒ Show (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

showsPrecIntMemoBytes t → ShowS #

showMemoBytes t → String #

showList ∷ [MemoBytes t] → ShowS #

Eq t ⇒ Eq (MemoBytes t) Source #

Both binary representation and Haskell types are compared.

Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

(==)MemoBytes t → MemoBytes t → Bool #

(/=)MemoBytes t → MemoBytes t → Bool #

(Typeable t, NoThunks t) ⇒ NoThunks (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

type Rep (MemoBytes t) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

type Rep (MemoBytes t) = D1 ('MetaData "MemoBytes" "Cardano.Ledger.MemoBytes.Internal" "cardano-ledger-core-1.19.0.0-inplace" 'False) (C1 ('MetaCons "MemoBytes" 'PrefixI 'True) (S1 ('MetaSel ('Just "mbRawType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t) :*: (S1 ('MetaSel ('Just "mbBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString) :*: S1 ('MetaSel ('Just "mbHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SafeHash (MemoHashIndex t))))))

type Mem t = Annotator (MemoBytes t) Source #

Useful when deriving DecCBOR(Annotator T) deriving via (Mem T) instance DecCBOR (Annotator T)

type family MemoHashIndex t Source #

Instances

Instances details
type MemoHashIndex (PlutusData era) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Data

mkMemoBytes ∷ t → ByteStringMemoBytes t Source #

Constructor that takes the underlying type and the original bytes as lazy ByteString.

Warning - This is a dangerous constructor because it allows one to construct a MemoBytes type with wrong bytes.

mkMemoBytesStrict ∷ t → ByteStringMemoBytes t Source #

Same as mkMemoBytes, but with strict bytes

getMemoBytesTypeMemoBytes t → t Source #

Extract the inner type of the MemoBytes

getMemoBytesHashMemoBytes t → SafeHash (MemoHashIndex t) Source #

Extract the hash value of the binary representation of the MemoBytes

memoBytes ∷ ∀ (w ∷ Wrapped) t. VersionEncode w t → MemoBytes t Source #

Create MemoBytes from its CBOR encoding

Warning - This is a dangerous constructor because it allows one to construct a MemoBytes type from the wrong encoding. Use mkMemoized instead when possible.

memoBytesEra ∷ ∀ era (w ∷ Wrapped) t. Era era ⇒ Encode w t → MemoBytes t Source #

Same as memoBytes, but derives Version from the era.

Warning - This is a dangerous constructor because it allows one to construct a MemoBytes type from the wrong encoding. Use mkMemoizedEra instead when possible.

shortToLazyShortByteStringByteString Source #

Helper function. Converts a short bytestring to a lazy bytestring.

contentsEqEq t ⇒ MemoBytes t → MemoBytes t → Bool Source #

Returns true if the contents of the MemoBytes are equal

Memoized

class Memoized t Source #

Class that relates the actual type with its raw and byte representations

Associated Types

type RawType t = (r ∷ Type) | r → t Source #

Instances

Instances details
Memoized (Data era) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Associated Types

type RawType (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

type RawType (Data era) = PlutusData era

Methods

getMemoBytesData era → MemoBytes (RawType (Data era))

wrapMemoBytesMemoBytes (RawType (Data era)) → Data era

mkMemoized ∷ (EncCBOR (RawType t), Memoized t) ⇒ VersionRawType t → t Source #

Construct memoized type from the raw type using its EncCBOR instance

mkMemoizedEra ∷ (Era era, EncCBOR (RawType t), Memoized t) ⇒ RawType t → t Source #

getMemoSafeHashMemoized t ⇒ t → SafeHash (MemoHashIndex (RawType t)) Source #

Extract memoized SafeHash

getMemoRawTypeMemoized t ⇒ t → RawType t Source #

Extract the raw type from the memoized version

zipMemoRawType ∷ (Memoized t1, Memoized t2) ⇒ (RawType t1 → RawType t2 → a) → t1 → t2 → a Source #

This is a helper function that operates on raw types of two memoized types.

eqRawType ∷ (Memoized t, Eq (RawType t)) ⇒ t → t → Bool Source #

getMemoRawBytesMemoized t ⇒ t → ShortByteString Source #

Extract the raw bytes from the memoized version

lensMemoRawType ∷ (Era era, EncCBOR (RawType t), Memoized t) ⇒ (RawType t → a) → (RawType t → b → RawType t) → Lens t t a b Source #

This is a helper Lens creator for any Memoized type.

MemoBytes MemPack instance definitions

Raw equality

class EqRaw a where Source #

Type class that implements equality on the Haskell type, ignoring any of the potentially memoized binary representation of the type.

Minimal complete definition

Nothing

Methods

eqRaw ∷ a → a → Bool Source #

default eqRaw ∷ (a ~ t, Memoized t, Eq (RawType t)) ⇒ a → a → Bool Source #