This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-18
Channels
- # aleph (4)
- # announcements (2)
- # babashka (48)
- # beginners (59)
- # calva (5)
- # cider (14)
- # clj-kondo (4)
- # cljs-dev (3)
- # clojure (77)
- # clojure-europe (6)
- # clojure-italy (6)
- # clojure-nl (5)
- # clojure-spec (4)
- # clojure-uk (67)
- # clojurescript (19)
- # clr (3)
- # cursive (7)
- # datomic (36)
- # duct (33)
- # events (3)
- # figwheel (1)
- # fulcro (4)
- # funcool (2)
- # graalvm (3)
- # jobs (1)
- # joker (25)
- # kaocha (1)
- # leiningen (45)
- # malli (17)
- # off-topic (103)
- # quil (1)
- # re-frame (16)
- # reitit (1)
- # rewrite-clj (27)
- # shadow-cljs (39)
- # spacemacs (3)
- # sql (11)
- # tools-deps (14)
- # vim (41)
@i Searching GitHub doesn't turn up much. The three top results have almost no stars and no forks so I don't think it's an approach that Clojure folks use much?
https://github.com/auxoncorp/clj-cucumber https://github.com/cucumber/cucumber-jvm-clojure https://github.com/schmorgurken/schmorgurken -- those seem to be the top three results -- I've never heard of any of them...
is there a way to add a "default" to one of two values being dispatched on without breaking out derive and namespaced keywords?
Hello folks, Can I do SPA web development with Clojure only?
Some food for thought: functions and macros behave substantially different from a usability perspective. My understanding right now is that functions evaluate their arguments before executing their body, whereas macros pass the arguments unevaluated (or probably, more correctly, I imagine the code gets expanded with the unevaluated arguments) and then resolve the underlying code. With this in mind, would it not make sense to have a special sort of marker to unequivocally show when a certain call is a macro versus a function? Any thoughts please put them in a thread 🙂 👇
They do… they have ^{:macro true}
metadata on their var
is
<groupId>com.cognitect.aws</groupId>
<artifactId>ses</artifactId>
not a thing?
cannot seem to find it on
https://repo1.maven.org/maven2/com/cognitect/aws/sesah yes that works, thanks
is the definitive list to be found at https://repo1.maven.org/maven2/com/cognitect/aws/
is there a better place to pick the specific api names?
Hey, I am using [org.clojure/data.json "0.2.6"]
and it’s not behaving as I would have expected as it’s happily parsing invalid JSON eg
user=> (require '[clojure.data.json :as j])
nil
user=> (j/read-str "{\"a\": 123,,}")
{"a" 123}
user=> (j/read-str "{\"a\": 123,\"b\",}")
{"a" 123}
am I missing something ?you may want to use Cheshire since it's the de facto JSON library for Clojure afaik. Just did a quick test and it immediately failed on detecting those commas.
yeah I have been recommended https://github.com/metosin/jsonista as well that looks good - find it weird that the standard one is broken though
I raised in issue on ask-clojure as that seems to be the preferred way for that type of issues https://ask.clojure.org/index.php/8860/is-the-standard-json-parser-broken
Is it expected that prewalk
doesn't preserve metadata like this?
user=> (meta (walk/prewalk (fn [x] (if (seq? x) (with-meta x {:a 1}) x)) '(1 2 3)))
nil
it's a similar problem, but not exactly the same? I just want clojure.walk/prewalk to preserve metadata
small hack that might be usefull (p
(def original-empty empty)
(meta
(with-redefs [empty (fn [x]
(with-meta
(original-empty x)
(meta x)))]
(clojure.walk/walk (comp vec reverse) identity ^{:x 1} {0 :start 1 :inprogress 2 :end})))
;; => {:x 1}
what is the state-of-the-art for java.time tagged readers? should I use https://github.com/magnars/java-time-literals ?
thankyou
Are there any good patterns for a DSLs that can express a sequence of events, where sometimes the events do not have to be sequenced? e.g. A, then B and C in either order, followed by D?
I think that's accurate. Definitely directed, and yes cycles can be avoided by unrolling.
You could use an adjacency map, one that looks like the examples here: https://github.com/nwjsmith/generators.graph#usage
I think that's too noisy as a DSL, as I'm trying to express "X then Y then Z happens" in a test, and this would separate the descriptions of X Y and Z from the ordering.
If nothing ever happened in parallel, the DSL would just be Clojure functions that waited for things to happen.
Heya, does anyone know of a nice string formatting tool that gives a similar style of formatting that Python offers? i.e.
(nice-format "Hello my name is {name}, and I live in {country}" :name "Bobby" :country "Canada")
@sansaripour that looks like a templating library - there's plenty to choose from, https://github.com/fhd/clostache or https://github.com/yogthos/Selmer
clojure.pprint/cl-format is pretty powerful if you need something fancy but built-in
Those work, thanks!
I’m also a fan of just str
(let [name "Bobby"
country "Canada"]
(str "Hello my name is " name ", and I live in " country))
Hey! I am trying to learn spec and how generator works. Trying to accomplish something like this:
(["FOO-1" "FOO-1"]
["FOO-2" "FOO-2"]
["FOO-3" "FOO-3"]
["FOO-4" "FOO-4"]
["FOO-5" "FOO-5"])
A serie of unique and increasing numbers.so uniqueness and increasing are properties of the collection?
if so, you'll need to make a custom generator that conforms to those properties
I would probably take the approach of 1. create numbers 2. make distinct 3. sort 4. make vector of string of each number
gen/fmap is a good tool to use for most of that
it applies a function to generated values
I've followed your video series and found something like this.
(s/def ::id (s/and string?
#(str/starts-with? % "FOO-")))
(s/exercise ::id)
(defn foo-gen []
(->> (s/gen (s/int-in 1 100))
(gen/fmap #(str "FOO-" %))))
But this will generate random, and often entires that are not uniqueyeah, you need to go up a level - make a collection of ints, not an int, then work on the collection
so start from (s/gen (s/coll-of (s/int-in 1 100)))
then apply distinct
sort
and (map #(str "FOO-" %) ...)
the key is that the uniqueness and sorting are properties of the collection, not the values
been trying to figure out why this code doesn't compile for me
(ns sample
(:refer-clojure :exclude [get]))
(defprotocol P
(get [this a]))
(defrecord R []
P
(get [this a]))
guessing it has to do with records being maps under the hood and therefore adding a get
method to the generated class, but couldn't justify my guess by looking at the implementation of defrecord
. any clue?
@lewis a defrecord is always a hash-map and always implements get https://github.com/clojure/clojure/blob/2cc37bb56a9125a1829c73c505e32995e663059a/src/clj/clojure/core_deftype.clj#L248
maybe you want deftype? there are libraries that try to simplify making things that are almost like hash-maps but override specific behaviors (like potemkin https://github.com/ztellman/potemkin#def-map-type)