Stream: beginners

Topic: ✔ Nothing is named `Present` in this scope.


view this post on Zulip Jason Hobbs (Dec 04 2023 at 18:07):

It seems like Present should be defined automatically by the core Dict types. Here's my code:

incrementDict : [ Missing, Present (Int Unsigned32) ] -> Present (Int Unsigned32)
incrementDict = \possibleValue ->
    when possibleValue is
        Missing -> Present 1
        Present value -> Present (value + 1)

The compiler:

Nothing is named `Present` in this scope.

47│  incrementDict : [ Missing, Present (Int Unsigned32) ] -> Present (Int Unsigned32)
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^

Did you mean one of these?

    Result
    Parser
    const
    Int

What's happening here?

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 18:11):

incrementDict : [ Missing, Present (Int Unsigned32) ] ->  [ Missing, Present (Int Unsigned32) ]

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 18:11):

Should be something like that

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 18:11):

Present is just a part of a tag, not a type

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 18:13):

That said, if we can think of a good name for it, we could exposed a type SomeName: [ Missing, Present (Int Unsigned32) ] from the dict module.

view this post on Zulip Jason Hobbs (Dec 04 2023 at 18:13):

Ah, I didn't realize there's a distinction. I thought type was renamed to tag in Roc.

I see just adding the brackets [ Present (Int U32) ] was enough to fix it

view this post on Zulip Jason Hobbs (Dec 04 2023 at 18:14):

In your example, SomeName would be a type and Missing, etc would be tags?

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 18:14):

[ Present (Int U32) ] -> That is a full type. It is a tag with one variant, Present

view this post on Zulip Brendan Hansknecht (Dec 04 2023 at 18:14):

In your example, SomeName would be a type and Missing, etc would be tags?

yep

view this post on Zulip Notification Bot (Dec 04 2023 at 18:25):

Jason Hobbs has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC