Suppose I have two Roc files - one defines an interface, and another an app. I want to import my interface into my app.
The interface (BinaryTree.roc) looks like:
interface BinaryTree
exposes [
Tree, Node, Null, listToTree, hasLhs, hasRhs,
]
# rest of roc code ...
And the complete app (LeafSimilar.roc) code is:
app "leafsimilar"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.1/..." }
imports [
pf.Stdout,
BinaryTree.{
Tree,
Node,
Null,
listToTree,
hasLhs,
hasRhs
}
]
provides [main] to pf
main = Stdout.line "Hello, world!"
But when I run roc dev LeafSimilar.roc
, I get an error message that doesn't make much sense to me:
── WEIRD IMPORTS ────────────────────────────────────────────── BinaryTree.roc ─
I am partway through parsing a header, but I got stuck here:
10│ ]
^
I am expecting the imports keyword next, like
imports [Animal, default, tame]
I'm not finding much documentation on how to do imports, but from the examples I've looked at, I think my import statement looks good, also the error message doesn't really make sense, as I see no reason that it would expect the imports
statement next, on line 10, after my existing imports
statement. Any help?
At the top right of the error message it shows the filename BinaryTree.roc. Can you also show us the full header of that file?
Without seeing it, my guess is that you might need to add an empty imports
?
That was it - thanks!
Ian McLerran has marked this topic as resolved.
Maybe the filename is too easy to miss in our error message layout?
Last updated: Jul 06 2025 at 12:14 UTC