Multiple Roc Files

You can use modules to organize your code into multiple files.

Code

Hello.roc:

# Only what's listed here is accessible/exposed to other modules
module [hello]

hello : Str -> Str
hello = |name|
    "Hello ${name} from module!"

main.roc:

app [main!] { cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br" }

import cli.Stdout
import Hello

main! = |_args|
    Stdout.line!(Hello.hello("World"))

Output

Run this from the directory that has main.roc in it:

$ roc main.roc
Hello World from module!