Stream: ideas

Topic: Set operations on Tag Unions enabling psudo gradual typing.


view this post on Zulip Patrick G (Aug 05 2024 at 12:26):

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.

view this post on Zulip Anton (Aug 05 2024 at 12:34):

@Richard Feldman

view this post on Zulip Patrick G (Aug 05 2024 at 13:11):

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

view this post on Zulip Anton (Aug 05 2024 at 14:24):

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.

view this post on Zulip Richard Feldman (Aug 05 2024 at 20:53):

yeah that's correct - it's not supported and there aren't plans to support it

view this post on Zulip Richard Feldman (Aug 05 2024 at 20:55):

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:

view this post on Zulip Patrick G (Aug 06 2024 at 11:15):

That makes sense, thanks for letting me know.


Last updated: Jun 16 2026 at 16:19 UTC