I got these definitions and strengths from Roc's docs. Please suggest more, and we can compile a little guide to data modeling!
ex: Bool.true
ex: 12.34
ex: Dict.fromList [("Fred", "my friend"), ("Ang", "a stranger")])
ex: 12.34f64
ex: -1_234i16
ex: ["my", "friend", "Fred"]
ex: 1234
ex: { my: Friend, name: "Fred" }
ex: Result Friend Stranger
ex: Set.fromList ["my", "friend", "my", "Fred"]
ex: "my friend Fred"
ex: MyFriend "Fred"
ex: (my, Friend, "Fred")
ex: 1_234u16
Anything I post below is just my opinion. :blush:
Some strengths of tuples from the "Do we need tuples?" thread:
tup.6
(source: Brendan)when
statements to pattern match on multiple things at once (source: Luke)U8:
U8:
Bool:
Dict:
.values
open tag union:
(btw I'm very open to being wrong about these strengths I see - let me know if so!)
record:
This topic was moved here from #beginners > Strengths of each primitive/builtin Roc type by JanCVanB.
Result:
if foo bar then dbg bar
to larger diversions like when bar is Err e ->
with additional graceful handling of unmet expectations at runtime, without any obligation to treat every Err
like an exit-triggering Fatal Error in the stronger conceptual senseNote, dict and set are kinda ordered
Bool:
Dict:
Dec:
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.
Brendan Hansknecht said:
Note, dict and set are kinda ordered
Should we edit its docs?
Screenshot_20241214_132349.png
probably. Though maybe it is better to hide the ordering cause it is a kinda strange ordering
basically, inserts are ordered
removal swaps an item with then end and removes from the end
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.
oh I think we should document the insertion order!
Yeah, I guess my question is should we put it up front or as a detail later down
I think for most people, the order shouldn't matter and it is more a distraction/implementation detail
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
just as a like "you can use it in these use cases" kind of thing
:thumbs_up:
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