Skip to content
A functional programming language using a linear type system
Branch: master
Clone or download
Latest commit d17f4f6 May 26, 2019

README.md

The Blob FP language

Blob is a small FP language focused on implementing a basic linear type system.

The type system
Even though Blob's type system may seem pointless to many people, it's actually of a great strength. Thanks to it, it is possible to write GC-free VMs easily, because of the automatic memory handling. For example, a function whose signature is f: a ⊸ b would see its first argument forced to be consumed exactly once (⊸ = →[1]) in the function body. As another example, a function g: a →[3] b ⊸ a would force the developer to use the first argument 3 times and the second argument once.
Unicode characters mapping
Some unicode characters are part of the language itself, and may be used interchangeably with their ASCII correspondants.
ASCII Unicode
->
-o
=>
\ λ
::
Code examples

The Fibonacci sequence

fib: Num a  a  a
fib = go 0
  where -- go :: Num a ⇒ a ⊸ a ⊸ a
        go acc n =
            match n with
                0   acc
                n'  go (n' * acc) (n' - 1)

Factorial calculation

fact: Num a  a  a
fact n = match n with --  we clone “n”.
    0   1
    n'  n' * fact (n' - 1)

The Ackermann function

ack: Num a  a  a  a
ack m n = match m with --  we clone “m”.
    0   n + 1
    m'  match n with --  we clone “n”.
        0   ack (m' - 1) 1
        n'  ack (m' - 1) $ ack m' (n' - 1)
Roadmap
  • Implementing a fully working λ language inside the REPL. The goal is basically to replicate a small Haskell.
  • Making a VM using the Linear Abstract Machine scheme.
  • Making a full compiler targetting NASM.
You can’t perform that action at this time.