Multiple Roc Files
You can use modules to organize your code into multiple files.
Code
Hello.roc:
Hello :: {}.{ # Only what's listed here is accessible to other modules hello : Str -> Str hello = |name| { "Hello ${name} from ${module_name}!\n" } } # Anything located outside of the Hello type can only be used in this file. module_name = "Hello module"
main.roc:
import Hello exposing [hello] main! = |_args| { # here we're calling the `hello` function from the Hello module echo!(hello("World")) Ok({}) }
Output
Run this from the directory that has main.roc in it:
$ roc main.roc Hello World from Hello module!