 ;; Functions that make use of Allens' Interval Algebra
 
 (defprotocol IIntervalOps
-  (slice [_ beginning end] "Fit the interval between beginning and end, slicing off one or both ends as necessary")
-  (splice [ival1 ival2] "Splice two intervals together")
-  (split [ival t] "Split ival into 2 intervals at t, returned as a 2-element vector"))
+  (slice [this beginning end] "Fit the interval between beginning and end, slicing off one or both ends as necessary")
+  (splice [this ival] "Splice another interval on to this one")
+  (split [this t] "Split ival into 2 intervals at t, returned as a 2-element vector"))
 
 (defn split-with-assert [ival t]
   (assert

;; Use of Allen's Interval Algebra, inspired from a working
;; demonstration of time-count by Eric Evans.

(defrecord Interval [beginning end]
  t/ITimeSpan
  (beginning [_] beginning)
  (end [_] end))

;; Construction

(defn- make-interval [v1 v2]
  (assert (t/< v1 v2))
  (->Interval v1 v2))

(defn temporal? [o]
  #?(:clj (instance? Temporal o)

  (<= [x y] (t/<= (as-interval x) (as-interval y)))
  (> [x y] (t/> (as-interval x) (as-interval y)))
  (>= [x y] (t/>= (as-interval x) (as-interval y)))
  clojure.lang.APersistentMap
  (< [x y] (#{precedes? meets?} (basic-relation x y)))
  (<= [x y] (#{precedes? meets? equals? starts? overlaps? finished-by?} (basic-relation x y)))
  (> [x y] (#{preceded-by? met-by?} (basic-relation x y)))
