i want implement binary protocol (rfc3588, diameter) pure haskell. need know there better way (than e.g. data.binary...) read/write data from/to bytestrings. mapping haskell record bytestring, usual in c# using structlayout attribute (decorator).
haskell not give guarantees memory layout can not cast set of bytes struct - must parse using binary or rather (cereal, attoparsec, etc).
edit: example use of binary, consider:
{-# language derivegeneric #-} import data.binary import ghc.generics (generic) data foo = foo int | bar string deriving (eq, ord, show, read, generic) instance binary foo
now can encode
, decode
foo
type , bytes.
Comments
Post a Comment