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

Expose more structured decoding operations from cborg #264

Open
michaelpj opened this issue Aug 12, 2021 · 1 comment
Open

Expose more structured decoding operations from cborg #264

michaelpj opened this issue Aug 12, 2021 · 1 comment

Comments

@michaelpj
Copy link

Codec.CBOR.Term implements encoding/decoding of lists and maps, but they're not exported, so they can't be used elsewhere. For example, the instance for Serialise [a] uses very similar code.

It would be nice to export something like:

decodeListOf :: Decoder s x -> Decoder s [x]
decodeListOf decoder = CBOR.decodeListLenOrIndef >>= \case
  Nothing -> decodeSequenceLenIndef (flip (:)) [] reverse   decoder
  Just n  -> decodeSequenceLenN     (flip (:)) [] reverse n decoder

plus encoding, and maybe something similar for maps?

@michaelpj
Copy link
Author

Also perhaps similar things for indefinite-length bytestrings, like the encode/decodeChunked helpers in serialise.

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