假设:
- 通过代理,我的意思是像 Spring 中的包装器
- 通过你的功能,我的意思是简单的
(fn [x] (+ x 1))
考虑来自 Konrad Hinsen的以下内容:
(defn f [x]
(let [a x
b (inc a)]
(* a b)))
(defn f [x]
(domonad maybe-m
[a x
b (inc a)]
(* a b)))
(defn m-bind [value function]
(if (nil? value)
nil
(function value)))
现在的好处是,如果值为nil
,则m-bind
返回nil
,并且永远不会调用其余的计算。
我的问题是:Maybe Monad 的本质是您功能的代理吗?