1. Moritz Heidkamp
  2. edn

Commits

Moritz Heidkamp  committed 43e358e

Expose edn-tag-parsers and default-edn-tag-parsers, too

  • Participants
  • Parent commits dd76239
  • Branches master

Comments (0)

Files changed (2)

File edn-impl.scm

View file
 (define (make-edn-tag value namespace name)
   `(tag ,(cons namespace name) ,value))
 
-(define edn-tags
-  (make-parameter
-   `((#f (#f . ,make-edn-tag)
-         (inst . ,make-edn-tag)
-         (uuid . ,make-edn-tag)))))
+(define (default-edn-tag-parsers)
+  `((#f (#f . ,make-edn-tag)
+        (inst . ,make-edn-tag)
+        (uuid . ,make-edn-tag))))
+
+(define edn-tag-parsers
+  (make-parameter (default-edn-tag-parsers)))
 
 (define (register-edn-tag-parser! namespace name parser)
-  (edn-tags
+  (edn-tag-parsers
    (alist-update!
     namespace
     (alist-update!
      name
      (lambda (v _ _) (parser v))
-     (or (alist-ref namespace (edn-tags)) '()))
-    (edn-tags))))
+     (or (alist-ref namespace (edn-tag-parsers)) '()))
+    (edn-tag-parsers))))
 
 (define parse-unknown-edn-tags?
   (make-parameter #t))
   (if (string? s) (string->symbol s) s))
 
 (define (tag-ref* ns name)
-  (and-let* ((ns-tags (alist-ref ns (edn-tags))))
+  (and-let* ((ns-tags (alist-ref ns (edn-tag-parsers))))
     (alist-ref name ns-tags)))
 
 (define (tag-ref ns name)

File edn.scm

View file
 (read-edn
  edn-parsers
  default-edn-parsers
+ edn-tag-parsers
+ default-edn-tag-parsers
  register-edn-parser!
  register-edn-tag-parser!
  parse-unknown-edn-tags?