here's a syntax reference comparing Elm, Haskell, and Roc syntax created by @Mario! (source code here)
quick tip, custom types syntax seems to be wrong. It’s comma separated instead of the |
oops good point! @Mario accepts pull requests, so you can make a quick fix if you like :big_smile:
oh wait, you're on the road! I'll make a PR
:car:
Roc lists starts with 0 or 1 ? I read somewhere that it's not possible to pattern match on list, why? There was some Elm algorithms I made in the past (nothing incredible) that would be very hard to do without pattern matching on list.
0
And because they aren’t really lists, they are actually arrays
so it’s not some cons list like structure under the hood which would allow you to easily remove the head and capture the rest of the list in a pattern match.
I feel like that shouldn't restrict pattern matching. Givem the arrays are immutable anyway, we should be able to create some sort of slice type data structure to enable cons list pattern matching, right?
I’m also not sure what the implications would be for how ref counting with re-use works
it's kind of tricky to make that work. Ideally, we want a slice to be of type List *
, so the user is not really able to distinguish the two
but then, that means every list needs an "offset" field which is zero for "normal" lists and can be non-zero for slices
question is: where do you store this information: storing it on the stack makes all lists in your program bigger. We know that how many bytes an object takes really matters for performance
Is there any particular design-philosophy reason why Roc lacks tuples?
you can use either records { x: I64, y: F64 }
or a global tag, say x = Pair a b
or x = T a b
the difference with e.g. elm is that T a b
works without a type definition (you can just use it inline) and T a b c
also works
Last updated: Jul 05 2025 at 12:14 UTC