Skip to content
Noodle
InstallLearnPlayground
GitHub

Your first program

Start with one directory and one source file. A simple Noodle program does not need a manifest or a module declaration.

Terminal window
mkdir hello

Create hello/hello.nl:

func greeting(name : String) -> String do
"Hello, " ++ name ++ "!"
end
func main() -> Unit do
Console.println(greeting("Noodle"));
end

The greeting function declares the types at its boundary. Its final expression is the returned String. The main function is the program entry point and returns Unit, the type used when no meaningful value is returned.

Ask Noodle to check every source file in the directory:

Terminal window
noodle check hello

Then select hello.nl as the program entry file:

Terminal window
noodle run hello/hello.nl

The program prints:

Hello, Noodle!

Tests can live beside the code they exercise. Update hello/hello.nl so the complete file is:

func greeting(name : String) -> String do
"Hello, " ++ name ++ "!"
end
func main() -> Unit do
Console.println(greeting("Noodle"));
end
test "builds a greeting" do
Testing.assert_equal(greeting("Noodle"), "Hello, Noodle!")!;
end

Run all tests in the directory:

Terminal window
noodle test hello

The postfix ! propagates an assertion failure to the test runner. For now, read it as “this test fails if the assertion fails.” Its general behavior is explained in Error handling, while the Testing API is documented under Output, debugging, and tests.

Next, learn how these commands fit into the everyday workflow.