Maybe this doesn't apply to a language like roc, but I thought this might be an interesting discussion.
In Rust, it is quite common for projects to use error handling crates like anyhow. Anyhow enables fundamentally keeping around the original error type while adding extra context.
Given these projects are so common, it suggests there is a want for this kind of feature. Would we expect the same to come up in Roc? How would we expect it to be handled? Just adding wrapper tags with pattern matching to generate output strings?
Just kinda wondering if we will have a similar gap in extra information users would want with errors.
Any thoughts?
I think it will be inevitable (a similar thing occurs in go where you want to accumulate context). I do think however the lightweight feel of Roc's tag unions will make it much easier to construct and use those wrapper variants. Personally I think we should see the behavior in practice before trying to optimize
Sure, but if it is expected and an area that isn't addressed well by core languages in many cases, we may want to think about it some.
There is this really interesting article about the disadvantages of Result-based error handling and how to improve it: https://www.parsonsmatt.org/2018/11/03/trouble_with_typed_errors.html
This gave rise to the Plucky library in Haskell
and to the 'Veither' and ExceptV/VexceptT libraries/abstractions in PureScript.
I think those ideas are very closely related to what is possible with Roc's tag unions, so it might be a match made in heaven
A lot of it looks like just being able to use open tags and merge tags.
oh, this is the article that inspired tag unions! You found it! :smiley:
years later I kept looking for this and always failed to find it :laughing:
this sentence from the article specifically:
In PureScript or OCaml, you can use open variant types to do this flawlessly. Haskell doesn’t have open variants, and the attempts to mock them end up quite clumsy to use in practice.
I was like "wait hang on, how does that work?" and then went off on a tangent trying to prototype error handling in OCaml using only polymorphic variants
and it turned out it worked really nicely!
Last updated: Jun 16 2026 at 16:19 UTC