Stream: beginners

Topic: data interoperability


view this post on Zulip Tib (Mar 04 2025 at 04:33):

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 ?

view this post on Zulip Sam Mohr (Mar 04 2025 at 04:37):

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

view this post on Zulip Sam Mohr (Mar 04 2025 at 04:38):

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

view this post on Zulip Sam Mohr (Mar 04 2025 at 04:40):

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

view this post on Zulip Tib (Mar 04 2025 at 05:27):

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.

view this post on Zulip Sam Mohr (Mar 04 2025 at 08:07):

If you figure something out, we'd love to hear it! These are hard problems

view this post on Zulip Tib (Mar 04 2025 at 08:13):

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.

view this post on Zulip Brendan Hansknecht (Mar 04 2025 at 17:12):

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

view this post on Zulip Brendan Hansknecht (Mar 04 2025 at 17:13):

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)

view this post on Zulip Brendan Hansknecht (Mar 04 2025 at 17:13):

I assume for interacting with the outside (web, db, etc), custom types will be the default.

view this post on Zulip Brendan Hansknecht (Mar 04 2025 at 17:13):

So that may color a lot of the design

view this post on Zulip Tib (Mar 04 2025 at 17:14):

looks amazing

custom types will be designed like in elm or different ?

view this post on Zulip Brendan Hansknecht (Mar 04 2025 at 17:31):

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