1 # Lambda Lisp has several backends, here we are using
2 # the blc one. Ideally, this should be made into several
3 # packages such as lambda-lisp-blc, lambda-lisp-lazyk,
4 # lambda-lisp-clamb, etc.
16 s = import ./sources.nix { inherit fetchurl fetchFromGitHub; };
18 stdenv.mkDerivation rec {
19 pname = "lambda-lisp-blc";
20 version = s.lambdaLispVersion;
29 cp $blcSrc ./build/Blc.S
30 cp $flatSrc ./build/flat.lds
32 cat Blc.S | sed -e 's/#define.*TERMS.*//' > Blc.ext.S;
33 $CC -c -DTERMS=50000000 -o Blc.o Blc.ext.S
34 ld.bfd -o Blc Blc.o -T flat.lds
37 install -D -t $out/bin bin/Blc
38 install -D -t $out/lib bin/lambdalisp.blc
41 $CC ../tools/asc2bin.c -O2 -o asc2bin;
43 mv build/asc2bin ./bin;
44 chmod 755 ./bin/asc2bin;
45 install -D -t $out/bin bin/asc2bin
47 echo -e "#!${runtimeShell}\n( cat $out/lib/lambdalisp.blc | $out/bin/asc2bin; cat ) | $out/bin/Blc" > lambda-lisp-blc
48 chmod +x lambda-lisp-blc
50 install -D -t $out/bin lambda-lisp-blc
54 doInstallCheck = true;
56 installCheckPhase = ''
57 runHook preInstallCheck
59 a=$(echo "(* (+ 1 2 3 4 5 6 7 8 9 10) 12020569 (- 2 5))" | $out/bin/lambda-lisp-blc | tr -d "> ");
60 test $a == -1983393885
62 runHook postInstallCheck
66 description = "Lisp interpreter written in untyped lambda calculus";
67 homepage = "https://github.com/woodrush/lambdalisp";
69 LambdaLisp is a Lisp interpreter written as a closed untyped lambda calculus term.
70 It is written as a lambda calculus term LambdaLisp = λx. ... which takes a string
71 x as an input and returns a string as an output. The input x is the Lisp program
72 and the user's standard input, and the output is the standard output. Characters
73 are encoded into lambda term representations of natural numbers using the Church
74 encoding, and strings are encoded as a list of characters with lists expressed as
75 lambdas in the Mogensen-Scott encoding, so the entire computation process solely
76 consists of the beta-reduction of lambda terms, without introducing any
77 non-lambda-type object.
79 license = licenses.mit;
80 maintainers = with maintainers; [ cafkafk ];
81 platforms = [ "x86_64-linux" ];