Is there any way to namespace functions and values within the same file? Something like this.
main = Stdout.line "Part 1: \(Part1.run inputStr)"
namespace Part1
run = \input -> ...
I know I can create a Part1.roc
file, but sometimes it's nice to organize things inline and then refactor into an external file as needed.
We don't have anything exactly like that but you could do:
main =
part1.greet "Ryan"
part1 = {
hey,
greet
}
hey = Stdout.line "hey"
greet = \name -> Stdout.line "Hello, \(name)!"
Probably a bit better name spacing is to fully nest the functions so they don't take up top level names and can be shared between parts:
part1 =
run = \input -> ...
# other funcs
# exposed functions
{ run, ... }
Last updated: Jul 06 2025 at 12:14 UTC