+;;; Given a lambda-list, return a FUN-TYPE object representing the signature:
+;;; return type is *, and each individual arguments type is T -- but we get
+;;; the argument counts and keywords.
+(defun ftype-from-lambda-list (lambda-list)
+ (multiple-value-bind (req opt restp rest-name keyp key-list allowp morep)
+ (parse-lambda-list lambda-list)
+ (declare (ignore rest-name))
+ (flet ((t (list)
+ (mapcar (constantly t) list)))
+ (let ((reqs (t req))
+ (opts (when opt (cons '&optional (t opt))))
+ ;; When it comes to building a type, &REST means pretty much the
+ ;; same thing as &MORE.
+ (rest (when (or morep restp) (list '&rest t)))
+ (keys (when keyp
+ (cons '&key (mapcar (lambda (spec)
+ (let ((key/var (if (consp spec)
+ (car spec)
+ spec)))
+ (list (if (consp key/var)
+ (car key/var)
+ (keywordicate key/var))
+ t)))
+ key-list))))
+ (allow (when allowp (list '&allow-other-keys))))
+ (specifier-type `(function (,@reqs ,@opts ,@rest ,@keys ,@allow) *))))))
+