I have run into an issue when trying to create a package... Let's say I define a generic type in a module, and then have another module import the type and define a more specific version of it, for example
package/Parser/Advanced/Generic.roc
:
interface Parser.Advanced.Generic
exposes [Parser ]
imports []
Parser input value :=
input -> Result value Str
package/Parser/Bytes.roc
:
interface Parser.Bytes
exposes [Parser]
imports [Parser.Advanced.Generic]
Parser value : Parser.Advanced.Generic.Parser Str value
I also have a main file,
package/main.roc
:
And then I have an example file which tries to use the less generic version,
examples/example.roc
:
app "example"
packages {
cli: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br",
parser: "../package/main.roc",
}
imports [
cli.Stdout,
parser.Parser.Bytes.{ Parser }
]
provides [main] to cli
main =
Stdout.line "hello"
Then I get some errors when I try to build the example! But not when running `roc check package/main.roc´
The errors I get are:
── MODULE NOT IMPORTED ─────────────────────────── ../package/Parser/Bytes.roc ─
The `Parser.Advanced.Generic` module is not imported:
8│ Parser value : Parser.Advanced.Generic.Parser Str value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Did you mean to import it?
── MISSING DEFINITION ──────────────────────────── ../package/Parser/Bytes.roc ─
Parser is listed as exposed, but it isn't defined in this module.
You can fix this by adding a definition for Parser, or by removing it
from exposes.
────────────────────────────────────────────────────────────────────────────────
I can fix the error by also importing Parser.Advanced.Generic.Parser
in the example. But should I not be able to use the more specific type and not have to even know/care about the generic one? (this example is inspired by the elm parser, which is built in this way with one advanced parser and then a simpler parser which is a more specific type with fewer type variables)
Not sure this is a fix, but if you import Parser.Advanced.Generic
, I would assume you would have to references things as Generic.Parser
Is that the same issue as this? https://github.com/roc-lang/roc/issues/5477
Oh! Yes that seems to be the same. Ok then I know it’s a known issue at least
Brendan Hansknecht said:
Not sure this is a fix, but if you import
Parser.Advanced.Generic
, I would assume you would have to references things asGeneric.Parser
Hmm if I try to reference like this Parser value : Generic.Parser Str value
I get a panic:
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', crates/compiler/load_internal/src/docs.rs:382:71
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Last updated: Jul 05 2025 at 12:14 UTC