about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-07-24 17:27:31 +0300
committerBonfaceKilz2023-07-30 12:29:56 +0300
commit052bd28d234961e56a41412209bc7e990d8f8be7 (patch)
treeacab61e00b0a355c19d8b04f5f6f11de2a982624
parent5a2a7dc79c08997868c6644c20443263ac6c7fec (diff)
downloadgn-transform-databases-052bd28d234961e56a41412209bc7e990d8f8be7.tar.gz
Replace set! mutations with an alist
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rw-r--r--dump/special-forms.scm112
1 files changed, 49 insertions, 63 deletions
diff --git a/dump/special-forms.scm b/dump/special-forms.scm
index fce3a11..ad3296e 100644
--- a/dump/special-forms.scm
+++ b/dump/special-forms.scm
@@ -549,66 +549,52 @@ The above query results to triples that have the form:
 (define-syntax dump-with-documentation
   (syntax-rules ()
     ((_ (key value) ...)
-     (let ((name "")
-           (connection "")
-           (table-metadata? "")
-           (prefixes "")
-           (inputs "")
-           (outputs ""))
-       (for-each
-        (match-lambda
-          (('name n)
-           (set! name n))
-          (('connection conn)
-           (set! connection conn))
-          (('table-metadata? t-metadata?)
-           (set! table-metadata? t-metadata?))
-          (('prefixes p)
-           (set! prefixes p))
-          (('inputs i)
-           (set! inputs i))
-          (('outputs o)
-           (set! outputs o)))
-        (list (list 'key value) ...))
-       (let ((rdf-path (get-keyword-value outputs #:rdf ""))
-             (doc-path (get-keyword-value outputs #:documentation "")))
-         ;; Dumping the documentation first
-         (call-with-target-database
-          connection
-          (lambda (db)
-            (with-output-to-file        ;
-                doc-path
-              (lambda ()
-                (format #t "# ~a" name)
-                (for-each
-                 (lambda (proc)
-                   (proc db
-                         #:dump-metadata? #f
-                         #:dump-data? #f
-                         #:dump-documentation?
-                         (lambda () (for-each
-                                     (match-lambda
-                                       ((k v)
-                                        (begin
-                                          (prefix k v #f))))
-                                     prefixes))))
-                 inputs))
-              #:encoding "utf8")
-
-            ;; Dumping the actual data
-            (with-output-to-file
-                rdf-path
-              (lambda ()
-                ;; Add the prefixes
-                (for-each
-                 (match-lambda
-                   ((k v)
-                    (begin
-                      (prefix k v))))
-                 prefixes)
-                (newline)
-                (for-each
-                 (lambda (proc)
-                   (proc db #:dump-metadata? table-metadata?))
-                 inputs))
-              #:encoding "utf8"))))))))
+     (let* ((alist `((key . ,value) ...))
+            (name (assoc-ref alist 'name))
+            (connection (assoc-ref alist 'connection))
+            (table-metadata? (assoc-ref alist 'table-metadata?))
+            (prefixes (assoc-ref alist 'prefixes))
+            (inputs (assoc-ref alist 'inputs))
+            (outputs (assoc-ref alist 'outputs))
+            (rdf-path (get-keyword-value outputs #:rdf ""))
+            (doc-path (get-keyword-value outputs #:documentation "")))
+       (call-with-target-database
+        connection
+        (lambda (db)
+          (with-output-to-file        ;
+              doc-path
+            (lambda ()
+              (format #t "# ~a" name)
+              (for-each
+               (lambda (proc)
+                 (proc db
+                       #:dump-metadata? #f
+                       #:dump-data? #f
+                       #:dump-documentation?
+                       (lambda () (for-each
+                                   (match-lambda
+                                     ((k v)
+                                      (begin
+                                        (prefix k v #f))))
+                                   prefixes))))
+               inputs))
+            #:encoding "utf8")
+
+          ;; Dumping the actual data
+          (with-output-to-file
+              rdf-path
+            (lambda ()
+              ;; Add the prefixes
+              (for-each
+               (match-lambda
+                 ((k v)
+                  (begin
+                    (prefix k v))))
+               prefixes)
+              (newline)
+              (for-each
+               (lambda (proc)
+                 (proc db #:dump-metadata? table-metadata?))
+               inputs))
+            #:encoding "utf8")))))))
+