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-let' style nil-punning thing to a cond-let implementation but at that point I imagine it more appropriate to take a step back instead :-).
I'm not convinced yet that it's worth thinking about it like this in a dynamically typed language, but brought it up because there's a named concept that addresses the need people feel to extend cond/lets. On Thu, Oct 4, 2018 at 12:57 PM lei Shulang <gzm...@gmail.com> wrote: > 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 Trakhman <gary.t...@gmail.com> 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/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: >>> https://github.com/ztellman/manifold/blob/master/docs/deferred.md#let-flow >>> >>> The general idea is turning function application into something that >>> looks less nested. >>> >>> On Wed, Oct 3, 2018 at 10:22 PM Mark Engelberg <mark.en...@gmail.com> >>> 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 >>>> in there, a bunch of people are naturally going to arrive at the same >>>> solution and make it happen in their own utility libraries. A bunch of us >>>> Clojure programmers from the early 1.0 days had been privately passing >>>> around and using a "cond that supports :let bindings" macro for years. The >>>> first time I saw the macro was in a blog post by Christophe Grand. I really >>>> hoped it would make it into Clojure proper -- other functional languages >>>> like Racket and F# support ways to bind local variables with "clearer, more >>>> linear code, that doesn't make a march for the right margin", as Howard >>>> Lewis Ship put it. But after several years had passed without any >>>> indication that CLJ-200 was ever going to be addressed, I eventually made >>>> the improved cond macro into a clojars library. >>>> >>>> walmartlabs' cond-let addresses the most important thing (let), which >>>> is the critical piece of functionality that feels like the most natural, >>>> needed addition to the language. better-cond's :let syntax is identical. >>>> But as us old-school Clojurians passed around the "better cond" macro over >>>> the years, it grew in functionality. So in better-cond, I included the >>>> other little improvements that had accumulated over time, which I had found >>>> useful. So better-cond also supports :when, :when-let, and :do (and will >>>> soon have :when-some). :let is the only piece that I felt really belonged >>>> in the core language's cond, and if CLJ-200 had made it into the core >>>> language, I would have been content to just use Clojure's own cond. But >>>> once I realized I was going to need a library to achieve the much-needed >>>> :let inside of cond, I figured I might as well use that library to include >>>> the other convenient cond additions as well. So better-cond is a superset >>>> of cond-let's functionality, with support for :let plus a few bonuses. >>>> >>>> Use whichever one strikes your fancy. cond-let is perfect if all you >>>> care about is adding :let to your cond. If you want to experiment with >>>> some of the other features beyond :let, you could use better-cond and see >>>> what you think. >>>> >>>> Either way, I strongly encourage you to use one of these two libraries >>>> so you can start using :let inside your cond. I agree fully with Howard >>>> Lewis Ship that it results in clearer code. Try either library which >>>> supports this -- it will change your life! >>>> >>>> >>>> On Wed, Oct 3, 2018 at 5:05 PM Matching Socks <phill...@gmail.com> >>>> wrote: >>>> >>> 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 this group, send email to clo...@googlegroups.com >>>> >>>> >>>>> Note that posts from new members are moderated - please be patient >>>>> with your first post. >>>>> To unsubscribe from this group, send email to >>>>> >>>> clojure+u...@googlegroups.com >>>> >>>> >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/clojure?hl=en >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Clojure" group. >>>>> >>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to clojure+u...@googlegroups.com. >>>> >>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> >>> To post to this group, send email to clo...@googlegroups.com >>> >>> >>>> Note that posts from new members are moderated - please be patient with >>>> your first post. >>>> To unsubscribe from this group, send email to >>>> >>> clojure+u...@googlegroups.com >>> >>> >>>> For more options, visit this group at >>>> http://groups.google.com/group/clojure?hl=en >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> >>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to clojure+u...@googlegroups.com. >>> >>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> >> To post to this group, send email to clo...@googlegroups.com >> >> >>> Note that posts from new members are moderated - please be patient with >>> your first post. >>> To unsubscribe from this group, send email to >>> >> clojure+u...@googlegroups.com >> >> >>> For more options, visit this group at >>> http://groups.google.com/group/clojure?hl=en >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> >> To unsubscribe from this group and stop receiving emails from it, send an >>> email to clojure+u...@googlegroups.com. >> >> >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.