From 3005e128df284e2eaa2b1558c33c8636102ef0ba Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 7 Mar 2021 08:43:31 +0100 Subject: spec: primitive-type-checker: Recurse into lists. * language/aws/spec.scm (primitive-type-checker): Use the primitive-type-checker recursively for list values that are (wrappers around) primitive types. --- language/aws/spec.scm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/language/aws/spec.scm b/language/aws/spec.scm index 3a6614b..a4c56ee 100644 --- a/language/aws/spec.scm +++ b/language/aws/spec.scm @@ -70,13 +70,24 @@ if this is not a primitive data type." ("list" (let ((member-spec (assoc-ref exp "member"))) (if member-spec - `(lambda (value) - (let ((shape ',(string->symbol (assoc-ref member-spec "shape")))) - (and (list? value) - (every (lambda (item) - (and=> (aws-name item) - (cut eq? <> shape))) - value)))) + (let ((shape-name (string->symbol (assoc-ref member-spec "shape")))) + `(lambda (value) + (let ((shape ',shape-name)) + (and (list? value) + ;; Use the primitive type checker here as well + ;; in case the member spec is a wrapper around + ;; a primitive value. + (every ,(let ((target-spec (assoc-ref %shape-specs shape-name))) + (if (and=> target-spec primitive?) + ;; Apply the primitive type check + ;; directly. This allows us to + ;; avoid unnecessary wrapping. + (primitive-type-checker target-spec) + ;; Otherwise make sure the value has the correct type + '(lambda (item) + (and=> (aws-name item) + (cut eq? <> shape))))) + value))))) 'list?))) ("map" `(lambda (value) -- cgit v1.2.3