Hey, noob here. I'm going through the tutorial but got stuck trying to understand why I have this error with the following code:
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
}
import pf.Stdout
import pf.Task
# main : Task.Task {} _
main =
Stdout.line! "Hello, World!"
res1 = "test"
Stdout.line! "Hello, World! $(res1)"
res2 =
["a", "b", "c"]
|> List.append "d"
|> Str.joinWith ""
Stdout.line! res2
res3 =
(["a", "b", "c"])
|> List.append "d"
|> Str.joinWith ""
but, if I change it to this, it works
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
}
import pf.Stdout
import pf.Task
# main : Task.Task {} _
main =
Stdout.line! "Hello, World!"
res1 = "test"
Stdout.line! "Hello, World! $(res1)"
res2 =
["a", "b", "c"]
|> List.append "d"
|> Str.joinWith ""
Stdout.line! res2
res3 =
(["a", "b", "c"])
|> List.append "d"
|> Str.joinWith ""
Stdout.line! res3
Roc version: roc nightly pre-release, built from commit 0e1a9545c6c on Sat Jun 8 09:11:54 UTC 2024
Any help or explanation is appreciated. Thank you!
Fundamentally, basic cli requires that main
returns a task.
With the first example, the last thing you do is assign a variable instead of returning a task
With the second example, you end with a !
. !
ends up building up a chain of tasks.
So ending with Stdout.line! res3
will return the full chain of tasks, with the last task being printing res3
oh ok, it's clear now, thank you so much!
Rauny has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC