Importing a Package from a Module
You probably know how to add a package in an app file, for example with the unicode package:
app [main!] { cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.25.0/CZsY7tYZwR3rj9kYbpaCfxki2yVAaRL8bBwMLvB2xkbA.tar.zst", roc: "nightly-2026-10-09-258ab27", unicode: "https://github.com/roc-lang/unicode/releases/download/4.2.0/4W8SHzvwet9hH9qZewJ1J1CVQoH7YKA6zyijWFTB3y1w.tar.zst", }
But how can you add a package inside a module file? All dependencies go in the app file!
So we have the app file just like before:
### start snippet header app [main!] { cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.25.0/CZsY7tYZwR3rj9kYbpaCfxki2yVAaRL8bBwMLvB2xkbA.tar.zst", roc: "nightly-2026-10-09-258ab27", unicode: "https://github.com/roc-lang/unicode/releases/download/4.2.0/4W8SHzvwet9hH9qZewJ1J1CVQoH7YKA6zyijWFTB3y1w.tar.zst", } ### end snippet header import cli.Stdout import Module main! = |_args| { Module.split_graphemes("hello") |> Str.inspect |> Stdout.line! }
And the unicode import goes in the module file:
import unicode.Grapheme Module :: {}.{ split_graphemes = |string| Grapheme.split(string) }
Output
Run this from the directory that has main.roc in it:
$ roc main.roc Ok(["h", "e", "l", "l", "o"])