From 22798720a764c6e01022cedd9fbf8639cde49dd6 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 17 Aug 2025 03:22:50 +0100 Subject: 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. --- ravanan/reader.scm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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))) -- cgit 1.4.1