Skip to content

Composing parsers and decoders, parse overload selection #211

Answered by stephencelis
kamcma asked this question in Q&A
Discussion options

You must be logged in to vote

@kamcma Is there a reason your parsers aren't consuming the input? Parsers are supposed to incrementally consume the data handed to them, so you might want to call input.removeAll() after successfully decoding those types.

Alternately, you may want to use a conversion here, which better describe non-incremental transformations (and is what we do with JSON encoding/decoding). I understand you may not care about creating full parser-printer here, though, and maybe there is no encoder available to use conversions instead. But if you do, you could use the conversion in MapConversion.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@randomeizer
Comment options

Comment options

You must be logged in to vote
1 reply
@kamcma
Comment options

Answer selected by kamcma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants