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.26.0/GddgvsGjiNXrHFW6au5i5dUDbTs8FinQdrgE2Gqmw53t.tar.zst",
	roc: "nightly-2026-10-29-a0a9fc2",
	unicode: "https://github.com/roc-lang/unicode/releases/download/4.3.1/BNmth7q83JT3Pc2neutkWibVwFwNNNBLhhKfZhmDREeL.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.26.0/GddgvsGjiNXrHFW6au5i5dUDbTs8FinQdrgE2Gqmw53t.tar.zst",
	roc: "nightly-2026-10-29-a0a9fc2",
	unicode: "https://github.com/roc-lang/unicode/releases/download/4.3.1/BNmth7q83JT3Pc2neutkWibVwFwNNNBLhhKfZhmDREeL.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"])

Validated with Roc nightly-2026-10-29-a0a9fc2.