I think I read in some place that it's possible to import a Module from a sub-directory. I have tried to do it a few different ways but unfortunately none have succeeded. Is it possible? How?
Hi @Sajjad Naveed,
Can you share your specific project structure?
Is it like this?
myProject/
├── main.roc
└── subdir
└── Module.roc
Yeah @Anton , It's pretty much exactly like how you described it.
You can do that like this:
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
import Subdir.Hello
# You can also do:
# import Subdir.Hello as Hello
# Or:
# import Subdir.Hello exposing [hello]
main =
Stdout.line! (Subdir.Hello.hello "World")
I noticed that starting with a lowercase letter (e.g. "import subdir.Hello")causes roc check
to hang, I'll make an issue for that.
I'll also make an official example for how to do Subdir imports like this.
Turns out we already have an issue for the hang #6388
I'll have a fix for this soon!
Thanks guys :raised_hands:
Last updated: Jul 05 2025 at 12:14 UTC