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

Note that in this case you will need to use Hello.hello in your code (not just hello), for example: Hello.hello("World!").

Code

Dir/Hello.roc:

Hello :: {}.{
	# Only what's listed here is accessible to other modules
	hello : Str -> Str
	hello = |name| {
		"Hello ${name} from inside ${module_name}!\n"
	}
}

# Anything located outside of the Hello type can only be used in this file.
module_name = "Dir/Hello module"

main.roc:

import Dir/Hello exposing [hello]

main! = |_args| {
	# here we're calling the `hello` function from the Dir.Hello module
	echo!(hello("World"))
	Ok({})
}

Output

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

$ roc main.roc
Hello World from inside Dir/Hello module!