From fc1004d6c41c57e5ed9cae5da105e44937722959 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 13 Sep 2024 02:59:25 +0100 Subject: work/command-line-tool: Comment on match-type clauses. * ravanan/work/command-line-tool.scm (match-type): Comment on cond ladder clauses. --- ravanan/work/command-line-tool.scm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm index 5000100..a334285 100644 --- a/ravanan/work/command-line-tool.scm +++ b/ravanan/work/command-line-tool.scm @@ -79,20 +79,25 @@ directory after THUNK returns." type. The returned type may be different from @var{type}---for example, when @var{type} is a union type." (cond + ;; Match any type. ((eq? type 'Any) (object-type obj)) + ;; Match null values or empty arrays. ((eq? type 'null) (match obj ((or 'null #()) 'null) (_ #f))) + ;; Recursively match type of every element of array. ((array-type? type) (and (vector? obj) (every (cut match-type <> (array-type-subtype type)) (vector->list obj)) type)) + ;; Match any one of the subtypes of the union type. ((union-type? type) (any (cut match-type obj <>) (union-type-subtypes type))) + ;; Else, match the exact type of the object. (else (and (eq? (object-type obj) type) -- cgit v1.2.3