Modules
Oneway's module system is file-based and conventionally driven. There is
no mod declaration, no manifest of what's in scope.
File Rules
- Files are named
snake_case.ow. - A file's name must match the type it declares:
foo.owmust declare a type namedFoo. - A module is a folder. There is no
modkeyword. - The entry point is
main.ow. A library's root islib.ow.
Imports
To use a type defined in a sibling file, write:
use Foo
This imports Foo from foo.ow (or from the corresponding folder if
Foo is a module). No paths, no aliasing.
Multiple use statements at the top of a file must be in alphabetical
order.
Example: Multi-File Project
examples/multifile/
├── greeter.ow
└── main.ow
greeter.ow:
Greeter = String
Greeter.shout = () -> String {
"HELLO from greeter"
}
main.ow:
use Greeter
main = (Stdout) -> Noop {
Greeter("hi").shout().print(Stdout)
}
Run it with:
just example multifile
Visibility
Everything is public by default. To make a method private to its
declaring file, prefix it with *:
Type.*helper = () -> Noop {
...
}
There is no pub keyword and no per-item visibility annotation beyond
that single prefix.