Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode decimal-encoded numbers #11

Open
andrewthad opened this issue Oct 15, 2020 · 0 comments
Open

Decode decimal-encoded numbers #11

andrewthad opened this issue Oct 15, 2020 · 0 comments

Comments

@andrewthad
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant