Stream: beginners

Topic: Tutorial: Building an Application (No stdout)


view this post on Zulip Jason Hobbs (Dec 01 2021 at 22:43):

Any ideas on why I'm not getting output here? The example Hello World works.

File

~/projects/exploration/advent-of-code-2021/roc 0 (8.3ms)
$ cat Hello.roc
app "hello"
    packages { pf: "examples/cli/platform" }
    imports [ pf.Stdout ]
    provides [ main ] to pf

main = Stdout.line "I'm a Roc application!"

Roc runs...

~/projects/exploration/advent-of-code-2021/roc 0 (19.6ms)
$ roc Hello.roc
🔨 Rebuilding host... Done!


~/projects/exploration/advent-of-code-2021/roc 0 (324ms)
$ ./hello


~/projects/exploration/advent-of-code-2021/roc 0 (2.9ms)
$ roc examples/hello-world/Hello.roc
🔨 Rebuilding host... Done!
Hello, World!

Git info

~/projects/exploration/advent-of-code-2021/roc 0 (5.9ms)
$ git log -n 1 --oneline
2da0c48c6 (HEAD -> trunk, origin/trunk, origin/HEAD) Merge pull request #2118 from rtfeldman/fix_macos_docs

~/projects/exploration/advent-of-code-2021/roc 0 (10.6ms)
$ git status
On branch trunk
Your branch is up to date with 'origin/trunk'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    Hello.roc
    hello

nothing added to commit but untracked files present (use "git add" to track)

view this post on Zulip Brendan Hansknecht (Dec 01 2021 at 22:49):

There is a bug with tasks currently try awaiting the stdout.line task and the returning task succeed

view this post on Zulip Brendan Hansknecht (Dec 01 2021 at 22:51):

Something like:

    {} <- Task.await (Stdout.line "I'm a Roc application!")
    Task.succeed {}

view this post on Zulip Jason Hobbs (Dec 01 2021 at 22:53):

app "hello"
    packages { pf: "examples/cli/platform" }
    imports [ pf.Stdout, pf.Task.{ Task, await } ]
    provides [ main ] to pf

main : Task {} *
main =
  {} <- Stdout.line "I'm a Roc application!"
  Task.succeed {}

produces

$ roc Hello.roc
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/mono/src/ir.rs:8208:35
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

view this post on Zulip Brendan Hansknecht (Dec 01 2021 at 22:54):

You forget the await.

view this post on Zulip Jason Hobbs (Dec 01 2021 at 22:54):

Yes I did! That works


Last updated: Jul 05 2025 at 12:14 UTC