Skip to content

kognise/lamb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lamb 🐑

a very shitty lambda calculus.

  • literally just untyped lambda calculus.
  • no named parameters, only de bruijn indices written as multiple dots.
  • you can write ints but they're just syntax sugar for church numerals.
  • the evaluator is really bad right now and will die on anything recursive. (to be fixed later.)
  • basic subtraction can take, like, between seconds and minutes to run.

syntax

  • lambda: \
  • access closest variable: ., second closest: ..
  • numerals: 0, 1, 2, ...
  • call a with b as an argument: a b
  • left associative: a b c is (a b) c
  • create a global variable: name: value

so, the identity function $\lambda x. x$ is \..

the church encoding of the number two — $\lambda f. \lambda x. f (f x)$ — is written as \\.. (.. .).

stdlib

i've implemented a couple of basic definitions:

true: \\..
false: \\.

pair: \\\. ... ..
first: \. true
second: \. false

ident: \.
if: ident

pred: \\\... (\\. (.. ....)) (\..) (\.)
succ: (+ 1)
+: \\\\.... .. (... .. .)
*: \\\\.... (... ..) .
-: \\(. pred) ..
/: \\\\ ((.... \\. ..) \..) ((.... \((.... \\. ..) \(.... (. ..))) \.) .)
exp: \\. ..

&&: \\.. . ..
||: \\.. .. .

is_0: \. (\false) true
<=: \\is_0 (- .. .)
==: \\&& (<= .. .) (<= . ..)

running

opam switch create .
dune exec lamb

About

A very shitty lambda calculus.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published