This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-10
Channels
- # aws (45)
- # bangalore-clj (16)
- # beginners (109)
- # boot (137)
- # cider (7)
- # cljs-dev (54)
- # cljsrn (22)
- # clojure (77)
- # clojure-conj (1)
- # clojure-greece (2)
- # clojure-nl (5)
- # clojure-russia (36)
- # clojure-spec (15)
- # clojure-uk (54)
- # clojurescript (118)
- # cursive (7)
- # datomic (25)
- # emacs (33)
- # hoplon (276)
- # klipse (38)
- # lein-figwheel (1)
- # leiningen (9)
- # melbourne (1)
- # off-topic (18)
- # om (98)
- # onyx (6)
- # pedestal (1)
- # perun (24)
- # re-frame (46)
- # reagent (6)
- # ring-swagger (3)
- # spacemacs (67)
- # specter (15)
- # untangled (33)
- # vim (6)
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?The #inst
data reader is “in scope” before you read any Clojure in.
(binding [*data-readers* {'foo/baz #‘user/read-baz}]
(read-string "#foo/baz{:a \"a\" :b \”b\”}”))
will work as expectedThanks @seancorfield is there any way to make sure #foo/baz
is in scope in the same way?
Normally, data readers are processed by Clojure from a specific file, before it starts to read other code (that might contain tagged literals).
It will look for data_readers.clj
at the root of the classpath at startup.
ah, gotcha. ok, thought that might be it but was making the assumption that binding
would accomplish the same thing.
See https://clojuredocs.org/clojure.core/*data-readers* for more detail.
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.
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?
But yes. Fork, patch, publish under your own organization and revert to upstream when you can.
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.
No and don't worry about it? This is literally why artifacts have organization qualifiers.
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!
> 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
@doglooksgood functions ending in a question mark are predicates and should return a boolean value
not-empty returns the input collection if it’s not empty
see also some
, for instance
@joost-diepenmaat 👍 That's make sense, thank you!
@yonatanel I believe keyword rules only apply to those created by the reader, the function keyword
accepts any string
is there a special significance to the lein 'dev' profile? will it be included by just running lein repl
for example?
found my own answer here: https://practicalli.github.io/clojure/leiningen/profile.html
@alexmiller: That faq list is getting meaty! I hadn't looked at it in a long while.
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?
@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
see the bottom of this section: http://clojure.org/reference/special_forms#_map_binding_destructuring
thanks, @yonatanel
@yonatanel: no (but you could build it)
@aaelony: working on it, soon
@alexmiller Can I extend the reader with something like #:my-ns[:a :b]
?
We have discussed namespaced vectors a bit and eventually that may happen
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
But then it begs namespaced set syntax and that is pretty ugly looking
@roelofw: maybe Living Clojure?
@alexmiller I will take a look
This Google Group thread more or less answers my question: https://groups.google.com/forum/#!topic/clojure/VfAobY8uWvU
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 (
there are a couple of things that can cause that, so I'll go through a couple that I have hit @creese
is the version number right in lein deps per whatever its labeled in the corresponding project.clj?
and (here's the big one) did you remember to run lein install on the project youre depending on?
Why do you need run lein install
? I thought the whole point of checkouts was so you wouldn't have to
I know @cschep but when its a large clause, i like to put them on separate lines
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
not sure its a good idea, but i like
(cond
(condition)
#_=> (value)
…)
@adambros it might be a bit mysterious to people who aren't familiar with the reader macro
I find it a bit visually noisy as well