Last active
March 14, 2018 18:50
-
-
Save GEverding/e5f4ef4a6cbeebe557be211fef4c0b43 to your computer and use it in GitHub Desktop.
Experimenting with Promenade Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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