This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-26
Channels
- # aws-lambda (1)
- # beginners (71)
- # boot (70)
- # bristol-clojurians (1)
- # cider (2)
- # clara (13)
- # cljs-dev (96)
- # cljsjs (6)
- # cljsrn (5)
- # clojure (74)
- # clojure-android (3)
- # clojure-austin (4)
- # clojure-dev (10)
- # clojure-russia (6)
- # clojure-spec (28)
- # clojure-uk (128)
- # clojurescript (64)
- # cursive (2)
- # datascript (18)
- # datomic (116)
- # dirac (1)
- # emacs (12)
- # events (10)
- # hoplon (109)
- # jobs (1)
- # jobs-discuss (21)
- # leiningen (2)
- # luminus (6)
- # off-topic (19)
- # om (21)
- # om-next (5)
- # onyx (4)
- # parinfer (29)
- # perun (20)
- # re-frame (53)
- # reagent (21)
- # remote-jobs (5)
- # ring-swagger (2)
- # spacemacs (6)
- # untangled (42)
- # vim (5)
You can set unchecked-math to :warn-on-boxed
What does a following error message in Luminus mean: Parameter Mismatch: :type parameter data not found.
Trying to find the cause for a friend that is having this problem but I am suspecting this has something to do with Luminus functionality
@artur You have a db query which needs a parameter, when you call the query function it's important to use a map with the name of the parameter. e.g. (db/get-user-by-type {:type "guests"})
what’s the idiomatic way to query “is this a vec or list”? I can’t do (seq foo)
because that may barf on a keyword, and (seq? foo)
doesnt include vectors .. so that leaves (sequential? foo)
, but there seem to be so options I want to be sure I’m not missing something.
seqable?
is only available in 1.9 - I use sequential?
I guess the answer to this question is really dependent on what behaviour you want to rely on the collection having?
If you want to process items sequentially then sequential?
this is worth a read in general: http://insideclojure.org/2015/01/02/sequences/
What I’m actually trying to do is a postwalk that converts NaN
values (javascript) to clojurescript’s nil
, and the postwalk predicate is trying to determine if it should bother doing a form transformation (in the case of vectors/lists)
then probably your or
but trying to figure out sequences and postwalk at the same time doesn’t seem to be working so well
assuming it's a syntactical decision, i.e. very specifically only support lists and vectors
sequential?
will match vectors, lists, and sequences. Sometimes I end up writing #(and (coll? %) (not (map? %))
to include sets as well.
Is it possible to define optional values with schema/defrecord?
Like
(s/defrecord Foo
[required s/Num
optional s/Num]
)
records do not have optional properties
if you define a record type with a property that property is always there and dissocing it will change the type of the collection
what you can do is define a record with just the required props and then assoc any optional attributes into it
I found the answer in the code of schema, I can give an additional map with keys, there I can define optional ones.
How could I conj a vector into another, but ignore nil values?
(conj [:val1] nil) => [:val1]
(into [:a] [:b]) => [:a :b]
(into [:a] nil) => [:a]
When I give the arguments via [arg1 & args] the args are given as list, how can I turn them into a vector?
depending on what you want to do with the args you may or may not need to. but you can use vec
@danielgrosse If you have multiple values (into [] (keep identity) [nil 8])
otherwise I'd just do a simple (cond-> v x (conj x))
keep identity is a common idiom
Can I extend defrecords?
(defrecord ExtendedType
OriginalType
[extraKey]
)
@danielgrosse have you tried reify? https://clojuredocs.org/clojure.core/reify
hello guys, core.async
question 🙂
Is it possible to know if a channel is closed without taking the value ? (e.g (<!! ch)
)
@baptiste-from-paris In general, core.async doesn't have a closed?
predicate, to avoid common race conditions like (when-not (closed? ch) (>!! ch val))
ok, thanks :-); I’ll explain the use case in 2min
something like that
(let [from (chan 1024)
to (chan 1024)
xform (comp (filter even?)
(map #(+ 2 %)))]
(a/onto-chan from (range 100))
(go (loop []
(when (ASYNC/CLOSE? from)
(a/pipeline 1 to xform from)
(recur)))
(println "Shutting Down..."))
(go (loop []
(when-some [data (<! to)]
(println data)
(recur)))
(a/close! to)))
I suggested a public closed?
predicate in http://dev.clojure.org/jira/browse/ASYNC-126 but opinion was generally against it.
ok, thanks. I’ll take a look
@baptiste-from-paris I think the channel returned from pipeline will block until the pipeline is done processing
By default, the to channel will be closed when the from
channel closes, but can be determined by the close? parameter.
same for onto-chan
so from
is supposed to close and to
also
and I thought channels where GC’d when they are closed, but if you do something like that =>
(let [ch (chan 1)]
(>!! ch 42)
(<!! ch)
(a/close! ch)
(println (>!! ch 42))
(when ch
(println ch)))
it returns
>false
>#object[clojure.core.async.impl.channels.ManyToManyChannel...
@baptiste-from-paris also remember that GCs are lazy (the JVM very much so). So it may never actually get collected before your program exits.
what memory options are you using on your JVM instance?
@eugekev your memory usage looks well inside of the dyno limits (you're way under the 512m). Are you noticing any performance impact?
@eugekev can you open a ticket at https://help.heroku.com? support engineers can take a look at the runtime and see what's going on. I suspect it's benign (something OS is doing that's normal), but its worth having them take a look.
@tbaldridge: Tim will look but nothing particularly extraordinary I think. @codefinger no, response times good. Just interesting that paging starts without memory pressure. Thank you both! Yes hopefully benign and will see what heroic thinks.
@eugekev I'd pay attention to the memory settings on the JVM, if you give it a certain heap size it will let memory grow to that amount (and there's a default value) before even attempting to run a GC cycle.
@eugekev if you set this up you can get fine-grained metrics from the JVM (heap, non-heap, threads, etc) https://devcenter.heroku.com/articles/monitoring-jvm-metrics-with-the-heroku-java-agent