-- |Encoder Types
module Flat.Encoder.Types(
  Size,
  NumBits,
  Prim,
  S(..)
) where

import           Flat.Types
import           GHC.Ptr         (Ptr (..))

-- |Add the maximum size in bits of the encoding of value a to a NumBits
type Size a = a -> NumBits -> NumBits

-- |Strict encoder state
data S =
       S
         { S -> Ptr Word8
nextPtr  :: {-# UNPACK #-} !(Ptr Word8)
         , S -> Word8
currByte :: {-# UNPACK #-} !Word8
         , S -> NumBits
usedBits :: {-# UNPACK #-} !NumBits
         } deriving NumBits -> S -> ShowS
[S] -> ShowS
S -> String
forall a.
(NumBits -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S] -> ShowS
$cshowList :: [S] -> ShowS
show :: S -> String
$cshow :: S -> String
showsPrec :: NumBits -> S -> ShowS
$cshowsPrec :: NumBits -> S -> ShowS
Show

-- |A basic encoder
type Prim = S -> IO S