This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-08
Channels
- # announcements (3)
- # babashka (3)
- # beginners (25)
- # calva (12)
- # cider (58)
- # clara (11)
- # clj-kondo (19)
- # cljsrn (2)
- # clojure (84)
- # clojure-austin (1)
- # clojure-europe (5)
- # clojure-nl (4)
- # clojure-spec (23)
- # clojure-uk (53)
- # clojuredesign-podcast (5)
- # clojurescript (24)
- # core-async (57)
- # cursive (16)
- # datomic (39)
- # emacs (1)
- # fulcro (40)
- # funcool (2)
- # graphql (17)
- # jackdaw (31)
- # jobs (2)
- # joker (3)
- # malli (7)
- # off-topic (12)
- # re-frame (9)
- # reagent (2)
- # reitit (1)
- # ring (4)
- # shadow-cljs (170)
- # sql (36)
- # tools-deps (5)
- # xtdb (20)
What's the idiomatic or preferred way of writing a defxxx
macro without turning it into a global`def`? I'm considering either using swap!
on a global registry atom, or rewriting into a multimethod dispatch
Defining a def*
macro is a super-common anti-pattern in the clojure community. I’ve seen it done 100 times poorly and not once well.
I’ve written and used def*
macros many times happily and wouldn’t consider it an anti-pattern on its own, although any technique can be used poorly.
Happiness isn’t the factor I’m talking about. Many devs who wrote the ones I’m talking about are probably happy.
My point is: it’s basically never more effective/precise/flexible than an alternative.
> anti-pattern in the clojure community
my purpose is merely to interject that this is not a consensus opinion, and each case may be judged on its merits. many successful Clojure developers write and use def*
macros. it’s fine to prefer lower-level primitives, also fine to reach for higher-level tools and learn how & when (/not) to use them. 🛠️
I want to have multiple 'types' of things that share the same name without colliding, eg.
(def-action foo
...)
(def-transformation foo
...)
I could of course intern a (symbol (str % "-action"))
but that seems like an uglier hack
I saw that Meander uses a system of global "registry" atoms for its macros, and was wondering if that was a normal thing to do
is there a way to improve REPL I get with lein repl
because that one doesn't work with directional arrow keys
@roklenarcic have a look at rebel-readline
Why does cljs require a different library? I though cljs repl was just a command in the standard repl, i.e. I run the REPL and then run (cljs-repl)
Either because of completion or repl envs, but there's a lot happening to make it work in that repl, which isn't standard by some measures
What library would y'all recommend to parse a sequence of same attributes maps in to csv
usually, "parse" means read but the rest of your sentence sounds like "write"
org.clojure/data.csv can do both
Defining a def*
macro is a super-common anti-pattern in the clojure community. I’ve seen it done 100 times poorly and not once well.
Even really common ones like defroute
from compojure are less than ideal. You often want to close over state (e.g. a db connection) before your final definition. So make a fn that accepts any variables and returns the final state.
I have Record name Event
with several keys. How can I cast the Event record in to another Record with similar keys?
@contact904 something like this? https://gist.github.com/lukaszkorecki/7cf33665fb70e8357210af925834de4f
@vlaaad @lukaszkorecki yes! that is what I needed thank you
yup! I did not used select keys as the keys are similar.
I have an api library that allows a single stream of messages to be received and allows handlers to be attached to handle messages. I just realized that instead of managing my own handlers I could just have an atom which is always reset!
to the newest message, and have users use add-watch
to manage handlers. Is there a reason not to do that? Are there any examples of other libraries which use atoms in this way?
you could do that, but it appears to be shuffling stuff around, moving the handler business from the message connection to the atom, and it is not clear to me what the advantage would be
@jjttjj for serialized strictly ordered things that only take one action at a time, sometimes an agent is a better abstraction than an atom (with a wrapping function that knows what action to pass to the agent)
since an agent implicitly queues the functions sent to it, and only runs one at a time without retries
If you can run JDKs of pretty much any version on both, then it seems that the Clojure part of that question isn't terribly relevant? It becomes "which cloud has better APIs / infrastructures for back end development"?
last time i took a look around the integration between aws components was better. and i haven't looked around in the last 2 years anymore (since our company will probably never leave aws, it just wouldnt be economical)
@U6MHHF36J For what you’re using, is AWS cheaper than alternatives then?
no i mean converting stuff to a different platform would just take enormous amounts of effort
talking about man years in effort. just not worth it, even if someone else is 25% cheaper in hosting costs.
Big question, I know, just wondered if anyone had any strong opinions. Or if one was better tool-supported than the other
Aws generally has higher adoption, so support is generally higher. But not clojure specific.
Sure, I noticed Cognitect had AWS-native consulting. Wondered if that was for any particular reason other than general AWS adoption
Market share - Amazon was first so it capture the majority of the market. Both Microsoft and Google are catching up and do not have as many offerings in their cloud catalogue as Amazon does, though Microsoft is certainly catching up.
Hi, everyone. Which channel is recommended for technical questions (StackOverflow like)?
Cool! But is there any channel for this same purpose here in Slack?
Most channels here are for technical questions. But your original question asked for something "StackOverflow like"; http://ask.clojure.org is more like SO than Slack.
@UNZQ84WJV Specifically, Slack is temporary -- the free plan only let's us see the last 10,000 messages across the whole set of (hundreds of) channels so after a few days your questions (and answers) will no longer be visible.
Many channels are mirrored to Clojurians on Zulip which is searchable (and has a full archive of those channels from early 2019 on). But it's a one-way mirror -- messages typed into Zulip don't appear here.
So http://ask.clojure.org is the StackOverflow for Clojure in terms of questions & answers staying around "forever".
If you want real time help, Slack can be great. Novice questions can be asked in #beginners (where folks have opted in to help). More advanced questions can be asked here #clojure and if you have questions about specific topics or libraries, there is likely to be an appropriate channel for that too.
Alright, thank you all. It makes a lot of sense for me.
ask.clojure has the benefit that it will suggest similar questions to yours when you start adding it (and maybe you'll find the answer already exists). If it doesn't, then someone will answer it and the next person will find it. Whereas slack questions (while archived various places), are nearly impossible for someone to find later.
And is ask.clojure preferred over SO by the Clojure community?
Hard to say. ask is fairly new but it is dedicated to Clojure and it also includes all of the JIRA issues that were active at the time ask was set up, so it has a lot of history around issues. I hope it will become preferred (although I still monitor questions on SO about Clojure).
I'd say SO is under-used in Clojure vs other language communities
don't use s/coll-of
(s/* (s/alt :i int? :u uuid?))
thanks @alexmiller!
I am not sure of the meaning of your English description, but perhaps you wanted this instead? (s/* (s/cat :i int? :u uuid?))
. Alex's version allows all integers, or all uuids, or arbitrary mixes of both in any order. The latter one only allows int1, uuid1, int2, uuid2, ...
oops, sorry, that's what I meant :)
I'm trying to figure out what the error here is
{:type clojure.lang.ExceptionInfo
:message "error parsing spec form"
:data {:k :marketplace.accounting.keys/funding-channel-id, :m (nilable (or :uuid uuid? :string string?))}
:at [clojure.core$ex_info invokeStatic "core.clj" 4739]}
{:type java.lang.Exception
:message "Unable to resolve spec: :uuid"
:at [clojure.spec.alpha$reg_resolve_BANG_ invokeStatic "alpha.clj" 69]}]
is that the wrong way to use s/or
? I haven't touched spec stuff in a while, I'm trying to describe a field that can be nil, uuid, or string (for historical reasons all of these must be accepted)
here's the diff
+(s/def ::funding-channel-id
+ "The identifier for the funding / repayments channel for the loan this trade is for."
+ (s/nilable (s/or :uuid uuid?
+ :string string?)))
user=> (s/valid? (s/nilable (or :uuid)) "foo")
Execution error at user/eval142 (REPL:1).
Unable to resolve spec: :uuid
user=>
I thought the args to s/or were keys alternated with specs
they are, I am using clojure.core/or there and getting a similar error message to what you are getting
OK - nothing in my diff from master has or, only s/or, and only in the spec where I see that error
but this could be a misleading error because our lib does some funky things with spec merging
yeah, then this is internal to our lib, and I need to resolve this with internal resources, thanks