Import from Directory

To import a module that lives inside a Directory:

import Dir.Hello exposing [hello]

You can also do:

import Dir.Hello as Hello

Or:

import Dir.Hello

Note that in this last case you will need to use Dir.Hello in your code, for example: Dir.Hello.hello "World!".

Code

Dir/Hello.roc:

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

hello : Str -> Str
hello = \name ->
    "Hello $(name) from inside Dir!"

main.roc:

app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.18.0/0APbwVN1_p1mJ96tXjaoiUCr8NBGamr8G8Ac_DrXR-o.tar.br" }

import pf.Stdout
import Dir.Hello exposing [hello]

main! = \_args ->
    # here we're calling the `hello` function from the Hello module
    Stdout.line! (hello "World")

Output

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

$ roc main.roc
Hello World from inside Dir!