This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-19
Channels
- # beginners (50)
- # boot (82)
- # cider (42)
- # clojure (206)
- # clojure-india (1)
- # clojure-nl (2)
- # clojure-poland (2)
- # clojure-russia (1)
- # clojure-uk (6)
- # clojurescript (223)
- # code-reviews (17)
- # core-typed (3)
- # datomic (7)
- # dunaj (3)
- # editors (2)
- # instaparse (3)
- # jobs (1)
- # ldnclj (37)
- # overtone (3)
- # reactive (1)
- # reading-clojure (1)
- # reagent (24)
- # remote-jobs (1)
Is there a way to get a seq of what clojure.walk is walking?
@txus: don't mention it! I'm glad you found them useful
@bmay for Twitter's streaming API, I think there's nothing better than https://github.com/twitter/hbc
anybody here using https://github.com/rill-event-sourcing/rill ?
Appending a single element to a seq generated by for
— is there a better way than:
(conj (vec (for …)))
concat
came to mind but then I need to make the single element a seq first.@martinklepsch: I think concat
is the only way to keep lazyness.
don’t care about laziness in this case actually
@zoldar: event sourcing is really straightforward in Clojure. Not sure it's pertinent to be tied to a library for implementing es.
@martinklepsch: I don’t think there’s another way.
@jprudent: I guess, but still, if somebody put in the effort, why reinvent it. There probably are many corner cases I would have to cover when doing this myself - especially in the part responsible for persisting to event store.
@andrewmcveigh: that’s an equally valid answer ;D
thanks!
I’d usually use (concat .. [thing])
, I guess as a habit.
@andrewmcveigh: I guess I’d usually do that to but in this case it’s hiccup ...
(which would still work but may look confusing)
Ah, fair enough. Probably best to keep the vectors then.
Unless you can rewrite the for
with mapv
I could but I don’t think it’d make my eyes any happier
maybe a forv
macro 😈
haha yeah, I was actually thinking about that 😄
@acron: (defn vhm [c] (into {} (remove #(nil? (second %)) c)))
also: (defn vhm [c] (into {} (remove (fn [[k v]] (nil? v)) c)))
@ambrosebs: is that possible at all?
my hypothesis is if the collection changes size to 0 as we go down the then branch it can return null
haha, so you’d need “to pull the carpet from under it”
@martinklepsch: comp
can shrink down the predicate in remove
a bit:
(defn vhm [c] (into {} (remove (comp nil? val) c)))
![simple_smile](https://a.slack-edge.com/80588/img/emoji_2017_12_06/apple/simple_smile.png)
Pretty sure Medley has a transient version somewhere too if you don’t mind the dependency.
There's remove-vals
, which uses transients internally.
(defn- reduce-map [f coll]
(if (editable? coll)
(persistent! (reduce-kv (f assoc!) (transient (empty coll)) coll))
(reduce-kv (f assoc) (empty coll) coll)))
https://github.com/weavejester/medley/blob/master/src/medley/core.cljx#L105-L109@martinklepsch: could always do (lazy-cat (for [i (range 10)] i) [:foo])
Anyone tried using AWS Lambda from clojure, using their new Java support? Doable without too much friction?
@ragge is the author and has been chatting about it with others here.
Also a Nodejs/cljs POC - https://github.com/jpb/aws-lambda-cljs
How to make clojure.core/sort return nil: http://sprunge.us/VIFc?clj
So I’m using a Pegdown wrapper in Clojure and get "Error: <aside> is not recognized!” — same fore <figure>
& <figcaption>
. Any suggestions for getting those tags to work? It’s just HTML rihgt?
This seems to be the cause of my problem: 😕 https://github.com/sirthias/pegdown/blob/a1bb611ea64d48f78fca691f7cca7aae5b41ab1c/src/main/java/org/pegdown/Parser.java#L563-L569
Call for tests! tools.namespace reader conditional support in 0.2.11-SNAPSHOT.
Get it like this:
:dependencies [[org.clojure/clojure "1.7.0-RC2"]
[org.clojure/tools.namespace "0.2.11-SNAPSHOT"]]
:repositories [["sonatype-oss-public"
" "]]
@stuartsierra: niiiice!
@stuartsierra: that’s great thanks!
technically this is more support as I caught most of it in 0.2.10
I guess 0.2.10 added support for .cljc, and this adds support for reader conditionals in the ns macro
yes, this is exactly what I was waiting for
I was also initially confused how I got it basically working with 0.2.10 (given the snapshot adds support)
@stuartsierra: I don't use reader conditionals, but I don't detect any noticeable slowdown with 0.2.11
vs 0.2.10
or 0.2.9
(15.62s to refresh-all
as measured by criterium against Yeller's ~15k lines of code). Just in case that matters at all (it does to me - the time taken for reload
dominates nearly everything else in my inner development loop)
@stuartsierra: hm. getting an exception that seems totally unrelated with the snapshot that I didn’t get with 0.2.10.
It doesn't force the :clj
feature, but since it only runs under Clojure(JVM) anyway I assume that's unnecessary.
@stuartsierra: I use it within a boot task and I think something inbetween might be breaking things, will gist the stacktrace in a sec.
uhh, weird. now it’s gone 😄
I’m actually just using ns-tracker
really which seems to now correctly report changed namespaces with reader conditionals in their ns
form.
tcrayford: yikes, 15K lines in one reload.
@stuartsierra: ~2 year old app, only one dev, never felt enough pain to bother splitting it up across projects or whatever.
@stuartsierra: whats the timeframe to get this cut as a release?
So with sbt
is there an equivalent to lein install
that installs the thing into my local maven repo?
@tcrayford: is that AOT compilation on linux? can I tempt you to try [ragge/clojure "1.7.0-clj703-SNAPSHOT"]
if you dare, that's RC1 with this patch applied: http://dev.clojure.org/jira/browse/CLJ-703
@tcrayford: thankyou, really interested to hear impact on real codebases...
@ragge: CI time for circle is very variable. First run took 2:55, but I had a run last night that took 3:05 (without that patch), and times vary between about 3 and 4 minutes. The joys of cloud computing
@tcrayford: yeah, maybe not best environment to test in... do you develop on linux, if so you can give this a go: https://github.com/ragnard/clj-703
@tcrayford: ok, thanks anyway... have been trying to collect some data for that patch to show real-world impact
@ragge: I've pre-screened that ticket for 1.8 so I don't know that any additional data is needed at this point, just awaits the initial look at 1.8 tickets
@alexmiller: oh, great to hear
@ragge FWIW I'm running your script on my Ubuntu machine.
Will post results once it finishes
@aengelberg: ah, cheers... it's nice to know that it's not just a "my machine" problem... the data I've received so far only includes two other linux reports, but they both show a improvement similar to what I see
> 10x speed boost so far.
meant to say > 10x speed boost
RC1,incanter.core,98453
RC1+CLJ-703,incanter.core,5295
RC1,incanter.core,100599
RC1+CLJ-703,incanter.core,4537
RC1,incanter.core,96687
RC1+CLJ-703,incanter.core,4701
RC1,incanter.core,100557
RC1+CLJ-703,incanter.core,5203
RC1,aleph.http,76473
RC1+CLJ-703,aleph.http,5400
RC1,aleph.http,80024
RC1+CLJ-703,aleph.http,5688
RC1,aleph.http,76575
RC1+CLJ-703,aleph.http,5793
RC1,aleph.http,79155
RC1+CLJ-703,aleph.http,5691
(I submitted to the google form as well)oh wow... that's a much bigger difference than what I'm seeing... makes me wonder if the test is bad
@aengelberg: is your drive especially slow?
My computer is... special.
More likely a problem on my machine than with your tests, that's all I'm sayin
Style question… should a predicate named with a ?
suffix return strictly boolean, i.e., only true
or false
? Or is a looser truthy / falsey value considered acceptable.
The community style guide https://github.com/bbatsov/clojure-style-guide says "The names of predicate methods (methods that return a boolean value) should end in a question mark"
And when I asked on the mailing list in 2014 https://groups.google.com/forum/#!searchin/clojure/question$20mark$20boolean/clojure/y8ySWiLXGQc/E8VhX5-CN2cJ there seemed to be a consensus of ?
=> strictly boolean but it was a relatively small response sample, given the size of our community.
I think true/false is recommended
And this earlier thread seemed happy with a ?
predicate that was a set https://groups.google.com/forum/#!searchin/clojure/question$20mark$20boolean/clojure/ikXhkd3ULFs/an_77fdC9BgJ
@martinklepsch: Will release today if enough people look at it and convince me it's correct.
@seancorfield: I usually coerce foo?
functions to boolean
@stuartsierra: at all times? even foo? is used somewhere in a private helper function as in (if (foo?..) ), (when (foo?... )), when truthy/falsey is sufficient as foo?'s return value? or do we have a naming convention for a function which returns truthy/falsey?
@fhanreich: Not all the time. But usually.
@stuartsierra: Thank you I'm guessing no naming convention for my latter question?
@fhanreich: Not really. If it's a function to get a "foo" out of something else, or nil
if there isn't a "foo" to get, I just name it foo
.
@stuartsierra: Ah right! Thanks
if i want to include a java package (hbc - twitter client) in a lein project, do i have to build the package with maven first?
@bmay: Not if it is available in a maven repository that your project is searching. I don’t know if lein searches other than clojars by default. You can probably specify an additional repository. Or you can download it and “mvn clean install” and then it will be available locally.
@bmay: http://stackoverflow.com/questions/4615592/what-are-the-leiningen-default-repositories - if your package is in one of those you should be good to go.
@micah: not that I know of, but you could hack it yourself by having a flag def using reader conditionals
@arrdem I've already got a hack that looks for cljs.analyzer... but I was hoping for something more elegant. I recall discussion saying that such a var would exist.
clojure-version has existed for a long time
are you talking about clj vs cljs?
but we weren't planning on doing anything about it for 1.7
there is nothing definitive like that right now, but certainly many ways to infer it
@alexmiller: Yup.. That's what I was looking for
yeah, that's where it gets tricky
@alexmiller: Ok. I commented on the jira issue expressing my desire for the feature in 1.7.
low. I am really hoping that RC2==1.7
what's your use case?
why don't you just use reader conditionals?
(you know that thing where you keep asking "why?"... :)
My impression was that during macro expansion, the reader conditionals are always resolving to :clj
ok, so specifically macros you're trying to use in both clj and cljs?
@markstang: thanks. looks like if i include the two artifacts with jars it works fine, but there is another artifact without a jar (http://search.maven.org/#search%7Cga%7C1%7Ccom.twitter.hbc) - any idea why?
@micah: what I'm trying to tease is out is if there's a more important problem to solve. Luke was trying to do the same thing when he filed that ticket.
@bmay: Sorry, not familiar with the package. I would look around and see what they recommend for an implementation.
@alexmiller: I've been wondering the same. But this code is all about the macros. I could duplicate the macros for each platform... but yuk.
ragge: seems to shave off a few seconds on core.typed loading. Does your patch made normal loading faster?
@ambrosebs: no, it's only when writing classfiles to disk
@micah: if the macros are different then they’re different, it’s work that has to be done
@micah: if they aren’t different then just move them into a file where they can be loaded easily by both Clojure and ClojureScript
@ambrosebs: exactly
@ambrosebs: is core.typed doing any compile
calls?
@dnolen: they are only slightly different. The macros are currently easily available for both Clojure and ClojureScript.
@alexmiller: do you recall Luke's situation? Did he find a better solution?
don't know
I'm not sure in some of this why they're even macros and not functions
They throw exceptions. And if they were fns, the line numbers would be all wrong. The exceptions need come from the spec that made the assertion.
As a workaround, there are ways to detect, during execution of a macro, if I was called from CLJS.
I'm trying to think on the exact technique I used - I ended up not using that code so I don't have it any more.
Seems to me, the root of the issue is: Should macro code know the platform for which it is being expanded? Due to the incompatibilities between platforms, I think the answer has to be 'yes'.
micah: I have no answer for you at the moment but I will re-raise this with Rich before we release 1.7 and we may do something
and I apologize for conflating reader conditionals with this. the problem here is really in generating (writing) code with macros, so it is not something reader conditionals help with. macro files are always read as Clojure code.
tools.namespace 0.2.11 release is cooking…
@alexmiller: Sounds like a plan. No worries. And thanks for all your help today. You're awesome!
@bmay: it can use them via java interop, but you'll have to be more specific about your use-case.
afaik there isn't a third-party library that relies on guava's concrete lists, and clojure has its own, so you could just use those.
trying to mimic this java for hbc: List<Long> followings = Lists.newArrayList(1234L, 566788L);
java varargs are arrays, the compiler is stuffing those into an array for you. You'll have to do it manually in clojure with into-array to meet this signature: public static <E> ArrayList<E> newArrayList(E... elements)
also, imo, there's no reason to use newArrayList if you have java7 and can use the diamond operator.
ImmutableList.of(arg1,arg2,arg3) is kind of nice, but i'd just use clojure's from clojure.
has anyone put together something like clojure koans where the student needs to figure out what part of clojure would be most suitable given a description or a snippet of code? ... like "in this situation a defrecord would be better than deftype" ... and "in that situation you should use a vector instead of a list" ... and maybe the student proceeds with a choice and further down the road discovers and understands the pain if their choice was suboptimal .... ?
@andrew: it is not for idiomatic clojure specifically, but I like http://exercism.io as you can view and discuss others' approaches for the given problems