 
 ;; Generic
 (defn then
-  "Given a RSG.IPromise<T> run (f result-value) when the promise resolves."
+  "Given a RSG.IPromise<T> run (f result-value) when the promise resolves. A new
+  promise is returned."
   [ipromise f]
   (let [ptype (type ipromise)
-       of-type (.GetGenericArguments ptype)
-       atype (eval `(generate-generic-type Action ~of-type))
-       meth (.GetMethod ptype "Then" (into-array Type [atype]))
-       arg #_(eval `(sys-action ~(apply vector of-type) [~'s] (~f ~'s)))
-       (. clojure.lang.GenDelegate Create atype f)
-       ]
-       (.Invoke meth ipromise (into-array Object [arg]))))
+        of-type (.GetGenericArguments ptype)
+        atype (eval `(generate-generic-type Action ~of-type))
+        meth (.GetMethod ptype "Then" (into-array Type [atype]))
+        arg #_(eval `(sys-action ~(apply vector of-type) [~'s] (~f ~'s)))
+        (. clojure.lang.GenDelegate Create atype f)]
+    (.Invoke meth ipromise (into-array Object [arg]))))
 
 (defn pcatch
   "Given an RSG.IPromise p, if p is rejected, run (f e) where e is the

(defn read-from-minibuffer
  "Read a string from the minibuffer prompt. This returns an IPromise.

e.g. (then (read-from-minibuffer \"Who are you? \") #(message \"Hi, %s.\" %))"
  [prompt & {:keys [input history completer require-match require-coerce]
             :or {input "" history nil completer nil
                  require-match false require-coerce false}}]

   ))

(defn read-type
  "Read from the minibuffer but of a particular type. Basically Minibuffer.Read<T>().

(then (read-type Int64 \"How old are you?\")
      #(message \"%d is a fine age.\" %))
"
  [type prompt & {:keys [input history completer require-match require-coerce]
                  :or {input "" history nil completer nil
                       require-match false require-coerce false}}]
