Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-05 Thread Howard Lewis Ship
I'm glad my little library has gotten some attention on better-cond, which even I'm switching over to. On Thu, Oct 4, 2018 at 10:39 PM Mark Engelberg wrote: > Documentation for latest features in the 2.0.1 branch: > https://github.com/Engelberg/better-cond/tree/v2.0.1 > > An example: > > (cond

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Mark Engelberg
Documentation for latest features in the 2.0.1 branch: https://github.com/Engelberg/better-cond/tree/v2.0.1 An example: (cond (odd? a) 1 :let [a (quot a 2)] :when-let [x (fn-which-may-return-nil a), y (fn-which-may-return-nil (* 2 a))] :when (seq x) :do (println x)

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Alan Thompson
How would the :when and :do forms work? Alan On Wed, Oct 3, 2018 at 7:22 PM Mark Engelberg wrote: > This looks like a case of "convergent evolution". > > Having the ability to do a :let in the middle of a cond feels like one of > those things that *should* be in the core language, so if it's not

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Howard Lewis Ship
Yes, I wouldn't have bothered if I had known about better-cond, so there you go. I think I first wrote this code at Aviso at least five years ago. On Wed, Oct 3, 2018 at 7:22 PM Mark Engelberg wrote: > This looks like a case of "convergent evolution". > > Having the ability to do a :let in the

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Gary Trakhman
The short-circuiting is a 'feature' of letting the type control the sequencing of operations. In practice you mix multiple interacting monads depending on what your requirements are, for example I regularly work with Deferred Options and Deferred Results. In clojure, you could try to add a 'if-le

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread lei Shulang
But a Maybe/Nothing will short-circuit the whole flow where cond-let won't? On Thursday, 4 October 2018 08:38:05 UTC-7, Moe Aboulkheir wrote: > > See https://funcool.github.io/cats/latest/#mlet for something closer to > home, in the monadic vein. > > > On Thu, Oct 4, 2018 at 4:10 PM Gary Trakhm

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Moe Aboulkheir
See https://funcool.github.io/cats/latest/#mlet for something closer to home, in the monadic vein. On Thu, Oct 4, 2018 at 4:10 PM Gary Trakhman wrote: > These are all just sugar over monadic bind, right? > > Here's one way to do it in the ocaml alternate universe: > https://github.com/janestree

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Gary Trakhman
These are all just sugar over monadic bind, right? Here's one way to do it in the ocaml alternate universe: https://github.com/janestreet/ppx_let#syntactic-forms-and-actual-rewriting But it can be made to work for async or options or whatever, too. We can put the async helpers in the same bucket

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-03 Thread Mark Engelberg
This looks like a case of "convergent evolution". Having the ability to do a :let in the middle of a cond feels like one of those things that *should* be in the core language, so if it's not in there, a bunch of people are naturally going to arrive at the same solution and make it happen in their

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-03 Thread Matching Socks
Is this a refinement of Mark Engelberg's "better-cond", or an alternative approach? I have not used better-cond myself, but it starts here: https://dev.clojure.org/jira/browse/CLJ-200. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

[ANN] com.walmartlabs/cond-let 1.0.0

2018-10-03 Thread Howard Lewis Ship
A micro library of a single macro, cond-let. cond-let acts like a cond, but adds :let terms that are followed by a binding form (like let). This allows conditional code to introduce new local symbols; the result is clearer, more linear code, that doesn't make a march for the right margin. Exampl