This question already has an answer here:
- Is it possible to define a recursive type in Common Lisp? 2 answers
So I would like to write a type specifier for list that allows one to specify the types of the list elements. Something like :
(deftype list-of (v) (cons ,v (or null (list-of ,v))))
but of course, that's not going to work because as we all know, recursive types are not supported. One could map something like "satisfies" of course (as has been mentioned here: Is it possible to define a recursive type in Common Lisp?), but that kind of negates the advantage of a clean recursive definition suitable for language analysis and offline code analysis. (E.g., proving code is correct, and or translating between languages).
Any suggestions? Seems like this is a missing bit of standard, unless I'm missing something obvious, given we typically use lists to represent sets - why not have a simple way to declare the types of set elements?