diff options
author | colin <colin@cicadas.surf> | 2024-09-08 07:33:21 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-09-08 07:33:21 -0700 |
commit | a0f32d5ac333b88bb294c613698389ac8e687f92 (patch) | |
tree | 326a9268bb3c6567696880db96b4471f312a073c /petty-types.lisp | |
parent | 4fc872fb435f11b8bcc7838c6eff4f6b3b48e60c (diff) |
added sequence-of type
Diffstat (limited to 'petty-types.lisp')
-rw-r--r-- | petty-types.lisp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/petty-types.lisp b/petty-types.lisp index 9f98e78..9392191 100644 --- a/petty-types.lisp +++ b/petty-types.lisp @@ -34,7 +34,7 @@ (or (not len) (= len (length xs))) (every is-type xs))))))))) -(defun ordered-sequence-of (types) +(defun tuple-sequence-predicate-of (types) "Returns the name of a predicate that checks whether its argument is a list of exactly (LENGTH TYPES) members such that the type of the NTH member is the NTH member of TYPES." @@ -63,9 +63,13 @@ member is the NTH member of TYPES." "Type specifier for vectors all of the same TYPE." `(and vector (satisfies ,(sequence-of-predicate-for 'vector type len)))) +(deftype sequence-of (type &optional len) + "Type specifier for vectors all of the same TYPE." + `(and sequence (satisfies ,(sequence-of-predicate-for 'sequence type len)))) + (deftype tuple (&rest types) "Type specifier for a list of specific types" - `(and list (satisfies ,(ordered-sequence-of types)))) + `(and list (satisfies ,(tuple-sequence-predicate-of types)))) (deftype optional (type) "Type specifier for an optional type." |