Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

Commit

Permalink
add missing cl-typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
politza committed Dec 3, 2024
1 parent 218bf7e commit 64f31c2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
29 changes: 29 additions & 0 deletions packages/Emil/src/Emil/Type.el
Original file line number Diff line number Diff line change
Expand Up @@ -573,4 +573,33 @@ Returns nil, if TYPE is not an alias."
(eq 'Trait (Struct:get type :name))
(= 1 (length (Struct:get type :arguments)))))

(cl-deftype Cons (head tail)
`(and list
(satisfies ,(lambda (cons)
(or (null cons)
(and (or (null (car cons))
(cl-typep (car cons) head))
(or (null (cdr cons))
(cl-typep (cdr cons) tail))))))))

(cl-deftype List (type)
`(and list
(satisfies ,(lambda (list)
(or (null list)
(null (car list))
(cl-typep (car list) type))))))

(cl-deftype Sequence (type)
`(and sequence
(satisfies ,(lambda (sequence)
(or (null sequence)
(= 0 (length sequence))
(cl-typep (elt sequence 0) type))))))

(cl-deftype Vector (type)
`(and vector (Sequence ,type)))

(cl-deftype Array (type)
`(and array (Sequence ,type)))

(provide 'Emil/Type)
9 changes: 3 additions & 6 deletions packages/Struct/src/Struct/Function.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@
(cl-deftype List (type)
`(and list
(satisfies ,(lambda (list)
(and (or (null list)
(cl-typep (car list) type))
(or (null (cdr list))
(cl-typep (cadr list) type))
(or (null (cddr list))
(cl-typep (caddr list) type)))))))
(or (null list)
(null (car list))
(cl-typep (car list) type))))))

(Struct:define Struct:Function
"Defines a declared function."
Expand Down

0 comments on commit 64f31c2

Please sign in to comment.