funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
luxbock 2016-04-05T14:06:47.000171Z

how would I translate this to Clojure using cats? https://gist.github.com/luxbock/8e9bb642b309b42f5001ed1b0de8e246

luxbock 2016-04-05T14:10:22.000172Z

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

2016-04-05T18:09:50.000173Z

(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)

2016-04-05T18:11:34.000176Z

@luxbock: the above example does what you want

luxbock 2016-04-05T18:41:06.000177Z

@dialelo thanks

2016-04-05T18:41:48.000178Z

happy to help