Stream: beginners

Topic: Confusion about how imports and platforms work


view this post on Zulip Tankor Smash (Dec 02 2023 at 16:47):

Hey there,

I've got two files, src/main.roc and src/OtherFile.roc, running roc version: roc nightly pre-release, built from commit a56d7ad on Fr 01 Dez 2023 09:08:29 UTC.

It seems to want me to import pf.Path, but then complains it isn't used if I do.

src/main.roc:

app "import issue"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.0/bkGby8jb0tmZYsy2hg1E_B2QrCgcSTxdUlHtETwm5m4.tar.br" }
    imports [pf.Stdout, pf.Task, OtherFile, pf.File]
    provides [main] to pf

main =
    result <- OtherFile.foo
    Stdout.line "Result: \(result)"

src/OtherFile.roc

interface OtherFile
    exposes [foo]
    imports [pf.Stdout, pf.Path]

foo = \_anything ->
    path = Path.fromStr "input.txt"
    (Stdout.line "Trying to read '\(Path.display path)'")

image.png

So then if I add the pf.Path import to src/main.roc, I get a warning (?) telling me that Path is not used in main.roc:

updated src/main.roc:

app "import issue"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.0/bkGby8jb0tmZYsy2hg1E_B2QrCgcSTxdUlHtETwm5m4.tar.br" }
    imports [pf.Stdout, pf.Task, pf.Path, OtherFile, pf.File]
    provides [main] to pf

main =
    result <- OtherFile.foo
    Stdout.line "Result: \(result)"

image.png


Potentially related, if I remove pf.Task import from main.roc, I get the following MODULE NOT IMPORTEd error too:

image.png


I think If I use those imports in main.roc the warnings would go away, but it doesn't compile if I don't. What am I doing wrong?

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 16:53):

This is a know bug.

view this post on Zulip Tankor Smash (Dec 02 2023 at 16:54):

Oh okay thanks!

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 16:55):

Trying to find some links rn with extra context. I think that @Agus Zubiaga is working on a feature that revamps the import system and should fix this.

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 16:56):

#ideas > module params has some info about the overarching feature change

view this post on Zulip Tankor Smash (Dec 02 2023 at 16:57):

Looks like a potentially large change to imports. Cool!

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:01):

Yeah, I think Agus, is working on a full group at once, so may take a bit of time, but hopefully will cleanup this issues as part of the work.

view this post on Zulip Agus Zubiaga (Dec 02 2023 at 20:10):

Yeah, here’s the issue for this specific problem: https://github.com/roc-lang/roc/issues/5477

view this post on Zulip Agus Zubiaga (Dec 02 2023 at 20:16):

As Brendan said, most of these problems should go away as I rewrite big parts of the module system for that proposal implementation. It probably won’t be done this year, though :big_smile:


Last updated: Jul 06 2025 at 12:14 UTC