

Bosatsu: a python-ish pure and total functional programming language
source link: https://www.tuicool.com/articles/hit/yyUzEjU
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

The Bosatsu Programming Language
Bosatsu (菩薩) is the transliteration in Japanese of the sanskrit bodhisattva. A bodhisattva is someone who can reach enlightenment but decides not to, to help others achieve that goal. -- Wikipedia
Bosatsu is a simple, non-turing complete language designed for configuration, queries and scripting. It borrows from Python , Haskell , Dhall and Rust .
An example of Bosatsu
Here is a working Bosatsu program to solve the first Project Euler problem:
package Euler/One # see: # https://projecteuler.net/problem=1 # Find the sum of all the multiples of 3 or 5 below 1000. def filter(as, fn): as.foldLeft([], \tail, item -> if fn(item): [item, *tail] else: tail) under1000 = range(1000) def or(a, b): True if a else b def keep(i): or(i.mod_Int(3).eq_Int(0), i.mod_Int(5).eq_Int(0)) def sum(as): as.foldLeft(0, add) # >>> sum(i for i in xrange(1000) if keep_fn(i)) # 233168 computed = trace("computed", under1000.filter(keep).sum) test = Assertion(computed.eq_Int(233168), "expected 233168")
For more details see the language guide in particular the section on syntax
Use cases
Currently we have only implemented type-checking, the package system, and an interpreter to evalute expressions. This could already be useful if you want to give some programmability to configuration that can load, type-check and evaluate the configuration before executing the rest of the scala or java code.
As a JSON templating engine
Along with Bazel Bosatsu can be used as a JSON generation system, which could be useful for generating complex configurations in a way that has type-checking and ability to compose. For a working example see this example .
cd test_workspace bazel build ... cat bazel-build/testjson.json
Future features
We would like to implement a number of features:
- a REPL
- a java backend and bazel rules which can call java and scala functions
- a skylark backend to allow writing strongly typed bazel rules compiling to untyped skylark
Recommend
-
95
README.md www.pointfree.co macOS
-
67
README.md Fo Fo is an experimental language which adds functional programming features to Go. The name is short for "Functional Go". Table of Contents
-
65
README.md
-
47
Luna Studio Visual and textual functional programming language with a focus on productivity, collaboration and development ergonomics. Luna is a developer’s whiteboard on steroids. Design, prototyp...
-
33
forest-lang Forest is a functional programming language that compiles to WebAssembly. This repository contains the compiler and core syntaxes, currently implemented in Haskell. Forest is pre-alpha expe...
-
41
README.md Mirth Mirth is a new type-safe concatenative functional programming languague. Mirth was inspired by Forth,...
-
13
Byte-sized functional programming: Pure functions make testing easy Submitted by Larry on 14 July 2020 - 9:28am...
-
4
Functional Programming (Part 2): Pure FunctionsPhoto by Miguel Á. Padriñán from
-
12
Reading Time: 2 minutes What is Functional Programming? Firstly, Functional programming is a...
-
11
Use Pure Functions to understand Functional ProgrammingPlay this article
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK