Fork me on GitHub
#clojure
<
2017-01-26
>
alexmiller02:01:44

You can set unchecked-math to :warn-on-boxed

bradford03:01:55

disregard that, it was an eldritch dependency from the Mountains of Maven

sova-soars-the-sora04:01:24

@qqq @arthur thank you both very much.

artur06:01:46

What does a following error message in Luminus mean: Parameter Mismatch: :type parameter data not found.

artur06:01:20

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

danielgrosse13:01:06

@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"})

lwhorton13:01:12

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.

agile_geek13:01:39

seqable? is only available in 1.9 - I use sequential?

lwhorton13:01:14

looks like seqable? isn’t quite what I’m looking for, given maps return true

lwhorton13:01:30

maybe I should just manually do (or (vec? foo) (list? foo))

schmee13:01:07

the answer depends on what you are trying to accomplish

agile_geek13:01:14

I guess the answer to this question is really dependent on what behaviour you want to rely on the collection having?

agile_geek13:01:57

If you want to process items sequentially then sequential?

dominicm13:01:24

Yeah, sequential? is probably what you want if you don't want maps.

lwhorton13:01:50

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)

agile_geek14:01:29

then probably your or

lwhorton14:01:31

but trying to figure out sequences and postwalk at the same time doesn’t seem to be working so well

agile_geek14:01:45

assuming it's a syntactical decision, i.e. very specifically only support lists and vectors

lwhorton14:01:41

yea I think that makes the most sense given its a form transform

stuartsierra14:01:06

sequential? will match vectors, lists, and sequences. Sometimes I end up writing #(and (coll? %) (not (map? %)) to include sets as well.

danielgrosse15:01:44

Is it possible to define optional values with schema/defrecord?

danielgrosse15:01:34

Like

(s/defrecord Foo
[required s/Num
 optional s/Num]
)

joost-diepenmaat15:01:52

records do not have optional properties

joost-diepenmaat15:01:45

if you define a record type with a property that property is always there and dissocing it will change the type of the collection

joost-diepenmaat15:01:35

what you can do is define a record with just the required props and then assoc any optional attributes into it

danielgrosse15:01:59

I found the answer in the code of schema, I can give an additional map with keys, there I can define optional ones.

danielgrosse15:01:16

How could I conj a vector into another, but ignore nil values?

danielgrosse15:01:26

(conj [:val1] nil) => [:val1]

joost-diepenmaat16:01:28

(into [:a] [:b]) => [:a :b]

joost-diepenmaat16:01:40

(into [:a] nil) => [:a]

danielgrosse16:01:35

When I give the arguments via [arg1 & args] the args are given as list, how can I turn them into a vector?

joost-diepenmaat16:01:09

depending on what you want to do with the args you may or may not need to. but you can use vec

rauh16:01:28

@danielgrosse If you have multiple values (into [] (keep identity) [nil 8]) otherwise I'd just do a simple (cond-> v x (conj x))

schmee16:01:13

(remove nil?) reads better than (keep identity) IMO

pesterhazy16:01:59

keep identity is a common idiom

spacepluk16:01:03

hi, has anybody run into problems with method size in android?

jr16:01:03

no just nil values

danielgrosse16:01:48

Can I extend defrecords?

danielgrosse16:01:34

(defrecord ExtendedType
OriginalType
[extraKey]
)

mpenet16:01:56

Oh right, didnt expect this

jr16:01:45

not sure if that's quite the extension you want

bronsa16:01:46

no you can't extend types, just interfaces

baptiste-from-paris17:01:15

hello guys, core.async question 🙂 Is it possible to know if a channel is closed without taking the value ? (e.g (<!! ch) )

jr17:01:41

what's the use case?

stuartsierra17:01:28

@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))

baptiste-from-paris17:01:11

ok, thanks :-); I’ll explain the use case in 2min

baptiste-from-paris17:01:49

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)))

stuartsierra17:01:30

I suggested a public closed? predicate in http://dev.clojure.org/jira/browse/ASYNC-126 but opinion was generally against it.

baptiste-from-paris17:01:54

ok, thanks. I’ll take a look

jr17:01:43

@baptiste-from-paris I think the channel returned from pipeline will block until the pipeline is done processing

jr17:01:17

(go
 (a/<! (a/pipeline 1 to xform from))
 (println "Shutting down"))

jr17:01:53

so when (a/close! to) happens that go will unpark from the pipeline

baptiste-from-paris17:01:34

By default, the to channel will be closed when the from
channel closes, but can be determined by the close?  parameter.

baptiste-from-paris17:01:14

same for onto-chan so from is supposed to close and to also

baptiste-from-paris17:01:32

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...

jr17:01:44

channels are GC'd when there are no references to them

jr17:01:11

by printing the channel, you still have a reference to it

tbaldridge19:01:22

@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.

tbaldridge19:01:30

what memory options are you using on your JVM instance?

codefinger19:01:13

@eugekev your memory usage looks well inside of the dyno limits (you're way under the 512m). Are you noticing any performance impact?

codefinger19:01:58

@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.

eugekev19:01:32

@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.

tbaldridge19:01:51

@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.

codefinger20:01:01

@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