Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- data MemoBytes t where
- MemoBytes {
- mbRawType ∷ !t
- mbBytes ∷ ShortByteString
- mbHash ∷ SafeHash (MemoHashIndex t)
- pattern Memo ∷ t → ShortByteString → MemoBytes t
- MemoBytes {
- type family MemoHashIndex (t ∷ Type) ∷ Type
- mkMemoBytes ∷ t → ByteString → MemoBytes t
- mkMemoBytesStrict ∷ ∀ t. t → ByteString → MemoBytes t
- getMemoBytesType ∷ MemoBytes t → t
- getMemoBytesHash ∷ MemoBytes t → SafeHash (MemoHashIndex t)
- memoBytes ∷ Version → Encode w t → MemoBytes t
- memoBytesEra ∷ ∀ era w t. Era era ⇒ Encode w t → MemoBytes t
- shorten ∷ ByteString → ShortByteString
- showMemo ∷ Show t ⇒ MemoBytes t → String
- printMemo ∷ Show t ⇒ MemoBytes t → IO ()
- shortToLazy ∷ ShortByteString → ByteString
- contentsEq ∷ Eq t ⇒ MemoBytes t → MemoBytes t → Bool
- decodeMemoBytes ∷ (DecCBOR t, MonadFail m) ⇒ Version → ByteString → m (MemoBytes t)
- class Memoized t where
- mkMemoized ∷ ∀ t. (EncCBOR (RawType t), Memoized t) ⇒ Version → RawType t → t
- mkMemoizedEra ∷ ∀ era t. (Era era, EncCBOR (RawType t), Memoized t) ⇒ RawType t → t
- decodeMemoized ∷ Decoder s t → Decoder s (MemoBytes t)
- getMemoSafeHash ∷ Memoized t ⇒ t → SafeHash (MemoHashIndex (RawType t))
- getMemoRawType ∷ Memoized t ⇒ t → RawType t
- zipMemoRawType ∷ (Memoized t1, Memoized t2) ⇒ (RawType t1 → RawType t2 → a) → t1 → t2 → a
- eqRawType ∷ ∀ t. (Memoized t, Eq (RawType t)) ⇒ t → t → Bool
- getMemoRawBytes ∷ Memoized t ⇒ t → ShortByteString
- lensMemoRawType ∷ ∀ era t a b. (Era era, EncCBOR (RawType t), Memoized t) ⇒ (RawType t → a) → (RawType t → b → RawType t) → Lens t t a b
- getterMemoRawType ∷ Memoized t ⇒ (RawType t → a) → SimpleGetter t a
- byteCountMemoBytes ∷ MemoBytes t → Int
- packMemoBytesM ∷ MemoBytes t → Pack s ()
- unpackMemoBytesM ∷ (DecCBOR t, Buffer b) ⇒ Version → Unpack b (MemoBytes t)
- class EqRaw a where
Documentation
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 | |
Fields
|
Bundled Patterns
pattern Memo ∷ t → ShortByteString → MemoBytes t |
Instances
Generic (MemoBytes t) Source # | |
Show t ⇒ Show (MemoBytes t) Source # | |
Typeable t ⇒ ToCBOR (MemoBytes t) Source # | |
DecCBOR t ⇒ DecCBOR (MemoBytes t) Source # | |
SafeToHash (MemoBytes t) Source # | |
Defined in Cardano.Ledger.MemoBytes.Internal Methods originalBytes ∷ MemoBytes t → ByteString Source # originalBytesSize ∷ MemoBytes t → Int Source # makeHashWithExplicitProxys ∷ Proxy i → MemoBytes t → SafeHash i Source # | |
NFData t ⇒ NFData (MemoBytes t) Source # | |
Defined in Cardano.Ledger.MemoBytes.Internal | |
Eq t ⇒ Eq (MemoBytes t) Source # | Both binary representation and Haskell types are compared. |
(Typeable t, NoThunks t) ⇒ NoThunks (MemoBytes t) Source # | |
type Rep (MemoBytes t) Source # | |
Defined in Cardano.Ledger.MemoBytes.Internal type Rep (MemoBytes t) = D1 ('MetaData "MemoBytes" "Cardano.Ledger.MemoBytes.Internal" "cardano-ledger-core-1.18.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 family MemoHashIndex (t ∷ Type) ∷ Type Source #
Instances
type MemoHashIndex (PlutusData era) Source # | |
Defined in Cardano.Ledger.Plutus.Data |
mkMemoBytes ∷ t → ByteString → MemoBytes 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. t → ByteString → MemoBytes t Source #
Same as mkMemoBytes
, but with strict bytes
getMemoBytesType ∷ MemoBytes t → t Source #
Extract the inner type of the MemoBytes
getMemoBytesHash ∷ MemoBytes t → SafeHash (MemoHashIndex t) Source #
Extract the hash value of the binary representation of the MemoBytes
memoBytes ∷ Version → Encode 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 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.
showMemo ∷ Show t ⇒ MemoBytes t → String Source #
Deprecated: As unused. Show instance will show the hash, which is enough most of the time
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.
printMemo ∷ Show t ⇒ MemoBytes t → IO () Source #
Deprecated: As unused. Show instance will show the hash, which is enough most of the time
shortToLazy ∷ ShortByteString → ByteString Source #
Helper function. Converts a short bytestring to a lazy bytestring.
contentsEq ∷ Eq t ⇒ MemoBytes t → MemoBytes t → Bool Source #
Returns true if the contents of the MemoBytes are equal
decodeMemoBytes ∷ (DecCBOR t, MonadFail m) ⇒ Version → ByteString → m (MemoBytes t) Source #
Memoized
Class that relates the actual type with its raw and byte representations
mkMemoized ∷ ∀ t. (EncCBOR (RawType t), Memoized t) ⇒ Version → RawType t → t Source #
Construct memoized type from the raw type using its EncCBOR instance
getMemoSafeHash ∷ Memoized t ⇒ t → SafeHash (MemoHashIndex (RawType t)) Source #
Extract memoized SafeHash
getMemoRawType ∷ Memoized 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.
getMemoRawBytes ∷ Memoized t ⇒ t → ShortByteString Source #
Extract the raw bytes from the memoized version
lensMemoRawType ∷ ∀ era t a b. (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.
getterMemoRawType ∷ Memoized t ⇒ (RawType t → a) → SimpleGetter t a Source #
This is a helper SimpleGetter creator for any Memoized type
MemoBytes MemPack instance definitions
byteCountMemoBytes ∷ MemoBytes t → Int Source #
packMemoBytesM ∷ MemoBytes t → Pack s () Source #
Raw equality
Type class that implements equality on the Haskell type, ignoring any of the potentially memoized binary representation of the type.
Minimal complete definition
Nothing