#clojure logs

2015-03-13

00:15ccurriehey folks, leiningen question. I'm new to clojure. I'd like :java-source-paths to have a computed value based on :target-path, but I can't figure out the right syntax. I can't even get simple things to work. :java-source-paths ["src/java"] works fine, but :java-source-paths [(str "src/java")] is breaking trying to call :as-file on PersistentList, which makes me thing I'm missing something fundamental.
02:54lxsameerhey guys, I'm looking for a clojure ebook to read. Do you have any book suggestion ?
02:55arrdem_Clojure Programming_ by Chas Emerick et all is good.
02:55arrdem_The Joy of Clojure_ by Michael Fogus is also good but less introductory iirc
02:56lxsameerthanks guys
03:04nsjphi refer to cloj programming a bit more than joy of
03:05nsjphim also a fan of the pragprog editing style
03:30appleflaphi! when i try (require 'om.core) in the new cljs repl, i get the error: Cannot find module '/Users/sander/Code/cljs/hello_world/.cljs_node_repl/goog/react.inc.js' -- is there anything i can do to make cljs look a directory level higher for the file?
03:31appleflap(react.inc.js is put there by cljs.closure/build)
03:33appleflapwhen i copy react.inc.js to goog/, i get a "React is not defined" error in om/dom.js
03:37irctc4hi, is there way to initialize global variables at start of the program so that all namespaces sees them? Like your program was a function and you wrote (let [vars (initialize)] (program-executes-in-vars-scope))
03:38appleflapirctc4: are you looking for https://clojuredocs.org/clojure.core/binding ?
03:38clojurebotCool story bro.
03:39gko__What do you think of Luminus vs bunch of libs (lein app) for a simple Web server (input form -> output data from database server (no input to database))? Luminus seems overkill, but bunch of libs require lots of DIY (?) for things such as edit file.clj -> file.clj is reloaded automatically, etc...?
03:40winki didn't look at it for a months, but overkill?
03:40winkit's a bit of nice duct tape that holds a few libs together :)
03:41wink(not to downplay quality, but it's not like rails or something)
03:41gko__or are there other alternatives "mid-way" between these two options?
03:42michaelr`hey
03:43michaelr`can anyone share a light color scheme for cursive?
03:44irctc4appleflap: I think no. The story is folowing: I've separeted functionality in several namespaces and have global params for them that are stored in conf file. I tried first to read it at start from main and pass it, but the usega is very nested and they are passing over and over throug function parameters.
03:50arrdemirctc4: can you refheap your code?
04:17figoeThere's a Java class defined like this public class Foobar <A extends SomeInteface> { ... } How do I construct it?
04:18figoeIn Java, it's constructed as: Foobar<B> obj = new Foobar<B>();
04:18figoeHow do I do that in clojure?
04:19arrdemSo the type parameter <t> is an illusion of javac. It doesn't actually exist at the bytecode level (implemented via erasure). As a result, Clojure doesn't know anything about type parameters.
04:19figoeRight.. but how do I initiate the object in clojure then?
04:20figoe(Foobar.)
04:20figoe(Foobar.)?
04:20arrdem(let [x (Foobar.)] ...)
04:20figoeNo need for B?
04:20arrdemNope.
04:21Empperiah... java and it's type erasure...
04:21Empperihow I hate that in java
04:21figoeHmm, okay... let me try that... I'm not good at Java, better at clj actually ;)
04:21figoeBut gotta working with some java libraries
04:21arrdemClojure: how much java did you really need anyway? :P
04:21figoeOnly when we interface with some interesting java library :)
05:49sveriHi, I included prismatic/schma into my project and now get this error: #<CompilerException java.lang.RuntimeException: No such var: sm/protocol, compiling:(plumbing/fnk/schema.clj:22:13) anyone knows what is going on?
06:13wizzohi. if i use take-last on a vector is it still going to run as fast as subvec or will it get turned to a sequence in the background?
06:14justin_smith$source take-last
06:14lazybottake-last is http://is.gd/ciXuD9
06:14justin_smithwizzo: yeah, that definitely won't use subvec
06:14wizzoahhh ok thanks
06:15wizzoyeah :(
06:15wizzooh well not a big deal
07:16SirRobinwhen writing macros in cljs: how do I refer to a macro from another namespace?
07:16ssiderissveri: I don't have a solution but I had the same problem yesterday
07:16ro_styou have to write your macros in .clj files
07:17SirRobincljs.core.async/go gives me: WARNING: Use of undeclared Var cljs.core.async/go at line ...
07:17ro_stand (:require-macros [your.clj-macros-ns :as macros])
07:17SirRobinro_st: yes, but in the .clj file, how do I refer to the go macro?
07:18ro_st(ns foo (:require-macros [cljs.core.async.macros :refer [go]])
07:18ro_st)
07:19ro_stthat'd be from a .cljs file
07:19ro_stif you wrote your own macro with (defmacro …), that'd have to be in a .clj file
07:19SirRobinyes
07:19SirRobinI have my own macro in a clj, and in that macro I want to use "go"
07:20ro_stoh that's much easier
07:20SirRobinfor async functions, in that macro I use "cljs.core.async/chan", but that doesn't work for macros
07:21ro_sthave you tried plain old (:require [cljs.core.async.macros :refer [go]])?
07:23dnolenSirRobin: CLJS macros in core.async don't live in the same logical ns
07:23SirRobinro_st: yeah, of course that worked :) writing macros fries my brain, thanks
07:24ro_styou're not alone SirRobin
07:24dnolenYou want cljs.core.async.macros/go not cljs.core.async/go
07:24SirRobinaaaah
07:24dnolenit's a bit confusing as most libraries now have adopted the pattern that macro ns and the runtime ns have the same name
07:24dnolenwould be a breaking change for core.async but probably one for the better
07:24ro_stgood thing it's still in alpha -grin-
07:25dnolenheh yeah
07:25SirRobindnolen: I should have noticed that, that's what we use in :require-macros
07:25ro_stpeople would complain, but it's not like they weren't forewarned
07:51CookedGryphonHey, I'm using clj-http-lite with 1.7-alpha5
07:52CookedGryphonand it's complaining about the update function being unbound
07:52CookedGryphonI wouldn't have expected that, I would have expected it to pick *one* of the two implementations
07:53stuartsierraCookedGryphon: Probably a version dependency conflict.
07:55CookedGryphondon't think so
07:56CookedGryphonI think it needs update adding to :refer-clojure :exclude, but unbound var is definitely not what I'd expect
07:56CookedGryphonI'm aot compiling as well, which might make some difference
07:57justin_smithCookedGryphon: here's what I imagine - you have the newer clj-http-lite that got rid of the newly conflicting "update" function, so other code that wants to use clj-http-lite hits an error when it wants to call the update function (which no longer exists)
07:58stuartsierrahttps://i.imgflip.com/h9gtq.jpg
07:58justin_smithheh
07:58Bronsathere was a bug wrt aot and shadowing core vars, should be fixed in the next alpha
07:59CookedGryphonah, thanks
07:59CookedGryphonjustin_smith: I am using the latest clj-http-lite
07:59CookedGryphonand it still has the update function
07:59justin_smithoh, OK
07:59CookedGryphonI think I'm just hitting the bug Bronsa mentioned
08:00justin_smithI know one of the libs has updated to remove update already
08:00justin_smithmaybe the regular clj-http
08:00BronsaCookedGryphon: yeah http://dev.clojure.org/jira/browse/CLJ-1604
08:00CookedGryphonany ideas for workarounds where I don't have to pull in my own version of clj-http-lite, while I wait for the next alpha?
08:00Bronsapre alpha5 it used to throw a NPE, alpha5 works in some cases and in others leaves the var unbound
08:00Bronsaalpha6 will have it fixed for good
08:01puredangerhoping to have the next alpha soon
08:02CookedGryphonthanks guys, most helpful
08:39sverissideris: I opened an issue for it: https://github.com/Prismatic/schema/issues/194 if you want you can add your stuff to it, maybe it helps finding the root cause
08:39ssiderissveri: great, thanks
08:50mpenetdnolen: do you know if someone is working on implementing the cljs part of promise-chan, offer! etc on c.c.async?
08:51dnolenmpenet: I was going to do it eventually but if you want to take it on go for it!
08:51dnolenseriously want promise-chan for CLJS
08:52mpenetno feel free to do it, I was just wondering if/when. I need the jvm version like yesterday and I know it's waiting for the cljs part for a release.
08:52clojurebotPardon?
08:53mpenetI didn't touch cljs in a long time, I guess I'd probably waste tons of time on doing that compared to you
09:00dnolenmpenet: not sure when I'll get to it, lots of more fundamental cljs things for me to work through these days
09:02mpenetalright, thanks for the info
10:13borkdudeI guess not, but is it possible to undo only a region in emacs?
10:14schmirborkdude: yes
10:14herrwolfeborkdude: http://www.emacswiki.org/emacs/SelectiveUndo
10:14borkdudenice!
10:17eraserhdI has a question: I'd like to break out the JNI pieces of Avi into a separate dependency, but is there a way to distribute a jar with native extensions?
10:17eraserhdIt doesn't seem like I could upload it to maven... what do people do?
10:25crack_userhello guys
10:25enrico_\l
10:26crack_usersome one have a good resource to introduction in functional programing?
10:27alcazoidcrack_user: clojure for brave?
10:29crack_useralcazoid: i will check that
10:30vipaca I'm having trouble refactor a function that takes as option a map with meta-data in it. I keep getting the generic Don't know how to create ISeq from: clojure.lang.Symbol. This gist should illuminate some of the details https://gist.github.com/anonymous/a96e87b9cfe663e45373
10:31justin_smith vipaca metadata in it, or on it?
10:31vipacaIts probably something stupid.
10:31vipacaon it???
10:31lazybotvipaca: How could that be wrong?
10:32justin_smith,^{:message "message1"} Exception
10:32clojurebotjava.lang.Exception
10:32justin_smith,(meta ^{:message "message1"} Exception)
10:32clojurebotnil
10:33justin_smithhow would you get the metadata out again? it doesn't seem like that's actually working
10:33Ibm-irc-73- Someone here can help me with Unity 3d ?
10:34justin_smith,(meta ^{:message "message1"} {})
10:34clojurebot{:message "message1"}
10:34justin_smithvipaca: where is "ok" defined?
10:35vipacaring.util.http-response
10:37vipacajustin_smith this is working but the responses are common and I would like to DRY this code up. So being able to pass the structure around would be ideal.
10:37vipacabut I can't figureout if it can be done outside of the macro makes use of it
10:37vipacaI assume that's defapi
10:38justin_smithvipaca: yeah, that GET* macro clearly does not like error-responses
10:38justin_smithit's treating it as a symbol, it isn't resolving it to the var
10:38vipacais there a way not to loose meta info
10:38justin_smithvipaca: use a type that supports metadata
10:38vipacait seems like I should be able to quote the meta data
10:38justin_smithvipaca: most java classes do not support clojure metadata
10:39vipacajustin_smith I'm way over my head here can you break down what you mean by use a type that supports metadata in this use case?
10:39justin_smith,(meta ^{:message "message1"} {})
10:39clojurebot{:message "message1"}
10:39justin_smiththat had metadata
10:40justin_smith,(meta ^{:message "message1"} Exception)
10:40clojurebotnil
10:40justin_smiththat had no metadata
10:40justin_smithclojure datatypes support metadata, most java classes do not
10:41hyPiRionThe java class clojure.lang.PersistentVector does!
10:41vipacaok I gotcha now its Exceptions fault then.
10:41justin_smithhyPiRion: most :) of course all the clojure datatypes are java classes
10:41hyPiRiontehee
10:42vipacawow that is so helpful I didn't realize the meta was being packed in the Exception object.
10:42vipacaI thought it was being used by macro directly in the hash structure, which did seem wierd because there would be three element tuples.
10:42justin_smithvipaca: what did you expect that metadata to do?
10:43vipacaThe one question I have is why does the meta argument not need parathesis? Seems like for the first time this would have made it more clear.
10:43justin_smith^ is a reader macro
10:43justin_smithit attaches the next form, to the form after it
10:44vipacageez two macro's!
10:44vipacaThank you justin_smith I really appreciate your help
10:44justin_smithvipaca: so, this is the code that actually implements GET* https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj#L205
10:44vipacaI'll pop back on later and let the channel know if I got it clean up or not.
10:45justin_smithvipaca: the answer to your question of why the literal map works and the symbol does not is hiding somewhere in the function definition
10:46vipacaI definatley looked at the signature for that function during investigating this issue, but again I think I'm over my head at this point to get through that function. Thanks again I have to run.
10:50oskarthTrying to debug a channel issue using Om. I have a go loop in IWillMount that reads from an event (chan), and a (put! event...) in another view component. The channel works the first time, and if I switch view, but not if I stay in the same view. If I use a sliding-buffer the put! returns true, but if I just use a regular chan it doesn't return anything, so
10:50oskarthit seems as if the problem is in taking things from the channel. Does anyone have any idea what could be wrong?
10:50Deraenvipaca: Metadata is restructured during macroexpansion and compojure-api doesn't know how to handle the symbol error-responses
11:16tbaldrid_oskarth: I'd need to see the code
11:17oskarthtbaldrid_: https://github.com/oskarth/unfolds/blob/master/src/cljs/unfolds/core.cljs#L252 and ~L200 for event loop
11:19tbaldridgeoskarth: I think we need more info about "the channel works the first time", perhaps add some logging to the onClick and also the event loop and that might help?
11:19tbaldridgefor example, are we sure onClick is sending to the correct channel? Or that onClick is being called more than once?
11:19oskarthtbaldridge: I mean that it sends through whatever it's supposed to
11:20oskarthtbaldridge: onclick is being called more than once (sliding-buffer => true after 2nd click)
11:21mmitchellattempting to get lein-ring to reload code on file saves - i get a java.lang.StackOverflowError (ns_tracker.dependency) when making subsequent requests. Anyone seen that before?
11:21oskarthtbaldridge: how can I know for certain it's sending to the correct channel? might be something weird happening there, but don't know how to debug it
11:22justin_smithmmitchell: any chance you introduced a circular namespace dependency?
11:22mmitchelljustin_smith: hmm i don't _think_ so. Haven't ever seen any warnings or anything
11:23oskarthtbaldridge: it seems as if re-mounting the main app-view component is what makes it work again, so it could be that the chan is just the right one the first time around but not the second time, for some reason
11:24justin_smithmmitchell: it wouldn't be a warning on a fresh start, it would be an error. But if the namespaces were already loaded before the circularity was introduced, it might not hit that error (require does nothing if the namespace is already loaded, unless you use the :reload key)
11:24tbaldridgeoskarth: yeah this seems like a problem with how you're using Om, I don't really see a problem with the core.async code.
11:25mmitchelljustin_smith: oh i see, sounds tricky to debug hmm
11:25oskarthtbaldridge: ok, thanks. I'm trying some things with init-state now, hopefully it works. Do you have any good resources for how to debug channels in general? Having a hard time inspecting them
11:26justin_smithmmitchell: for example, this introduces a circular dependency, but it doesn't trigger the error because the namespace is already loaded https://www.refheap.com/98412
11:26tbaldridgeoskarth: most of the time I just log the puts/takes form a channel. And go from there. The best way to debug something like this is to log how data flows through it,
11:26tbaldridgeat least that's my view on it
11:27mmitchelljustin_smith: i see yep. I'll have a look at each of my ns's, hope that's it!
11:27justin_smithmmitchell: it's not tricky to debug. Restart the app completely, and the compiler will tell you which (if any) namespaces have cyclical deps
11:28oskarthtbaldridge: and what if you can put something but then not take it? Any hope left?
11:28oskarthlike some kind of meta data on the channel, or something
11:28mmitchelloh sorry, that's what i originally thought would happen but as a warning instead of error. OK then no circular deps!
11:29justin_smithcool
11:29mmitchellring middleware.reload/wrap-reload causes the same behavior
11:30tbaldridgeoskarth: that's often where more data is needed. "Cannot take" what does that mean, did it try to call take! did it call take on the right channel? Is something else taking from the channel?. All this can be done with logging, or even with a logging macro that can be disabled in production
11:30justin_smithmmitchell: hmm, I don't know what other than a dependency cycle would make those things stack overflow
11:30oskarthtbaldridge: I mean that there's a go loop block that normally takes from that channel, but then it doesn't
11:31oskarthtbaldridge: probably some problem with how I use Om though, will look into it more, thanks again :)
11:31tbaldridgeoskarth: right, and I'm saying that doesn't provide enough information. The question is if it ever tried? Did something else cause it to block, did you miss a recur somewhere and so it's no longer looping, etc.
11:31mmitchelljustin_smith: ok gtk. I'll try simplifying/cutting-out some of the app code and try again. I must be doing something weird here
11:55mmitchelljustin_smith: oh i think it might be because my app is built on the Component lib. So even though the code has changed and its reloaded, the "System" is not reloaded. Reviewing this now - https://github.com/stuartsierra/component#reloading
11:56mmitchellI should say: the "System" is not _restarted_ -- that hmm why the stack overflow
11:57stuartsierrammitchell: 'component' is not compatible with the wrap-reload middleware
11:57mmitchellstuartsierra: thanks for the confirmation, that actually makes sense now that i think about it
11:58stuartsierrawrap-reload just naively require's all the namespaces, relies on Var dynamism to work
11:59mmitchellright, no concept of Lifecycle. Trying out your user.clj stuff now.
12:01mmitchellAlthough, one thing I was hoping I could do (to make it easier for other devs) is to reload code and restart the System when files do change. Maybe I'd need to hook into tools.namsepace to do something special there?
12:02oskarthtbaldridge: fyi I fixed it by passing init-state into other comps, and having the event-chan def be before the go block. https://github.com/oskarth/unfolds/commit/887d9bb93355b03b8d2774818f8086db3182d47b Not sure exactly what did it, might minimize and see if dnolen can find out what went wrong
12:34dnolenoskarth: don't have any time to look at it but you have to be very careful w/ core.async and the React life-cycle
12:34dnolenoskarth: at some point need to go back and rip out core.async from all the Om tutorials
12:34oskarthdnolen: ok, would you like a minimized version or is it irrelevant?
12:35gfredericksis it weird to want to get the result from a call to send and therefore using a promise?
12:35dnolenoskarth: don't want a minimized version, I would only look at it if you can actually the problem yourself
12:35dnolensorry too bandwidth constrained these days for stuff like this
12:35gfredericks(defn send-and-return [ag f & args] (let [p (promise)] (send ag ...) @p))
12:35dnolens/actually/actually find
12:35oskarthdnolen: np understand, issue is rsolved now too
12:36oskarthmight have a look at it and send PR to documentation
12:36oskarthif I can figure it out ;)
12:36dnolenoskarth: that would be sweet, thanks
12:37KevinCorcorangfredericks: ha, just did the same thing. in my case, it was an indication that we were attempting to force something to be sync that really didn't need to be. using a watch is a much better option, if possible.
12:37mmitchellstuartsierra: ok i have your user.clj (dev) code setup with my componentized app. I see my System restarting, but the code I changed (and file saved) is not getting picked up. Anything obvious I should look for?
12:37kaphello clojurists! I have a question, i have my dependency set in lein, it should be enough for importing some lib require right?
12:38gfredericksKevinCorcoran: I'm using the agent for locking mostly I think
12:38gfrederickskap: you have to require in whatever namespace you're using it from
12:38KevinCorcoranif that's really all you want, maybe just use clojre.core/locking?
12:38KevinCorcorani know it's kind of a red-headed step child, but ...
12:39kapyes, but lein compile does not see it, it is precisely clojure.tools.cli/parse-opts
12:39kapCaused by: java.lang.IllegalAccessError: parse-opts does not exist
12:40gfrederickskap; how are you requiring it?
12:40gfredericksand using
12:41kapthe error is on line 1, so it is the require...
12:41kap(:require [clojure.tools.cli :refer [parse-opts]] [clojure.string :as string])
12:41kapin a ns
12:41hiredmanyou are likely pulling in an old version or something
12:42kapmmm...i "lein deps" and in my .m2 I have 0.3.1
12:42kapbut probably yours is the right explanation
12:43hiredmanlook at `lein deps :tree`
12:44kaphiredman you are right
12:44kapbut my defproject says something different Oo
12:46kapdo i miss some task, some deps :clear-cached
12:46kap?
12:47hiredmanwhat makes you say I am right?
12:47justin_smithkap: that's not how the m2 cach works
12:48justin_smithkap: every version you ever use for any project will be in the cache (unless you clear it), what is used by your project is defined by the dependencies and exclusions you declare
12:48hiredmanjust because you see an older version of tools.cli in the output of `lein deps :tree` that doesn't mean it is the one lein is using, different libraries can depend on different versions and they will all be shown in the output of `lein deps :tree`
12:48kapbecause lein deps :tree returned 2.* for clojure.tools.cli
12:48kapok
12:48hiredmanwas there only one entry for clojure.tools.cli?
12:48kapyes
12:49hiredmandid you save your project.clj file after editing?
12:49kapnow it says 0.3.1 for clojure.tools.cli, but still does not compile
12:49kap [org.clojure/tools.cli "0.3.1"
12:50kapno i had not saved (sorry)
12:50kapbut the problem is still there...
12:50hiredmanhave you restarted your repl since you saved your project.clj?
12:51kapjava.lang.IllegalAccessError: parse-opts does not exist, compiling:(solver.clj:1:1)
12:51kapi am comiling with lein compile
12:51gfredericks`lein clean` first maybe?
12:52kapoh great thanks!
12:52kapnow it compiles :)
12:52gfredericksphew
12:52kapsorry guys, lein newbie here
12:52kap:D
12:53kapwe all started from scratch right :D
12:54delaneyquick quesiton about the data structures. say i have a map and assoc on :a and cycle between setting to 1 & 2... does the background structure literally just use the old one (guessing via hashcodes) or does it create new parts of the tries with the diff?
12:55delaneybasically if i having X -> Y -> Z -> X... is the last X not only == to the first X, but is it in jvm terms the exact same memory address
12:55gfredericksyou can check with identical?
12:56gfredericks,(def data {:a 1})
12:56clojurebot#'sandbox/data
12:56gfredericks,(-> data (assoc :a 2) (assoc :a 1) (identical? data))
12:56clojurebotfalse
12:56gfredericks,(-> data (assoc :a 1) (identical? data))
12:56clojurebottrue
12:57Bronsauh
12:57Bronsa,(class data)
12:57clojurebotclojure.lang.PersistentArrayMap
12:57Bronsa,(def data (hash-map :a 1))
12:57clojurebot#'sandbox/data
12:57Bronsa,(-> data (assoc :a 1) (identical? data))
12:57clojurebottrue
12:57Bronsanice
12:58justin_smith,(-> data (assoc :a 2) (assoc :a 1) (identical? data))
12:58clojurebotfalse
12:59gfredericksI should hope that one never works
12:59justin_smithoh, gfredericks already did that one
12:59justin_smithyup yup
13:02l1xjustin_smith: thans again for the help yesterday, i havent had much time, what is a vararg method?
13:02delaneyso no its not using the same memory
13:02delaneyi guess my question, is why not?
13:02delaneyi mean there is a hashcode that will never change to map to a memory address
13:03l1xthat library still does not function in clojure and I still dont understand why, the previous version just worked fine
13:03dnolenhttps://github.com/clojure/clojurescript/wiki/Reporting-Issues
13:03l1xat least the connector creation is working
13:03gfredericksdelaney: that's a lot of overhead though
13:04justin_smithl1x: a vararg method is a method that takes any number of args when called from java. In clojure that just means the last arg is an array.
13:04justin_smithas in java array, not vector
13:04l1xthank you!
13:05or9obHello folks, question on cycling through two collections at the same time: http://stackoverflow.com/q/29037732/117750
13:05l1xso i i would like to implement it in clojure i would reduce the params into an array and this is how i call the java method
13:05or9obPlease answer here if you don't like SO and I'll collate it. Or answer on SO and get those brownie points
13:05delaneygfredericks: well i was thinking about realtime game state, a lot of thing are changing but there is also a lot of return to old state (like with inputs).
13:05gfredericksor9ob: use (cycle ["A" "B"])
13:06gfredericksdelaney: this is something you can opt into *if you know you really need it*
13:06delaneyoh?
13:06gfredericksthe jvm is pretty good at GC so I wouldn't bother unless you've measured differences
13:06gfredericksdelaney: by "opt in" I mean you can do it by hand
13:06delaneyright
13:06or9ob@ gfredericks inside the for? That doesn't seem to work
13:06gfredericksthe jvm has some kind of soft reference or something
13:06justin_smithl1x: for example String/format http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#format(java.util.Locale,%20java.lang.String,%20java.lang.Object...)
13:07delaneygood point, always end up doing entity pooling etc, guess this is just a simplier version of that
13:07or9obPlease see the SO link
13:07gfredericksor9ob: (map vector things (cycle ["A" "B"])) gives you tuples
13:07justin_smithl1x: you might notice how the last arg is Object...
13:07or9obWhat about the other collection?
13:07l1xyes
13:07gfredericks,(take 10 (map vector (range (cycle ["A" "B"]))))
13:07clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.Number>
13:07gfredericks,(take 10 (map vector (range) (cycle ["A" "B"])))
13:07clojurebot([0 "A"] [1 "B"] [2 "A"] [3 "B"] [4 "A"] ...)
13:07l1xthe ... means it support more of those
13:07gfredericksor9ob: ^ like so
13:07justin_smithl1x: that means in java it could be called with any number of object args
13:08justin_smith,(String/format "%s, %s, %s" (into-array Object [:a "b" 'c]))
13:08clojurebot":a, b, c"
13:08justin_smithso in clojure we create an array of the apropriate type, and make that the last arg
13:08l1xjustin_smith: i was wondering what should i do in clojure? just have a mandatory array param? have a list that i turn into array?
13:08justin_smithl1x: in order to wrap a varargs java method?
13:09l1xyes
13:09l1xexactly
13:09or9obgfredericks: so I'll have to take the result of that, and then doseq over it to put it into channels?
13:09bacon1989he wants (apply ...)
13:09bacon1989i think
13:09l1xi used to have this ([one] do something) ([one two] (do something) ([one two & more] (do something else))
13:09gfredericksor9ob: yep
13:09justin_smithl1x: I would do (defn format [fmt & args] (String/format fmt (into-array Object args))
13:10justin_smithif you are wrapping something that is varargs on the jvm level
13:10l1xyes
13:10justin_smithreplace Object with the apropriate class, of course
13:10l1xyep
13:10justin_smithObject being the type that String/format wants in this case
13:10l1xalright i might do this one
13:10or9obcool, thanks, gfredericks. I was wondering if there was a way to do that with doseq directly.
13:10gfredericksnope
13:17mmitchellweird. i can get the reloaded workflow to reload an initial code change, but only the first time. After that, nothing reloads, even though the namespaces are being reloaded (see it in the logs) and the system restarts. hmmph.
13:18justin_smithmmitchell: it seems like component and autoreload just wouldn't play nice with each other
13:18mmitchellah yes. I stopped using the reload (lein-ring and middleware) and am only using the reloaded workflow now
13:19mmitchellthis little snippet - https://github.com/stuartsierra/component#reloading
13:21justin_smithso after manually reloading changed namespaces, you reset?
13:23mmitchelljustin_smith: i'm just changing a ns file, saving it. Then calling reset
13:30mmitchellstrange, so if i change a function, evaluate it in emacs, then restart my System, it works. But the ns reload thing doesn't seem to be doing anything. I might misunderstanding something
13:31justin_smithmmitchell: you need both for the ns to be reloaded, and for the components to be restarted
13:31justin_smitheither of those alone won't do much
13:33mmitchelljustin_smith: when you say i need both, you mean reload the ns + restart the System?
13:33justin_smithyes
13:33mmitchellthat's what I'm doing hmm
13:34justin_smithhow do you reload the ns?
13:34mmitchellclojure.tools.namespace.repl/refresh
13:34mmitchelland also trying clojure.tools.namespace.repl/reload-all
13:35mmitchelland i can actually see that clojure.tools.namespace.repl is reloading changed files through its logging
13:35javjarferhi there! Anyone knows how to use the function "set-screen-wrapper!" from play-clj to avoid the repl break when a exception is thrown?
13:41stuartsierrammitchell: sorry, got busy, will be leaving soon
13:41mmitchellstuartsierra: np! continuing my adventures here :)
13:50mmitchelli wonder if it's because I'm using the repl that lein-ring spawns?
13:51justin_smithmmitchell: as long as the repl and the server are in the same clojure process, it should work
13:51justin_smithyou could start the server from the repl, or start a repl from the server
13:52mmitchelltrue yeah
14:15mmitchellso i can see now that my repl session properly reloads code, and a System restart also does what's expected. The problem is that lein-ring (the jetty server) is not picking up the same changes.
14:16justin_smithinstead of passing handler to lein-ring, pass #'handler
14:16justin_smiththat way it does a fresh lookup on each request
14:17justin_smith(or whatever you name your handler / app arg, of course)
14:17weavejes_justin_smith: I believe Lein-Ring already does that, and a var wouldn't work in the project.clj file anyway.
14:17justin_smithahh, OK
14:17justin_smiththen I don't know why he's not seeing a reload
14:19l1xhttps://www.irccloud.com/pastebin/rmxELREf
14:19l1xjustin_smith: what do you think about this ^
14:20justin_smithl1x: you should provide the type for the array
14:20justin_smith(into-array String topics) iirc
14:20l1xohh
14:20l1xyes you are right
14:21justin_smithit won't match the method def if the type is wrong
14:21justin_smithI mean if the first arg is a string, it will be automatic
14:21justin_smithbut might as well be explicit when you can
14:22l1xwell, i want to be explicit
14:22l1xi guess
14:22l1xis there an easy way to list all of the elements in the java array?
14:23justin_smith(into [] a)
14:23justin_smith,(into [] (.getBytes "hello"))
14:23clojurebot[104 101 108 108 111]
14:26l1xgreat you can also map .toString on each iteam
14:26justin_smithsure
14:26l1xhttps://www.irccloud.com/pastebin/DeTN7PHb
14:27justin_smith(into-array String (map str args))
14:27l1xi need to check for nil though
14:27l1xcause (fn 1) works and than & b is nil afaik
14:27justin_smithjust use str, str is .toString plus smart nil handling
14:28l1xi mean before i call the java method
14:28justin_smithand the String declaration in the into-array will make sure it is the right type, even if empty
14:28l1xcool
14:28justin_smiththat's what I mean
14:28justin_smith(into-array String (map str args))
14:37l1xthanks Justin!
14:37l1xhttps://gist.github.com/l1x/d8af14720ddb8d19a313
14:37l1xthis is the last thing i cannot explain
14:37l1xi supply the props
14:37l1xand it says it does not know the supplied params
14:37l1xi suspect i need to import one class
14:38l1xhttps://apache.googlesource.com/kafka/+/0.8.2.1/clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerConfig.java
14:40justin_smithl1x: as in, make sure the class's static initializers get run?
15:11mmitchellI can get reload to work with embedded-jetty! Wonder why jetty doesn't see my changes when running through "lein-ring ring server" and reloading namespaces + restarting the System
15:32l1xjustin_smith: not sure how to do that
15:32justin_smithI think that, currently at least, importing does the initializations
15:32justin_smiththough something about this may have changed with one of the recent 1.7 releases? it rings a bell.
15:33l1xthanks, just import it?
15:33l1xok i try that
15:34amalloywell, referring to a class at all causes it to be loaded, which causes its initializers to be run
15:34amalloyimport refers to a class, but it's not the only way to do so; you could probably just write the qualified classname as a single top-level form if you wanted
15:34l1xthanks amalloy this might be the problem
15:35justin_smithOh, OK. I thought there was some bug (affecting javafx iirc?) where the fix was not running the initializers on import.
15:35justin_smithI may be confusing something about this.
15:36amalloyi think there are some libraries (probably javafx) where loading the classes too soon causes disasters
15:36amalloyyou can't avoid running initializers when you import, so the solution is to not import, but load the class via reflection once you're actually ready to use it
15:37justin_smithamalloy: hmm... maybe I am remembering an unmerged patch from jira that affected how import works
15:37l1x [org.apache.kafka.clients.consumer KafkaConsumer Consumer ConsumerConfig ]
15:37cemerickIs there an emacs incantation that will keep *nrepl-server XXX* buffers pinned to the bottom, unless I scroll away from it?
15:38l1xthis is what i got in my namespace
15:38amalloymaybe. i haven't heard of such a thing, so it sounds like you know better than i
15:38l1xbut it still does not understand the config
15:38l1xdoes the order matter?
15:39justin_smithcemerick: there is auto-revert-tail-mode for files that are changing on disk
15:39justin_smithcemerick: maybe there is something similar for process buffers...
15:39cemerickjustin_smith: yeah, "this buffer is not visiting a file"
15:39justin_smith(setq comint-scroll-to-bottom-on-input t) if cider uses comint
15:40justin_smithI forget if cider uses comint or not
15:41cemerickappears not :-P
15:41cemerickjustin_smith: thanks for the suggestions :-)
15:41amalloyl1x: why do you think this has anything to do with class initializers?
15:42justin_smithcemerick: can't hurt to try the "output" version too
15:42justin_smithit may be opposite of the java concepts of in/out
15:42justin_smithwould not surprise me
15:42cemerickheh
15:42cemerickno luck
15:42justin_smithamalloy: the source he linked to showed a class with static initializers to set up config
15:43cemerickI'll live. Could just start the REPL elsewhere, I suppose
15:44justin_smithcemerick: you could put a hook on cider-repl-emit-output
15:45cemerickjustin_smith: Probably more elisping than I'm up for; would need to check if point was at the end of the buffer, etc. I'd probably have to look up what (interactive) means *again*, etc.
15:46cemerickI'm sure there's-a-package-for-that
15:46justin_smithchecking out the source, they derive cider-repl-mode from fundamental-mode
15:46justin_smiththere are so many nice free things to be had if you use comint or something instead...
15:54l1xamalloy: i am not sure
15:54l1xthe java version works perfectly
15:59mmitchellweavejester: have you been able to get tools.namespace to reload namespaces, then restart a Component System and see the changes in the server? I can only get it to work if I use the ring-jetty-component library. Which means restarting jetty when refreshing my app.
15:59mmitchelloops, i mean get it all to work under "lein ring server"?
16:00weavejestermmitchell: I'm not sure I understand. How are you using "lein ring server" together with components? I can't think of an obvious way they could be connected.
16:01arohnermmitchell: weavejester: you can make it work if you define {:ring {:handler}} to be the handler created by component
16:02arohnerand your handler is reloadable
16:02arohnerbut ofc, jetty doesn't restart
16:02mmitchellyes ^^ exactly
16:02mmitchellah, so jetty must restart then?
16:02weavejesterSo you have a "wrapper" handler that points to the handler created by the component?
16:02mmitchellyes something like that
16:03arohnermmitchell: restarting jetty isn't necessary, but it is nice. I prefer to just start jetty myself
16:03arohnerbut in production, using beanstalk, I do:
16:03arohner(alter-var-root #'system (fn [_] (com/start (new-system options)))) (alter-var-root #'ring-handler (constantly (-> system :app :app)))
16:03weavejesterTBH the idea of using "lein ring server" together with components is kinda odd. You have to make a wrapper to make it work, and I don't see what benefit it would have otherwise.
16:04arohnerthen project.clj {:ring {:handler rasterize.system/ring-handler}}
16:04justin_smithit's really not hard to just use run-jetty
16:04mmitchellarohner: yeah that's the same thing i do
16:04arohnerweavejester: yeah, I'd prefer not to need it, but it's required by lein-beanstalk
16:04arohneror rather, uberwar
16:05weavejesterarohner: Oh, right, that's because it's generating a servlet. I can see how that would be tricky to reconcile with the component model.
16:05justin_smitharohner: you can use lein ring to make an uberwar and run-jetty from -main
16:05justin_smithbecause the uberwar will not get -main called
16:06arohnerjustin_smith: AWS beanstalk "requires" a .war, and runs inside of tomcat
16:06weavejestermmitchell: Anyway, it depends on how you're referencing the component handler.
16:06justin_smitharohner: right, I am saying you can still run without lein ring locally, during dev, when things like reloading actually matter
16:06weavejestermmitchell: Lein-Ring watches for changes to files, then reloads those files and all dependant ones.
16:06arohnerjustin_smith: yep, I do that
16:07weavejestermmitchell: So you need to make sure that reloading your handler namespace recreates your component
16:07arohnermmitchell: I have a ring middleware for reloading: https://gist.github.com/arohner/c5e0fa45229c408301e2
16:08arohnerreloading the handler, that is
16:08arohnerotherwise I just restart the system
16:08mmitchellarohner: and jetty too?
16:08arohnerin dev, I start jetty as part of the system
16:08mmitchellweavejester: ok thanks, i'll keep that in mind and have another crack at it
16:08mmitchellarohner: ah ok, that is actually working for me too now
16:08weavejestermmitchell: Are you using lein-ring to create uberwars?
16:08mmitchellyes
16:09mmitchellworks great
16:09weavejesterAh, okay
16:09mmitchellcouldn't live without lein ring uberwar
16:09mmitchell:)
16:09arohnernow I just wish it were easier to use jetty w/ beanstalk
16:09weavejesterThat's good to know. Fortunately these days I don't need to work with servlet containers :)
16:10mmitchelllucky you! i've been thinking about trying out http-kit, haven't yet had the time though
16:11justin_smithmmitchell: it's pretty straightforward - though you might want to manage some things like startup / shutdown / log rotation that the containers do for you
16:12mmitchelljustin_smith: good points
16:36mmitchellso weavejester, I think the problem comes down to lein-ring-server and (clojure.tools.namespace.repl/refresh). It's like the handler link link gets permanently broken when refresh is called.
16:36mmitchelleven though in the repl I can call my handler and it works
16:48weavejestermmitchell: I'd honestly have to see how you've created your handler component wrapper to tell
16:48mmitchellweavejester: yeah for sure! sorry, not providing enough details here. I'll see if I can extract the meaningful bits sometime
16:49weavejestermmitchell: Have you excluded your handler wrapper from the refresh function?
16:51mmitchellweavejester: no I haven't. that may be why i'm having the problem
16:53weavejestermmitchell: If you're removing the handler namespace altogether, maybe that's causing the problem. Under a normal reload the var would just be updated/replaced, but refresh blanks the slate.
16:53weavejestermmitchell: So you want a namespace that contains a handler that points to your component
16:53l1xamalloy:
16:53mmitchellweavejester: yeah makes sense. I bet that's it
16:53mmitchellwill try
16:53l1xi was wondering what is the difference
16:53l1xfound this
16:53l1xpublic KafkaConsumer(Properties properties, ConsumerRebalanceCallback callback, Deserializer<K> keyDeserializer, Deserializer<V> valueDeserializer) {
16:53weavejestermmitchell: And then use (disable-unload!) or (disable-reload!) to stop refresh from clearing that namespace
16:54l1xand try to go through calling each by hand
17:20gfredericksso I'm thinking of adding a test.chuck thing for asserting that a generator generates an x such that (pred x) "often enough"
17:20gfredericksand I'm not sure if there's a way to do this without generating noisy false failures
17:21gfrederickslike if I set it to only fail if p<0.0001, is the test still useful?
17:22arrdemI can't see how this would be useful TBH
17:23arrdemI mean I see how a generator which can only generate an interesting coverage case with P(0.0001) is useless..
17:23arrdembut trying to ensure that your generators are "meaningful" seems problematic
17:25arrdemI suppose this opens up the entire category of meta-tests...
17:26gfrederickswait maybe I miscommunicated
17:26gfrederickswhat did you mean by "interesting coverage case"?
17:27gfredericksI'm saying the test only fails if it's 99.99% sure that (pred x) is not true often enough
17:27l1xamalloy: nevermind i am able to reproduce the problem in Java
17:34hiredmanI have in the past written tests, typically for concurrent stuff, which I wanted to express things like a tendency of results to be in a certain order
17:35sandbagscljx is stabbing me right through the eye
17:35sandbagsis native support for clj/cljs coming soon?
17:36hiredmanto test code that pulls things from queues, and the queues have weights so the results should tend to be sorted by what queue the input came in on
17:42hiredmanI think what I ended up doing for that test was doing some number of runs, taking the average positions of each item, and comparing the levenshtein distance between items in their average position and the sorted collection
17:43sandbagsanyone else using Cursive? One one machine I can load a cljx file into the REPL no problem, on the other I get "No reader function for tag +cljs". Supposedly same project on both machines.
17:43sandbagsi've had so many problems getting this project across to the other machine though, starting to lose the will to live
17:44arrdem##(read-string "#+cljs :foo")
17:44lazybotjava.lang.RuntimeException: No reader function for tag +cljs
17:44arrdem##*clojure-version*
17:44arrdem##(print *clojure-version*)
17:44lazybot⇒ {:major 1, :minor 7, :incremental 0, :qualifier alpha1}nil
17:44sandbagsarrdem: i guess what you are telling me is that help is not at hand on that front
17:45sandbagsmy searches for "No reader function for tag +cljs" have not been illuminating
17:45arrdemcfleming: ping
17:46arrdemsandbags: yeah that means that a version of Clojure without support for feature expressions is trying to read a feature expression form.
17:46arrdemsandbags: as reproduced above
17:46Bronsafeature expressions are not coming to clojure, the new proposal is about "feature conditionals"
17:46sandbagsarrdem: sorry, i understand what the error means ... what i do not understand is why i am seeing it in this case and not on the other machine
17:46sandbagswith the same version of IDEA, Cursive, CLJX, project etc...
17:47arrdemsandbags: Not a cursive guru, hence why I pinged cfleming, who may actually have a clue since he's the main cursive dev.
17:47sandbagson my laptop i am able to load .cljx sources into the REPL no problem
17:47sandbagsoh cool, thanks
17:48arrdemsandbags: my gut is that something (I have no idea what) is in fact different about your REPL setup, but I'll defer to cfleming as to what that could be.
17:48arrdemBronsa: yeah I've been watching that thread with interest.
17:48sandbagsarrdem: i'm with you on that
17:48sandbagsbut struggling to know where to look next
17:49arrdemTo ask the obvious question, is cursive at the same version on both machines?
17:49sandbagsmaybe i can tempt him an exception i just got in cursive :)
17:49sandbagshrmm... i think so
17:50sandbagsah
17:50sandbags0.1.48 on the working machine
17:50sandbags0.1.49 on the non-worky one
17:50sandbagsi wonder
17:50sandbagsi guess i should update the working one and see if it breaks
17:50sandbagsand then make myself very depressed
17:51arrdemspoken like a true engineer.
17:51arrdemhey at least you can send cfleming a bug report then :P
17:51sandbagswell i may be saved by the fact that IDEA doesn't seem to want to let me update it :)
17:55sandbagsdarn
17:55sandbagslooks like something changed in Cursive
17:55sandbags0.1.48 -> 0.1.49 and its b0rked on my laptop too
17:55sandbagsgreat
17:57sandbagsoh well, i secretly wanted to get back to playing Darkest Dungeon anyway
17:57sandbagsthanks arrdem
18:47l1xamalloy: i found the problem, it is on the java library side, there is something that is not implemented yet. it was just not obvious at the first sight. thanks for the hint
19:09creeseI'm getting "could not find or load class clojure.main" when I run the uberjar. What can cause this?
19:09justin_smithcreese: are you sure it's the uberjar? when uberjars are generated a regular jar is created too
19:10justin_smiththe uberjar will usually have "standalone" in the name
19:10creeseit does
19:14creesethe uberjar was built using 1.8 but is run from 1.7, could that be the cause?
19:16amalloycreese: i think you should paste the entire error message to refheap or something. don't make anyone debug from just a single line
19:16creeseI have the one line
19:17justin_smithno stack trace?
19:17creeseright
19:17justin_smithis clojure.jar inside the uberjar?
19:17justin_smithis clojure a dep your app declares?
19:18creeseof course
19:18justin_smithto both?
19:19creesewhat do you mean, both?
19:19justin_smithI asked two questions
19:19creeseyes to the 2nd
19:19justin_smiththe uberjar is a zip file, you can open it and see what is inside
19:19justin_smithemacs and vim can open it like a directory
19:22creeseclojure.jar is not inside when I unzip
19:22creeseI do see dir clojure/
19:28madalynnany one in here use cemerick friend? I had a question about how people use authorization or role aspect of friend. It seemed weird to me you should authorize something with a static variable like ::admin or ::user, since for example you can possible have 1000s of users and you only want users to see their specific information.
19:30justin_smithmadalynn: if it's per-user info, that isn't authroization, that's authentication (verifying who they are), friend has facilities for both
19:31madalynnjustin_smith the authentication just assocs an identity to the request. authorization checks the identity has a role
19:31madalynnfor example i can authorize as user then get rejected from an admin path
19:31justin_smithright, if nobody has special in-app priveledges, you don't care about authorization
19:31justin_smith::admin is for a role, not for differentiating a specific user
19:32madalynnjustin_smith understood, but lets say a user and my user id is 1, i want to be able to access pages that all users can access lets say a common user guide, but i also want to be able to access my particular profile
19:33madalynni can't wrap the profile path, lets say "/user/1" with ::user
19:33justin_smithmadalynn: I think the best choice there is to let "current user profile" be a single page, and let the authentication drive what the content is
19:33justin_smithand wrap that in an authenticated check, not an authorized check
19:34justin_smithand then "other user profile" would likely check authorization for showing certain data
19:36madalynnat justin_smith lets assume we have this very typical url layout /user/1/products or user/3/products
19:36madalynnand supages from there
19:36madalynnso user/3/products/wishlist and user/3/products/wishlist/2 certianly you can't make these single pages
19:37justin_smiththen use authentication + authorization, and offer certain options if the visitor is that user, or an admin
19:37justin_smithbut regardless, the keyword based stuff obviously only makes sense for checking generic roles, not specific users
19:37madalynni tried this once with friedn what i did was dynamically create roles so i would dynamically create a namespaced keyword ::user/1 and then i would say (derive ::user/1 ::user)
19:38justin_smitha unique role for every user sounds like a terrible idea to me
19:38justin_smithwhy not just compare an id in the session or something?
19:40madalynnjustin_smith, thats essentially what i'm doing, but as far as i see it this was the only way i could do it using the friend framework. i was just wondering if anyone else had a similar use case. all my roles were dynamically generated based on variables in the requesting url
19:40madalynnjust trying to see what others thought
19:43justin_smithI don't think friend is even meant for that kind of fine grained stuff. I would use the authentication to get the proper user id and user data, and use that id and data in checks (wrapping them also in an authenticated requirement)
19:45madalynnjustin_smith i think essentially you just confirmed what i was thinking, that the use case for friend did not fit my use case. at the time i spent a lot of time struggling to make it work..
19:49cflemingsandbags: Sorry, was afk there
19:49cflemingarrdem: pong
19:52creesejustin_smith: I think it's a problem with my project.clj
19:57creesebut only the version changed
20:00creesehttps://www.refheap.com/98430
20:01creesehttps://www.refheap.com/98431
20:28sandbagscfleming: hi, i sent you some details via pm
20:29cflemingsandbags: Thanks. In 0.1.49 I upgraded the bundled leiningen to 2.5.1, which I suspect is the cause of this, although I'm not sure why.
20:30cflemingsandbags: Which version of lein do you use on the command line?
20:30sandbags2.5.1
20:31cflemingOk, if you start a REPL with lein repl :headless, and connect to it from Cursive using a Remote REPL, does that work?
20:31cflemingBTW I haven't received anything via pm, but I saw the conversation with arrdem earlier.
20:31sandbagsodd
20:32sandbagsi've not been on IRC for a bit so maybe its nickserv related
22:13casionreminder guys
22:13casionhttp://bedroomproducersblog.com/2015/03/13/get-uvi-digital-synsations-for-free-199-regular-price/
22:14casionwrong window. sorry.