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.21.0/4rAQg8kUYZ3Vksr4qMQHpaFYNiHSn9GgS7gVxghd1XYV.tar.zst",
	unicode: "https://github.com/roc-lang/unicode/releases/download/2.0.0/9ZvqNzsNkpqFmGTeATAY3BNBD7mP41jqZx2w2N19tBvh.tar.zst",
	roc: "nightly-2026-08-12-606470f",
}

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.21.0/4rAQg8kUYZ3Vksr4qMQHpaFYNiHSn9GgS7gVxghd1XYV.tar.zst",
	unicode: "https://github.com/roc-lang/unicode/releases/download/2.0.0/9ZvqNzsNkpqFmGTeATAY3BNBD7mP41jqZx2w2N19tBvh.tar.zst",
	roc: "nightly-2026-08-12-606470f",
}

### 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"])