This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-22
Channels
- # aws (1)
- # beginners (102)
- # boot (5)
- # cljs-dev (59)
- # cljsjs (1)
- # clojure (154)
- # clojure-australia (1)
- # clojure-brasil (1)
- # clojure-dusseldorf (4)
- # clojure-greece (36)
- # clojure-italy (10)
- # clojure-poland (5)
- # clojure-romania (1)
- # clojure-russia (7)
- # clojure-spec (32)
- # clojure-uk (113)
- # clojure-ukraine (3)
- # clojurescript (107)
- # cursive (13)
- # data-science (25)
- # datomic (23)
- # emacs (3)
- # events (1)
- # fulcro (72)
- # funcool (10)
- # graphql (1)
- # leiningen (1)
- # luminus (2)
- # lumo (38)
- # off-topic (14)
- # onyx (78)
- # planck (4)
- # re-frame (55)
- # reagent (1)
- # ring (3)
- # ring-swagger (2)
- # rum (19)
- # shadow-cljs (89)
- # spacemacs (101)
- # sql (2)
- # unrepl (88)
you might be looking for something like https://github.com/zalando-stups/cats.match @sinistral
Thanks for the link @mccraigmccraig. I'll look into that and instaskip; hopefully that will give me a better idea of the patterns (no pun intended) that make sense.
i haven't used cats.match
myself @sinistral, so can't comment on how straightforward or effective it is - i have surprisingly little code which needs to process error states, so i've been ok with the more awkward branch style approach
Is that an acceptable approach? Every time I use a branch-*
, I can't help but feel that I should be using something like fmap
instead. Between branch-*
and with-context
, I feel like I'm doing something wrong; I feel like I'm adding the kind of boilerplate that monads are monads are supposed to alleviate. (As I said ... very naïve questions, sorry)
fmap
won't do anything to errored values - that's the point of short-circuit evaulation
a quick survey of my codebase - we've got 80kloc and 1000 uses of mlet - but only 20 branches - most of the branches are at component boundaries, doing things like formatting an http error response, so they aren't very common
your use-case could be different of course, in which case i'd go for a pattern matching approach
No, that reinforces my feeling that I'm doing something wrong, and that I'm resorting to branch
when I shouldn't be. In most cases, I'd like short-circuit evaluation, but I'm using branch
to package function return values correctly ... which probably means that I'm not using return
as I should.
I'll break my use-case down into a simpler example when I have a bit more time; that will give me something concrete to talk about (and hopefully help me to answer my questions on my own).
Thanks for taking the time to respond @mccraigmccraig.