Hey, I still don't get how we could send "tags aka union types (?!)" from one context to another context, for exemple : from a pg db to a CLI app ? Because, let's assume we have 2 package having the same tags (Toto Int and Toto String), how can it be parsed correctly ?
This a point of confusion with tag unions, since tags with the same name but different payloads are not related at all, except for causing type errors when you try to make a single union with two tags of the same name but different payloads
Meaning you'll have to go another way, for example making a sub-union like TotoData : [Int, String]
or something that Toto
holds onto, or otherwise do manual threading of the data
As much as this is a hindrance, I think some alternative where there there can only be one payload type per tag would be a super annoying global poisoning, so I don't know a way around this limitation
We could also namespace things, but it would sacrify naming simplicity, but I guess it's the price to pay. I still struggle to imagine it at scale.
If you figure something out, we'd love to hear it! These are hard problems
My biggest issue is also updatability, imagine I merge 2 databases with "old" values, then we have a problem, because if tags are only strings, then a tag can mean 2 (or more) different things.
Yep, it's a tough problem, I don't have any solution, I'm just thinking about the problem, you know for example in Lamdera, you have migration of data, and when you migrate, you take the old "tags" (aka adt), and make them follow the new schema, it's all pretty clear, asks some boilerplate, but what's cool is that's it isn't ambiguous at all. In lamdera, it's namespaced by the name of the file. But if we store that inside a db, it doesn't belong to a "file" anymore, so it's complex.
Roc does have opaque types (which could be seen as a namespace and stop tags from unifying). And longer term, those will switch to the slighly more useable/friendly custom types
Via that, you have uniquely grouped tags that are defined in a single location and won't merge with other tags (even if they have the exact same names and types)
I assume for interacting with the outside (web, db, etc), custom types will be the default.
So that may color a lot of the design
looks amazing
custom types will be designed like in elm or different ?
I think like in elm, but I'm not actually sure. I have only done a tiny bit of elm and it has been quite a while. #ideas > custom types has a design doc as the very first message
Last updated: Jul 05 2025 at 12:14 UTC