-- Leo's gemini proxy

-- Connecting to idiomdrottning.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en

Call-tables and Medea


Here’s a simple way to write JSON from call-tables. It’s very unoptimal for now since it uses an intermediate representation instead of writing directly:


(import brev-separate medea srfi-69)

(json-unparsers
 `((,symbol? . ,(o write symbol->string))
   (,call-table*?
    . ,(fn (write-json
            ((over (cons (car x)
                         (list->vector (cdr x))))
             (hash-table->alist (x))))))
   (,call-table? . ,(fn (write-json
                         (hash-table->alist (x)))))
   ,@(json-unparsers)))

It makes writing them straight-forward:


(define fruit-color
  (ctq* apple red pear (green yellow)))

(write-json fruit-color)

-- Response ended

-- Page fetched on Fri May 17 09:39:00 2024