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?
incrementDict : [ Missing, Present (Int Unsigned32) ] -> [ Missing, Present (Int Unsigned32) ]
Should be something like that
Present
is just a part of a tag, not a type
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.
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
In your example, SomeName
would be a type and Missing
, etc would be tags?
[ Present (Int U32) ]
-> That is a full type. It is a tag with one variant, Present
In your example, SomeName would be a type and Missing, etc would be tags?
yep
Jason Hobbs has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC