Stylised as, though this is subject to change, ...
__
|__) _ _ | _ _ _
|__) (_) | ) | (_| | ) (_)
_/
It's a programming language! A minimalist programming language.
I wrote (most) this during the ZuriHac 2016 weekend, and it's still a work in progress.
Head over to the examples folder for some good stuff.
Basically, your basic hello-world
looks like this:
/*
* file: main.bl
*
* This is where I tell you things
*/
module Main where
def main [] = {
print $ "Hello World!";
}
You need to always have a Main
module with a main
method defined. This
is what the runtime looks for in order to start the program.
The language is lazy, so this yields "Lazy Hello" but not "Hello World"
module Main where
def main [] = {
val sayHello = puts-ln $ "Hello World!";
puts-ln $ "Lazy Hello!";
}
Those curly braces indicate "Instruction blocks". The runtime will try go through semicolon-separated expressions, reducing where necessary.
So this will produce output
module Main where
def main [] = {
val print' = print $ "Hello World!";
print'; // Needs evaluation to happen
}
The language supports automatic currying:
module Main where
/**
* Adds two values
*/
def addValues [x, y] = + $ x y
def main [] = {
val add2 = addValues $ 2;
val four = add2 $ 2;
// Will output '4'
puts-ln $ four;
}
Function application is done with the $
operator after an expression. If
the expression is a function, it will be applied. The runtime will throw an
error otherwise.
You should be familiar with Polish notation.
The language supports lambdas (closures)
module Main where
/**
* Will output '4' twice in new lines
*/
def main [] = {
val λ1 = lambda [x, y] => + $ x y;
val λ2 = lambda [y] => λ1 $ 2 y;
puts-ln $ (λ1 $ 2 2) (λ2 $ 2);
}
This is developed in Haskell, I wanted to
test stack
and parsec
,
and that eventually turned into this.
I first read (and actually this contains code from) Write Yourself a Scheme in 48 Hours. That prompted me to design this. It has elements from Haskell, Scala, and Lisp.
It's fun.
Carlos D'Agostino.
You can visit my blog here https://cdagostino.io
About my fixation with the number 4.
See LICENSE file in this repo.
See TODO file in this repo.