Stream: beginners

Topic: Do we still need a special syntax for open tag unions?


view this post on Zulip Aurélien Geron (Aug 29 2026 at 11:55):

Since PR #10434 will make unions in output positions implicitly open, we won't need to write Try(X, [A, B, ..]) anymore, we'll just write Try(X, [A, B]) instead. Very cool!

I'm wondering whether we will still need the [A, B, ..] syntax anymore? Are there important use cases where it might still be useful? It would be nice if there was just one syntax for all tag unions.

view this post on Zulip Jonathan (Aug 29 2026 at 12:04):

I can't think of something concrete, but one that comes to mind is saying "this function only concerns itself with these specific tags". Whether that's because you only take an action on some subset, or because the api is in flux and you want to be able to handle other cases with a default.

view this post on Zulip Jonathan (Aug 29 2026 at 12:07):

I think this might happen with libraries, where you can't depend on the specific platform types, but you say "this function expects at least these two tags for the core behaviour". That's just a hunch though, and it could be an antipattern to do so, I don't know.

view this post on Zulip Richard Feldman (Aug 29 2026 at 12:49):

I don't think we will still need it, unless @Jared Ramirez is aware of a scenario I'm not :smile:

view this post on Zulip Richard Feldman (Aug 29 2026 at 12:50):

that said, we do still need the type variable version, e.g. [A, B, ..others]

view this post on Zulip Richard Feldman (Aug 29 2026 at 12:50):

just not the .. on its own

view this post on Zulip Richard Feldman (Aug 29 2026 at 12:51):

although I suppose .. is just syntax sugar for .._unused aka .._ so there's no way to prevent it from being expressible if you really want to :laughing:

view this post on Zulip Jared Ramirez (Aug 29 2026 at 14:52):

right, and if you ever really did want a closed union, you could do ..[] to override polarity auto-opening

but ya, just plain .. will not commonly be used in output positions! and that PR will warn you that .. is redundant if used in an output position

view this post on Zulip Jared Ramirez (Aug 29 2026 at 14:53):

you could also in theory need .. in an input position to indicate that a tag union is open, since polarity only opens in closed positions

view this post on Zulip Romain Lepert (Aug 29 2026 at 16:20):

I suppose this means the “no polarity” experiment is done.

personally I did not mind the explicit open tag union in return type and the consistency with respect to the type system but I don’t mind either way.
Did you find it too intrusive ? Is their other reasons where it is a problem that I may not be aware of ?

view this post on Zulip Aurélien Geron (Aug 29 2026 at 19:12):

Yes, I must admit that I preferred tag unions in the old roc, they felt simpler. Having to write .map_err(|Foo| Foo) to turn a Try(X, [Foo]) into a Try(X, [Foo, Bar]) feels a bit weird, and it's worse when the error union has more than one tag.
Also, it's easy to forget .. in error unions, so some function have it and others don't (e.g., in the stdlib).

view this post on Zulip Romain Lepert (Aug 29 2026 at 22:04):

Ok. My policy was open tag in all Try return position, in which case these don’t happen. I Thought a warning was coming to make this practice more obvious but nvm


Last updated: Sep 03 2026 at 15:16 UTC