I have this compiler error. Does anyone know what's wrong?
TYPE MISMATCH
This 1st argument to `readUtf8` has an unexpected type:
22│ File.readUtf8! (Path.fromStr "yarn.lock")
^^^^^^^^^^^^^^^^^^^^^^^^
This `Path.fromStr` call produces:
InternalPath.InternalPath
But `readUtf8` needs its 1st argument to be:
Str
It's because the File.readUtf8
function takes a path as a Str
, to use a Path
as the path, you can use the Path.readUtf8
function
The docs for the File module have a link on each function to the other version of it that takes a Path
and vice versa
I get the problem, but why do docs also give this example if it can never compile?
Unlike Rust, we don't (yet) test our doc code examples. That would be a good thing to do in the future!
This PR fixes the outdated example
Sam Mohr said:
Unlike Rust, we don't (yet) test our doc code examples. That would be a good thing to do in the future!
How involved would this be? Could you just find all code blocks in the docs and run their contents through roc check
or would it be more complicated than that?
Vladimir Zotov has marked this topic as resolved.
How involved would this be? Could you just find all code blocks in the docs and run their contents through
roc check
or would it be more complicated than that?
Examples may be missing imports and an app header but yeah should be pretty straightforward
Last updated: Jul 06 2025 at 12:14 UTC