diff options
author | Arun Isaac | 2025-08-17 03:22:50 +0100 |
---|---|---|
committer | Arun Isaac | 2025-08-17 03:24:44 +0100 |
commit | 22798720a764c6e01022cedd9fbf8639cde49dd6 (patch) | |
tree | b85d955b7d93096ba5f7c35f27ab1b05c8ab6b9e | |
parent | f768089f8e3dc8bad2342fe9fb4385b0615c1cb2 (diff) | |
download | ravanan-22798720a764c6e01022cedd9fbf8639cde49dd6.tar.gz ravanan-22798720a764c6e01022cedd9fbf8639cde49dd6.tar.lz ravanan-22798720a764c6e01022cedd9fbf8639cde49dd6.zip |
reader: Add read-yaml-file.
read-yaml-file is a wrapper around read-yaml-file from (yaml). It raises the relevant exceptions when it fails.
-rw-r--r-- | ravanan/reader.scm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ravanan/reader.scm b/ravanan/reader.scm index 0117007..bf8d8aa 100644 --- a/ravanan/reader.scm +++ b/ravanan/reader.scm @@ -24,7 +24,7 @@ #:use-module (ice-9 filesystem) #:use-module (ice-9 match) #:use-module (json) - #:use-module (yaml) + #:use-module ((yaml) #:prefix yaml:) #:use-module (ravanan work command-line-tool) #:use-module (ravanan work monads) #:use-module (ravanan work types) @@ -320,3 +320,16 @@ array of array of @code{File}s, etc. Else, return @code{#f}" c)))) (call-with-input-file file json->scm))) + +(define (read-yaml-file file) + "Read YAML @var{file} and return scheme tree." + (guard (c ((and (message-condition? c) + (string-prefix? "read-yaml-file:" (condition-message c))) + (raise-exception + (condition (make-who-condition 'read-yaml-file) + (make-irritants-condition + (match (string-split (condition-message c) #\:) + ((_ message file) + (list (string-trim message) + (string-trim file))))))))) + (yaml:read-yaml-file file))) |