From 604ec469667f1bff32c8043729ea0bfd93ee61e3 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 24 Jan 2025 18:44:37 +0000 Subject: command-line-tool: Support float and double types. * ravanan/work/command-line-tool.scm (object-type, match-type): Support float and double types. * ravanan/command-line-tool.scm (command-line-binding->args): Handle float arguments. --- ravanan/command-line-tool.scm | 2 +- ravanan/work/command-line-tool.scm | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm index 3493db1..958d99e 100644 --- a/ravanan/command-line-tool.scm +++ b/ravanan/command-line-tool.scm @@ -339,7 +339,7 @@ in which the G-expressions are inserted." (list (case type ((string) value) - ((int) + ((int float) #~(number->string #$value)) ((File) #~(assoc-ref* #$value "path")) diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm index 4787e3d..9e5c8a1 100644 --- a/ravanan/work/command-line-tool.scm +++ b/ravanan/work/command-line-tool.scm @@ -1,5 +1,5 @@ ;;; ravanan --- High-reproducibility CWL runner powered by Guix -;;; Copyright © 2024 Arun Isaac +;;; Copyright © 2024, 2025 Arun Isaac ;;; ;;; This file is part of ravanan. ;;; @@ -52,13 +52,17 @@ directory after THUNK returns." thunk (cut chdir original-current-directory)))) -;; TODO: Support float types. (define (object-type obj) "Return the type of @var{obj}." (cond ((eq? obj 'null) 'null) ((boolean? obj) 'boolean) - ((integer? obj) 'int) + ((and (number? obj) + (inexact? obj)) + 'float) + ((and (number? obj) + (integer? obj)) + 'int) ((string? obj) 'string) ;; For vector objects, we use the first element to guess at the ;; subtype. @@ -86,6 +90,10 @@ example, when @var{type} is a union type." (match obj ((or 'null #()) 'null) (_ #f))) + ;; Treat floats and doubles as the same thing. It is unclear to me why the + ;; CWL specification needs separate types for these. + ((eq? type 'double) + (match-type obj 'float)) ;; Recursively match type of every element of array. ((array-type? type) (and (vector? obj) -- cgit v1.2.3