how would I translate this to Clojure using cats
? https://gist.github.com/luxbock/8e9bb642b309b42f5001ed1b0de8e246
I added a solution that works, but it's not using mlet
which I'm trying to use, since I think it's supposed to be equivalent to the do
notation as far as I've understood
(require '[cats.core :as m])
(require '[cats.context :as ctx])
(require '[cats.labs.writer :as w])
(defn halfer [x]
(ctx/with-context w/context
(m/mlet [_ (w/tell (str "I just halved " x "!"))]
(m/return (/ x 2)))))
(halfer 10)
@luxbock: the above example does what you want
@dialelo thanks
happy to help