#clojure logs

2015-05-11

00:51bucketh3adIs there any way to step through a call to reduce so I can see the intermediate values and figure out where my function is going awry?
00:52Bronsa,(reductions + '(0 1 2 3 4))
00:52clojurebot(0 1 3 6 10)
00:53bucketh3adThat might be helpful, but the reduce call is within a recursive loop, so the results will get thrown away before it returns the final value.
00:57bucketh3adI could use that if I had a way to pause execution before the call to recur.
01:00mavbozobucketh3ad, is logging the reductions result not possible?
01:05bucketh3adThat's what I ended up doing mavbozo. I also found this answer on stack overflow which is a pretty useful one-liner macro"
01:05bucketh3adhttp://stackoverflow.com/a/2352280
03:45sm0keif in lein i have a composite profile [:provided-pom-scope :test-pom-scope :shared] would the pom scopes be still preserved?
04:48mnngfltgI just came up with this way of applying operations conditionally in the thread-first macro: https://gist.github.com/pesterhazy/e191d0157b6f5cfe2ed8
04:49mnngfltgIs that useful? Am I reinventing something that already exists?
04:52mpenet,(doc cond->)
04:52clojurebot"([expr & clauses]); Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression is true. Note that, unlike cond branching, cond-> threading does not short circuit after the first true test expression."
04:53mnngfltgHuh
04:53mnngfltgmpenet, true, but I'll have to specify a condition (true?) for every expression I'm threading
04:56mnngfltgthanks for the pointer though, that seems like what I'm looking for
04:56mpenetnot necessarly
04:57mpenet,(-> {} (cond-> true (assoc :bar 1)))
04:57clojurebot{:bar 1}
04:57mpenet(-> {} (cond-> (true? true) (assoc :bar 1)))
04:57mpenet,(-> {} (cond-> (true? true) (assoc :bar 1)))
04:57clojurebot{:bar 1}
04:58mpenetit's more or less a macro version of what you wrote
04:58mnngfltgright, or I could use :alwaws
04:58mpenet(source cond->)
04:58mpenet,(source cond->)
04:58clojurebotSource not found\n
04:58mpenet,(clojure.repl/source cond->)
04:58clojurebotSource not found\n
04:58mpenetwell
04:58mnngfltgI'll find the source :)
04:59mpenet(require 'clojure.repl)
04:59mpenet,(require 'clojure.repl)
04:59clojurebotnil
04:59mpenet,(clojure.repl/source cond->)
04:59clojurebotSource not found\n
04:59mpenetgiving up :]
05:38crazydiamondHi. Can anyone suggest way to create/delete Datomic DB synchronously?
05:43ordnungswidrigcrazydiamond: create/delete a fact?
05:44crazydiamondordnungswidrig, I get answer on #datomic now. The problem was that it's deleted and created in async way
05:44crazydiamondand I can't make a loop with schema changes
05:44ordnungswidrigcrazydiamond: :-)
05:45crazydiamondbut solution is always create new DB
05:45crazydiamondalso, I'll probably use mem storage. so thanks for answering! :)
05:49michaelr`anyone knows of a cool compnay names generator?
05:49michaelr`juxt is take ;)
05:49michaelr`taken
05:51ordnungswidrigmichaelr`: the swing demo application had a panel creating those.
05:51winkhmm, I only wrote a WoW guild name generator and a product name generator for our company :P
05:55michaelr`ordnungswidrig: which one?
05:55ordnungswidrigmichaelr`: the swingset, I think
05:55michaelr`wink: can you generate a few names for me ;)
05:56ordnungswidrigmichaelr`: I don't know if this is in jdk8 anymore
05:59winkmichaelr`: you could just try creating a new github repo, it generates random names
05:59winkalso, https://www.google.de/search?q=random+company+name ;)
06:01michaelr`yes, lot's of generators online but they don't give cool names by default
06:01michaelr`you'd need to give them some ideas for words to combine but I have none :)
06:01winkwell yeah
06:02winkunless you want to name a company "The Epic Pirate Unicorns of Darkness" then my guild name generator wont help you either
06:03winkmichaelr`: but feel free to be inspired, https://github.com/winks/GuildNameGenerator/blob/master/GNGText.luahttps://github.com/winks/GuildNameGenerator/blob/master/GNGText.lua
06:04michaelr`haha
06:33borkdudewhy is there no dissoc-in? :)
06:34hyPiRionborkdude: I think the problem was that it wasn't evident whether (dissoc-in {:foo {:bar {}}} [:foo :bar]) would return {:foo {}} or {}
06:36bcn-florHi ! I have a map with a tree of nodes, each node has a :children item with the child nodes, eg. {:title "Hi" :children {:title "Child1" :children {:title "Child1-1"}}}... I want to recursively remove (dissoc) some keys from all the nodes in tree. Can anyone point me towads the light ?
06:38hyPiRionbcn-flor: Children or just a single child? You example shows only a single map (presumably the child), not a sequence of children
06:40bcn-florYou're right, actually it's like this: {:title "a" :children [:child1 child2] :child1 {:title "a" :children [:child3 child4] :child3 {...} :child4 {...}}}
06:41hyPiRionah
06:42Bronsabcn-flor: look at clojure.walk/postwalk
06:45bcn-florBronsa: will do, thanks..
06:45hyPiRionI find it usually easier to just implement a recursive function. It would probably look something like (defn tree-dissoc [root key] (-> (reduce (fn [root' child] (update-in root' [child] tree-dissoc key)) root (:children root)) (dissoc key)))
06:48bcn-florhyPiRion: yeah, I've been trying to build the two-liner for 3 hours.. but haven't tried with reduce
06:50bcn-florhyPiRion: was trying to (merge (dissoc mymap :bad-key) mapped_children) , where mapped children is a recusrive map over the child nodes, converted back to {}. Doesn't work though
06:53hyPiRionbcn-flor: that should also work, but you have to use (apply merge ...) or (reduce merge)
06:54hyPiRion,(apply merge {:foo :z} [{:bar :a} {:baz :g}])
06:54clojurebot{:foo :z, :bar :a, :baz :g}
07:05joelkuiperI'm not sure if it's against the rules ... but there's a stackoverflow question that's been bothering me https://stackoverflow.com/questions/30081260/enumerate-namespaces-and-dynamically-load-them-in-clojurescript
07:25borkdudejoelkuiper you can try something in combination with a macro or cljc?
07:25borkdudejoelkuiper so the vars also are created in clojure/jvm
07:25borkdudejoelkuiper and you can enumerate them from there and use that output in clojurescript
07:31joelkuiperborkdude: yeah, I guess something like that would work. It's a bit contrived though, since I'll be relying on the cljc compiler
07:32joelkuiperborkdude: In plain clj I would've probable tried to get the reified vars by name, but that's not an option in cljs
07:32borkdudejoelkuiper you could write a macro that registers the var to a collection inside an atom when you define a component
07:33borkdudejoelkuiper or just do it manually when you define a component
07:33joelkuiperborkdude: yeah that was my other thought ... I tried a similar approach without macro's but that lead to some circular dependencies in some edge cases
07:34joelkuiperborkdude: I could fix those cases probably, and indeed just call some (register component) fn that writes to an atom. Still have to list all the namespaces though
07:34joelkuiperbut that's inevitable I guess
09:58escherizeWhen I'm using emacs inside a clojure file, what's the best way to jump to or create its test file counter part??
09:58lazybotescherize: What are you, crazy? Of course not!
09:58escherize:(
09:59timvisheris there a library that makes the output of :pre and :post conditions a little more humane?
09:59timvisherlike maybe printing the offending value and the expression that produced it?
09:59hyPiRionRaynes: I think lazybot's responses just cause confusion right now. People assume it's a serious reply
10:00hyPiRionisn't that true lazybot???
10:00lazybothyPiRion: Oh, absolutely.
10:00timvisheri'll second hyPiRion here :)
10:00winktimvisher: if your values offend you and you need humane output, maybe try a badword censoring? ;)
10:01escherizeI've been told pre and post conditions are a code smell.
10:02bensuescherize: what's the reasoning behind that?
10:06escherizeIf it's not clear enough with out them your functions need refactoring
10:06escherizeIs what I was told
10:06escherizeI dont actually use them either, though.
10:06winkit shouldn't be about clarity, imo
10:07escherizeThat's a good point. I usually use prismatic.schema/defn if I want to be explicit about preconditions. And havn't thought terribly hard about post conditions.
10:07winkinvariants aren't bad, they're just not very commonly used. in any language
10:07escherizeI use invariants a bit
10:07winkmost people just seem to write tests instead :P
10:08escherizeyeah I need to be writing more tests.
10:08escherizeBTW: When I'm using emacs inside a clojure file, what's the best way to jump to or create its test file counter part??
10:08lazybotescherize: Definitely not.
10:08escherizeThanks lazybot
10:08winkstop using ?? then ;)
10:10escherizewhy??
10:10lazybotescherize: Uh, no. Why would you even ask?
10:11escherizelazy bot why must u harrass me??
10:11lazybotescherize: What are you, crazy? Of course not!
10:16joelkuiperhehe??
10:16lazybotjoelkuiper: What are you, crazy? Of course not!
10:16joelkuipernice
10:20justin_smithescherize: I know there is a function in cider to derive the recommended test file location given a namespace, so if there isn't a "jump to test file" already, it seems like it would be easy to write
10:23bensujustin_smith escherize: cider-test-infer-test-ns
10:24justin_smithbensu: thanks
10:24justin_smith(inc bensu)
10:24lazybot⇒ 1
10:24bensujustin_smith: you are right, ideally you would just (comp jump-to cider-test-infer-test-ns)
10:24bensu:)
10:24justin_smithbensu: I knew it was there, but not being a cider user myself it would be tricky to find :)
10:25bensujustin_smith: well, I remember because I customized it. It used to be: append "-test" to the ns
10:25bensubut I use preppend "test." to the namespace
10:26justin_smithoh, there would be an extra step, if it gives you the ns - you would also have to turn the ns into a path under test/
10:27bensujustin_smith: that's right!
10:28escherize(inc bensu)
10:28lazybot⇒ 2
10:29escherizeI learned you can also projectile-find-test-file (in prelude C-c p T)
10:31justin_smithat my workplace, we tried to do a workshop on Friday to change colorization in cljs and cljc files via elisp. We hit some weird speed bumps.
10:39escherizelike what justin_smith?
10:42wasamasafont-lock in emacs is generally weird
10:43justin_smithescherize: trying to override highlighting locally is weird. At first we just tried to apply a buffer-specific color scheme, but this just didn't seem to work (thought the docs seemed to claim it would).
10:43justin_smithroot problem is probably just that we were a bunch of amateur elispers (despite being professional clojure devs) and should not have expected results in the first two hours of work.
10:44escherizesounds pretty scary to me
10:44escherizeI'm getting back into learning about emacs - i just made an anki deck for prelude
10:46escherizealso stuff like C-u C-u C-u C-n
10:47wasamasajustin_smith: I did for instance have to use M-x font-lock-fontify-buffer to reapply it interactively
10:47justin_smithescherize: alternately, M-4 C-n
10:47wasamasajustin_smith: doing so for a C buffer however... is slow as heck
10:48justin_smithwasamasa: ahh, maybe we got it right, but had to explicitly ask for refontification
10:48wasamasajustin_smith: it isn't necessary if you've just started writing a document though as it seems to do lazy contextual updates
10:48escherizejustin_smith: C-u C-u C-u C-n moves down 64 lines
10:48wasamasajustin_smith: and many more weirdness :P
10:49justin_smithescherize: oh, I thought it went up by powers of 2
10:49escherizeit's powers of 4 i guess, but even so M-4 C-n moves me 4 spots
10:50justin_smithescherize: C-u 64 C-n is still arguably better if I am avoiding chords, though it's not easier to type of course
10:50escherizeI really should learn mark better.
10:51escherizeyeah I don't use chords either
10:51escherizeI think i might use helm till i die though
10:51justin_smithescherize: I actually switched to evil mode because I have some residual memory of vi, and wanted to cut back drastically on chord usage
10:52escherizewith spacemacs?
10:53justin_smithno, I don't do canned configs, I just turned evil mode on
10:53wasamasadeath to canned configs
10:55broquaintQuick straw poll - any one do mainly Java dev but use Clojure for poking about etc? (yes that's quite a hand-wavey question)
10:55escherize I didn't do much Java before I picked up Clojure
10:57kaiyinHow do you create a byte in clojure?
10:58broquaintescherize: Me either, but I'm about to do a whole lot of Java :)
11:00patrickgombertkaiyin: https://clojuredocs.org/clojure.core/byte
11:01kaiyinpatrickgombert: thanks. I am wondering what these two functions are for, they don't seem to do anything: https://github.com/smee/binary/blob/master/src/org/clojars/smee/binary/core.clj#L29-L35
11:01kaiyinor maybe i still don't quite understand the difference between byte and unsigned byte.
11:03patrickgombertkaiyin: Java doesn't have unsigned types afaik
11:03escherizelooks like they swap between 2s compliment unsigned notations
11:04escherizebyte being signed?
11:05kaiyinescherize: that only matters when you convert it to an int, right?
11:05hyPiRionor from an int to a byte
11:05hyPiRion,(unchecked-byte 255)
11:05clojurebot-1
11:10kaiyinhyPiRion: yeah.
11:10kaiyinhow exactly does this convert a byte into a unsigned byte? (defn byte->ubyte [b] (int (bit-and b 255)))
11:12hyPiRion,(bit-and (byte -20) 255)
11:12clojurebot236
11:12hyPiRionthe int wrapper just ensures it's an integer instead of a long, I guess
11:13hyPiRion,(bit-and (byte -20) (unchecked-byte 255)) ;; => -20
11:13clojurebot-20
11:15kaiyinhyPiRion: ok, this means (int ...) turns -20 into 236?
11:16hyPiRionI probably confused you with the byte calls. Better example:
11:16hyPiRion,(bit-and -20 255)
11:16clojurebot236
11:17hyPiRion-20, which presumably is a byte, is converted into a long, which is then bit-anded with 255 (lowest 8 bits). Finally it's cast to an int.
11:19kaiyinwell, why should bit-and do anything to -20 in this case? 255 is just 11111111.
11:19kaiyinwhy is it converted to a long first?
11:20hyPiRionkaiyin: because 255 is a long
11:20kaiyinah, ok.
11:21hyPiRionI'm pretty sure the behaviour is equal in Java, actually. (byte)-20 & (long)255 should yield 236 as a long.
11:21kaiyinbut still, why doesn't (bit-and -20 255) return -20?
11:23kaiyin,(Integer/toString -20 2)
11:23clojurebot"-10100"
11:25hyPiRionyeah, that's a stupid way of representing it.
11:25hyPiRionOr well, it's not stupid, but it's confusing.
11:25hyPiRion,(defn bitify [n] (apply str (for [b (range 32 -1 -1)] (bit-and 1 (bit-shift-right n b)))))
11:25clojurebot#'sandbox/bitify
11:25hyPiRion,(bitify -20)
11:25clojurebot"111111111111111111111111111101100"
11:25hyPiRion,(bitify 255)
11:25clojurebot"000000000000000000000000011111111"
11:26hyPiRion,(bitify (bit-and -20 255))
11:26clojurebot"000000000000000000000000011101100"
11:26hyPiRionkaiyin: Does it make more sense now, or is it still black magic?
11:27mikerodDoes anyone have a good way to type hint the return value of an anonymous function?
11:27mikerodI found this to be surprisingly difficult/impossible?
11:28mikerodI don't mean to type hint it when you call it.
11:31bensuI remember a google group discussion about this
11:31bensumikerod: ^
11:32mikerod_Hmm, I guess I'll start searching then
11:32bensuhttps://groups.google.com/forum/#!topic/clojure/2DyGQ6fH1ZU
11:32bensunot sure if it leads somewhere
11:33mikerod_some initial searching has left me empty of ideas. I could just read some compiler and see probably.
11:33puredangermikerod_: there is a ticket related to that that was fixed in 1.7
11:33mikerod_puredanger: oh, interesting
11:33puredangerhttp://dev.clojure.org/jira/browse/CLJ-1378
11:34bensumikerod_: who needs google when you have puredanger? :)
11:34puredangersome day I will reclaim my memory of thousands of JIRA tickets and be able to remember other general knowledge
11:35mikerod_(inc puredanger)
11:35lazybot⇒ 49
11:35mikerod_puredanger: that was some amazingly fast Jira link response time
11:35mikerod_I've actually read this Jira before myself - and forgot about it...
11:35mikerod_thanks!
11:35puredangerI have a lot of them memorized unfortunately
11:36puredangerhyPiRion: there is also http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#toBinaryString(int) for binary string conversion btw
11:36kaiyinhyPiRion: that's cool. totally makes sense.
11:36puredanger(Integer/toBinaryString -20)
11:37puredanger,(Integer/toBinaryString -20)
11:37clojurebot"11111111111111111111111111101100"
11:37hyPiRionpuredanger: That's convenient, didn't know about that one.
11:37puredangeralso toHexString, etc
11:37Bronsa(inc puredanger)
11:37lazybot⇒ 50
11:37hyPiRion(inc puredanger)
11:37lazybot⇒ 51
11:43escherize(inc puredanger)
11:43lazybot⇒ 52
11:44escherizedoes this oracle end of lifing java have any effect on me a humble clojure dev?
11:45TimMcescherize: You mean EOL'ing Java 7?
11:45TimMcUnless I've missed some pretty big news.
11:46escherizeYes thats what i meant
11:49puredangerit means you won't get security updates on Java 7 unless you pay oracle
11:49puredangerother than that, no
11:49escherize(inc puredanger)
11:49lazybot⇒ 53
11:50puredangerI expect we will remove java 6 support from Clojure in the next release or two
11:50TimMcpuredanger: I read that as "add java 6 support to Clojure" :-D
11:52TimMcescherize: It means you should feel a little more free to use features introduced in Java 8 and should probably not have Java 7 the default on your own computers.
11:52escherizeI havent written any java in like 3 years
11:53TimMcescherize: You use the Java libraries and JVM features from Clojure so that's neither here nor there.
11:54escherizeBut I dont breathe any style into them
11:57puredanger"next release" not including Clojure 1.7 that is
12:18marcoslamuriaHi folks, I have a question about types and protocols
12:20marcoslamuriais anyone here?
12:21Bronsamarcoslamuria: ask your question and you might get an answer
12:21marcoslamuriais it possible to have a type that extends another type and implements a protocol?
12:22Bronsano. deftype doesn't support type inheritance
12:23marcoslamuriahumm
12:24marcoslamuriaok thanks
12:24patrickgombertmarcoslamuria: it can happen with some macro magic (eg https://github.com/sdegutis/oops)
12:26marcoslamuriahumm
12:26marcoslamurialet me see
12:27Bronsapatrickgombert: he asked about extending a type to another type. that's not possible no matter how many layers of macros you use, deftype simply doesn't allow it
12:28patrickgombertyeah, you're right... it might be possible to do something similar though
12:29Bronsai might be wrong but the way he phrased the question, it sounded like he wanted concrete type inheritance, not mixins
12:29marcoslamuriayeh a want concrete type
12:30marcoslamuriaok, no problem.. I'll find another way to do what I need
13:13clojerIs there a significant difference between reloading a Clojure web app (eg. Luminus) already loaded into a REPL and reloading a Scala/Play2 app compiled inside InteliJ? I'm trying to understand how Clojure REPL editing differs from Scala/SBT reloading.
13:18wasamasaI'd describe it for lisp generally as "additive"
13:18wasamasawhere a few dialects like clojure or racket offer the option to flush out everything and replace it with a clean slate
13:19clojerwasamasa: Does this mean with Clojure you're not actually recompiling after an edit but in Scala/Java it's always a full recompile?
13:20wasamasaclojer: you recompile selectively
13:20wasamasaclojer: or compile a new addition
13:20wasamasaclojer: I didn't try out scala, but I can confirm that for java you need a full recompile, yes
13:21clojerwasamasa: So as your codebase increases that could make a big difference in your edit/reload cycle?
13:21wasamasaclojer: yes
13:21wasamasaclojer: it also makes for fun bugs you only encounter while developing :P
13:21wasamasaclojer: so there's that
13:22clojerwasamasa: Are you saying you find these bugs better with Clojure?
13:22wasamasaclojer: no, I mean that if you for instance evaluate version A of a function, decide to change it to version B *and* rename it
13:23wasamasaclojer: code still using the old name will keep using the old definition
13:23wasamasaclojer: so you won't run into an error telling you the function isn't defined because you're additively accumulating state
13:23justin_smithsee also redefinition of defrecord
13:23justin_smith(related but different error)
13:24wasamasaclojer: and only cleaning up the namespace (be it with advanced trickery or a REPL restart) will make that obvious
13:24wasamasaclojer: what I'm trying to convey is that it's a mixed bag for me, on the one hand very useful because it makes for a faster workflow, on the other hand messier
13:26clojerwasamasa: Does clojure.tools.namespace.repl cover all these bases safely?
13:27wasamasaclojer: C-c C-x does that namespace cleanup here, I don't appear to have the necessary middleware installed for it though
13:29justin_smithclojer: clojure.tools.namespace.repl/refresh works well, though you need to code your app so that it won't break (by using defonce for things that carry state for example)
13:29clojerThanks. Have to dash.
13:35goraciohi, are there any monger users ?
13:36goracioi got something like that {:_id #<ObjectId 554e4552162a0207b425a903>, :title "First article"} how i can transform _id key to just int ?
13:53jleglerYou don't have much of a say in that unless you yourself will be generating the ids.
13:53jleglerYou can ignore them and put int your own int ids if you want to use ints.
13:54jleglerThe _int paradigm is a mongo thing, not a monger thing.
13:58jleglerthe _id thing I mean. Mongo doesn't use ints for ids.
14:12djamesI'm wondering about pub-sub options in Clojure ... perhaps over nrepl or ZeroMQ. Any suggestions on what to look at?
14:12djamesAlso interested in how lightweight one could make a JVM process to serve as an nrepl server
14:29wasamasalol
14:31justin_smithdjames: grench exists as a lightweight nrepl client (written in ocaml)
14:31djamesjustin_smith: thanks, will look
14:31djamesI think I'll look closer at Netty too
14:44goraciohey there ) given [{:a 1} {:b 2}] how to change :a value with string 1-> "1" in each map in vec
14:44goracioand return [{:a "1"} {:b 2}]
14:50justin_smith,(map #(reduce-kv (fn [m k v] (assoc m k (if (= k :a) (str v) v))) {} %) [{:a 1} {:b 2}])
14:50clojurebot({:a "1"} {:b 2})
14:56goraciojustin_smith: this is crazy )
14:56goracio(map #(update-in % [:_id] str) ( [{:a 1} {:b 2}]))
14:57goracio,(map #(update-in % [:a] str) ( [{:a 1} {:b 2}]))
14:57clojurebot#error{:cause "Wrong number of args (0) passed to: PersistentVector", :via [{:type clojure.lang.ArityException, :message "Wrong number of args (0) passed to: PersistentVector", :at [clojure.lang.AFn throwArity "AFn.java" 429]}], :trace [[clojure.lang.AFn throwArity "AFn.java" 429] [clojure.lang.AFn invoke "AFn.java" 28] [sandbox$eval55 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compil...
14:57goracio,(map #(update-in % [:a] str) [{:a 1} {:b 2}])
14:57clojurebot({:a "1"} {:b 2, :a ""})
14:59goracioah sorry [{:a 1} {:a 2}] this is the case )
14:59goracio,(map #(update-in % [:a] str) [{:a 1} {:a 2}])
14:59clojurebot({:a "1"} {:a "2"})
15:20justin_smithgoracio: if you always expect an :a key, yes update-in is simpler. But the reduce-kv (or something equivalent) is needed if the :a key may not be present
15:21goracioок
15:21justin_smithalso you can use update instead of update-in for this case
15:21justin_smith,(map #(update % :a str) [{:a 0} {:a 1}])
15:21clojurebot({:a "0"} {:a "1"})
15:22justin_smithwith newer clojure versions
15:22amalloy,*clojure-version*
15:22clojurebot{:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true}
15:23amalloyjustin_smith: 1.7 isn't even out yet, right? so you have to be running an alpha to use update
15:23justin_smithor a beta, yeah
16:03amalloycfleming: intellij keeps giving me warning messages like "The directory /Users/.../myproj/ is under Git, but is not registered in the Settings". do you know what the deal is with that? the best i could find online was a 2-year-old SO question with the answer "you can't do anything about it"
16:04cflemingamalloy: You should be able to fix that - go to Settings->Version Control and set up the directory as a git root
16:05amalloycfleming: that's fine, but it does this for every project
16:05amalloywhy do i need to keep adding them as git roots?
16:05cflemingamalloy: But once you've configured it for a particular project it stops, right?
16:05amalloyi think so
16:06cflemingok
16:06cflemingSo you just want to turn that warning off?
16:06goraciois there are any way to run server and figwheel in one process ? or in one repl ?
16:06amalloyi don't know. i want to know why that warning exists, so i know what i should do about it, which might be turning off the warning
16:08cflemingamalloy: So IntelliJ has to have that configured so that its VCS integration works. In multi-module projects these setups can get pretty complex (i.e. multiple VCSes or multiple roots for a single IntelliJ project)
16:08amalloycan i uh...turn off VCS integration?
16:08cflemingamalloy: So generally in those settings you configure this. Since people might not realise that they have to do that, IntelliJ warns you when it hasn't been done.
16:09cflemingamalloy: Sure - if you only ever use Git on the command line, Settings->Plugins and remove Git
16:09amalloyaha
16:09amalloythanks
16:13cflemingamalloy: While you're there, it's generally a good idea to remove any other plugins you're not using too
16:13amalloyyeah, i did
16:18goracioso ?
16:25cfleminggoracio: Try asking in #clojurescript
16:25cfleminggoracio: brucehauman (the Figwheel author) hangs out in there
16:26goraciook
17:15hyPiRionIs the common pattern when you have a protocol definition and want to provide a default implementation for one of the protocol methods to split it into two protocols?
17:27the-kennyhypirion: I think so, yes.
17:28hyPiRionthanks
17:59kaiyin,(aset ^ints int-array 4 5) why do we need the ^ints here, since it's obviously an int-array?
18:00clojurebot#error{:cause "clojure.core$int_array cannot be cast to [I", :via [{:type java.lang.ClassCastException, :message "clojure.core$int_array cannot be cast to [I", :at [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]}], :trace [[sandbox$eval25 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.core$eval invoke "core.clj" ...
18:00kaiyin,(aset ^ints int-array 4 5)
18:00clojurebot#error{:cause "clojure.core$int_array cannot be cast to [I", :via [{:type java.lang.ClassCastException, :message "clojure.core$int_array cannot be cast to [I", :at [sandbox$eval49 invoke "NO_SOURCE_FILE" -1]}], :trace [[sandbox$eval49 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.core$eval invoke "core.clj" ...
18:01kaiyinsorry, my bad.
18:01kaiyin,(def i (int-array [0 1 2 3 4 5 6]))
18:01clojurebot#'sandbox/i
18:02kaiyin,(aset ^ints i 4 5)
18:02clojurebot5
18:04amalloykaiyin: why is it obviously an int-array?
18:04kaiyinwell, it's generated by int-array.
18:06TimMckaiyin: Clojure's compiler doesn't do very much type inference.
18:06amalloykaiyin: once you def it to something, it's just a var with an unknown value. that's the downside of dynamic typing
18:06TimMcAlso, that ... yeah, what he said.
18:06amalloyof course you don't *need* the ^ints hint - it still works fine without it, but it's faster if you hint it
18:08kaiyinok, got it.
19:58escherizeGood news! I merged a cljs project into a clojure project! (I started them seperately for some reason.)
19:58escherizeWhat's the best approach for deployment? I guess it doesn't matter
19:59escherizemy previous workflow is a script that ssh's in, git pulls a tag, and restarts the app
19:59escherizebut with the cljsbuild step, should I actually commit my advanced compiled javascript files in the repo?
20:02justin_smithescherize: git and lein on prod is a bad idea anyway
20:03justin_smithcreate your js while generating an uberjar
20:04escherizeoh really, justin_smith? Lein I can understand, but why is git a bad idea on prod? I worked at a sizable clojure shop for a while and never encountered this line of thought
20:04escherizealso you're On the Money with the uberjar idea
20:05justin_smithescherize: git on prod means an intruder gets to not only your server instance, but your repository.
20:05justin_smithwhich means they can backdoor not just a machine, but your infrastructure
20:06justin_smithand also uberjars are just simpler - you just deploy one artifact, and maybe a couple of scripts
20:08escherizethanks man
20:08escherizeI wonder if I still have git access.. over there.. :)
20:09justin_smithhaha
20:09escherizeso totally unrelated.. what's a good way to ransom a set of servers.. or sell trade secrets on the black market?
20:16cflemingDoes proxy propagate type hints to the parameters of method implementations?
20:18amalloycfleming: reify certainly does. i'm not sure about proxy; the code for that is pretty complicated
20:19cflemingamalloy: Yeah deftype/defrecord do as well
20:19amalloyright, those are basically the same code
20:19cflemingamalloy: Looks like it doesn't
20:20cfleming,(binding [*warn-on-reflection* true] (proxy [MouseAdapter] [] (mousePressed [event] (.getButton event))))
20:20clojurebot#error{:cause "Can't resolve: MouseAdapter", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.Exception: Can't resolve: MouseAdapter, compiling:(NO_SOURCE_FILE:0:0)", :at [clojure.lang.Compiler macroexpand1 "Compiler.java" 6644]} {:type java.lang.Exception, :message "Can't resolve: MouseAdapter", :at [clojure.core$proxy$fn__5707 invoke "core_proxy.clj" 329]}], :trace [[clo...
20:20cfleming,(binding [*warn-on-reflection* true] (proxy [java.awt.event.MouseAdapter] [] (mousePressed [event] (.getButton event))))
20:20clojurebot#object[sandbox.proxy$java.awt.event.MouseAdapter$ff19274a 0xfe6ce0c "sandbox.proxy$java.awt.event.MouseAdapter$ff19274a@fe6ce0c"]
20:21amalloycfleming: binding doesn't work there
20:21cflemingHmm, I guess clojurebot doesn't show the warnings, but I get one in my REPL here
20:21amalloybecause the binding applies to runtime, but you want to set it at compile time
20:21cflemingIt doesn't?
20:21cflemingActually I .... right
20:21amalloycfleming: you shouldn't, if you were actually using binding and not set!
20:22cflemingamalloy: I used set! here
20:22cfleming(set! *warn-on-reflection* true)
20:22cfleming,(set! *warn-on-reflection* true)
20:22clojurebot#error{:cause "Can't change/establish root binding of: *warn-on-reflection* with set", :via [{:type java.lang.IllegalStateException, :message "Can't change/establish root binding of: *warn-on-reflection* with set", :at [clojure.lang.Var set "Var.java" 221]}], :trace [[clojure.lang.Var set "Var.java" 221] [sandbox$eval75 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6792] ...
20:22cflemingMeh
20:22cflemingAnyway, I get a warning, so I guess hints are not propagated for proxy
20:23amalloyyeah. i was trying to read through the source for proxy to find out, but your way is better
20:23cflemingYeah, often the code is just too complicated to figure out reliably
20:24cflemingI'm adding type inference for Java interop, should be pretty nice - type aware autocompletion etc
20:24escherizenice
20:25amalloycfleming: how do you plan for it to work when the target object isn't known yet? eg in (.foo bar), how can you help me with typing foo?
20:26cflemingamalloy: You'll be able to type (bar .fo<caret>), when you autocomplete I'll convert that to (.foo bar <caret>)
20:27cflemingamalloy: In cases where the type is already present that won't be necessary, like if you wrap an existing form and then start typing (so the second form is already there)
20:27cflemingamalloy: The second form is also implicitly already there in threading forms etc
20:28amalloyinteresting. what about not even requiring the parens or the space, so it looks like i'm typing a java method invocation? bar.foo<tab> -> (.foo bar)
20:29cflemingI thought about that, it's a little trickier since bar.foo is normally resolved as a single symbol - I might be able to make that work though. The form with the space is more consistent when the first form is e.g. a list
20:29cflemingi.e. ((.method object).otherMethod<caret>)
20:31crack_userhello guys
20:31amalloyoh sure, i forgot foo.bar already looks like a classname
20:31crack_usersomeone knows what can cause this error? java.lang.IllegalArgumentException: No implementation of method: :success? of protocol: #'buddy.auth.accessrules/IRuleHandlerResponse found for class: buddy.auth.accessrules$success
20:32cflemingamalloy: In cases where it's really unknown I can also be smarter now by walking all available local symbols, looking at their types, and offering methods available on those types
20:32amalloycrack_user: you probably reloaded the namespace containing a protocol definition, while leaving around instances of the old protocol
20:33cflemingamalloy: right, I can special case that though, so if foo.bar looks like a classname but doesn't actually resolve to a class I can then do a secondary search
20:59escherizeanyone seen java.lang.NoClassDefFoundError: clojure/tools/logging/impl/LoggerFactory before?
21:04justin_smithescherize: with clojure.tools.logging you can provide an implementation (sl4j or log4j are the main ones iirc) - it can't depend on either, but one of them has to be present
21:05escherizeAhh thank you
21:06amalloycfleming: i had a clojure file with some usages of class Foo in it, which were correctly flagged by cursive as errors, because i hadn't added an import for Foo. then in emacs, i added an import for Foo. now cursive still thinks the usages of Foo are unresolved *and* i have an unused import of Foo in my ns form
21:10amalloycfleming: i think it's because i also added the dependency to my project.clj, but cursive hadn't reloaded/synced it. a bit weird that it thought the imports were unused as well as being unresolvable, but i guess as long as it flags them as unresolvable it's not a huge deal that it also flags them as unused
21:12escherizehow do I put the log4j jar on the classpath, like it says to do in https://github.com/clojure/tools.logging
21:13justin_smithescherize: add log4j as a dep in project.clj
21:13escherizeI downloaded apache-log4j-2.2-bin.tar.gz and it unzips into a folder with a lot of jars in it.
21:13escherizederp
21:17escherizeso then, the vector I added to :dependencies is [org.apache.logging.log4j/log4j-core "1.2.17"]
21:18escherizebut that is wrong :)
21:18escherizehttp://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
21:18escherizelein could not find the artifact in maven or clojars (probably it will be in maven?)
21:19escherizeoh yeah i got it.
21:19escherize[org.apache.logging.log4j/log4j-core "2.2"] worked. Thanks again justin_smith
21:19escherize(inc justin_smith)
21:19lazybot⇒ 252
21:46escherizewell, I'm still getting the same problem. It looks like I'm using the wrong neo4j? the clojure.tools.logging wants the one listed here https://github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging/impl.clj#L145 , but The only two I can find are [org.apache.logging.log4j/log4j-core "2.2"] and [log4j/log4j "1.2.17"]
21:47escherizeso I'm pretty confused about how to pull "org.apache.log4j.Logger" into my project.
21:48justin_smithwait, that's a version?
21:48justin_smithlog4j-core 2.2 shoudl provide org.apache.log4j.Logger
21:49escherizeI'm using [org.apache.logging.log4j/log4j-core "2.2"]
21:50escherizeso I'm thinking (Class/forName "org.apache.log4j.Logger") should just work?
21:50justin_smiththat's what I thought...
21:50justin_smithit is definitely provided by log4j 1.2 https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html
21:50justin_smithperhaps it is missing from 2.x
21:50escherizeis there a special place to put the log4j.properties file?
21:51justin_smithit just needs to be on classpath
21:51escherizeso, I've tried: [log4j/log4j "1.2.17"]
21:53escherizeit's in ./resources so that should be ok
21:55escherizecool, so (Class/forName "org.apache.log4j.Logger") works from the repl. but lein uberjar is throwing the same error.
21:55justin_smithtry lein do clean, uberjar
21:59amalloylein do clean, clean, clean, uberjar just in case
21:59justin_smithhaha
21:59escherizeikr
21:59escherizeI bet my uberjar task is fudged.
21:59justin_smithin all seriousness, I have had situations where I changed my deps and uberjar went wrong until I did an explicit clean
22:00cflemingamalloy: Right, if Cursive can't resolve the class correctly it can't know that the import and the class usage are the same class
22:01cflemingamalloy: Well, anything is possible, obviously, but that's all built around class resolution now
22:43escherizeouch, my brain. So my main file won't compile because no logging factory. Then I import the logging factory in the same repl: https://gist.github.com/f2143af6deb55923676b
22:52justin_smithescherize: I don't know what's going on there
22:53justin_smithescherize: do you have to tell it to use a particular impl?
23:10lokeI have a long list of things, and I want to apply a transformation on the first element that matches a certain criteria. Right now I've implemented it as such: (map (fn [v] (if (criteria v) (dosomething v) v) some-list). However, this has two problems: 1) It applies the function on every single element when it would be efficient to stop after the first one that matches criteria and 2) if I really want to prevent processing of subsequent matches, I need a stat
23:10lokee variable to track that. Is there a better solution?
23:13justin_smith,(loop [acc [] [e & r] [2 4 6 7 8 10]] (if (odd? e) (into (conj acc (inc e)) r) (recur (conj acc e) r)))
23:13clojurebot[2 4 6 8 8 ...]
23:13justin_smiththat's one way to do it at least
23:14lokejustin_smith: Thanks
23:15lokejustin_smith: Another solution I was thinking of was to first get the index of the first match and then use a single conj on that element. Would that be more efficient?
23:17justin_smithI wanted to use reduce / reduced, but it needs to use the remains of the coll
23:17justin_smithcould be, if the input is a vector
23:17lokeThe input is indeed a vector
23:18lokeI was surprised to notice that standard clojure doesn't seem to have an equivalent of CL's POSITION function. Or did I miss something?
23:19justin_smithloke: many functions aren't implemented in clojure if they don't have a fast solution (not sure if that's why position is missing though)
23:24justin_smitheg. that's definitely why we have hashtables but no alists
23:24lokeInteresting
23:25lokeAlists are faster than hashtables though, up to some value of n.
23:25lokeI have no idea what n is, which might be the reason why it's not supported.
23:25justin_smiththat's true, but clojure opts not to implement them (it's biased toward fancy data structures)
23:26justin_smithloke: small hashtables may be something close to that, but they autopromote
23:26justin_smith,(type {:a 0})
23:26clojurebotclojure.lang.PersistentArrayMap
23:26lokejustin_smith: Yes. It's clearly a very different application. The application I'm working on has the server written in Common Lisp, but the client side were recently rewritten in clojurescript, which is why I'm here askign questions. :-)
23:27justin_smith,(type (reduce conj {:a 0} (repeat 100 [1 2])))
23:27clojurebotclojure.lang.PersistentArrayMap
23:27justin_smithhmm... I think I did that wrong
23:28justin_smithoh, of course, lol
23:29justin_smith,(type (into {:a 0} (map vector (range 1000) (range)))
23:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
23:29justin_smith,(type (into {:a 0} (map vector (range 1000) (range))))
23:29clojurebotclojure.lang.PersistentHashMap
23:29justin_smiththere we go
23:29justin_smithrepeating the key won't force the switch :)
23:30justin_smithmore info http://clojure.org/data_structures#Data%20Structures-ArrayMaps
23:30puredangerof course that may all change post 1.7 with unrolled small collections :)
23:30justin_smithpuredanger: what difference would you expect to see?
23:31puredangerarray maps will basically be replaced a family of N-pair map implementations
23:31justin_smithahh
23:31puredangerup to some TBD N
23:31justin_smithso the same kind of unrolling we see for arities in clojure.core
23:31puredangeryeah, code generated
23:32puredangergiven the typical distribution for map sizes, it might be a significant bump in perf
23:33puredangerI can't remember what Zach measured in his impl but it was bigger than I expected
23:35puredangercreation time was 5x faster than PAM