Stream: beginners

Topic: Default platform question


view this post on Zulip Андрей Краевский (Aug 19 2026 at 16:08):

It seems like roc has default platform on each it runs programs so this program runs succesfuly.

progress = |n| {
    "Progress ${n.to_str()}\n"
}

foo = |n| {
    ((0..<n).iter().map(progress)).fold("", Str.concat)
}

main! = |args| {
    echo!(foo(I64.from_str(args.first()?)?))
    Ok({})
}

But somehow this program in which i try to avoid as much string allocations (which all call mmap)
complains about platform not been specified

progress = |str, n| {
    str.concat(str, "Progress " )
        |> str.concat(n.to_str())
        |> str.concat("\n")
}

foo = |n| {
    ((0..<n).iter().fold("", progress)
}

main! = |args| {
    echo!(foo(I64.from_str(args.first()?)?))
    Ok({})
}
> roc hello.roc 100
──  expected app header ───────────────────────────────────────────────────────────────────────────────────────────────

Expected an app header in hello.roc.

but found: non-app

An app header looks like:

    app [main!] { pf: platform "..." }

Tip: Maybe you wanted to run roc test or roc check?

What did i change to cause it to stop using default platform? This two programs seems to be identical in functionality. Also which language works best for code blocks?

view this post on Zulip Anton (Aug 19 2026 at 16:20):

Hi @Андрей Краевский,
I will take a look at this, I typically use coffee for the code blocks.

view this post on Zulip Anton (Aug 19 2026 at 16:31):

The line below has unbalanced parenthesis, you can leave out the first one. Also, it is Str.concat instead of str.concat. That fixes the code.

((0..<n).iter().fold("", progress)

The original error message is still bad though, I will improve it.


Last updated: Sep 03 2026 at 15:16 UTC