Fork me on GitHub
#clojure
<
2016-11-10
>
manderson01:11:34

I'm working with data readers and wondering why this works:

#inst"2016-11-09"
=> #inst"2016-11-09T00:00:00.000-00:00"
but this throws an exception:
(defn read-baz [x]
  (mapv second x))

(binding [*data-readers* {'foo/baz #'user/read-baz}]
  #foo/baz{:a "a" :b "b"})

RuntimeException No reader function for tag foo/baz  clojure.lang.LispReader$CtorReader.readTagged (LispReader.java:1347)
RuntimeException Unmatched delimiter: )  clojure.lang.Util.runtimeException (Util.java:221)
My guess is because of this line from the *data-readers* doc: > The data reader function is invoked on the form AFTER it has been read as a normal Clojure data structure by the reader. But wondering what magic keeps this error from happening with the built in inst and if I can tap into it?

seancorfield01:11:30

The #inst data reader is “in scope” before you read any Clojure in.

seancorfield01:11:17

(binding [*data-readers* {'foo/baz #‘user/read-baz}]
  (read-string "#foo/baz{:a \"a\" :b \”b\”}”))
will work as expected

manderson02:11:08

Thanks @seancorfield is there any way to make sure #foo/baz is in scope in the same way?

seancorfield02:11:22

Normally, data readers are processed by Clojure from a specific file, before it starts to read other code (that might contain tagged literals).

seancorfield02:11:59

It will look for data_readers.clj at the root of the classpath at startup.

manderson02:11:21

ah, gotcha. ok, thought that might be it but was making the assumption that binding would accomplish the same thing.

agigao02:11:51

Hi Clojurians, any suggestions about actively developed web-scraping library?

rmoehn03:11:03

Not sure what you mean by “web-scraping”, but have a look at https://github.com/swannodette/enlive-tutorial/. The first part is about scraping web pages. Don't be mislead by the 2015 dates on the tutorial and Enlive itself. It's widely used and I think there are no new commits, because Christophe Grand deems it complete or good enough.

agigao03:11:05

Thank you!

yonatanel08:11:33

What's the common practice for using my own library fork as a dependency in production until the original catches up? Do I publish to clojars and remove it later, or use lein-git-deps plugin, or something else?

arrdem08:11:32

Well you can't remove it later, that would break repeatability.

arrdem08:11:00

But yes. Fork, patch, publish under your own organization and revert to upstream when you can.

yonatanel08:11:21

Is there a way to later mark the jar as irrelevant and intentionally get low priority or hide it from search results? I don't want the repository to stay dirty and confuse others.

arrdem08:11:04

No and don't worry about it? This is literally why artifacts have organization qualifiers.

seancorfield08:11:52

The key here is publishing it under your org name so folks can tell it's not the original. Some clown published their updated version of a common Java library (from Maven) under the original group ID on Clojars and now lein ancient thinks I need to update to that version. Very annoying!

danielcompton08:11:41

> Is there a way to later mark the jar as irrelevant and intentionally get low priority or hide it from search results? I don't want the repository to stay dirty and confuse others. @yonatanel Use org.clojars.<your-username> : https://github.com/clojars/clojars-web/wiki/Groups#personal-groups

tianshu08:11:56

why not-empty, why not not-empty? ?

joost-diepenmaat08:11:04

@doglooksgood functions ending in a question mark are predicates and should return a boolean value

joost-diepenmaat08:11:14

not-empty returns the input collection if it’s not empty

joost-diepenmaat08:11:54

see also some, for instance

tianshu08:11:38

@joost-diepenmaat 👍 That's make sense, thank you!

yonatanel12:11:15

Should empty keyword exist/work or is it incidental? (keyword "") => :

cycle33712:11:57

i think that's a bug, it shouldn't exist

moxaj12:11:48

@yonatanel I believe keyword rules only apply to those created by the reader, the function keyword accepts any string

danielstockton12:11:02

is there a special significance to the lein 'dev' profile? will it be included by just running lein repl for example?

roelofw14:11:09

someone who can help me on my question on the beginners channel ?

andy.fingerhut17:11:54

@alexmiller: That faq list is getting meaty! I hadn't looked at it in a long while.

yonatanel17:11:38

Is there a way to destructure a bunch of same-namespaced map keys without repeating the namespace? Perhaps aliasing the namespace just for the scope of destructuring?

bja17:11:56

@yonatanel in 1.9 you can use {:some-ns/keys [foo bar baz]} to destructure a map with keys :some-ns/foo, :some-ns/bar, and :some-ns/baz

yonatanel17:11:49

Nice, thanks!

yonatanel18:11:26

@bja Is there anything similar for select-keys?

aaelony18:11:59

is anyone aware of the timeline for euroclojure 2016 videos release?

yonatanel18:11:09

@aaelony Someone here said two weeks a week ago

aaelony18:11:50

just in time for Thxgiving then

yonatanel18:11:24

@alexmiller Can I extend the reader with something like #:my-ns[:a :b]?

Alex Miller (Clojure team)18:11:31

We have discussed namespaced vectors a bit and eventually that may happen

roelofw18:11:03

Is there a beter alternative for learning as the brave book. I did the first two chapters and I find the exercises way to difficult for a beginner. I get more and more confused and frustated

Alex Miller (Clojure team)18:11:05

But then it begs namespaced set syntax and that is pretty ugly looking

roelofw18:11:05

@alexmiller I will take a look

shdzzl20:11:55

Is there a way I can use apply with a java class constructor?

shdzzl20:11:25

ie. (apply MyClass. constructor-arg-vector)

shdzzl20:11:09

This Google Group thread more or less answers my question: https://groups.google.com/forum/#!topic/clojure/VfAobY8uWvU

creese20:11:09

I have some dependencies in a checkouts/ folder. When I run lein deps, why doesn't Leiningen see them? I get errors like Could not find artifact foo:jar:0.1.6-SNAPSHOT in clojars ()

idiomancy20:11:59

there are a couple of things that can cause that, so I'll go through a couple that I have hit @creese

idiomancy20:11:57

is the version number right in lein deps per whatever its labeled in the corresponding project.clj?

idiomancy20:11:32

is the thing in the checkouts folder a symlink?

creese20:11:52

It is a symlink

idiomancy20:11:07

and (here's the big one) did you remember to run lein install on the project youre depending on?

idiomancy20:11:14

that one always gets me

creese20:11:37

Why do you need run lein install? I thought the whole point of checkouts was so you wouldn't have to

idiomancy20:11:02

yeah, you do. lein checkouts is what it is.

creese21:11:20

Okay, I did that. Now it says it can't find it on the classpath.

creese21:11:39

The lib is in my .m2.

creese21:11:39

I removed the dep from my project.clj. Works now.

cschep21:11:44

the reason is that usually you just put the cond and the result on the same line

cschep21:11:59

(cond
    (< n 0) "negative"
    (> n 0) "positive"
    :else “zero”))

danielstockton21:11:12

I know @cschep but when its a large clause, i like to put them on separate lines

danielstockton21:11:42

I'm just not sure if its possible to write such an indentation spec. I end up indenting it manually which is a bit annoying, I'd like to be able to automatically format an entire file

adambrosio22:11:48

not sure its a good idea, but i like

(cond
  (condition)
  #_=> (value)
  …)

cschep22:11:39

ah right, right.

danielstockton22:11:41

@adambros it might be a bit mysterious to people who aren't familiar with the reader macro

danielstockton22:11:30

I find it a bit visually noisy as well

bbloom23:11:54

uuugh burned by (apply assoc m []) again!

bbloom23:11:58

every time!