The REPL is a very helpful tool for functional programming languages like bruijn. You can use it to continuously test or execute parts of your code.

You can start the REPL using stack run or (if installed) bruijn.

Any valid term will get reduced to normal form after pressing enter. Common data structures will get resolved in a seperate line if detected (e.g. numbers, lists or strings).


Since everything you type will get evaluated, definitions (compared to definitions in files) require an equal sign:

> id = [0]
> id



Equivalent to the respective commands in files.

> :import std/Math .


Equivalent to the test command in files.

> :test ([0]) ([[1]])
ERROR test failed: [0] = [[1]]
      reduced to [0] = [[1]]


:watch re-imports the file automatically after every saved change. It will rerun any test the watched file contains.

> :watch collatz-proof

This can be very helpful for test driven development.


Measures the time from start of reduction to its end (normal form) in seconds.

> :time fac (+30)
0.15 seconds


Translates both the unreduced and the reduced expression to binary lambda calculus. Helpful for golfed compilation.

> :blc [0] [0]


Measures the length of the binary lambda calculus encoding of both the unreduced and the reduced expression. Helpful for golfed compilation.

> :length [0] [0]


The free command frees the current environment including all defined identifiers and imported files.

> id = [0]
> :free
> id
ERROR undefined identifier id