Skip to content

Decode decimal-encoded numbers #11

Description

@andrewthad

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions