This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-08
Channels
- # announcements (2)
- # asami (2)
- # babashka (7)
- # beginners (59)
- # cider (12)
- # cljdoc (1)
- # cljs-dev (18)
- # clojure (23)
- # clojure-europe (15)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-uk (5)
- # clojured (16)
- # clojurescript (22)
- # core-typed (8)
- # cursive (3)
- # datomic (24)
- # events (2)
- # fulcro (4)
- # gratitude (1)
- # helix (13)
- # hoplon (18)
- # integrant (2)
- # introduce-yourself (1)
- # jobs-discuss (1)
- # joyride (5)
- # minecraft (1)
- # off-topic (76)
- # pathom (18)
- # podcasts-discuss (8)
- # polylith (11)
- # remote-jobs (4)
- # rewrite-clj (22)
- # sci (4)
- # shadow-cljs (152)
- # sql (4)
- # tools-build (26)
- # tools-deps (34)
I'm using spec. Is there 1. A way to check if a collection contains keywords? 2. A way to make unexpected keys cause the conform check to fail?
On the first one, something like (s/coll-of keyword?)
I have a large number of items for which I need to run a db query and save each result. I'm currently collecting the query results in a for-loop and the consuming the result by saving it to the db as one write transaction. The query for some of the items may throw an exception, which makes my implementation brittle. The queries are also resource-intensive and take a long time. Can anyone suggest some improvements to my implementation?
I feel like I'm going crazy; I'm following the https://clojure.org/guides/deps_and_cli. It mentions the find-versions
tool, also mentioned by the https://clojure.org/reference/deps_and_cli. When I run the example code for finding maven artifact versions, it fails.
$ clj -X:deps find-versions :lib clojure.java-time/clojure.java-time
Unqualified function can't be resolved: find-versions
$ clj -version
Clojure CLI version 1.11.1.1113
What am I doing wrong?Ok, I think my ~/.clojure/deps.edn
might be old...
Indeed... it's working now.
I'm implementing a mutable collection and attempting to have it implement some relevant Clojure interfaces, like Seqable
, Sequential
, IObj
, IHashEq
, etc.
This collection is mutable because it's intended as an alternative to a java.util.concurrent collection that is missing a critical api that I need in my application of this data structure.
I am currently implementing metadata-related interfaces, and while IObj
is pretty obvious how to implement, I'm not sure how to implement IMeta
, because it's not entirely clear to me what API it's intending to present. Specifically, I know it's intended to return an object that is equal to the old one with new metadata, but because this is a mutable value it should only compare as equal if the two objects are identical?
(according to the definition of egal), which implies that it should mutate the meta on the original object, but that feels incorrect to me since it appears as if that's the intended definition of the methods on IReference
, which I would like to implement, but I'm unsure if I can if I can't define a sensible IMeta
implementation, since IReference
extends it.
So I guess my question is: is it acceptable for IMeta
implementations to mutate the original object, and if not, should I just provide my own functions for changing the metadata even though Clojure already has them with alter-meta!
?
Maybe important information here is I'm specifically not implementing the IPersistentCollection
interface as this collection is not persistent or immutable.
Oh? That surprises me. What part of the contract for IObj am I not conforming to?
Ah, I see, yeah, it looks like I did have them swapped around in my head
Thanks, that clears it up.
Yeah, that's what I was thinking of. I just got confused because I had IMeta and IObj swapped in my head but saw IReference extends IMeta
It's occurred to me that perhaps I shouldn't implement IHashEq
either as the hash can change over time across multiple calls, since it's mutable.
Should I be using the default java hash implementation that's basically just based on object identity and leaving this hash out entirely since this is a mutable collection?
Looks like I just had IMeta
and IObj
backwards in my head.
I'm trying to better understand this statement:
> You can reference your own own custom authorizers. Note that this is running as a named tool, so the deps of your projects are not loaded in the current runtime. You can, however, load namespaces from the root of your project (eg from ".").
from https://github.com/atomisthq/jibbit#push-to-gcr.
I was able to get a custom authorizer working by defining a function in a namespace in a .clj file in the project root (like it says). Is that my only option, or can I modify/initialize the environment in some way so that I can reference a function in a namespace under src/
or some subdirectory?