A categorical programming language
修订版 | a12a5d8c3511ccb1a85f4464b881de031023c5f0 (tree) |
---|---|
时间 | 2022-04-09 10:29:59 |
作者 | Corbin <cds@corb...> |
Commiter | Corbin |
Use CPython 2.7 instead of PyPy.
This is a nixpkgs issue, but I genuinely don't know how it'll turn out,
and I can't afford to wait for them.
@@ -4,7 +4,7 @@ let | ||
4 | 4 | inherit (nixpkgs.pkgs) |
5 | 5 | fetchFromGitLab stdenv |
6 | 6 | pkg-config libffi stb |
7 | - pypy pypyPackages; | |
7 | + python2 python2Packages; | |
8 | 8 | # https://foss.heptapod.net/pypy/pypy/ |
9 | 9 | pypySrc = fetchFromGitLab { |
10 | 10 | domain = "foss.heptapod.net"; |
@@ -28,9 +28,9 @@ in | ||
28 | 28 | buildInputs = [ |
29 | 29 | # always required |
30 | 30 | pypySrc pkg-config stb |
31 | - pypy pypyPackages.py | |
31 | + python2 python2Packages.py | |
32 | 32 | # only required for JIT |
33 | - pypyPackages.pytest libffi | |
33 | + python2Packages.pytest libffi | |
34 | 34 | ]; |
35 | 35 | |
36 | 36 | # JELLY_PATH = "${jelly}/bin/jelly"; |
@@ -42,7 +42,7 @@ in | ||
42 | 42 | cp -r ${pypySrc}/rpython . |
43 | 43 | chmod -R u+w rpython/ |
44 | 44 | # Do the actual translation. |
45 | - ${pypy}/bin/pypy -mrpython -O${opt} ${entrypoint} | |
45 | + ${python2}/bin/python2 -mrpython -O${opt} ${entrypoint} | |
46 | 46 | ''; |
47 | 47 | |
48 | 48 | installPhase = '' |
@@ -1,3 +1,5 @@ | ||
1 | +# coding: utf-8 | |
2 | + | |
1 | 3 | import math, sys |
2 | 4 | |
3 | 5 | from rpython.rlib.jit import JitDriver, unroll_safe #, set_param |
@@ -1,7 +1,7 @@ | ||
1 | 1 | (comp |
2 | 2 | (comp |
3 | - (fractal-membership-color v2/burning-ship nat/9) | |
4 | - (monads/maybe/guard (pair/of nat/lte id (fun/const nat/8)))) | |
3 | + (fractal-membership-color v2/burning-ship (comp nat/16 succ)) | |
4 | + (monads/maybe/guard (pair/of nat/lte id (fun/const nat/16)))) | |
5 | 5 | (case |
6 | 6 | (comp (comp nat/to-f f/radians-to-turns) h2rgb) |
7 | 7 | (v3/broadcast f-zero))) |
@@ -0,0 +1,3 @@ | ||
1 | +(fold nil list/append) | |
2 | + | |
3 | +Flatten a list of lists into a single list. |
@@ -0,0 +1,11 @@ | ||
1 | +(uncurry | |
2 | + (fold | |
3 | + (fun/name (fun/const nil)) | |
4 | + (curry | |
5 | + (comp | |
6 | + (pair | |
7 | + (pair (comp fst fst) snd) | |
8 | + (fun/apppair (comp fst snd) snd)) | |
9 | + cons)))) | |
10 | + | |
11 | +Zip a single value into a list. |
@@ -0,0 +1,4 @@ | ||
1 | +(comp (pair @2 id) (uncurry (bool/if (fun/const @1) @0))) | |
2 | + | |
3 | +Given the unit and zero of some monad, and some filtering predicate, test a | |
4 | +value in that monad. |
@@ -0,0 +1,3 @@ | ||
1 | +list/append | |
2 | + | |
3 | +Addition in the list monad. |
@@ -0,0 +1,3 @@ | ||
1 | +(comp (comp list/pair (list/map (comp pair/swap fun/app))) list/flatten) | |
2 | + | |
3 | +Internal bind in the list monad. |
@@ -0,0 +1,3 @@ | ||
1 | +list/flatten | |
2 | + | |
3 | +The join operation in the list monad. |
@@ -0,0 +1,3 @@ | ||
1 | +nil | |
2 | + | |
3 | +The zero of the list monad. |
@@ -23,9 +23,9 @@ in pkgs.stdenv.mkDerivation { | ||
23 | 23 | # using cammy-repl |
24 | 24 | rlwrap |
25 | 25 | # working with sexps |
26 | - ocamlPackages.sexp | |
26 | + # ocamlPackages.sexp | |
27 | 27 | # benchmarking |
28 | - busybox feedgnuplot | |
28 | + busybox feedgnuplot linuxPackages.perf | |
29 | 29 | # publishing |
30 | 30 | keychain mktorrent pngcrush |
31 | 31 | # experimenting with GLSL |
@@ -63,3 +63,31 @@ | ||
63 | 63 | * CI: automatic generation of demo images |
64 | 64 | * Would be nice to know how long it takes, too |
65 | 65 | * Parameterize by number of iterations? |
66 | +* Native code generation with QBE | |
67 | + * Strategy: Emit one procedure for each expression under a (curry) or | |
68 | + (uncurry), defunctionalizing | |
69 | + * Should arity be implied, so that these procedures can take their pairs | |
70 | + as two arguments? | |
71 | + * Execution proceeds like the CAM | |
72 | + * Like ZINC? | |
73 | + * There's an accumulator, an environment stack, and a code pointer | |
74 | + * Uniform values: every value fits into the same 64-bit cell | |
75 | + * Opaque: Polymorphic values are passed as-is, cannot be inspected | |
76 | + * Unit: doesn't matter! | |
77 | + * Bools: nonzero and zero | |
78 | + * Nats: tagged union of smallnat and bignat | |
79 | + * smallnat: up to 2**63-1 | |
80 | + * bignat: pointer to heap-allocated size-prefixed array | |
81 | + * Floats: IEEE 754 double-precision, native endianness | |
82 | + * Lists: pointer to heap-allocated size-prefixed array of pointers | |
83 | + * Maybe lists of bits would be stored as nats | |
84 | + * Pairs: pointer to heap-allocated array of two cells | |
85 | + * Sums: pointer to heap-allocated array of two cells | |
86 | + * The first cell is a Boolean | |
87 | + * Maybe sums of unit, bools, nats, lists, pairs can be encoded with | |
88 | + tagged pointers | |
89 | + * Homs: pointer to heap-allocated array of two cells | |
90 | + * The first cell is a code pointer | |
91 | + * The second cell is the curried data | |
92 | +* fun/precomp is an ingredient of CPS transformation | |
93 | + * https://okmij.org/ftp/continuations/undelimited.html |