Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Binrep.Generic
Description
Derive BLen
, Put
, Get
and CBLen
instances generically.
Synopsis
- data Cfg a = Cfg {}
- cSumTagHex :: forall a. Integral a => (String -> String) -> String -> a
- cSumTagNullTerm :: String -> AsByteString 'C
- cDef :: Cfg (AsByteString 'C)
- blenGeneric :: (Generic a, GBLen (Rep a), BLen w) => Cfg w -> a -> BLenT
- putGeneric :: (Generic a, GPut (Rep a), Put w) => Cfg w -> a -> Builder
- getGeneric :: (Generic a, GGet (Rep a), Get w, Eq w, Show w) => Cfg w -> Parser String a
- type CBLenGeneric w a = GCBLen w (Rep a)
Documentation
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.
type CBLenGeneric w a = GCBLen w (Rep a) Source #