Fork me on GitHub
#beginners
<
2017-01-09
>
roelof12:01:25

I want to say that the input of a function is a collection of objectNumber

roelof12:01:44

so I did :args (s/cat (s/coll-of ::objectNumber))

roelof12:01:41

where objectNumber is (s/def ::objectNumber (s/and string? #(re-matches #"[A-Z]{2}-[A-Z]-\d{1,4}" %)))

roelof12:01:16

but now I see this error message :

Assert failed: cat expects k1 p1 k2 p2..., where ks are keywords
(c/and (even? (count key-pred-forms)) (every? keyword? keys)), compiling:(paintings2/api_get.clj:94:8) 

roelof12:01:44

anyone a tip or a hint how I can tell that the args are a collection of objectNumbers ?

schmee12:01:39

roelof your cat form is wrong, it should be (s/cat :args (s/coll-of ::objectNumber))

schmee12:01:55

which coincidentally is exactly what is says in the error message 🙂

roelof12:01:52

I hope the last spec question

roelof12:01:00

I have these two specs

roelof12:01:14

(s/def :image/object
 (s/keys :req-un [:output/tiles])) 

roelof12:01:40

(s/def :basic/artObject
  (s/keys :req-un [::id ::name ::title])) 

roelof12:01:08

now I use them both like this :

:ret (s/merge :basic/artObject :image/object))  

roelof12:01:32

but now I see this message : No value supplied for key: (s/merge :basic/artObject :image/object)

roelof12:01:47

anyone who can give me a hint ?

roelof12:01:53

I see the same error message when I use (s/and)

schmee13:01:34

can you post your entire fn spec?

roelof13:01:21

of course :

(s/fdef fetch-paintings-and-images-front-page
 (s/cat :args (s/coll-of ::objectNumber))
 :ret (s/and :basic/artObject :image/object)) 

schmee13:01:20

it should look like this:

(s/fdef fetch-paintings-and-images-front-page
 :args (s/cat :args (s/coll-of ::objectNumber))
 :ret (s/and :basic/artObject :image/object)) 

schmee13:01:10

note that you need to tag each argument in s/cat

schmee13:01:32

so the :args there can be any keyword you want

schmee13:01:12

look at the docs for fdef and cat 🙂

hl2zip20:01:51

hey all, I am working on a function that processes a csv file. It looks like this:

(defn read-and-insert [upload-id rdr]
  (let [[header & rows] (csv/read-csv rdr)]
    (doseq [row rows]
      (let [row-id (create-row upload-id)]
        (doseq [[key value] (map vector header row)]
          (create-cell row-id key value))))))
I use clojure's core csv reader. I am running into an issue with the above and how it is parsing my csv file. My problem is that I am having trouble debugging the above code. I believe it is lazy, which means that I cannot just put print statements in it. If this is the case, what is a a solid approach to debugging the above code?

hl2zip20:01:17

For example, how would I see what that value of row is in the above?

williewillus20:01:09

doseq realizes the sequence(s) its given

hl2zip20:01:48

Based on that, what would be a good approach for debugging the above?

dpsutton21:01:37

what's your dev environment?

hl2zip21:01:30

I use Atom/Protorepl

hl2zip21:01:37

(emacs will come later ;))

dpsutton21:01:43

should be able to debug and step through right?

hl2zip21:01:19

That sounds right, but I am not sure how to do that at the moment. I was hoping there was a manual way until I learn protorepl better.

dpsutton21:01:04

well it being doseq you can just litter some printlns in there right?

hl2zip21:01:20

that is what I was hoping. I will give it another try, but it did not seem to output anything. Just wanted to know that it is possible and not me missing something basic

neurogoo21:01:24

I am trying to do a list in Reagent that when you click item, the subitems are dynamically fetch from server. I can't seem to get handle on how to give id to on-click event. I am trying to use atoms but it seems that the atom does not have any value when the on-click event is triggered. . Piece of code that I am working on is here http://pastebin.com/EGZD3Ewc

notanon21:01:25

@hl2zip is the problem (create-row upload-id) ? you're passing in the same id for every row. just guessing, cuz the code you have pasted above looks fine to me. the only unknowns are the a) return value of csv/read-csv b) return value of create-row and c) return value of create-cell. if the bug is in one of those three, we wont be able to help.