I just rewrote the whole roc-for-elm-programmer.md
section on tags based on some design ideas we've been discussing - love to hear any feedback anyone has about it!
Ooh, < Type >
is a new notation?
Ok, coffee made me too reactive, just saw other sentence. :)
By the way, inside a tag union annotation, the < and > angle brackets around each tag are syntactically optional because they don't add any information.
Is there a reason to keep < >
notation if above holds true?
As always maybe there is a pedagogical use of it to not mix lists and tag unions
> y = Foo [ 1.1 ] "hi"
Foo [ 1.1 ] "hi" : <Foo (List Float) Str>
> z = Foo "hi" True
Foo "hi" True : <Foo Str <True>>
Is there a reason to keep
<
>
notation if above holds true?
yes! There are two reasons:
Foo
value on its own be [ Foo ]*
like it is today (whereas in this draft it'd be <Foo>
instead).List.first : List a -> Result a <ListWasEmpty>
instead of
List.first : List a -> Result a [ ListWasEmpty ]*
but I'm honestly not sure overall if this is an improvement, or if we should stick to [ ]*
over < >
My only issue with < >
is that you are forced to deal with both [ Bar, Baz ]*
and <Baz>
vs [ Bar, Baz ]*
and [Baz]*
So like you have to learn 2 pieces of syntax instead of just one.
fair point!
would it be weird if values of [ Foo ]*
could be passed to things that wanted functions? e.g. if [ Foo ]*
could be passed to a function that wanted [ Foo ]*
or a -> [ Foo a ]*
or a, b -> [ Foo a b ]*
or a, b, c -> [ Foo a b c ]*
etc?
(I thought it might be less weird with the <Foo>
syntax, but maybe that's not helping?)
Ah, i see. Hmmm. That's a really valid point for separate syntax.
:thinking: I wonder if it might be more straightforward if the rule were "<Foo>
is syntax sugar for [ Foo ]*
"
I kind of like [ Foo ]*
over <Foo>
too. Not because its more or less confusing, but because I like there being just one way to convey that (they would be co-existing alternatives? If <Foo>
was a thing, then [ Foo ]*
would still be valid right?
What would be the natural way of reading [ Foo ]*
? "At least Foo
"? What about <Foo>
? If its the same thing, I guess it should read the same way in natural language, but it kind of feels different to me. Like its meant to convey that it is just Foo
and nothing else.
Not sure! Just sharing my impressions. I guess the wild card ultimately means "and nothing else" in the same way that List *
is necessarily empty, but can be joined with something non-empty, so [ Foo ]*
is "a group containing Foo
and also nothing else"
Maybe, if we kick out parenthesis from tag unions?
Song :
Fun ,
Sad Int,
Sexy (Result Str (Male, Female, Alien,|*)),
|*
and we can even have functions xx: Foo |* -> Foo, Bar
or extendFoo : Foo -> Foo, Bar, Faux |*
Where |*
would serve as ]*
as currently is it can easy only be just *
Last updated: Jul 06 2025 at 12:14 UTC