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:

module
    # Only what's listed here is accessible to other modules
    [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.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br" }

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

main =
    Stdout.line! (hello "World")

Output

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

$ roc main.roc
Hello World from inside Dir!