small-steps-0.1.0.0: Small step semantics
Safe HaskellNone
LanguageHaskell2010

Data.Coders

Description

MemoBytes is an abstration for a datetype that encodes its own seriialization. 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

Documentation

data Encode (w :: Wrapped) t where Source #

Constructors

Sum :: t -> Word -> Encode 'Open t 
Rec :: t -> Encode 'Closed t 
To :: ToCBOR a => a -> Encode 'Closed a 
E :: (t -> Encoding) -> t -> Encode 'Closed t 
ApplyE :: Encode w (a -> t) -> Encode 'Closed a -> Encode w t 

data Decode (w :: Wrapped) t where Source #

Constructors

Summands :: String -> (Word -> Decode 'Open t) -> Decode 'Closed t 
SumD :: t -> Decode 'Open t 
RecD :: t -> Decode 'Closed t 
From :: FromCBOR t => Decode 'Closed t 
D :: (forall s. Decoder s t) -> Decode 'Closed t 
ApplyD :: Decode w (a -> t) -> Decode 'Closed a -> Decode w t 
Invalid :: Word -> Decode w t 
Map :: (a -> b) -> Decode w a -> Decode w b 

Instances

Instances details
Functor (Decode w) Source # 
Instance details

Defined in Data.Coders

Methods

fmap :: (a -> b) -> Decode w a -> Decode w b #

(<$) :: a -> Decode w b -> Decode w a #

(!>) :: Encode w (a -> t) -> Encode 'Closed a -> Encode w t infixl 4 Source #

(<!) :: Decode w (a -> t) -> Decode 'Closed a -> Decode w t infixl 4 Source #

data Wrapped Source #

Some CBOR instances wrap encoding sequences with prefixes and suffixes. I.e. prefix , encode, encode, encode , ... , suffix A type that MUST do this is called 'Open. Other types are called 'Closed. The point is that a Closed type may have a prefix, but it can still be inlined by using the context it appears in, inside another Closed type. It does so by sharing the prefix of its containing type, and using positional context. In terms of Open and Closed, a datatype with more than one constructor is Open, and one with only one constructor is Closed (we call these records). Primitive types with no constructors can also be inlined, so we mark them as closed.

Constructors

Open 
Closed 

decode :: Decode w t -> Decoder s t Source #

runE :: Encode w t -> t Source #

decodeSet :: Ord a => Decoder s a -> Decoder s (Set a) Source #

decodeRecordNamed :: Text -> (a -> Int) -> Decoder s a -> Decoder s a Source #