Lambda Discipline

Lambda Discipline

A lazy, statically typed functional language built on the lambda calculus.

Install Read the reference

-- Types are inferred; annotations are checked.
fibonacci : Number -> Number = \n.
    (if (lt n 2) n (add (fibonacci (sub n 1)) (fibonacci (sub n 2))))

compose = \f. \g. \x. (f (g x))          -- (a -> b) -> (c -> a) -> c -> b

(println (map fibonacci (range 0 10)))   -- [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
(println ((compose show (mul 2)) 21))   -- 42

A first program#

Save this as hello.lbd:

greet : String -> String = \name. (concat "Hello, " name)

(println (greet "World"))

and run it:

$ lbd run hello.lbd
Hello, World

Or start lbd with no arguments for a REPL, where :type shows the type of any expression:

λ> :type (map (add 1))
(map (add 1)) : List<Number> -> List<Number>

Where to next#