diff options
| author | Arun Isaac | 2026-04-12 18:09:49 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-04-12 18:09:49 +0100 |
| commit | fe32909d58a59407350043851970cb3004ad351e (patch) | |
| tree | 3e8d58df44ffd2de4b926f876b33081d3f285b59 /kaakaa/lens.scm | |
| parent | 968c5f2c9df53139729aa5356ad5a802d1c88f37 (diff) | |
| download | kaagum-fe32909d58a59407350043851970cb3004ad351e.tar.gz kaagum-fe32909d58a59407350043851970cb3004ad351e.tar.lz kaagum-fe32909d58a59407350043851970cb3004ad351e.zip | |
Rename project to kaagum.
kaakaa reminds too many Europeans of shit. 😅
Diffstat (limited to 'kaakaa/lens.scm')
| -rw-r--r-- | kaakaa/lens.scm | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/kaakaa/lens.scm b/kaakaa/lens.scm deleted file mode 100644 index f5c9370..0000000 --- a/kaakaa/lens.scm +++ /dev/null @@ -1,62 +0,0 @@ -;;; kaakaa --- Tiny, security-focused AI agent in Guile -;;; Copyright © 2026 Arun Isaac <arunisaac@systemreboot.net> -;;; -;;; This file is part of kaakaa. -;;; -;;; kaakaa is free software: you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by -;;; the Free Software Foundation, either version 3 of the License, or -;;; (at your option) any later version. -;;; -;;; kaakaa is distributed in the hope that it will be useful, but -;;; WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;;; General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with kaakaa. If not, see <https://www.gnu.org/licenses/>. - -(define-module (kaakaa lens) - #:use-module (srfi srfi-1) - #:use-module (srfi srfi-26) - #:use-module (srfi srfi-43) - #:use-module (lens) - #:export (vector-nth - in-json - push - prepend-over - alist-delete-over)) - -(define (vector-nth n) - "Like @code{nth}, but for vectors." - (lens (cut vector-ref <> n) - (lambda (vec proc) - (vector-append (vector-copy vec 0 n) - (vector (proc (vector-ref vec n))) - (vector-copy vec (1+ n)))))) - -(define in-json - (case-lambda - "Like @code{in}, but also allow integer components so that it is -possible to traverse JSON trees." - (() (id)) - ((key . tail) - (compose (apply in-json tail) - (if (string? key) - (key-ref key) - (vector-nth key)))))) - -(define (push lens x object) - "Cons @var{x} onto the part of @var{object} that @var{lens} focuses -on." - (over lens (cut cons x <>) object)) - -(define (prepend-over lens lst object) - "Prepend @var{lst} to the part of @var{object} that @var{lens} focuses -on." - (over lens (cut append lst <>) object)) - -(define (alist-delete-over lens key object) - "Delete @var{key} from the association list in @var{object} that -@var{lens} focuses on." - (over lens (cut alist-delete key <>) object)) |
