Tagged union wrapped in error union vs. errors in tagged union? (opens in new tab)
Ordinary errors can’t have additional data, so you have to return a tagged union instead of an error union. But what if of the possible errors of a function, only some have additional data and some are ordinary errors? For example, think of a CLI parser that can fail because of invalid input (which will return diagnostics about which input argument was bad) or because memory allocation failed. I could just return a tagged union, and include the ordinary error set in it, but returning errors t...
Read the original article