But how? Parsing function can return any of the types, we don’t know what was in the bytestring. So we’d need to deal with all variations in any case, no?
Is the difference in that it becomes possible to pattern-match on a type of an element inside the structure, rather than on the structure as a whole? So as long as you don’t need that element, you can access elements that are common without pattern-matching? I guess it’s a marginal benefit…
Or do I still misunderstand?
Well, I guess that I can see the value… Leaving copy-pasting problem aside, you might, for instance, want to have a type for a message with moderately complex envelope and a wide variety of possible payload types. It would be useful to have functions that act on the envelope, and treat payload as something opaque.
Thanks for the conversation!