Stream: beginners

Topic: What does [].{} syntax means?


view this post on Zulip gavr (Apr 03 2026 at 13:41):

What does [].{} syntax mean?
I found it inside the bindings https://github.com/lukewilliamboswell/roc-platform-template-zig/blob/main/platform/Stdout.roc

Stdout := [].{
    line! : Str => {}
}

view this post on Zulip Anton (Apr 04 2026 at 07:56):

Hi @gavr,
That's an excellent question, this is different from the old Roc.

Feel free to ask more questions :)

view this post on Zulip gavr (Apr 04 2026 at 12:28):

@Anton thanks, yea I just found

# Define a nominal type with a custom is_eq method
Animal := [Dog(Str), Cat(Str)].{
    is_eq = |a, b| match (a, b) {
        (Dog(name1), Dog(name2)) => name1 == name2
        (Cat(name1), Cat(name2)) => name1 == name2
        _ => Bool.False
    }
}

here https://github.com/lukewilliamboswell/roc-platform-template-zig/blob/main/examples/all_roc_syntax.roc

I will create new branch with new method question, for better discoverability

view this post on Zulip Anton (Apr 04 2026 at 12:34):

By the way, here you can find the most recent version of the all syntax overview file, it no longer requires a platform: https://github.com/roc-lang/roc/blob/main/test/echo/all_syntax_test.roc

view this post on Zulip gavr (Apr 04 2026 at 12:36):

@Anton yap, already found this, my next question includes it, #beginners > How to define a static method


Last updated: Apr 10 2026 at 12:38 UTC