Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Machine bytestrings.
I mix string and bytestring terminology here due to bad C influences, but this module is specifically interested in bytestrings and their encoding. String/text encoding is handled in another module.
Note that the length prefix predicate is also defined here... because that's just Pascal-style bytestrings, extended to other types. I can't easily put it in an orphan module, because we define byte length for *all length-prefixed types* in one fell swoop.
Synopsis
- data Rep
- = C
- | Pascal ISize Endianness
- type AsByteString (rep :: Rep) = Refined rep ByteString
- getCString :: Getter ByteString
- putCString :: ByteString -> Builder
Documentation
Bytestring representation.
C | C-style bytestring. Arbitrary length, terminated with a null byte. Permits no null bytes inside the bytestring. |
Pascal ISize Endianness | Pascal-style bytestring. Length defined in a prefixing integer of given size and endianness. |
Instances
Data Rep Source # | |
Defined in Binrep.Type.ByteString gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Rep -> c Rep # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Rep # dataTypeOf :: Rep -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Rep) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Rep) # gmapT :: (forall b. Data b => b -> b) -> Rep -> Rep # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rep -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rep -> r # gmapQ :: (forall d. Data d => d -> u) -> Rep -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Rep -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Rep -> m Rep # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Rep -> m Rep # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Rep -> m Rep # | |
Generic Rep Source # | |
Show Rep Source # | |
Eq Rep Source # | |
Predicate 'C ByteString Source # | A C-style bytestring must not contain any null bytes. |
Defined in Binrep.Type.ByteString validate :: Proxy 'C -> ByteString -> Maybe RefineException # | |
(irep ~ IRep 'U size, Bounded irep, Integral irep, Show irep, Typeable size, Typeable e) => Predicate ('Pascal size e :: Rep) ByteString Source # | |
Defined in Binrep.Type.ByteString validate :: Proxy ('Pascal size e) -> ByteString -> Maybe RefineException # | |
BLen (AsByteString 'C) Source # | |
Defined in Binrep.Type.ByteString | |
(itype ~ I 'U size end, irep ~ IRep 'U size, KnownNat (CBLen irep)) => BLen (AsByteString ('Pascal size end)) Source # | |
Defined in Binrep.Type.ByteString | |
Get (AsByteString 'C) Source # | |
Defined in Binrep.Type.ByteString | |
(itype ~ I 'U size end, irep ~ IRep 'U size, Integral irep, Get itype) => Get (AsByteString ('Pascal size end)) Source # | |
Defined in Binrep.Type.ByteString | |
Put (AsByteString 'C) Source # | |
Defined in Binrep.Type.ByteString | |
(itype ~ I 'U size end, irep ~ IRep 'U size, Put itype, Num irep) => Put (AsByteString ('Pascal size end)) Source # | |
Defined in Binrep.Type.ByteString | |
type Rep Rep Source # | |
Defined in Binrep.Type.ByteString type Rep Rep = D1 ('MetaData "Rep" "Binrep.Type.ByteString" "binrep-0.3.1-inplace" 'False) (C1 ('MetaCons "C" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Pascal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ISize) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Endianness))) | |
type CBLen (AsByteString 'C) Source # | |
Defined in Binrep.Type.ByteString type CBLen (AsByteString 'C) = TypeError ('Text "No CBLen associated family instance defined for " :<>: 'ShowType (AsByteString 'C)) :: Natural | |
type CBLen (AsByteString ('Pascal size end)) Source # | |
Defined in Binrep.Type.ByteString type CBLen (AsByteString ('Pascal size end)) = TypeError ('Text "No CBLen associated family instance defined for " :<>: 'ShowType (AsByteString ('Pascal size end))) :: Natural |
type AsByteString (rep :: Rep) = Refined rep ByteString Source #
A bytestring using the given representation, stored in the Text
type.
putCString :: ByteString -> Builder Source #