I was trying to follow along with the record builder example and noticed an ID
type used. At first I thought this was some made up type alias, but then I plugged it in to my roc repl and it seems to be built in.
I can't find any mention in the docs, so I'm wondering, what is ID
?
It's a made up tag I guess
Yes, tags don't need some earlier definition, you can create them on the spot.
Although I must admit that I also don't understand what := (ID, state)
means in the example
Since usually I thought that on the right hand side of a type definition there are other types or type variables, but as far as I know a tag is a value, not a type.
And if ID
were a tag with a payload state
the comma confuses me.
Good observation, I've looked at the full code and ID
is actually an alias for a U32.
I'll improve the example
So (ID, state)
is actually a tuple of U32 and the type variable state
that was passed to IDCount
However, if I enter IDCount state := (MyID, state)
in the REPL, it still accepts it. What is MyID
now?
Then it would be a tag
Yep, came here to report back that I got fooled by a tag :smiling_face_with_tear:
I've looked at the full code and ID is actually an alias for a U32.
I'll improve the example
Do you have a link to where you are looking?
Yes :)
Andy Hamon has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC