binrep-0.2.0: Encode precise binary representations directly in types
Safe HaskellSafe-Inferred
LanguageHaskell2010

Binrep.Generic

Description

Derive BLen, Put, Get and CBLen instances generically.

Synopsis

Documentation

data Cfg a Source #

Constructors

Cfg 

Fields

  • cSumTag :: String -> a

    How to turn a constructor name into a byte tag.

cSumTagHex :: forall a. Integral a => (String -> String) -> String -> a Source #

Obtain the tag for a sum type value by applying a function to the constructor name, and reading the result as a hexadecimal number.

cSumTagNullTerm :: String -> AsByteString 'C Source #

Obtain the tag for a sum type value using the constructor name directly (with a null terminator).

This is probably not what you want in a binary representation, but it's safe and may be useful for debugging.

The refine force is safe under the assumption that Haskell constructor names are UTF-8 with no null bytes allowed. I haven't confirmed that, but I'm fairly certain.

blenGeneric :: (Generic a, GBLen (Rep a), BLen w) => Cfg w -> a -> BLenT Source #

putGeneric :: (Generic a, GPut (Rep a), Put w) => Cfg w -> a -> Builder Source #

getGeneric :: (Generic a, GGet (Rep a), Get w, Eq w, Show w) => Cfg w -> Parser String a Source #

type CBLenGeneric w a = GCBLen w (Rep a) Source #