Stream: beginners

Topic: ✔ Documentation for `ID`


view this post on Zulip Andy Hamon (Jan 06 2024 at 09:27):

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?

view this post on Zulip mkrieger1 (Jan 06 2024 at 10:06):

It's a made up tag I guess

view this post on Zulip Anton (Jan 06 2024 at 10:08):

Yes, tags don't need some earlier definition, you can create them on the spot.

view this post on Zulip mkrieger1 (Jan 06 2024 at 10:09):

Although I must admit that I also don't understand what := (ID, state) means in the example

view this post on Zulip mkrieger1 (Jan 06 2024 at 10:12):

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.

view this post on Zulip mkrieger1 (Jan 06 2024 at 10:14):

And if ID were a tag with a payload state the comma confuses me.

view this post on Zulip Anton (Jan 06 2024 at 10:14):

Good observation, I've looked at the full code and ID is actually an alias for a U32.
I'll improve the example

view this post on Zulip Anton (Jan 06 2024 at 10:15):

So (ID, state) is actually a tuple of U32 and the type variable state that was passed to IDCount

view this post on Zulip mkrieger1 (Jan 06 2024 at 10:22):

However, if I enter IDCount state := (MyID, state) in the REPL, it still accepts it. What is MyID now?

view this post on Zulip Anton (Jan 06 2024 at 10:23):

Then it would be a tag

view this post on Zulip Andy Hamon (Jan 06 2024 at 10:32):

Yep, came here to report back that I got fooled by a tag :smiling_face_with_tear:

view this post on Zulip Andy Hamon (Jan 06 2024 at 10:35):

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?

view this post on Zulip Anton (Jan 06 2024 at 10:36):

Yes :)

view this post on Zulip Notification Bot (Jan 08 2024 at 20:17):

Andy Hamon has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC