cardano-ledger-core-1.15.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellSafe-Inferred
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 era 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

Memo' 

Fields

Bundled Patterns

pattern MemoEra era ⇒ t era → ShortByteStringMemoBytes t era 

Instances

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

Defined in Cardano.Ledger.MemoBytes.Internal

Generic (MemoBytes t era) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Associated Types

type Rep (MemoBytes t era) ∷ TypeType Source #

Methods

fromMemoBytes t era → Rep (MemoBytes t era) x Source #

toRep (MemoBytes t era) x → MemoBytes t era Source #

(Show (t era), HashAlgorithm (HASH (EraCrypto era))) ⇒ Show (MemoBytes t era) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

showsPrecIntMemoBytes t era → ShowS Source #

showMemoBytes t era → String Source #

showList ∷ [MemoBytes t era] → ShowS Source #

(Typeable t, Typeable era) ⇒ ToCBOR (MemoBytes t era) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

toCBORMemoBytes t era → Encoding Source #

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

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

SafeToHash (MemoBytes t era) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

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

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

rnfMemoBytes t era → () Source #

Eq (t era) ⇒ Eq (MemoBytes t era) Source #

Both binary representation and Haskell types are compared.

Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

Methods

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

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

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

Defined in Cardano.Ledger.MemoBytes.Internal

type Rep (MemoBytes t era) Source # 
Instance details

Defined in Cardano.Ledger.MemoBytes.Internal

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

type family MemoHashIndex (t ∷ TypeType) ∷ Type Source #

Instances

Instances details
type MemoHashIndex PlutusData Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Data

type Mem t era = Annotator (MemoBytes t era) Source #

Useful when deriving DecCBOR(Annotator T) deriving via (Mem T) instance (Era era) => DecCBOR (Annotator T)

mkMemoBytes ∷ ∀ era t. Era era ⇒ t era → ByteStringMemoBytes t era Source #

Smart constructor

getMemoBytesTypeMemoBytes t era → t era Source #

Extract the inner type of the MemoBytes

getMemoBytesHashMemoBytes t era → SafeHash (EraCrypto era) (MemoHashIndex t) Source #

Extract the hash value of the binary representation of the MemoBytes

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

Create MemoBytes from its CBOR encoding

shortenByteStringShortByteString Source #

Turn a lazy bytestring into a short bytestring.

showMemoShow (t era) ⇒ MemoBytes t era → String Source #

Turn a MemoBytes into a string, Showing both its internal structure and its original bytes. Useful since the Show instance of MemoBytes does not display the original bytes.

printMemoShow (t era) ⇒ MemoBytes t era → IO () Source #

shortToLazyShortByteStringByteString Source #

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

contentsEqEq (t era) ⇒ MemoBytes t era → MemoBytes t era → 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 ∷ TypeType) | r → t Source #

Instances

Instances details
Memoized Data Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Associated Types

type RawType Data = (r ∷ TypeType) Source #

Methods

getMemoBytesData era → MemoBytes (RawType Data) era

wrapMemoBytesMemoBytes (RawType Data) era → Data era

mkMemoized ∷ ∀ era t. (Era era, EncCBOR (RawType t era), Memoized t) ⇒ RawType t era → t era Source #

Construct memoized type from the raw type using its EncCBOR instance

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

Extract memoized SafeHash

getMemoRawTypeMemoized t ⇒ t era → RawType t era Source #

Extract the raw type from the memoized version

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

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

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

getMemoRawBytesMemoized t ⇒ t era → ShortByteString Source #

Extract the raw bytes from the memoized version

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

This is a helper Lens creator for any Memoized type.

getterMemoRawTypeMemoized t ⇒ (RawType t era → a) → SimpleGetter (t era) a Source #

This is a helper SimpleGetter creator for any Memoized type

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 era, Memoized t, Eq (RawType t era)) ⇒ a → a → Bool Source #

Instances

Instances details
Crypto c ⇒ EqRaw (BootstrapWitness c) Source # 
Instance details

Defined in Cardano.Ledger.Keys.Bootstrap

(Crypto c, Typeable kr) ⇒ EqRaw (WitVKey kr c) Source # 
Instance details

Defined in Cardano.Ledger.Keys.WitVKey

Methods

eqRawWitVKey kr c → WitVKey kr c → Bool Source #