Stream: beginners

Topic: syntax


view this post on Zulip Richard Feldman (Aug 09 2021 at 12:40):

here's a syntax reference comparing Elm, Haskell, and Roc syntax created by @Mario! (source code here)

view this post on Zulip Lucas Rosa (Aug 09 2021 at 15:17):

quick tip, custom types syntax seems to be wrong. It’s comma separated instead of the |

view this post on Zulip Richard Feldman (Aug 09 2021 at 15:58):

oops good point! @Mario accepts pull requests, so you can make a quick fix if you like :big_smile:

view this post on Zulip Richard Feldman (Aug 09 2021 at 16:00):

oh wait, you're on the road! I'll make a PR

view this post on Zulip Lucas Rosa (Aug 09 2021 at 16:01):

:car:

view this post on Zulip Gabriela (Aug 11 2021 at 13:52):

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.

view this post on Zulip Lucas Rosa (Aug 11 2021 at 14:04):

0

view this post on Zulip Lucas Rosa (Aug 11 2021 at 14:04):

And because they aren’t really lists, they are actually arrays

view this post on Zulip Lucas Rosa (Aug 11 2021 at 14:05):

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.

view this post on Zulip Brendan Hansknecht (Aug 11 2021 at 16:23):

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?

view this post on Zulip Lucas Rosa (Aug 11 2021 at 20:35):

I’m also not sure what the implications would be for how ref counting with re-use works

view this post on Zulip Folkert de Vries (Aug 11 2021 at 20:39):

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

view this post on Zulip Folkert de Vries (Aug 11 2021 at 20:39):

but then, that means every list needs an "offset" field which is zero for "normal" lists and can be non-zero for slices

view this post on Zulip Folkert de Vries (Aug 11 2021 at 20:40):

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

view this post on Zulip Joseph Anthony Zullo (Oct 25 2021 at 20:47):

Is there any particular design-philosophy reason why Roc lacks tuples?

view this post on Zulip Folkert de Vries (Oct 25 2021 at 20:48):

you can use either records { x: I64, y: F64 } or a global tag, say x = Pair a b or x = T a b

view this post on Zulip Folkert de Vries (Oct 25 2021 at 20:49):

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