Lukáš Hozda

World Peace

A small but funny complete no-types programming language. If static typing and function programming arguments create so much flamewars, then what will lead to world peace? This. It has a REPL, source runner, image compiler, module loading, examples, tests, and (janky) editor support.

Basic info

README

We take inspiration from some niche and less niche things.

PartDetails
Values64-bit numbers and nested numeric arrays. Strings are byte arrays by convention.
Functionsdec declarations, --- body lines, and end return clauses.
PatternsExact values, ranges, wildcard arms, array prefixes, array suffixes, and parameter filters.
Modulesload support; resolves a local module.
Commandspeace repl, peace run FILE.wp, peace compile FILE.wp -o OUTPUT.

Code examples

examples

Case patterns

Matches empty arrays, array starts, array ends, and a fallback arm.

dec array_tag(num values):
--- num tag = 0;
--- case {
---     values <- []: tag = 69,
---     values <- [1, 2, ..]: tag = 83,
---     values <- [.., 9]: tag = 57,
---     _: tag = 63,
--- }
end {
    tag
}

Parameter filters

A function can split cases by exact argument values or by array slices.

// exact-value filters
dec fibonacci(num[=0] n):
end {
    0
}

dec fibonacci(num[=1] n):
end {
    1
}

Run it

flake.nix
TaskCommand
Run a tour filenix run .# -- run examples/tour/01-hello.wp
Start the REPLnix run .# -- repl
Compile an executable./peace compile examples/tour/01-hello.wp -o /tmp/world-peace-hello