Safe Haskell | None |
---|---|
Language | Haskell2010 |
MemoBytes is an abstraction for a data type 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
Memo | |
|
Instances
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 #