This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-03
Channels
- # beginners (98)
- # boot (18)
- # chestnut (2)
- # cider (90)
- # cljdoc (3)
- # cljs-dev (1)
- # clojure (64)
- # clojure-dev (14)
- # clojure-dusseldorf (4)
- # clojure-italy (11)
- # clojure-nl (5)
- # clojure-spec (9)
- # clojure-uk (69)
- # clojurescript (63)
- # code-reviews (2)
- # core-logic (20)
- # cursive (13)
- # datomic (52)
- # dirac (2)
- # emacs (4)
- # figwheel (6)
- # hyperfiddle (13)
- # luminus (4)
- # nrepl (1)
- # off-topic (7)
- # onyx (9)
- # overtone (3)
- # parinfer (3)
- # pedestal (1)
- # re-frame (31)
- # reagent (74)
- # reitit (34)
- # rum (3)
- # shadow-cljs (51)
- # spacemacs (22)
- # specter (7)
- # tools-deps (23)
- # uncomplicate (3)
- # vim (9)
clojure.lang.IHashEq tells you whether the object implements .hasheq()
. Is there a single interface that tells you whether the object implements .equiv(other)?
Tragically, no
Are there any good examples of writing test.check generators for data-dependent sequences? I’m trying to figure out how to use test.check to model a finite state machine, and the best thing I’ve got is recursive application of choice of functions of a state to a state with a longer execution history. Writing that out as a reduction is pretty simple and definitely works, but it’s kinda hard to model in a way which integrates with the rose tree AFAIK.
I got this sorted out - I have a system which implements has a pretty simple accumulator FSM, and I want to use test.check to generate a sequence of inputs and a predicted end state so that I can drive the inputs against the live system and show that the final states align.
I settled on the fmap bit I posted below which worked out perfectly. Write generators for functions of a “trace” [starting-state, request-sequence, ending-state]
to another (presumably longer) trace, let test.check pull from generators of such functions to a sequence of transformers, then apply the transformers in order over an initial input state to realize a sequence of requests and produce a final state.
I used this and ideas from this and the talk referenced in the post to build something similar to what you want
gen/recursive-gen
isn’t really what I want, because there’s a recursive structure to my generator I want to capture.
I guess one way to do it would be to (gen/fmap (fn [[seed-state xformers]] (reduce #(%2 %1) seed-state xformers)) (gen/tuple (s/gen ::state) (gen/vector (gen/one-of transformers))))
@puzzler I looked around the source for a few minutes and could not find an interface that tells you whether an object implements .equiv(other)
Consider (defrecord T [^long x])
and then (:x (T. 1))
. Am I correct that this expression will not return a primitive, and to get a primitive you need (.-x (T. 1))
?
Similarly, if I do (assoc (T. 1) :x 2)
, that 2 is going to get boxed and then immediately unboxed for storage in the defrecord, correct?
For Clojure at least that is correct - invoking the Keyword can only return a boxed value and no attempt is made to inspect the right hand side and determine that the keyword access could be a field access with a primitive type although the keyword as a field getter has some efficient machinery. I believe that your second example/statement is correct.
Hey guys, I made a tool in Cljs to translate boot-clj and Leiningen :dependencies
to the newer deps.edn
format: https://theronic.github.io/depsy/ (source on GitHub)
^ Are you talking about SQL?
What are the benefits of using namespaced keywords for applications, practically, assuming you don't care about namespace clashes ?
if the use of a keyword assumes a ns has been required, you can use a namespaced keyword and refer to it with a namespace alias, that way you ensure it's been required
(think about spec, re-frame...)
also, semantics
regarding simply namespaced keywords, it's not the same :product/price
than :price
, because you have more context
regarding fully qualified namespace keywords, knowing the namespace gives you information on where does the keyword come from and possibly additional documentation
so it has more meaning
true, but i suppose that begs the question, how often will you receive a map, working with an application, and not know the context anyway (even though it's not explicit in the namespace)
it simply makes things clearer, easier to document and specify, easier to read
but it's not always justified, ofc
Also it can help makes some datastructures simpler (single level map with lots of diff "types" instead of nesting)
yes.
(t/are [x y]
(= (let [{:keys [a b]} x] [a b]) y)
{:a 1 :b 2} [1 2]
{:a 1 :b 2} [2 2] ;; false
{:a 3 :b 4} [3 4]
) ;; true
eeeh….eh, the second binding is clobbering the previous a
and b
? Maybe renaming the second set of bindings?
(defmacro all-are
[argv expr & args]
(if (or
(and (empty? argv) (empty? args))
(and (pos? (count argv))
(pos? (count args))
(zero? (mod (count args) (count argv)))))
(let [c (count argv)]
`(clojure.core/and
~@(map (fn [a] (clojure.template/apply-template argv `(clojure.test/is ~expr) a))
(partition c args))))
(throw (IllegalArgumentException. "The number of args doesn't match are's argv."))))
clojure.test/is
and clojure.test/are
are like assertions, you shouldn't care about the return value
Is there a way not to parameterize HoneySQL values? E.g.
(honeysql.format/format
(-> (h/insert-into :FOO)
(h/values [{:a 1 :b 2 :c 3}])))
;; => ["INSERT INTO FOO (a, b, c) VALUES (?, ?, ?)" 1 2 3]
But as a single string?@xiongtx There's also an #inline
reader literal in HoneySQL: [{:a #h/inline 1 :b #h/inline 2 :c 3}]
should result in only 3
becoming a parameter.
Hello! Is there a way to tell which procols an object implement? When dumping certain objects in the repl I get things like reify__1987, which isn’t very descriptive
looks like
=> (parents (class (reify clojure.core.protocols/CollReduce)))
#{clojure.lang.IObj clojure.core.protocols.CollReduce java.lang.Object}
maybe works@U61HA86AG oh yes, that works. Thank you!
So if I see an object described as reify__1987
(or similar), I have no way to figure out what that thing is?
So...I converted some local project from lein to deps.edn for fun. One thing that surprised me was when my Project2 had a dependency of type ":local/root" to Project1. Project1 (also using deps.edn) had a dependency to "httpkit". I expected that Project2 would retrieve the transitive dependencies, but no. I had to add "httpkit" as a dependency to Project2 as well. Is this the way it is supposed to work?
that would surprise me quite a bit