Stream: beginners

Topic: type error in the tutorial app


view this post on Zulip Matthieu Pizenberg (Sep 22 2022 at 10:19):

I just installed the latest nightly linux build and when running roc Hello.roc on the first app of the tutorial, importing the platform from examples/interactive/cli-platform/main.roc I get a type error saying

This #UserApp.main value is a:

    Task.Task {} * [Write [Stdout]*]* ?

But toEffect needs its 1st argument to be:

    InternalProgram.InternalProgram ?

Did I do something wrong?

view this post on Zulip Richard Feldman (Sep 22 2022 at 10:33):

oops, I forgot to update the tutorial in https://github.com/roc-lang/roc/pull/4071

view this post on Zulip Richard Feldman (Sep 22 2022 at 10:35):

short version: the type of main should be Program now - here are ways to get one of those!

https://www.roc-lang.org/examples/cli/Program

view this post on Zulip Matthieu Pizenberg (Sep 22 2022 at 10:46):

hum, I'm not sure what to change where. I tried this but failed to find Program.roc

app "hello"
    packages { pf: "/home/matthieu/git/roc-lang/roc/examples/interactive/cli-platform/main.roc" }
    imports [pf.Stdout, Program]
    provides [main] to pf

main = Stdout.line "I'm a Roc application!" |> Program.quick

sorry really beginner here ^^

view this post on Zulip Richard Feldman (Sep 22 2022 at 10:58):

no worries! You'll want to import pf.Program

view this post on Zulip Richard Feldman (Sep 22 2022 at 10:58):

because that module comes from the CLI platform

view this post on Zulip Matthieu Pizenberg (Sep 22 2022 at 11:05):

alright I changed that and now I'm getting more errors related to an Effect.map call. Do you want me to open a PR for this forgotten change? meanwhile I'll just skip that part of the tutorial and continue forward.

view this post on Zulip Matthieu Pizenberg (Sep 22 2022 at 11:06):

Open an issue I meant, not a PR XD

view this post on Zulip Richard Feldman (Sep 22 2022 at 11:28):

haha yeah sounds good, thank you!

view this post on Zulip Richard Feldman (Sep 22 2022 at 11:29):

if you take a look at examples/interactive/file.roc you can see a working CLI app that uses Program - that may help!

view this post on Zulip Richard Feldman (Sep 22 2022 at 11:30):

(we check everything in the examples/ folder on CI, so I know it's been updated)

view this post on Zulip Anton (Sep 23 2022 at 08:16):

I'll make an issue to set up testing for the snippets in the tutorial.

view this post on Zulip Matthieu Pizenberg (Sep 23 2022 at 11:06):

It took me longer than expected to figure out my second issue. I think it was an incompatibility between the nightly executable and the example files in the git repo. So today I just rebuilt from scratch with the repo instead of using the nightly and now it works as expected with the following example code:

app "hello"
    packages { pf: "/home/matthieu/git/roc-lang/roc/examples/interactive/cli-platform/main.roc" }
    imports [pf.Stdout, pf.Program]
    provides [main] to pf

main = Stdout.line "I'm a Roc application!" |> Program.quick

I'll try to open a PR in the afternoon

view this post on Zulip Folkert de Vries (Sep 23 2022 at 11:08):

right that can happen

view this post on Zulip Matthieu Pizenberg (Sep 23 2022 at 13:49):

Here is the PR to update the tutorial programs: https://github.com/roc-lang/roc/pull/4104


Last updated: Jul 05 2025 at 12:14 UTC