A categorical programming language
Revisión | ec13b168d1f54a4e1c71d97a4676dc5347fa68c3 (tree) |
---|---|
Tiempo | 2023-09-19 12:57:12 |
Autor | Corbin <cds@corb...> |
Commiter | Corbin |
Flesh out a basic tree-insertion tool.
This is sufficient to implement a basic set of expressions, but it's
neither enumerable nor tagged, and doesn't have trails.
@@ -1,3 +1,30 @@ | ||
1 | -(import (git)) | |
1 | +(import scheme | |
2 | + (chicken blob) | |
3 | + (chicken process-context) | |
4 | + srfi-1 | |
5 | + (only matchable match match-lambda) | |
6 | + (git)) | |
2 | 7 | |
3 | -(print 42) | |
8 | +(define indices '(0 1 2)) | |
9 | +(define (mode expr) (if (symbol? expr) #o100644 #o040000)) | |
10 | + | |
11 | +(define (insert-tree repo) | |
12 | + (match-lambda | |
13 | + [(? symbol? s) | |
14 | + (blob-id (create-blob repo (string->blob (symbol->string s))))] | |
15 | + [t (let ((tb (make-tree-builder repo))) | |
16 | + (begin | |
17 | + (for-each | |
18 | + (lambda (i expr) | |
19 | + (tree-builder-insert | |
20 | + tb ((insert-tree repo) expr) (number->string i) (mode expr))) | |
21 | + indices t) | |
22 | + (tree-id (tree-builder-write tb))))])) | |
23 | + | |
24 | +(define (bk-insert path expr) | |
25 | + (let ((repo (repository-open (symbol->string path)))) | |
26 | + (print ((insert-tree repo) expr)))) | |
27 | + | |
28 | +(match (map (lambda (s) (read (open-input-string s))) | |
29 | + (command-line-arguments)) | |
30 | + [('insert path expr) (bk-insert path expr)]) |
@@ -15,6 +15,7 @@ in pkgs.stdenv.mkDerivation { | ||
15 | 15 | buildInputs = [ |
16 | 16 | pkgs.chicken |
17 | 17 | ] ++ (with eggs; [ |
18 | + srfi-1 matchable | |
18 | 19 | (git.overrideAttrs (attrs: { |
19 | 20 | prePatch = '' |
20 | 21 | sed -i -e '/asize/d' libgit2.scm |
@@ -1,6 +1,8 @@ | ||
1 | +srfi-1 | |
2 | +matchable | |
3 | +; git requires a bunch of stuff not handled by egg2nix | |
1 | 4 | git |
2 | 5 | foreigners |
3 | 6 | module-declarations |
4 | -srfi-1 | |
5 | 7 | test |
6 | 8 | with-current-directory |