Created
January 20, 2016 04:15
-
-
Save paomian/0a9bf63530b9fe740351 to your computer and use it in GitHub Desktop.
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
(defrecord Merror [wrap]) | |
(defmonad error-m | |
[m-bind (fn m-bind-error | |
[x f] | |
(if (contains? (:wrap x) :error) | |
x | |
(f x))) | |
m-result (fn m-result-error | |
[x] | |
x)]) | |
(defmacro m-> | |
[x & form] | |
`(-> ~x | |
~@(map (fn [xx] (if (seq? xx) | |
`((monad/m-lift 1 (fn [y#] (~(first xx) y# ~@(next xx))))) | |
`((monad/m-lift 1 ~xx)))) | |
form))) | |
#_(monad/domonad error-m | |
[x (Merror. {:success ""})] | |
(m-> x | |
(println "1" "2") | |
((fn [x] (println "0" x) (Merror. {:error 1}))) | |
(#(println "2" %)))) | |
#_(defendpoint request-sms | |
[req app_id] | |
{:pre [(not (adb/allow-verify-sms-code-api? (:flags (:app req)))) | |
kPFErrorOperationForbidden | |
(boolean-env | |
(keyword (format "%s.sms.blacklist" (-> req :app :app_id)))) | |
"Your app is in blacklist, please contact us."] | |
:validators [(when-let [st (-> req :json-params :smsType)] | |
(require-sms-type st)) | |
(require-mobile-phone-number | |
(-> req :json-params :mobilePhoneNumber))]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment