aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-09-13 02:47:12 +0100
committerArun Isaac2024-09-13 02:57:39 +0100
commit074abba55d1b0af085fe4995b6327388a1a32e23 (patch)
tree772bcff07ace139fa6730936f90ed24b1a3a68c7
parent85c561053241ee4ee4c7567324e4080b6fcc2a5a (diff)
downloadravanan-074abba55d1b0af085fe4995b6327388a1a32e23.tar.gz
ravanan-074abba55d1b0af085fe4995b6327388a1a32e23.tar.lz
ravanan-074abba55d1b0af085fe4995b6327388a1a32e23.zip
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).
-rw-r--r--ravanan/command-line-tool.scm1
-rw-r--r--ravanan/utils.scm12
-rw-r--r--ravanan/work/utils.scm10
-rw-r--r--ravanan/workflow.scm1
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 <https://www.gnu.org/licenses/>.
(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 <https://www.gnu.org/licenses/>.
(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)