Skip to content

Instantly share code, notes, and snippets.

@GEverding
Last active March 14, 2018 18:50
Show Gist options
  • Save GEverding/e5f4ef4a6cbeebe557be211fef4c0b43 to your computer and use it in GitHub Desktop.
Save GEverding/e5f4ef4a6cbeebe557be211fef4c0b43 to your computer and use it in GitHub Desktop.
Experimenting with Promenade Library
(require '[promenade.core :as prom])
(defn a [x] (prom/fail (str x)))
(defn b [x] (inc x))
(defn handle-error [failure] {:error (str "OH SNAP! " failure)})
(defn one [x] (prom/either->> x a b a b))
(defn two [] (prom/either->> 1 one one [handle-error]))
(two)
;; -----------------
(require '[promenade.core :as prom])
(defn a [x] (prom/fail (str x)))
(defn b [x] (inc x))
(defn error [x] (prom/! (throw (Exception. "ERROR"))))
(defn ok [x] (println "ok" x) x)
(defn handle-error [failure] {:error (str "OH SNAP ERROR! " failure)})
(defn handle-ex [failure] {:error (str "OH SNAP EXCEPTION! " failure)})
(defn one [x] (prom/either->> x a b b b))
;;(defn two [] (-> 1 one error one [handle-error ok]))
(defn two [] (-> 1 (prom/either-> one) (prom/either-> one) (prom/trial-> error) (prom/either-> [handle-error ok]) (prom/trial-> [handle-ex])))
(two)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment