Crosscut

Daily Thought - 2025-03-29

Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!

There's one last aspect to normalizing variant types (in addition to sorting and deduplication), that we'll probably need in the language: flattening of nested variants. That would mean that variant { A, variant { B, C } } would become variant { A, B, C }.

Assume we have a function A -> variant { B, NetworkError }, and follow that up with another function B -> variant { C, FileNotFound }. Due to automatic lifting, that would result in a variant { variant { C, FileNotFound }, NetworkError }, which seems unnecessarily complex. And consider, chaining more functions could make that much worse.

I think the problem becomes more pronounced, if both functions return the same error, for example resulting in variant { variant { C, FileNotFound }, FileNotFound }. What even is that? If we flatten it to variant { C, FileNotFound, FileNotFound }, we can then deduplicate, resulting in variant { C, FileNotFound }. Much more reasonable!

Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email every time I post a new one.