This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-30
Channels
- # announcements (14)
- # aws (2)
- # beginners (167)
- # calva (25)
- # cider (124)
- # cljs-dev (2)
- # cljsrn (7)
- # clojars (2)
- # clojure (113)
- # clojure-europe (2)
- # clojure-italy (6)
- # clojure-spec (30)
- # clojure-uk (90)
- # clojurescript (20)
- # code-reviews (16)
- # cursive (28)
- # data-science (2)
- # datomic (89)
- # duct (97)
- # emacs (4)
- # figwheel-main (12)
- # fulcro (37)
- # graphql (3)
- # java (3)
- # jobs (2)
- # juxt (3)
- # kaocha (37)
- # leiningen (2)
- # luminus (2)
- # off-topic (30)
- # onyx (2)
- # pathom (3)
- # qlkit (1)
- # re-frame (7)
- # reagent (2)
- # reitit (62)
- # remote-jobs (9)
- # shadow-cljs (26)
- # tools-deps (19)
- # vim (1)
- # yada (8)
måning
g'nite 🙂
good morning
I was pleased to discover that yada makes use of ex-data, so you can throw an ex-info with {:status 400 :body "Bad request: ..."}
in your handler functions and have that returned as the http response.
also, morning everyone!
how many other yada users are there here? you've given yourself away @peterwestmacott... anyone else?
I use yada.
My main bugbear with it is the heavy reliance on ztellman/manifold.deferred
; every interceptor call runs in a different manifold thread
which can make it awkward to debug a misbehaving REST call because every step of the processing happens in a different thread
morning
In my head the main http server choices are yada
and pedestal
which boils down to a choice between netty
or jetty
is there much http-kit
love on this channel
(I don't love it)
it’s ok — but IIRC I had problems with its handling of large request bodies… I think it topped out at 16mb or something. Could be wrong, but pretty sure I swapped it out for jetty.
I do use http-kit but honestly not with a great deal of thought. Something that will take my handler function and expose it as an http server. Yada appears to be an opportunity for me to go home and think about my life.
I already like the fact that yada offers this, "lean" option. Clojure seems to be an environment in which you write libraries for other people, and frameworks for yourself 😉. I can get behind that for sure.
@ben.hammond i have a solution to that problem (tracking ops spread out over many threads) waiting in the wings... it's going to be a little while yet before it's ready for primetime though
(and it involves the m word, so some people may be averse)
it's not really yada or manifold's fault - you are going to get callbacks on composed promises executed on different threads, it's just the nature of async
um what is the m word
is that the rws stuff you showed me?
an anagram of o damn
@lady3janepl umm, the other m word
yes, magic @dominicm, but pure & functional magic, so it's ok
that's the one @otfrom, award yourself a burrito
I think I've figured out what I dislike most about monads and monoids - the lack of readily available analogies for me to think my way in and the terrible ones that people come up with instead
@dominicm the price perhaps being that every problem starts to look like it can be solved with more m-like thingies
damn, spj never mentioned anything like that - perhaps he hasn't been entirely straightforward!
Every blog post I have ever read on, "monads explained", begins with, "There are many other blog posts that attempt to explain monads, but I found that they all do it badly, so here is my explanation". The rest of the post always reads like somebody explaining a dream that they had. All the basic facts are there, but there also seems to be some subjective context that cannot be communicated with simple language. I am pretty sure I get the general point, but I still find myself feeling like I haven't had the, "touch of the light", that seems to hit some people and change their life forever.
Some things, especially beyond a certain level of abstraction, you can only really understand through experience. I don’t think monads are quite beyond that level of abstraction, but they’re close. I mean you can understand them superficially with a lot reading — but then you just don’t understand what the big deal is. Not that monads are really that big a deal 😉.
@wesley.hall the only thing that worked for me was using the things... this was an example of some code with utility in clojure which set me on the path - http://funcool.github.io/cats/latest/#manifold-deferred (since other ways i've come across of composing promises in clojure are either equally scary or not nearly so nice)
@rickmoynihan Yes, this is another impression I get. The analogy being much like trying to explain the rules of a game to somebody who has never played before. You know that once you understand all the rules, it is actually incredibly simple and logical, but when you try to serialise the idea into a sequential explanation it makes both you and them feel like you are talking them through brain surgery.
I think this is fundamentally what realisation is. Or say Satori in zen. You achieve a level understanding/realisation where things finally click, but you can’t quite articulate what has changed in your understanding. It’s just somehow deepened.
@mccraigmccraig Thanks, will check out the example.
Monads require that kind of realisation to happen for you to appreciate them… likewise for all the things beyond Monads, e.g. Arrows.
I do sometimes wonder whether I used up all of my, "penny drop" credits during 15 years of Java development and all the various OOP pattern exposure that comes with it. I may simply now be too old to have those moments again 🙂
Empty your cup.
Actually I take some of that back… I think the big idea in monads can be understood; quite easily. It’s essentially composition, which is actually a much more general idea than Monads even. But monads show that composition can be applied to classes of things you might not have thought of. That class of things require certain categoric properties. If you have that particular set of properties (and obey the laws) then your class of thing is a Monad. And you can then target that Monad abstraction itself… e.g. do notation.
We have a room booked with SkillsMatter for Tuesday 5th February. Would anyone like to give a talk, workshop, demos, etc? No talks are booked as yet.
@jr0cket I can probably get involved if you like. The problem that I have is that most of the time people are more prone to asking me about the soft stuff. Building Signal as a tech co-founder, raising financing, putting a team together and the various trials and tribulations of that. Might be woefully off-topic for your intent though (I could probably talk about why we chose Clojure, or rather how long it took us to get there ;)). I've done a few panels, where the the panelists give their bios and then (ideally) get bombarded with questions, or (less ideally) simply share their own funny / informative / engaging / boring stories in an effort to entertain, and found these quite fun to do. Up for that too if you think it's appropriate, although there may be better people here than me for that, in which case, I would come to watch 🙂
No sure if there is a simple answer here, but in a thread-first macro, is there an accepted way to check if a value exists and then apply an update fn to it, otherwise simply return the original value? E.g.
(->
...
...
(some? :the-key ... )
...)
Apologies if this question is a little vague 😊
Would using something like (merge)
make sense here?
Goes to google 🙂
I think that would be more suited for the top level which wouldn't really apply here I think
Trying to think of a decent example without popping client code in here
check if a value exists and then apply an update fn to it, otherwise simply return the original value
that reads as if you’d return nil
if the value doesn’t exist
@yogidevbear Do you mean you want to do a thread-first macro where one of the steps is contingent on some predicate?
Yeah, kinda.
For example, I have a map that has certain mandatory kvs and some optional ones - e.g. {:foo "bar"}
or maybe {:foo "bar" :baz "plop"}
And I need to run an update
function on :baz
- if it exists
And this update function is in the middle of a thread first macro
@dominicm do you mean http://weavejester.github.io/medley/medley.core.html#var-update-existing ?
I guess I do. I don't think it was always called that. But maybe the name I'm using was a different library
Okay ta, I'll look into it
@yogidevbear Sounds to me like you need a function that takes a value (in this case your map), a predicate (in this case :baz) and a function to apply to the value if the predicate is true, or returning value as is, if the predicate is not true. My instinct is that something like this should probably be either 1) available in the core lib or 2) createable from composing functions in the core lib, but honestly the biggest issue I have with clojure is that I find it hard to remember the various core lib functions.... that said, easy enough to write something like this. Few lines. Might be an alternative to pulling in an entire library if you only need this.
(defn the-thing [v p f]
(if (p v) (f v) v))
(-> {:foo "bar" :baz "plop"}
....
(the-thing :baz #(update % .....))
....)
Now everybody can tell me about the core functions I forgot about 🙂Dominic suggested something along the lines of:
(defn update-contains
[m k & args]
(if (contains? m k)
(apply update m k args)
m))
...and apparently I don't know my slack formatting either 😉, but you get the idea
It looks fairly succinct so I'm going to test it out
cond->
@ben.hammond I was thinking that too, but cond->
doesn't let you thread into the predicate. The conditions have to be based on data that is separate from the thing you are threading through, unless there is something painfully obviously that I am missing.
that is correct, but you don't need that too often
oh I reread initial post
yeah that's the smell of a threading macro that is too complicated