Bosatsu (菩薩) is a simple, non-Turing complete language designed for configuration, queries, and scripting. It is inspired by Python, Haskell, Dhall, and Rust.
Key features include:
- Python-inspired syntax: Supports function definitions, literal integers/strings, lists, list comprehensions, tuples, and
(string key) dictionaries. - Pattern matching: Powerful pattern matching capabilities.
- Static type system: Uses a generalization of the Hindley-Milner (Damas-Milner) type system.
- Data structures: Supports
structs (named tuples/data classes) and enums (sum types). - Package system: Includes explicit
import and export syntax.
Constraints and 'Un-features':
- Limited recursion: Recursion is only allowed if it is guaranteed to terminate and cannot create infinite loops.
- Data structure constraints: Data structures can only be recursive in covariant positions (not in function arguments).
- No
while loops: Iteration is achieved via tail-recursive functions on sub-values or folds. There is no while syntax.
package Euler/One
# see:
# https://projecteuler.net/problem=1
# Find the sum of all the multiples of 3 or 5 below 1000.
operator == = eq_Int
operator % = mod_Int
def operator ||(x, y):
True if x else y
def keep(i):
(i % 3 == 0) || (i % 5 == 0)
def sum(as): as.foldl_List(0, add)
computed = sum([i for i in range(1000) if keep(i)])
test = Assertion(computed == 233168, "expected 233168")