Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.MemoBytes
Description
MemoBytes is an abstration for a datetype that encodes its own serialization. The idea is to use a newtype around a MemoBytes non-memoizing version. For example: newtype Foo = Foo(MemoBytes NonMemoizingFoo) This way all the instances for Foo (Eq,Show,Ord,ToCBOR,FromCBOR,NoThunks,Generic) can be derived for free.
Synopsis
- data MemoBytes t = Memo {
- memotype :: !t
- memobytes :: ShortByteString
- memoBytes :: Encode w t -> MemoBytes t
- type Mem t = Annotator (MemoBytes t)
- shorten :: ByteString -> ShortByteString
- showMemo :: Show t => MemoBytes t -> String
- printMemo :: Show t => MemoBytes t -> IO ()
- roundTripMemo :: FromCBOR t => MemoBytes t -> Either DeserialiseFailure (ByteString, MemoBytes t)
Documentation
Constructors
Memo | |
Fields
|
Instances
Eq t => Eq (MemoBytes t) Source # | |
Ord t => Ord (MemoBytes t) Source # | |
Defined in Data.MemoBytes | |
Show t => Show (MemoBytes t) Source # | |
Generic (MemoBytes t) Source # | |
Typeable t => ToCBOR (MemoBytes t) Source # | |
(Typeable t, FromCBOR (Annotator t)) => FromCBOR (Annotator (MemoBytes t)) Source # | |
NFData t => NFData (MemoBytes t) Source # | |
Defined in Data.MemoBytes | |
(Typeable t, NoThunks t) => NoThunks (MemoBytes t) Source # | |
type Rep (MemoBytes t) Source # | |
Defined in Data.MemoBytes type Rep (MemoBytes t) = D1 ('MetaData "MemoBytes" "Data.MemoBytes" "small-steps-0.1.0.0-2ipJpwzZFt642witnrAmH1" 'False) (C1 ('MetaCons "Memo" 'PrefixI 'True) (S1 ('MetaSel ('Just "memotype") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t) :*: S1 ('MetaSel ('Just "memobytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString))) |
type Mem t = Annotator (MemoBytes t) Source #
Useful when deriving FromCBOR(Annotator T) deriving via (Mem T) instance (Era era) => FromCBOR (Annotator T)
shorten :: ByteString -> ShortByteString Source #
roundTripMemo :: FromCBOR t => MemoBytes t -> Either DeserialiseFailure (ByteString, MemoBytes t) Source #