Stream: beginners

Topic: ✔ Dict no longer requiring Hash and Eq


view this post on Zulip timotree (Dec 11 2023 at 00:39):

After @Brendan Hansknecht's' recent rewrite of Dict, we don't need Hash & Eq bounds on the methods anymore. Why not? I imagine we still need to perform these operations on keys. Is it because all types implement them now somehow?

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 00:41):

The Dict type has the requirement. So saying Dict k v implies that k implements Hash & Eq. So no need to specify it at all call sites

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 00:41):

So I didn't change any requirements. I just removed redundant specifications

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 00:42):

I guess the docs here should really show the required abilities: https://www.roc-lang.org/builtins/Dict#Dict

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 00:42):

Cause I don't think that is currently specified in any docs.

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 00:43):

requirement is right here in the dict definition: https://github.com/roc-lang/roc/blob/f795d0856a8a68747aa7bc975827bd02ff8d4610/crates/compiler/builtins/roc/Dict.roc#L102

view this post on Zulip timotree (Dec 11 2023 at 00:43):

Ah makes sense. Thanks

view this post on Zulip Notification Bot (Dec 11 2023 at 00:43):

timotree has marked this topic as resolved.

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 00:45):

made #6248 about doc generation missing this info


Last updated: Jul 06 2025 at 12:14 UTC