From 074abba55d1b0af085fe4995b6327388a1a32e23 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Fri, 13 Sep 2024 02:47:12 +0100
Subject: utils: Move assoc-ref* to (ravanan work utils).
* ravanan/utils.scm: Do not import (rnrs base). Move assoc-ref* to ...
* ravanan/work/utils.scm: ... here. Import assertion-violation
from (rnrs base).
* ravanan/command-line-tool.scm, ravanan/workflow.scm: Do not
import (ravanan utils).
---
ravanan/command-line-tool.scm | 1 -
ravanan/utils.scm | 12 +-----------
ravanan/work/utils.scm | 10 ++++++++++
ravanan/workflow.scm | 1 -
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index 14f9269..5676ce0 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -52,7 +52,6 @@
#:use-module (ravanan propnet)
#:use-module (ravanan reader)
#:use-module (ravanan slurm-api)
- #:use-module (ravanan utils)
#:use-module (ravanan vectors)
#:use-module (ravanan work command-line-tool)
#:use-module (ravanan work types)
diff --git a/ravanan/utils.scm b/ravanan/utils.scm
index fd84efa..d56378e 100644
--- a/ravanan/utils.scm
+++ b/ravanan/utils.scm
@@ -17,22 +17,12 @@
;;; along with ravanan. If not, see .
(define-module (ravanan utils)
- #:use-module (rnrs base)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
- #:export (assoc-ref*
- json-ref
+ #:export (json-ref
call-with-temporary-file))
-(define (assoc-ref* alist key)
- "Return value mapped to @var{key} in @var{alist}. Raise an &assertion
-if not found."
- (match (assoc key alist)
- ((_ . value) value)
- (#f (assertion-violation (cons key alist)
- "Missing key in association list"))))
-
(define (json-ref scm . keys)
"Extract subtree of JSON @var{scm} that is addressed by @var{keys}."
(match keys
diff --git a/ravanan/work/utils.scm b/ravanan/work/utils.scm
index d005447..51da34c 100644
--- a/ravanan/work/utils.scm
+++ b/ravanan/work/utils.scm
@@ -17,12 +17,14 @@
;;; along with ravanan. If not, see .
(define-module (ravanan work utils)
+ #:use-module ((rnrs base) #:select (assertion-violation))
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 filesystem)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:export (list->dotted-list
+ assoc-ref*
assoc-set
call-with-temporary-directory
call-with-input-pipe))
@@ -35,6 +37,14 @@ pairs."
(cons key value)))
lst))
+(define (assoc-ref* alist key)
+ "Return value mapped to @var{key} in @var{alist}. Raise an &assertion
+if not found."
+ (match (assoc key alist)
+ ((_ . value) value)
+ (#f (assertion-violation (cons key alist)
+ "Missing key in association list"))))
+
(define (assoc-set alist . pairs)
"Functionally set @var{pairs} in @var{alist}. @var{alist} is not
mutated."
diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm
index 4d28716..9e9e868 100644
--- a/ravanan/workflow.scm
+++ b/ravanan/workflow.scm
@@ -25,7 +25,6 @@
#:use-module (ravanan monads)
#:use-module (ravanan propnet)
#:use-module (ravanan reader)
- #:use-module (ravanan utils)
#:use-module (ravanan vectors)
#:use-module (ravanan work command-line-tool)
#:use-module (ravanan work ui)
--
cgit v1.2.3