kolmodin / binary

Efficient, pure binary serialisation using ByteStrings in Haskell.
Other
105 stars 67 forks source link

How does one specify a fixed length string? #176

Open danwdart opened 3 years ago

danwdart commented 3 years ago

I was starting with:

data Variable = Variable {
    length :: !Word32,
    var :: !ByteString,
    tree :: !Word8
} deriving (Generic, Binary, Show)

but I need the var to be a static length of course. What's the recommended way to do this? Arrays? DataKinds types? Smart constructors on custom types?

Ta