Because of how GHC works, bytesmith always boxes the result of parse. This is normally fine. The result of a parse is typically some kind of boxed data that can live happily on the heap. However, in several different projects, I've ended up needed to define
decodeWord64 :: Bytes -> Maybe Word64
decodeWord64 = Parser.parseBytesMaybe (Latin.decWord64 ())
It's sad to have to allocate for the W# data constructor. I've been avoiding adding Char8/Ascii/Latin module to this library, but I think that Data.Bytes.Latin would be a good place for these:
decWord64 :: Bytes -> Maybe Word64
splitDecWord64 :: Bytes -> Maybe (Word64, Bytes)
The second variant allows extra bytes to be leftover. The first does not.
Because of how GHC works,
bytesmithalways boxes the result of parse. This is normally fine. The result of a parse is typically some kind of boxed data that can live happily on the heap. However, in several different projects, I've ended up needed to defineIt's sad to have to allocate for the
W#data constructor. I've been avoiding addingChar8/Ascii/Latinmodule to this library, but I think thatData.Bytes.Latinwould be a good place for these:The second variant allows extra bytes to be leftover. The first does not.