Stream: beginners

Topic: Too many args error using Stdout


view this post on Zulip victor dumbiri (Jun 23 2023 at 01:15):

Why do i get Too many args error when is use Stdout.line this way

Stdout.line "Hello, world"
 Stdout.line "Hello, Again"

view this post on Zulip Notification Bot (Jun 23 2023 at 01:19):

A message was moved here from #beginners > Formatting a closure in a record by Luke Boswell.

view this post on Zulip Luke Boswell (Jun 23 2023 at 01:20):

Hey @victor dumbiri , it may help to think of it like this

main =
    Stdout.line "Hello, World" |> Task.await \{} ->
        Stdout.line "Hello Again"

view this post on Zulip Luke Boswell (Jun 23 2023 at 01:22):

If you look at the type that main is expecting, it requires a Task {} * I think, and the type of Stdout.line is Task {} *, but when you want to chain these in sequence you need to use another function to combine them

view this post on Zulip Luke Boswell (Jun 23 2023 at 01:22):

My example shows how you can do this using Task.await

view this post on Zulip Luke Boswell (Jun 23 2023 at 01:23):

That is also the same as this, which uses backpassing syntax <- which de-sugars into the above example

main =
    {} <- Stdout.line "Hello, World" |> Task.await
    Stdout.line "Hello Again"

view this post on Zulip victor dumbiri (Jun 23 2023 at 01:27):

@Luke Boswell okay, thanks

view this post on Zulip Brendan Hansknecht (Jun 23 2023 at 01:32):

Just to add some extra context, with the original code, roc essentially is seeing it as:

Stdout.line "Hello, world" Stdout.line "Hello, Again"

Where the first Stdout.line is getting passed 3 args the string "Hello, world", the function Stdout.line and the string "Hello, Again".
This is probably a place where we should invest in better error messages.

view this post on Zulip Anton (Jun 25 2023 at 11:00):

I made #5602 for this


Last updated: Jul 06 2025 at 12:14 UTC