From 1af3c087d46fb8049ec59ee9c03e4e812d132e52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludovic.courtes@inria.fr>
Date: Thu, 21 Jan 2021 18:49:26 +0100
Subject: [PATCH] Switch to Guile-JSON 4.x.

* environment.scm <propagated-inputs>: Update to GUILE-JSON-4.
* jupyter/json.scm: Use (json parser) instead of (json).  Explain the
difference with what Guile-JSON provides.
* guix-jupyter-kernel.scm: Use (json parser) and (json builder) instead
of (json).
* guix/jupyter/kernel.scm: Likewise.
* guix/jupyter/proxy.scm: Likewise.
* jupyter/guile.scm: Likewise.
* jupyter/kernels.scm: Likewise.
* jupyter/messages.scm: Likewise.
* jupyter/servers.scm: Likewise.
* tests/guile.scm: Likewise.
* tests/kernels.scm: Likewise.
* tests/servers.scm: Likewise.
* configure.ac: Check for (json parser) rather than JSON.
---
 configure.ac            |  4 ++--
 environment.scm         |  2 +-
 guix-jupyter-kernel.scm |  3 ++-
 guix/jupyter/kernel.scm |  5 +++--
 guix/jupyter/proxy.scm  |  5 +++--
 jupyter/guile.scm       |  5 +++--
 jupyter/json.scm        | 13 ++++++++++---
 jupyter/kernels.scm     |  5 +++--
 jupyter/messages.scm    |  5 +++--
 jupyter/servers.scm     |  2 +-
 tests/guile.scm         |  5 +++--
 tests/kernels.scm       |  5 +++--
 tests/servers.scm       |  5 +++--
 13 files changed, 40 insertions(+), 24 deletions(-)

diff --git a/configure.ac b/configure.ac
index ec593bc..c7352b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,9 +38,9 @@ if test "x$have_guile_simple_zmq" != "xyes"; then
 fi
 
 dnl Check dor Guile-Json.
-GUILE_MODULE_AVAILABLE([have_guile_json], [(json)])
+GUILE_MODULE_AVAILABLE([have_guile_json], [(json parser)])
 if test "x$have_guile_json" != "xyes"; then
-   AC_MSG_ERROR([Guile-Json is missing; please install it.])
+   AC_MSG_ERROR([Guile-JSON is missing; please install it.])
 fi
 
 dnl Check for Guile-Gcrypt >= 0.2.0.
diff --git a/environment.scm b/environment.scm
index 88149e8..fcacf7b 100644
--- a/environment.scm
+++ b/environment.scm
@@ -91,7 +91,7 @@
    `(("guix" ,guix)
      ("guile" ,@(assoc-ref (package-native-inputs guix) "guile"))))
   (propagated-inputs
-   `(("guile-json" ,guile-json-3)
+   `(("guile-json" ,guile-json-4)
      ("guile-simple-zmq" ,guile-simple-zmq)
      ("guile-gcrypt" ,guile-gcrypt)))
 
diff --git a/guix-jupyter-kernel.scm b/guix-jupyter-kernel.scm
index 03b68e2..630d235 100644
--- a/guix-jupyter-kernel.scm
+++ b/guix-jupyter-kernel.scm
@@ -16,7 +16,8 @@
 ;;; You should have received a copy of the GNU General Public License
 ;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-(use-modules (json)
+(use-modules (json parser)
+             (json builder)
              (simple-zmq)
              (git)                                ;for 'git-error-message'
 	     (srfi srfi-1)
diff --git a/guix/jupyter/kernel.scm b/guix/jupyter/kernel.scm
index b5e72ce..812b413 100644
--- a/guix/jupyter/kernel.scm
+++ b/guix/jupyter/kernel.scm
@@ -1,5 +1,5 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
-;;; Copyright (C) 2019 Ludovic Courtès <ludovic.courtes@inria.fr>
+;;; Copyright (C) 2019, 2021 Ludovic Courtès <ludovic.courtes@inria.fr>
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -29,7 +29,8 @@
   #:use-module ((gnu build linux-container) #:select (%namespaces))
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:export (%language-info
             %kernel-info-reply
 
diff --git a/guix/jupyter/proxy.scm b/guix/jupyter/proxy.scm
index 398cb3a..a6bf8a4 100644
--- a/guix/jupyter/proxy.scm
+++ b/guix/jupyter/proxy.scm
@@ -1,5 +1,5 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
-;;; Copyright (C) 2019 Ludovic Courtès <ludovic.courtes@inria.fr>
+;;; Copyright (C) 2019, 2021 Ludovic Courtès <ludovic.courtes@inria.fr>
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -19,7 +19,8 @@
   #:use-module (jupyter messages)
   #:use-module (jupyter kernels)
   #:use-module (jupyter servers)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:use-module (gcrypt base16)
   #:use-module ((guix build utils) #:select (delete-file-recursively))
   #:use-module (srfi srfi-1)
diff --git a/jupyter/guile.scm b/jupyter/guile.scm
index d69c581..e214561 100644
--- a/jupyter/guile.scm
+++ b/jupyter/guile.scm
@@ -1,5 +1,5 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
-;;; Copyright (C) 2019 Ludovic Courtès <ludovic.courtes@inria.fr>
+;;; Copyright (C) 2019, 2021 Ludovic Courtès <ludovic.courtes@inria.fr>
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -18,7 +18,8 @@
   #:use-module (jupyter messages)
   #:use-module (jupyter kernels)
   #:use-module (jupyter servers)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:use-module (simple-zmq)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
diff --git a/jupyter/json.scm b/jupyter/json.scm
index cd2658c..8ede1a9 100644
--- a/jupyter/json.scm
+++ b/jupyter/json.scm
@@ -1,5 +1,5 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
-;;; Copyright (C) 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright (C) 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
 ;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 (define-module (jupyter json)
-  #:use-module (json)
+  #:use-module (json parser)
   #:use-module (guix records)
   #:export (json
             <=>
@@ -23,7 +23,14 @@
 
 ;;; Commentary:
 ;;;
-;;; Helpers to map JSON objects to SRFI-9 records.  Taken from (guix swh).
+;;; Helpers to map JSON objects to records.  Taken from (guix swh).
+;;; Guile-JSON 4.x includes a variant of this code.  The difference is that
+;;; this module builds upon the 'define-record-type*' feature of (guix
+;;; records), whereas Guile-JSON builds on top of SRFI-9.
+;;;
+;;; Consequently, the syntax is a bit different; in particular, this variant
+;;; uses the 'json' keyword to distinguish parameters of the JSON mapping
+;;; from other properties of record fields, such as default values.
 ;;;
 ;;; Code:
 
diff --git a/jupyter/kernels.scm b/jupyter/kernels.scm
index 86b7918..2680d05 100644
--- a/jupyter/kernels.scm
+++ b/jupyter/kernels.scm
@@ -1,6 +1,6 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
 ;;; Copyright (C) 2018, 2019 Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
-;;; Copyright (C) 2018, 2019 Ludovic Courtès <ludovic.courtes@inria.fr>
+;;; Copyright (C) 2018, 2019, 2021 Ludovic Courtès <ludovic.courtes@inria.fr>
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -25,7 +25,8 @@
   #:use-module (ice-9 match)
   #:use-module (ice-9 ftw)
   #:use-module (simple-zmq)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
diff --git a/jupyter/messages.scm b/jupyter/messages.scm
index 8e0841f..c4069d4 100644
--- a/jupyter/messages.scm
+++ b/jupyter/messages.scm
@@ -1,6 +1,6 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
 ;;; Copyright (C) 2018 Evgeny Panfilov <epanfilov@gmail.com>
-;;; Copyright (C) 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright (C) 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -17,7 +17,8 @@
 
 (define-module (jupyter messages)
   #:use-module (simple-zmq)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:use-module (jupyter json)
   #:use-module (gcrypt mac)
   #:use-module (gcrypt base16)
diff --git a/jupyter/servers.scm b/jupyter/servers.scm
index f13512d..16a8bd7 100644
--- a/jupyter/servers.scm
+++ b/jupyter/servers.scm
@@ -19,7 +19,7 @@
   #:use-module (jupyter kernels)
   #:use-module (jupyter messages)
   #:use-module (simple-zmq)
-  #:use-module (json)
+  #:use-module (json parser)
   #:use-module (rnrs bytevectors)
   #:use-module (ice-9 match)
   #:use-module (ice-9 vlist)
diff --git a/tests/guile.scm b/tests/guile.scm
index f3d8555..f002b3f 100644
--- a/tests/guile.scm
+++ b/tests/guile.scm
@@ -1,5 +1,5 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
-;;; Copyright (C) 2019 Inria
+;;; Copyright (C) 2019, 2021 Inria
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -20,7 +20,8 @@
   #:use-module (jupyter servers)
   #:use-module (jupyter guile)
   #:use-module (simple-zmq)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
diff --git a/tests/kernels.scm b/tests/kernels.scm
index fdbde44..a46cf61 100644
--- a/tests/kernels.scm
+++ b/tests/kernels.scm
@@ -1,5 +1,5 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
-;;; Copyright (C) 2019 Inria
+;;; Copyright (C) 2019, 2021 Inria
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -18,7 +18,8 @@
   #:use-module (jupyter kernels)
   #:use-module (jupyter messages)
   #:use-module (simple-zmq)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
diff --git a/tests/servers.scm b/tests/servers.scm
index 4289934..2716a5f 100644
--- a/tests/servers.scm
+++ b/tests/servers.scm
@@ -1,5 +1,5 @@
 ;;; Guix-kernel -- Guix kernel for Jupyter
-;;; Copyright (C) 2019 Inria
+;;; Copyright (C) 2019, 2021 Inria
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -19,7 +19,8 @@
   #:use-module (jupyter messages)
   #:use-module (jupyter servers)
   #:use-module (simple-zmq)
-  #:use-module (json)
+  #:use-module (json parser)
+  #:use-module (json builder)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
-- 
GitLab