Hello, this is my first time seeing Roc, I've never used it personally.
However after looking at it, I was wondering if it's currently possible to define Tag Unions, that are a result of a set operation (union, exclusion, intersection, etc.) ? This could enable something akin to gradual typing.
eg
digits : [Zero 0, One 1, Two 2, Three 3, Four 4, Five 5, Six 6, Seven 7, Eight 8, Nine 9]
notFive: digits `exclusionOperator` Five
In a function, it could gradually narrow the type with some sort if isContainedInUnion operator / patten matching.
IDK. Just though I'd share. Since set operations can express any logical statement, it could be really powerful to expose.
Thanks.
@Richard Feldman
Here is an expansion of the idea with Claude:
Examples: https://claude.site/artifacts/37e1d156-e7f7-48ef-8ae1-bb07c002c1ea
Examples: https://claude.site/artifacts/1d7de243-c442-4808-bff0-e0bff4b42521
Full Convo: https://paste.quest/?48bd76eba8619fd5#2mz1tfGwDLveFh9covAn3KrcpB9KV2wrFZezZVSDegRE
Issues / Solutions: https://paste.quest/?c5b2d92994259e47#Xe8RbLpL72s4FLvDDF9KCH5zhXfKPKCoiTtFNvEPMjc
On Abilities / Effects: https://claude.site/artifacts/abab2552-87bd-4eae-923b-0feac8b99b5d
On Records: https://claude.site/artifacts/28e1227c-f322-456f-a8e2-f6c755ae6156
Yeah, from what I know we don't support exclusion and intersection of tag unions and do not plan to, but Richard will be able to give the full background on that decision.
yeah that's correct - it's not supported and there aren't plans to support it
this is the type of feature where I'd want to start with a motivating use case of either an application or library that someone wanted to build, but currently couldn't, and then discuss alternative approaches etc. :big_smile:
That makes sense, thanks for letting me know.
Last updated: Jun 16 2026 at 16:19 UTC