-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstatus.lisp
35 lines (24 loc) · 966 Bytes
/
status.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(in-package #:org.shirakumo.simple-tasks)
(defvar +status-started+ '(:created :scheduled :running))
(defvar +status-running+ '(:running))
(defvar +status-ended+ '(:completed :errored :stopped))
(defgeneric status (status-object))
(defgeneric status= (a b))
(defclass status-object ()
((status :initform :created :accessor status)))
(defun status-list-p (list)
(every #'symbolp list))
(deftype status ()
'(or symbol status-object (and list (satisfies status-list-p))))
(defmethod status= ((a status-object) (b status-object))
(eql (status a) (status b)))
(defmethod status= ((a status-object) (b list))
(loop for status in b thereis (eql (status a) status)))
(defmethod status= ((a status-object) b)
(eql (status a) b))
(defmethod status= ((b list) (a status-object))
(status= a b))
(defmethod status= (b (a status-object))
(status= a b))
(defmethod status= ((a list) (b list))
(loop for status in a thereis (find status b :test #'eql)))