aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.lisp1
-rw-r--r--petty-types.lisp8
2 files changed, 7 insertions, 2 deletions
diff --git a/package.lisp b/package.lisp
index ae36c5c..1bf33cb 100644
--- a/package.lisp
+++ b/package.lisp
@@ -9,4 +9,5 @@
#:optional ; deftype
#:tuple ; deftype
#:vector-of ; deftype
+ #:sequence-of ; deftype
#:list-of)) ; deftype
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."