Stream: contributing

Topic: Strengths of each primitive/builtin Roc type


view this post on Zulip jan kili (Dec 14 2024 at 19:20):

I got these definitions and strengths from Roc's docs. Please suggest more, and we can compile a little guide to data modeling!

Bool

ex: Bool.true

Dec

ex: 12.34

Dict

ex: Dict.fromList [("Fred", "my friend"), ("Ang", "a stranger")])

F*

ex: 12.34f64

I*

ex: -1_234i16

List

ex: ["my", "friend", "Fred"]

Num

ex: 1234

record

ex: { my: Friend, name: "Fred" }

Result

ex: Result Friend Stranger

Set

ex: Set.fromList ["my", "friend", "my", "Fred"]

Str

ex: "my friend Fred"

tag / closed/open tag union

ex: MyFriend "Fred"

tuple

ex: (my, Friend, "Fred")

U*

ex: 1_234u16


Anything I post below is just my opinion. :blush:

view this post on Zulip jan kili (Dec 14 2024 at 19:20):

Some strengths of tuples from the "Do we need tuples?" thread:

view this post on Zulip jan kili (Dec 14 2024 at 19:26):

U8:

view this post on Zulip jan kili (Dec 14 2024 at 19:28):

U8:

Bool:

view this post on Zulip jan kili (Dec 14 2024 at 19:32):

Dict:

view this post on Zulip jan kili (Dec 14 2024 at 19:35):

open tag union:

view this post on Zulip jan kili (Dec 14 2024 at 19:36):

(btw I'm very open to being wrong about these strengths I see - let me know if so!)

view this post on Zulip jan kili (Dec 14 2024 at 19:37):

record:

view this post on Zulip Notification Bot (Dec 14 2024 at 19:42):

This topic was moved here from #beginners > Strengths of each primitive/builtin Roc type by JanCVanB.

view this post on Zulip jan kili (Dec 14 2024 at 19:47):

Result:

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:06):

Note, dict and set are kinda ordered

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:08):

Bool:

Dict:

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:11):

Dec:

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:20):

Example of where dec would shine and float can suck: https://www.youtube.com/watch?v=SBfR3ftM1cU&t=3276s

Essentially 1597.0000 and 1597.0001 round to the same value in floats, but in dec, what you see is what you get. So thos are two distinct values.

view this post on Zulip jan kili (Dec 14 2024 at 20:24):

Brendan Hansknecht said:

Note, dict and set are kinda ordered

Should we edit its docs?
Screenshot_20241214_132349.png

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:28):

probably. Though maybe it is better to hide the ordering cause it is a kinda strange ordering

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:28):

basically, inserts are ordered

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:28):

removal swaps an item with then end and removes from the end

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 20:29):

so with a set if you insert 1, 2, 3, 4 then remove 1, you will get 4, 2, 3. Same with a dict just with attached values.

view this post on Zulip Richard Feldman (Dec 14 2024 at 21:07):

oh I think we should document the insertion order!

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 21:21):

Yeah, I guess my question is should we put it up front or as a detail later down

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 21:22):

I think for most people, the order shouldn't matter and it is more a distraction/implementation detail

view this post on Zulip Richard Feldman (Dec 14 2024 at 21:27):

ah, so I think that's how it ended up being for us, but it actually makes it useful in more situations so I think it's worth noting up front

view this post on Zulip Richard Feldman (Dec 14 2024 at 21:27):

just as a like "you can use it in these use cases" kind of thing

view this post on Zulip Brendan Hansknecht (Dec 14 2024 at 21:43):

:thumbs_up:

view this post on Zulip Notification Bot (Dec 14 2024 at 21:49):

2 messages were moved from this topic to #ideas > remove if to promote tags by Brendan Hansknecht.


Last updated: Jul 06 2025 at 12:14 UTC