   (pending* [_]
     (not (.isDone cf)))
 
+  IPromise
   (then* [_ callback]
     (let [cf' (.thenApply cf (reify java.util.function.Function
                                (apply [_ v]

;; The main abstraction definition.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defprotocol IPromise
  "A promise abstraction."
  (^:private rejected* [_] "Returns true if a promise is rejected.")
  (^:private resolved* [_] "Returns true if a promise is resolved.")
  (^:private done* [_] "Retutns true if a promise is already done.")
  (^:private pending* [_] "Retutns true if a promise is stil pending.")
  (^:private then* [_ callback] "Chain a promise.")
  (^:private error* [_ callback] "Catch a error in a promise."))


          (.setStackTrace e' (.getStackTrace e))
          (throw e')))))

  IPromiseState
  (rejected* [_]
    (.isCompletedExceptionally cf))

