#clojure logs

2014-09-16

00:50gzmaskhello guys, what is the clj-http translation of "curl -s https://aaa.com -d "a=b&c=d" ?
00:52justin_smith(client/post "https://aaa.com" {:form-params {"a" "b", "c" "d"}})
00:53justin_smithalso, example.com is the canonical filler url
00:57gzmaskthanks justin_smith. but paypal doesn't think they are the same :(
01:02dbaschgzmask: the user agent obviously is not the same. Does it work with curl and not clj-http?
01:03gzmaskyes, it worked with curl, but gives RESPMSG=User authentication failed for clj-http
01:04dbaschwhat if you do (client/post "https://aaa.com" {:form-params {:a “b” :c “d”}})
01:05gzmasksame error. I tried the query-params, no luck either.
01:06gzmaskit's escaping my "!" char to "%21" . now sure if this cause the error
01:13gzmaskIt did cause the error!! Why in the world would you change ! to %21 ....
02:16ciszaHi guys
02:17seangonehi cisza !
02:27raspasovhello
02:27noncomhi
02:28ciszawhat's up guys?
02:29raspasovcoding :)
02:29seangonetends to be quiet in here at night US time :)
02:29raspasovyea
02:29raspasovI'm SFF
02:29raspasovSF*
02:29seangoneI'm off to The Strange Loop in a few hours...
02:30raspasovyea? nice
02:31seangonePowered by JavaScript too... should be fun...
02:31raspasovwhat do you mean powered by JavaScript? :)
02:32seangoneManning's one day three track conference the day before Strange Loop
02:32raspasovah I see
02:32seangonehttp://www.manning.com/poweredbyjavascript/
02:32raspasovany ClojureScript in that?
02:32seangonethere's a bunch of pre-conference stuff... workshops, future of programming, and pbj :)
02:33seangoneI was hoping there would be some compile-to-JS stuff but there doesn't seem to be
02:33seangoneI'm interested in React.js and stuff like that tho'...
02:33raspasovyea React is good
02:45clj-learnerhi, im trying to solve http://www.4clojure.com/problem/82 and having difficulty, this seems like it can be solved with graph theory(?) could someone point me to a tutorial to be able solve this?
02:51averellit would be possible. you make edges between words where the distance is 1, then find a hamilton-path (that is a path of all nodes). Pretty sure it's overkill for this though.
02:52amalloyheh, looking back at my solution to that problem it's not actually correct
02:52clj-learnerso how would i solve it?
02:52averelldo you have distance already? just try all combos
02:53clj-learnerdistance?
02:53averelli mean, something to decide if the words are "similar enough"
02:53amalloyor, i dunno, maybe it does. the flaw i thought i saw in my algorithm is exercised by the tests
02:54averelldid you do something clever?
02:54clj-learneri did this (fn chain? [s1 s2] (= (inc (count s1))
02:54clj-learner (count (union (set s1) (set s2)))))
02:55averellok, that's not enough though
02:56amalloyi'm not sure. i compute the degree of each node, and then i assert that there are are at most two nodes with degree less than two. that certainly doesn't sound sufficient to me
02:56amalloyseems like i should fail on '(sit sat sot dog)
02:56averellah, that's for euler-path i think :)
02:57amalloyaverell: well it's not really sufficient in either case, because of disjoint subgraphs
02:57clj-learneri think this is probably too much for me, ill just pass this one for now
02:57clj-learneri dont know graph theory
02:57averelloh right
02:57clj-learnerat least i completed all other 81
02:57averellnice
02:57clj-learnerthanks for the help
02:59dbaschclj-learner: you want to find a Hamiltonian path
03:06dbaschamalloy: even with connected subgraphs it's still not sufficient
03:06amalloyindeed, it's quite wrong in a lot of ways
03:07dbaschthat problem should have test cases that forced you to solve it right
03:08amalloydbasch: of course. but it's easy to miss edge cases; 4clojure is littered with such problems
03:08dbaschamalloy: for that one it's not hard, just create a couple of evil graphs
03:09dbasche.g. a fork and a join
03:10amalloybut that entails thinking of all the hard cases that someone might incorrectly identify with a wonky algorithm. you say "not hard", but of course it's impossible to find a set of inputs that causes only correct algorithms to pass
03:10amalloyif nothing else, the standard 4clojure cheat of mapping each input test case directly to its output will always work
03:10averellthere certainly are drawbacks to posting all test-cases :)
03:11amalloy*shrug* i don't think so, averell. you only cheat yourself when you cheat a 4clojure problem. if that's what gives you satisfaction, feel free. i don't see that as a drawback
03:12amalloyand it drastically improves the user experience for the actual target market, ie people trying to learn clojure. imagine "you passed all the test cases you can see, but there's an input i won't tell you about that breaks your program"
03:12averellhm true. but i have poor self-control...
03:13amalloythere certainly are drawbacks to having no self control
03:13averellobviously a problem that should be solved externally.
03:16dbaschamalloy: yeah, I was just thinking of cases that would force you to either cheat or try to solve the Hamiltonian path problem
03:19dbaschyou also learn by breaking other people's solutions :P
03:23dbaschI ran into some code that goes (defn foo ^String [^bytes x] ….)
03:24dbaschI have no idea what's the intended purpose of ^String there
03:41cdr_Hey :)
04:01SagiCZ1~lazy-logs
04:01clojurebotlazy-logs is http://logs.lazybot.org/
04:12cdr_Soo... does some1 chat here ?
04:12cdr_Or just come online and leave ?
04:13TEttingerwhen people have questions they usually get answered, cdr_
04:13cdr_Ohh, thanks :)
04:13TEttingerthis is more of a quiet time since most of the US-based people are asleep
04:14cdr_Ohh... i am from EU, so this is morning for me :D
04:16maxthoursieThere's a bunch of EU ppl here too
04:18hyPiRionIt's usually silent until about 2-4pm EU time, but it varies
04:57ssiderisEU-based and present! (but yes, usually silent)
05:07yotsovIf I want to build a clojure webapp with some ajax-like functionality but without clojurescript, are there tools that would be recommended?
05:14perplexado people use System/getenv or weavejester/environ?
05:41ddellacosta_perplexa: I like environ, personally
05:42ddellacosta_yotsov: the backend wouldn't change (from a typical Clojure web app), and the front-end would be whatever non-CLJS thing you wanted...what are you asking about in particular though? I'm not sure I understand.
05:50yotsovddellacosta_: just wondering if there are things known to work together with examples out there, such as a particular js ajax framework with a particular clojure lib on server side...
05:52ddellacosta_yotsov: well, based on my experience with Om, I can tell you that using React with an immutable data structure lib like Mori and a Clojure backend could be a good fit
05:52ddellacosta_yotsov: but I will sell ClojureScript a bit--it's quite nice, seriously. :-)
05:54yotsovddellacosta_: thanks. Do you think cljs makes sense even for just like 2 very small ajax-ish features? It would not feel like an overkill?
05:55ddellacosta_yotsov: I mean, no, but I use it every day and find it to be "no big deal." Have you done much CLJS?
05:56ddellacosta_yotsov: for example, take a look here for something very simple to set up and get going: http://swannodette.github.io/2013/10/27/the-essence-of-clojurescript/
05:56ddellacosta_yotsov: apologies if you're beyond that
05:56borkdudeCLJS makes me less afraid of javascript.
05:56ddellacosta_borkdude: ha, never thought of that, but I think that's true for me too
05:57ddellacosta_it also makes me more aware of JS's idiosyncracies
05:59borkdudeActually I find it quite fun to write front end code now.
05:59borkdudealthough I haven't really got much experience with javascript
06:00yotsovddellacosta_: I am not very familiar with cljs, have just played with it a bit (hello world, a bit of Om). I wanted to postpone learning it, as I have a lot going on right now. But, interestingly enough, it seems that for clojure+ajax it is pretty much the easiest way to start, due to the sheer amount of examples out there
06:01borkdudeyotsov ajax, look at cljs-http and channels
06:01ddellacosta_yotsov: yeah, I would say that it's actually easier in terms of the "impedance mismatch" to get CLJS + CLJ working vs. Clojure and JS
06:01borkdudeit's also lots easier to just be able to send edn back and forth
06:02borkdudehaven't tried Transit though
06:05yotsovborkdude: If I go the cljs road, I hope to be able to do without channels, just with Om. I actually still have hard time understanding how people mix the two
06:06yotsovto me it sounds a bit contradictory, basically injecting mutability into something immutable
06:06borkdudeyotsov you can also just use a callback, but working with channels and asynchronous is really nice, because you have the illusion that they work synchronously
06:06borkdude*requests
06:07borkdudeyotsov the combination ajax+channels is something apart from Om
06:08yotsovborkdude: yes, but it seems to be in fashion to use both channels and Om, which confuses me
06:08borkdudeyotsov You can use channels with Om to communicate changes to components, like: the request has finished and here are the results, now update yourself
06:09borkdudeor: update the app state, or whatever
06:09borkdudeyotsov in this way you can decouple logic from components
06:09yotsovwouldn't you rather send the full state of the page to Om then, which would then update just the necessary component?
06:09yotsovI see
06:10borkdudeyotsov to "send the full state" you would first have to update it
06:11borkdudefor example, I have a function: lookup-items. Its parameter is a channel. It doesn't know where it sends the results, but the component that reads from the channel knows that it should update the app state when something arrives there.
06:11yotsovborkdude: in my case, the webapp is fairly simple, and I can have everything the user sees at any point of time in just one data structure. In that case Om is enough and I do not need channels, right?
06:12borkdudeyotsov you can do everything in one giant component and avoid channels
06:12yotsovborkdude: got it, thanks
06:13ddellacosta_yotsov: actually Om *without* channels is a major mess and a pain in the ass, basically impossible if you ask me.
06:13ddellacosta_yotsov: no way to effectively communicate back up the component hierarchy
06:13borkdudeyotsov ddellacosta_ communication upwards happens through channels or handlers
06:14ddellacosta_borkdude: yeah, I find using a lot of handlers is more frustrating
06:14ddellacosta_...thank channels
06:14ddellacosta_than*
06:14borkdudeyotsov ddellacosta_ but if you have just a small app and every part has access to the whole app-state, you can do without. That's what I meant with "giant"
06:15ddellacosta_borkdude: sure, fair enough--if you don't have a deep component stack it's fine, it becomes tricky when you have complicated UI interactions
06:15borkdudeddellacosta_ yeah
06:15yotsovborkdude ddellacosta_ I think handlers should be fine for me
06:16ddellacosta_yotsov: give it a shot, just keep in mind that channels really do help out once communication gets complex--if you find yourself swearing about passing state around, come back and talk to us. ;-)
06:17borkdudeddellacosta_ I actually found having many channels wiring component to each other can get complex too. I am now using just one channel and a pub/sub mechanism to keep it simple, where I can, unless the communication is very local.
06:17ddellacosta_borkdude: that's a fair point. I have a few components with like six channels, and that really is not nice to keep track of. I guess there's a sweet spot with a few channels.
06:18ddellacosta_borkdude: I need to look into something like your pub/sub mechanism, it's become pretty obvious we need something like that to alleviate the pressure in a few spots
06:18ddellacosta_"complexity pressure" so to speak
06:18yotsovborkdude ddellacosta_ thanks guys, I think I see a bit more clearly now. Can you recommend a sample Om webapp that uses handlers rather than channels?
06:18borkdudeddellacosta_ yotsov http://yobriefca.se/blog/2014/06/04/publish-and-subscribe-with-core-dot-asyncs-pub-and-sub/
06:19ddellacosta_borkdude: nice, thanks
06:19cityspirityotsov: you could also look at luminus with reagent. with the +cljs option you'll get a template with an example built in. I found that a really easy way to get started with simple clojure app with a clojurescript + react frontend.
06:19ddellacosta_borkdude: oh, but that has no Om, sad. Well, still, good tip
06:20ddellacosta_(we're using pub/sub elsewhere not just with Om yet)
06:20borkdudeddellacosta_ in Om I have two channels in global state: one event-ch to write to and one event-publication to subscribe to.
06:20borkdudeddellacosta_ the rest is very easy to figure out, once you read the blog post
06:20ddellacosta_borkdude: and then if a child component needs to talk to a parent, the parent just listens on that topic basically, right?
06:20ddellacosta_...and child sends on that topic? That could work really well, hmm
06:21borkdudeddellacosta_ that's what I meant with "local", if it's just a parent-child relationship, I will sometimes still use a dedicated channel, but you could do it with pub sub also
06:21ddellacosta_borkdude: gotcha
06:22ddellacosta_that along with shared data is our biggest problem
06:22borkdudeddellacosta_ shared data?
06:23ddellacosta_borkdude: yeah, if you have a bit of data that needs to be used in child components pretty deep in the stack. I have used shared a bit, but it doesn't seem to update in the way I need it to--so I end up putting stuff in state or app data
06:23borkdudeddellacosta_ you can also use pub sub for this
06:24ddellacosta_borkdude: well, but then I have to manage updates myself somehow
06:24borkdudein IWillMount you put a go loop that reads from the subscription
06:24ddellacosta_borkdude: I want to leverage React/Om's update mechanisms as much as possible
06:25borkdudeddellacosta_ it depends on what the data is. it could be something worthy of the app-state
06:25yotsovOm examples without core.async seem to be as common as clojure ajax examples without cljs :) I guess I should not try kicking against the pricks and go with Om + core.async channels...
06:25ddellacosta_borkdude: that's the thing, it usually is--it's just not in the right form, or it needs to be referenced deep in the hierarchy, so a child has to have a copy of something that has effectively been "stirpped out" by that point
06:25ddellacosta_*stripped
06:25borkdudeddellacosta_ if you do a go loop in will-mount that reads from the right subscription and updates it's local state, the component will re-render
06:26ddellacosta_borkdude: yeah, but again, I don't want to have to do that--I do stuff like that now
06:27borkdudeddellacosta_ then pass it down the hierarchy with state. I don't know other options so far, sorry. My time with Om has been limited to a few weeks now :)
06:27ddellacosta_borkdude: no, we do that too...again, though, it is usually app data that we are abusing. I do like to keep state and app data appropriately separate.
06:27ddellacosta_borkdude: I mean, yeah, everything you're suggesting makes sense, I think this is a limitation in Om right now is all
06:28borkdudeddellacosta_ actually, I'm rewriting an app now that "abused" the app state to store component state
06:28ddellacosta_ha
06:28ddellacosta_"Abusing State for Fun and Profit with Om," my new ebook
06:28borkdudeddellacosta_ in order to make components re-usable, it should not depend on the app state too much
06:28yotsovddellacosta_ borkdude there are several alternatives to Om for using react.js. Are you guys familiar with them? Is any of them simpler than Om and making using core.async more optional?
06:29ddellacosta_yotsov: a lot of folks seem to like reagent, and say it is simpler, per what cityspirit was saying above
06:29borkdudeyotsov I hear reagent is simpler, but I don't know its limitations, my only experience is with Om really
06:30yotsovborkdude: ddellacosta_: thank you!
06:31ddellacosta_yotsov: my sense is that it's easier to get going but (this is a guess, I don't know for sure) harder to build out bigger systems with--Om's rigidity also helps enforce some good practices, not withstanding its weak points
06:31ddellacosta_...which makes it easier to build big complex web apps (as we have done)
06:32ddellacosta_but again, that's not really fair to reagent, since I have barely touched it; it could be equally good, I need to give it a shot
06:32borkdudeddellacosta_ is what you want a shared local state between parent and childs?
06:32yotsovddellacosta_: thanks. I need to build just a small demo that will never become more than that
06:32ddellacosta_borkdude: no, I basically want to be able to restructure app data and re-attach things at various points/drop new cursors in at various points
06:33ddellacosta_re-attach things = re-attach different pieces of app data
06:34ddellacosta_maybe shared can do it, but my recent experiences suggest it doesn't update as predictably as I need it to, not like app-data/state
06:34borkdudeso for example, app-state: {:foo {:bar :baz}}, parent component has cursor too app-state, child component gets cursor into :bar, but his child component needs :foo again?
06:38ddellacosta_borkdude: (assuming app-state in your example is app data, not component local state, to be clear)
06:38borkdudeddellacosta_ yes
06:38ddellacosta_borkdude: yeah, or more like I have {:foo [{:id 1 ...}{:id 2 ...}] :bar [...other relevant data...]} and I use build-all on :foo, and I need :bar also in each :foo
06:39borkdudeI'm guessing that is not how react works: you can't re-render a child without re-rendering the parent maybe?
06:39ddellacosta_borkdude: no, you can totally re-render a child without re-rendering the parent...if your data is structured correctly
06:40ddellacosta_borkdude: that's the point of the virtual DOM really
06:40borkdudeddellacosta_ ok, could be, I don't know :)
06:40ddellacosta_borkdude: well, if you've only been using it a few weeks, then I'm still impressed with your knowledge of Om. ;-)
06:40borkdudeddellacosta_ I've been asking a lot of dumb questions in #clojurescript ;)
06:41ddellacosta_borkdude: jeez, I should be hanging out there, I'm never in there
06:47borkdudeddellacosta_ so basically, the whole parent-child structure makes no sense in re-rendering. Each component should just be able to pick what to subscribe to in the app-state?
06:47ddellacosta_borkdude: no, it totally makes sense I think--it's just that I want to be able to restructure the data itself, or pass different bits around so they are reintegrated later, at certain points in the component hierarchy. I find this hard to do now in Om.
06:47borkdudeddellacosta_ you can just pass (dissoc cursor :foo :bar) to the components, but probably that's not what you want either
06:47ddellacosta_borkdude: well, but what if I want those things later on down the chain?
06:47borkdudeddellacosta_ oops, I mean the opposite of dissoc, only select those two keys
06:47yocapybaraany emacs/cider whizzes here? I'm finding I'm working in a certain way and it feels like it isn't optimal, just wanted to check with others whether they do a similar thing or if they (as I suspect) do something much smarter
06:48ddellacosta_borkdude: oh, yeah, but again--what about all the stuff it's leaving off, and what if it's a build-all?
06:48ddellacosta_yocapybara: I've gone back and forth between cider and just having a repl open w/emacs separate
06:48borkdudeddellacosta_ often I don't use build-all, but just map
06:49ddellacosta_borkdude: to be fair, that's all build-all is
06:49borkdude(map #(om/build ... cursor {:opts {:foo %)}) [1 2 3 4])
06:49ddellacosta_yocapybara: sorry, not a super useful answer. Some folks I know are really brilliant with loading and running stuff in cider, but I think it takes some practice. :-/
06:50ddellacosta_borkdude: opts means it's not going to trigger a re-render though.
06:50borkdudeddellacosta_ it's not the same, because in my map example the children get acces to the whole cursor
06:50ddellacosta_borkdude: yeah, I mean, that's one solution
06:50borkdudeddellacosta_ yeah, whatever, could be :state as well :)
06:51ddellacosta_borkdude: it's tough though, if you want to build individual elements and take advantage of keys and whatnot
06:51yocapybaraddellacosta_: any info is useful man, thanks! I'm finding that I copy or (C-c M-p) each expression into the REPL buffer so I can play around with my code, if I execute an expression it doesn't seem to be executed in the actual repl buffer even if I've got one running. I feel like I'm missing something about how it works - like there should be a very easy way to issue a command to have the REPL run all the expressions in
06:51yocapybara my buffer.
06:51yocapybaraI've had good luck with lighttable but I wanted to give emacs/cider a proper go
06:52borkdudeddellacosta_ I think we need concrete cases to talk about.
06:53borkdudeddellacosta_ but I'm very interested, because these are the problems I also deal with \
06:55apodyocapybara: you probably need to switch the namespace, try C-c M-n
06:55ddellacosta_borkdude: yeah, I'm probably not explaining it well, sorry. I have to put some solid examples together that really expose these confusing points, 'cause I run into them a lot day-to-day
06:57apodyocapybara: to evaluate the buffer C-c C-k
06:59yocapybaraapod: thanks, this is exactly what I was missing and I hadn't put the pieces together - have just tried it and that's doing exactly what I was missing
07:00yocapybaraapod: thanks loads :)
07:00apodyocapybara: also you can evaluate an expression under the point with C-c C-e (or C-c C-c to evaluate the top level form under point) and see the result on the minibuffer
07:03yocapybaraapod: thanks also for that - I was doing that but I think perhaps due to not switching the namespace it seemed like anything I had previously executed with C-c C-e wasn't accessible. But having switched the namespace all clicks into place. I should have realised but didn't. Thanks! :) closer to clojure nirvana
07:05yotsovddellacosta_: borkdude: my first attempt will be to use this approach https://github.com/yogthos/reagent-example (corresponding blog post http://getprismatic.com/story/1405451329953 ), It looks so simple and accessible and great that I got high on adrenaline+endorphin combo like in my early clojure days :)
07:06ddellacosta_yotsov: awesome, whatever keeps the enthusiasm going. :-)
07:06borkdudeyotsov :)
07:45lvhIn clojure.test, how do I test multiple predicates, but retain useful error messages?
07:46lvhcurrently I'm doing (and (p? example) (q? example)) which results in totally useless error messages :(
07:56hyPiRionlvh: I usually `(do (is (p? example)) (is (q? example)))`
07:56hyPiRionat least then you know which one failed
09:09piranhaI wonder if anybody has some code to generate simplest documentation for a liberator-based API? It seems there are no ready tools for that so I'll have to invent something...
09:20CookedGryphonwhat's the best way to do distinct? on a collection?
09:20CookedGryphonwhere the collection might be empty
09:20CookedGryphonbest I can come up with so far is (apply distinct? :unlikely/ham coll)
09:21CookedGryphonotherwise I get an error with empty collections and have to do a separate check
09:21TimMcFile a JIRA, wait, and sob.
09:22TimMcMourn for http://dev.clojure.org/jira/browse/CLJ-1179
09:22CookedGryphonffs
09:23TimMcsrsly
09:23TimMcIt's shit like this...
09:23justin_smith,(map (fnil #(apply distinct? %) [0]) (map seq [[] [:a] [:a :a] [:a :b :c]])) ; CookedGryphon
09:23clojurebot(true true false true)
09:24justin_smithunless you want (distinct? []) to be false, then change the last arg of fnil to [0 0]
09:25justin_smithsadly fnil only does its magic if the input is coerced via seq before you use it
09:29CookedGryphonjustin_smith: yeah, it's still a bit messy though
09:29CookedGryphonfeels a bit more professional than my :ham version :P
09:31justin_smith(defn distinctish? [& args] (or (empty? args) (apply distinct? args)))
09:31justin_smithanother option
09:32justin_smiththat's likely the clean one ... or (and args (apply distinct? args))
09:33CookedGryphonyeah, that's what I've done
09:33CookedGryphonjust defined the less stupid distinct? function
09:33dnolen_(defn distinct-coll [coll] (reduce (fn [s x] (if (contains? s x) (reduced false) (conj s x))) #{} coll))
09:34CookedGryphonIt would make some amount of sense if it errored out on one argument as well
09:34CookedGryphonbut apparently that's fine
09:36CookedGryphoncan anyone offer any sort of explanation as to why it would be undesirable behaviour to return true rather than explode?
09:37CookedGryphonone single example of where it's not correct behaviour to just return true for the zero arity version
09:37xemdetiaI don't think there is an opposing argument CookedGryphon
09:38xemdetiaif you have variable length arguments surely you must handle gracefully a case where no arguments are passed
09:38CookedGryphonsorry, not in here, but on the jira ticket linked earlier apparently the change was rejected by rich
09:39xemdetiadid anyone follow up with Rich?
09:39CookedGryphonnot sure, all I have is the info on the ticket http://dev.clojure.org/jira/browse/CLJ-1179
09:40xemdetiaI saw the ticket a while ago but it's clearly a sore point
09:40xemdetiathat's why I asked if anyone followed up
09:46dnolen_CookedGryphon: xemdetia: likely not considered that important, also there are other fns with the exact same "problem" i.e. =, <, etc.
09:47xemdetiaah
09:47CookedGryphondnolen_: I'm not sure it's as clear cut with = and <
09:47xemdetiastill I think it's one of those
09:48xemdetiavariable # arity functions should do something other then exceptions
09:48xemdetiawhen passed 0 args
09:48CookedGryphonthere's an equal argument for true and false with = and not=, it's undefined i would say...
09:48dnolen_CookedGryphon: anyways, clearly there are more nuances none which are in the ticket
09:55justin_smithxemdetia: what about / ?
09:55justin_smith,(/ 2)
09:55clojurebot1/2
09:55justin_smith,(/)
09:55clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core//>
09:55justin_smith,(/ 1 2 3) ; for good measure
09:55clojurebot1/6
09:56justin_smithI guess (/) could return NaN
09:56xemdetiajustin_smith, I wouldn't normally consider / a variable length argument
09:56justin_smithbut it is!
09:56xemdetiait is clearly :)
10:04xemdetiaI guess I have to adjust my expectation, but so I will reduce it to still believing vararity -? functions should handle a 0 case. A query against an empty set still should provide a meaningful result, even if it's NOSETSILLY
10:07CookedGryphonbut yeah, especially for distinct, it's really cut and dry. It currently does not perform the function described in its docstring "Returns true if no two of the arguments are =", point at the two arguments which are equal in (distinct?) and (distinct? 1)
10:11bjaI should start returning 'NOTSETSILLY instead of nil for the 0 case
10:11bjawith a link to this irc history
10:11TimMcdnolen_: I've never heard rhickey give nuance on tickets regarding base cases.
10:12TimMcI *have* to assume he just doesn't see the problem.
10:13dnolen_TimMc: I also don't see the problem unless there's some larger discussion about apply not working on empty collections.
10:13dnolen_for many fns.
10:13TimMcWhat do you mean?
10:13TimMc&(apply + [])
10:13TimMcOh, not apply, but the fns themselves.
10:14xemdetiawell it should be well-defined that it's going to error out so we don't have to point to some obscure Jira issue
10:14dnolen_,(apply = [])
10:14clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/=>
10:14dnolen_,(apply < [])
10:14clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/<>
10:15xemdetianumeric functions make sense to fail, I now reduce my argument to only predicate functions (-?)
10:15TimMcI don't think there's much to discuss -- base cases need to be defined unless there's a compelling reason not to. I mean it's a Lisp ffs. You'd think we'd get recursive base cases correct. :-/
10:16TimMcBut all I get from JIRA is... "nah".
10:16dnolen_xemdetia: they do not make sense to fail
10:16dnolen_,(apply + [])
10:16clojurebot0
10:16dnolen_,(apply * [])
10:16clojurebot1
10:17dnolen_people can keep pretending like there a simpler answer here
10:17dnolen_or just write distinct-coll? and move on
10:17TimMcTo the extent that there needs to be a larger discussion, it's "why do so many reasonable patches get rejected without comment?"
10:18justin_smithTimMc: meanwhile, Hickey is all like "let them eat transducers"
10:18TimMc(I am fine with comments like "we don't need that feature in core", that's a perfectly reasonable judgement call to make, even if I disagree sometimes.)
10:30mavbozoin leiningen :repl-options, the :ack-port is used for what?
10:31borkdudepiranha I have seen a presentation on someone who used Swagger in combination with Liberator. That might be interesting for you?
10:31piranhaborkdude: for sure!
10:31borkdudepiranha it was at Euroclojure 2014. The video might be up
10:31piranhaI'll look for that, thanks
10:32borkdudepiranha http://vimeo.com/100485830
10:32mavbozoi couldn't find the description for :ack-port in leiningen sample project here https://github.com/technomancy/leiningen/blob/master/sample.project.clj
10:32piranhaborkdude: thanks :)
10:32mavbozobut :ack-port is used in leiningen.repl
10:33corecode_hi
10:33corecode_i think i found a bug in 4clojure or clojail, but i'm new to clojure and might be wrong
10:34hyPiRionmavbozo: ack-port is used to decide which port the acknowledgement from the repl server is sent/received
10:34corecode_anybody like to indulge in following the issue?
10:34hyPiRionIt's then used to generate e.g. .nrepl-port and similar
10:34hyPiRion~anyone
10:34clojurebotanyone is anybody
10:34hyPiRion~anybody
10:34clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
10:34corecode_https://www.4clojure.com/problem/21 <- if you supply (fn [[h &t]] 1), it complains about nth being used
10:35corecode_hyPiRion: finger reflexes?
10:35borkdudepiranha sorry, no liberator in it, but still interesting ;)
10:35corecode_hyPiRion: did you read what i wrote before?
10:36tbaldridgecorecode_: yeah, I think the destructuring is calling nth
10:36corecode_tbaldridge: ah, not in my clojure
10:36tbaldridge,(macroexpand ,(let [[x y] (range 2)] x))
10:36clojurebot0
10:36tbaldridge,(macroexpand '(let [[x y] (range 2)] x))
10:36clojurebot(let* [vec__52 (range 2) x (clojure.core/nth vec__52 0 nil) y ...] x)
10:36hyPiRioncorecode_: right, just saying that people would reply if they know the answer :) It's not always easy to say "I'll help" if they don't know the problem
10:37tbaldridgecorecode_: see my example there, it is calling nth via the let macro. So 4clojure is probably mocking out nth to make sure you're not calling it. But you are, just via a macro
10:37corecode_hyPiRion: i think mindlessly doing the ~anybody is as bad as mindlessly asking such questions the bot refered to
10:37jcsimsI've got a friend who wants to participate in the clojure cup with me, but is not familiar with clojure (he's comfortable in haskell). Any recommendations for someone coming to clojure from haskell?
10:38corecode_tbaldridge: (macroexpand (read-string "(fn [[h & t]] h)"))
10:38corecode_(fn* ([p__978] (clojure.core/let [[h & t] p__978] h)))
10:38corecode_different clojure, i guess
10:38tbaldridgecorecode_: that only macro expands a single form, you'd want something like macro expand all.
10:38corecode_aha!
10:38corecode_thanks
10:38tbaldridgecorecode_: your let inside the fn hasn't been expanded to let*
10:39corecode_right
10:39piranhaborkdude: indeed, just watched slides. fnhouse-swagger is 54 lines, so maybe it won't be very hard to swaggerize my bidi + liberator setup...
10:41corecode_hyPiRion: wouldn't you agree?
10:42ncthom91hey y'all. Can I define a map literal where one of hte keys is a local variable?
10:43ncthom91{ my-var "val" } ?
10:43ncthom91oh nvm, that works :P
10:45hyPiRioncorecode_: I'm not saying it's bad to ask for help in that way, neither does the bot. It's just very common that new people ask "does anybody want to help me?", in which the reply rate is significantly lower than if you just ask the question itself
10:45mavbozohyPiRion: why leiningen.repl creates another nrepl-server just to handle ack replies from the nrepl-server it creates?
10:47hyPiRionmavbozo: No, it creates only a single nrepl-server. Let me see if I can explain
10:48mavbozohyPiRion: thanks
10:48corecode_hyPiRion: what i'm saying is that it is bad to type ~anybody as a reflex to seeing the word
10:49dbaschI saw this code: (defn foo ^String [^bytes x] ….) <- is there something I'm missing or the ^String does nothing?
10:49justin_smithdbasch: it means foo returns String right? or is that the wrong place for that metadata?
10:50dbaschjustin_smith: thst would be (defn ^String foo …)
10:50justin_smithin that case, I would guess it was a typo, and they were trying to do that
10:51dbaschjustin_smith: it's interesting that it compiles quietly
10:51hyPiRioncorecode_: Sure, but that wasn't what I did (or at least not what I was trying to convey). You asked if anybody wanted to indulge in the issue, which most people won't reply to
10:51justin_smithdbasch: well, it's not an error to add metadata to whatever silly thing you want to put it on
10:52justin_smithI guess that is putting metadata on the args vec?
10:52cocquecigruehas anyone ever had issues testing monger code in tests? I have a weird issue where when I run tests in the repl it works fine, the app itself works fine but when I use lein test it fails with nullpointerexception
10:53cocquecigruei use clojure.test
10:53justin_smithcocquecigrue: the first thing I would suspect is that you are using something like map, where the result is forced in the repl but not in your code
10:54dbaschjustin_smith: I suppose, but how would you even access that metadata?
10:54justin_smithdbasch: I don't think you could
10:54cocquecigruejustin_smith: what do you mean by map?
10:54cocquecigruewait a second I push my code to github
10:54justin_smithcocquecigrue: the function map, which is lazy, but will seem not to be lazy in the repl because the print stage forces the result
10:55justin_smithcocquecigrue: but yeah, push your code, that will help
10:55cocquecigruehttps://github.com/joelmarty/bonjour-compojure/blob/master/src/bonjour_compojure/database.clj
10:56cocquecigrueso the idea is to store the db object in an atom
10:56cocquecigruewhen I call the init function
10:56justin_smithcocquecigrue: why would (:mongo-host (io/resource "app.edn")) return anything but nil?
10:57justin_smithoh, sorry, "defconfig", I missed that
10:57cocquecigruethat's the first thing i looked into :)
10:58cocquecigrueyou can check the test in test/database
11:00justin_smithlist-empty? is oddly named
11:00justin_smithit tests the reverse of that, right?
11:01cocquecigrueI don't use that yet
11:01cocquecigrueso it doesn't really matter
11:01justin_smithwhy do you nest use-fixtures inside deftest?
11:01justin_smithI don't know if that works, but I have never used it that way
11:01justin_smithit works just fine as a top level form
11:01cocquecigruethat's how the doc says to use it
11:02justin_smithweird
11:02justin_smithI have only used it as a top level form, and it works
11:03cocquecigruewhen I use https://github.com/joelmarty/bonjour-compojure/blob/master/src/bonj
11:03cocquecigrueoops
11:03cocquecigruewhen I use clojure.test/run-tests 'namespace in the repl it works just fine
11:04cocquecigruebut when I use it through lein that fails because the atom that holds the db is nil
11:04cocquecigrueso I guess the issue is not from the test but from the interaction with lein
11:05cocquecigruemaybe it's related to my environment i don't know
11:05justin_smithcocquecigrue: use-fixtures is a side-effecting function that changes how all functions in an ns are run, putting it inside a test makes no sense
11:05cocquecigruehow would you use it?
11:05justin_smithit is global, it does not modify the current scoped test definition, it alters all tests in the ns
11:05cocquecigrueyou said to use it as a top form, what did you mean with that?
11:06justin_smith(use-fixtures :once f) will wrap all tests in one invocation of f
11:06justin_smithtop level means not inside any other definition
11:06cocquecigrueok
11:06justin_smithat the top level of the namespace
11:06justin_smithbecause it is a function that modifies the whole namespace
11:07justin_smithI think you would want (use-fixtures :each f) for your example
11:07cocquecigrueno I just want to create the db, run all the db-related tests and destroy it
11:07justin_smithOK
11:07cocquecigrueaaaaaaaaaaaah
11:08justin_smiththen yeah, :once is fine
11:08cocquecigrueand it works
11:08justin_smithright, I told you you were using use-fixtures wrong
11:08cocquecigrueI must have misunderstood the doc, thank you :)
11:08cocquecigruekudos
11:09nburtsevHello
11:09justin_smithhi
11:09nburtsevuser=> (defn test2 [] (prn "hello") (map (fn [[k v]] (prn k "-" v)) {:test "test" :test2 "test2"}) (when-not false (prn "hello2")))
11:09nburtsev#'user/test2
11:09nburtsevuser=> (test2)
11:09nburtsev"hello"
11:09nburtsev"hello2"
11:09nburtsevanyone knows why map is not running ?
11:09justin_smithmap is lazy
11:10agarman(doall ...
11:10justin_smithif you want it to run for side effects use dorun on it, or use doseq instead of map
11:10agarmanor that
11:10justin_smithagarman: doall is pointless if you are not using the return value
11:10justin_smithit just generates garbage
11:11justin_smithdoall is for when you need to force evaluation within a specific scope
11:11nburtsevthanks a lot!
11:12nburtsevit was starting to hurt my brain :\
11:12justin_smithlaziness is weird (it also creates weird stack traces sometimes)
11:22perplexais (let [x []]) preferable over (let [])
11:22borkdudeIs it possible in Om to inspect the state of children components? I have a form with fields that have local state :valid? and I want to "calculate" if the form as a whole is valid
11:22perplexais (let [x []]) preferable over (let [x (vector)]) ?
11:22justin_smithyes
11:22perplexaty
11:22clgvperplexa: is a matter of taste I guess - in the minimal case you posted [] is awful ;)
11:23clgvperplexa: but usually [a b ...] is pretty concise
11:23perplexawell i need an empty vector to which i conj later :P
11:24borkdudeI could solve this with callbacks, but it really seems overhead to me
11:24justin_smithperplexa: usually, I find putting [] directly at the site of usage makes more sense than binding it to some symbol and using the symbol
11:27clgvborkdude: I have no idea about Om, but couldnt those components just implement a protocol where you can ask them "(valid? child)"?
11:27perplexajustin_smith: yeah i prefer it too tbh :)
11:28clgvlol yeah, since [] already is that symbol when you think about it ;)
11:28justin_smithif I am binding [], that would be in an atom or agent
11:28justin_smithclgv: indeed
11:29borkdudeclgv don't know if this is possible
11:29clgvborkdude: me neither, it's just a general strategy where you do not have to know about the state which works often in general ;)
11:34agarman@justin_smith yeah I didn't read his example completely... missed that he was only doing prn
11:52pjstadigany opinions experience around sending a schema definition over the wire as data (Clojure->ClojureScript), reading it in as data, then using it to validate something ClojureScript side?
11:54nooniani think more commonly you would just use the same source file client and server side using cljx
11:54schmirpjstadig: why not? I'm doing something similar with clojure on both sides
11:55noonianyou'd have to make sure they are serializable
11:55pjstadignoonian: we want to describe services and their data in a generic way, we don't know the schema ahead of time
11:55noonianah, i see
11:55pjstadigthe service would send a schema over the wire that could be used to construct a UI and validate before submitting a request
11:57clgvpjstadig: you might have to define a schema data since some constructs are not EDN serializable (if that is a requirement), e.g. regexps...
12:06pjstadigclgv: the challenge is that s/Str resolves to either java.lang.String or a javascript string and gets printed out in a way that cannot be read in the same with both Clojure and ClojureScript, most of the other stuff like vectors and sets seem to be fine
12:07clgvpjstadig: yeah and regexps are problematic ;)
12:07pjstadigso we're thinking of defining a deftype that represents a string, extending the schema protocol to it, defining its print method, and defining a data reader that we can use to write/read the schema as edn
12:08clgvsounds reaonable
12:21radixthere's no insert operation for vectors, right? just double-checking my reading :)
12:23justin_smithradix: only append
12:23justin_smithradix: maybe you want a finger-tree
12:23justin_smithhttps://github.com/clojure/data.finger-tree
12:24radixoh, I see that hyPiRion is here. I actually got confused because his blog post (ostensibly about clojure vectors) talks about efficient insertion, but I guess that's not a property of clojure's vectors
12:24radixjustin_smith: oh cool
12:24justin_smithefficient insertion, but only at the end :)
12:26hyPiRionradix: Hrm, where do I talk about that? Because that's wrong, and I should change the wording if you belived that
12:26hyPiRionApologies for the confusion
12:26radixhyPiRion: I guess I just assumed mentions of "insertion" are the generalized case of insertion, not just appending.
12:27radixhyPiRion: by the way, thank you for writing that series, it's very very good :)
12:27hyPiRionradix: Ah, right. I should clarify that I mean appends. And thanks! :)
12:28clgvradix: you found bad wording there ;)
12:30radixfinger trees look cool.
12:33dnolen_radix: there's also rrb-trees, they are available for both Clojure/ClojureScript
12:34noonianyou could also just use a hashmap
12:35dnolen_radix: rrb-trees have the same api as vectors and can be used in their stead
12:37radixthat's cool, I'll look at those too.
12:56lodinThere's no harm in firing up lots of go blocks, right?
12:59bendlaslodin: not for your thread count, if that's what you mean
12:59clojer_Compiling my cljs file produces: "Invalid token: :America/North_Dakota/Beulah" but this map key causes no errors when I test it in an Emacs cider repl.
12:59bendlasyou'll eventually run out of memory though
13:01bendlasclojer_: hm, looks like symbols with more than one / are not allowed in cljs. They are definitely allowed in clj. dnolen_ do you know about this?
13:01clgvlodin: you won't be able to sell it as "Green IT" ;) :P
13:01clojer_bendlas: Token originates from tzinfo so I need to keep it exactly as is.
13:02lodinbendlas: Sure. Memory is a cap. But that I don't think I have to worry about.
13:02perplexammh, i have a vector and want to append to that vector for each item in a different list with conj. i assumed it would change the referenced vector but didn't. what i got is: (doseq [source-cfg sources-cfg] (conj sources (source-tap (key source-cfg) (val source-cfg)))) - how do i get conj to append to the existing vector repeatedly?
13:02justin_smithclojer_: why not use it as a string?
13:02bendlasclojer_: maybe not save it into a keyword? seems wrong.
13:02justin_smithor a symbol
13:02lodinclgv: I'll have to find another angle then. ;-)
13:03clgvperplexa: persistent datastructures!
13:03justin_smith,(get {"a" 0} "a") ; the syntax is a little funkier, but it works
13:03clojurebot0
13:03perplexa,(let x [] (conj x "1") x)
13:03clojurebot#<CompilerException java.lang.IllegalArgumentException: let requires a vector for its binding in sandbox:, compiling:(NO_SOURCE_FILE:0:0)>
13:03clgvclgv: you need `reduce`
13:03perplexa,(let [x []] (conj x "1") x)
13:03clojurebot[]
13:03perplexahow do i make that return 1?
13:03perplexa[1] to be precise
13:04clojer_bendlas: Do you mean use a string as a map key instead?
13:04justin_smithperplexa: as clgv said, use reduce
13:04bendlas,[(namespace :name/space/name) (name :name/space/name)] <- also consider this
13:04clojurebot["name" "space/name"]
13:04clgvperplexa: please do read some introductory material on clojure since you fail the simplest basics
13:04justin_smithclojer_: no, use a string as the key
13:04perplexaclgv: i know :P
13:04perplexathx
13:04bendlasclojer_: yes, string is the way to go
13:04perplexai know about macros though :D
13:05perplexai'm actually just learning it by implementing a project
13:06clojer_bendlas: OK. The map is very large so will it impact performance significantly using strings?
13:06clgvperplexa: you'll have much quicker learning progress if you read either one of the online available introductions or a book while implementing that project
13:07bendlasclojer_: probably not, the map entry is found by hash anyway
13:07perplexaclgv: well i do that, too.
13:07perplexabut i honestly don't get how to use reduce in that case.
13:08bendlasclojer_: if you want to make sure to have no performance impact, intern the strings
13:08bendlasbut shouldn't be nessecary at all
13:08clgvperplexa: then read up on reduce ;)
13:08perplexaat it
13:11perplexaclojurebot: so reduce + fn + conj it is :P
13:11clojurebotOk.
13:11perplexaoh dude left :)
13:12bendlasperplexa: I think your case is served by into
13:12bendlas,(into [1 2 3] (list 4 5 6))
13:12clojurebot[1 2 3 4 5 ...]
13:13bendlasjust make sure that you always go ahead with the return value (same as with conj)
13:13bendlasinto is essentially (reduce conj to from)
13:14perplexathx
13:15bendlas_the_ central value proposition of clojure is that functions like conj _never_ mutate in-place
13:17lodinperplexa: Beware that conj depends on the data type though.
13:17lodin,(into (seq [1 2 3]) (list 4 5 6))
13:17clojurebot(6 5 4 1 2 ...)
13:21perplexalodin: yeah i read about that.
13:29dnolen_bendlas: "'/' has special meaning, it can be used once in the middle of a symbol to separate the namespace from the name"
13:29dnolen_bendlas: http://clojure.org/reader
13:29dnolen_bendlas: it's not clear to me that means / can be used multiple times even though the reader implementation may allow it
13:31bendlasdnolen_: ok, question rephrased: is that incompatibility with clojure intentional? Schould we harmonize behavior in either direction?
13:32dnolen_bendlas: I don't see a need to harmonize an implementation detail w/o asking on clojure-dev what is intended
13:33BronsaAFAIK some-ns// is the only valid symbol that can have multiple "/"
13:34hlprmnky_I have myself confused about a simple syntax question and cannot see what I’m doing wrong - I’m binding a java class inside a let form, and the thing I get in the form reports itself as a class, but calling ‘new’ on it is passing the bound name to ‘new’ instead of the class symbol
13:35hlprmnky_e.g. (let [class java.lang.String] class) returns java.lang.String, but (let [class java.lang.String] (new class)) throws a CompilationException that the class ‘class’ cannot be found
13:35bendlasBronsa: is that your interpretation of the reader doc?
13:35hyPiRion,'_//_
13:35hlprmnky_I have searched many permutations of germane terms, read docs on java interop, and I still don’t see what I’m doing wrong htere
13:35clojurebot_//_
13:35hlprmnky_there*
13:35bendlashlprmnky_: new is a special form, that only works with literal classes
13:36hyPiRionIt's strange stuff.
13:36hyPiRion,'_//_//_
13:36clojurebot_//_//_
13:36Bronsabendlas: no, until 1.4.0 IIRC foo// would throw an exception and only clojure.core// was allowed. then a ticket was made to allow any-ns// that got in, but never has foo/bar/baz been a valid symbol
13:36bendlasif you want to instantiate from a class object, you need reflection
13:36Bronsahlprmnky_: new is a special form that doesn't evaluate its first expression, the class name must be literal
13:37bendlas,(namespace 'foo/bar/baz)
13:37clojurebot"foo"
13:37hlprmnky_I see
13:37bendlas,(name 'foo/bar/baz)
13:37clojurebot"bar/baz"
13:37bendlasBronsa, seems to be valid
13:37Bronsa,(symbol "foo bar")
13:37clojurebotfoo bar
13:37agarmanname of symbols accounts for the namespace it's in
13:37agarman,(name 'foo.bar/baz)
13:37clojurebot"baz"
13:37Bronsabendlas: clojure doesn't do much input validation, just because it accepts some inputs doesn't mean they are valid
13:38bendlasBronsa: so what was the ticket to _make_ it valid about?
13:38hyPiRionbendlas: defining a function named /
13:38hyPiRionin other namespaces other than clojure.core
13:38Bronsabendlas: only symbols whose name is "/"
13:39bendlasSo that was the only thing, that didn't actually work?
13:39hyPiRionthat works fine
13:40hyPiRion,(defn / [x y] (+ x y))
13:40clojurebot#<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)>
13:40hyPiRionexcept not in clojurebot
13:40Bronsabendlas: right, in 1.4.0 'foo// would cause an exception
13:40bendlasor is a working foo/bar/baz a side effect of makeing foo// work?
13:40bendlasBronsa: ok, IC
13:41Bronsabendlas: I suspect that the reader change that made foo// a valid symbol made the reader accept foo/bar/baz aswell, unintentionally
13:42dnolen_Bronsa: foo/bar/baz has actually worked for a long time, it's seems like a real ambiguity to me
13:42agarmanBronsa: not sure why bar/baz shouldn't be valid
13:43Bronsatools.reader for example doesn't use tha same regex as LispReader.java and errors out when trying to read foo/bar/baz
13:43bendlasinteresting, so i guess clojure.tools.reader does more input validation; and since that's what cljs uses by now there is this incompatibility
13:43Bronsadnolen_: oh, you're right
13:43Bronsadnolen_: well it's just another case of GIGO
13:45Bronsathe docs are explicit about that, so I'm confident in saying that foo/bar/baz is -- and has always been -- invalid
13:46bendlasBronsa: I'm not so sure, stuff like (symbol "foo bar// $#%" "baz//zab") is perfectly valid
13:46bendlasthere is just no reader syntax for it
13:46Bronsabendlas: it's allowed because there's no validation, but it's not valid
13:47bendlasnope, even if there was validation, it should only ever be in the reader
13:47bendlasthe docs you're referring to are also on a page called /reader
13:48bendlasBronsa: at least that's my firmly held opinion, that constructors for symbol, keyword, ... should do no further validation than to see if namespace and name are strings
13:49agarmanBronsa: the docs I'm reading just says that symbols containing / are qualified
13:50agarmanBronsa: my understanding of qualified is that the namespace will consume the symbols string to the first / not that there can be no additional /
13:50bendlasagarman: well, it says '/' has special meaning, it can be used once in the middle of a symbol
13:50hyPiRionThe docs are outdated
13:50bendlasthat can conceivably be interpreted to mean "at most once"
13:51hyPiRionThere's nothing about quote being a legal part of a symbol on the /reader page.
13:51agarmanbendlas: the rest of that doc is "to separate the namespace from the name" nothing stating that an additional / can't be used, but it's assumed that it won't have special meaning then
13:52agarmannot assumed it's explicit that any other / won't have special meaning
13:52bendlasagarman: yes, I tend to follow this interpretation. Bronsa seems to be against it and dnolen_ seems to be on the fence and wants it discussed on clojure-dev
13:53agarmanhyPiRion: (other characters will be allowed eventually, but not all macro characters have been determined) would cover '
13:54agarmanin that the expected behavior is indeterminate
13:55Bronsabendlas: agarman wrt "foo/bar/baz", as hyPiRion says the clojure.org docs are outdated and open to interpretations, however if you read https://github.com/edn-format/edn#symbols it's clear that "foo/bar/baz" is not valid
13:56agarmanedn is a data exchange format... it doesn't represent the full capabilities of the reader
13:56agarmanthough I'd agree that they should be fairly consistent
13:56Bronsaagarman: I'm well aware of that but I hardly doubt that an edn symbol and a clojure symbol would differ
13:57bendlasBronsa: but they do, ' isn't mentioned in edn symbols either
13:58bendlasBronsa: (edn/read-string "foo'") works though
13:58Bronsabendlas: eh, that's a bug in the spec
13:58agarman,(clojure.edn/read-string "foo/bar/baz")
13:58clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.edn>
13:59agarman,(require '[clojure.edn :as edn])
13:59clojurebotnil
13:59agarman,(edn/read-string "foo/bar/baz")
13:59clojurebotfoo/bar/baz
13:59agarmanvalid is what works
13:59dnolen_Bronsa: well I think supporting quirks is OK - but I definitely never thought of foo/bar/baz as being valid
13:59agarmandocs or code should be fixed though
13:59dnolen_agarman: sadly it is not, it's just undefined
13:59justin_smith,(edn/read-string "this\nis\nmultiple\lines")
13:59clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \l>
13:59hlprmnky_Bronsa, bendlas: thanks for the assistance - I was (after only a few moments of slack-jawed disdain) able to use .getConstructor … .newInstance to do what I wanted
13:59justin_smith,(edn/read-string "this\nis\nmultiple\nlines")
13:59clojurebotthis
14:00hlprmnky_slack-jawed disdain at the hoops you have to jump through to make Java give you an instance of something via reflection, not at new being a special form :)
14:00agarman,(type (edn/read-string "foo/bar/baz/quux/giggle"))
14:00clojurebotclojure.lang.Symbol
14:01bendlashlprmnky_: yw
14:01hyPiRionthat's because
14:01hyPiRion,(read-string "foo/bar/baz/quux/giggle")
14:01clojurebotfoo/bar/baz/quux/giggle
14:02Bronsaagarman: bendlas I'm in the difficult position of using an uncomplete/outdated spec as basis of my thesis, but I think the documentation is clear on the foo/bar/baz issue.
14:04Bronsaagarman: bendlas paraphrasing, it says "those are the valid characters you can use in a symbol, additionally you can use '/' once in the middle of the symbol", that "once" is definitely "once and only once" if you take into account how it's phrased for '.': "it can be used one or more times in the middle of a symbol"
14:04bendlasbut why not take a step back, and admit that it should mean, what we want it to mean, with Rich having the last say of course.
14:06bendlasBronsa: yeah, ok, foo/bar/baz really should be disallowed in edn _and_ in the reader, because it's unnessecarily surprising
14:06bendlashowever, (symbol "foo/bar" "baz") aswell as (symbol "foo" "bar/baz") should be considered valid
14:07bendlas(and distinct)
14:11bendlasBronsa, dnolen_, agarman, hyPiRion: unless any of you is already at it, I'll do a writeup to clojure-dev
14:14Bronsabendlas: you might be right about "runtime symbols" not being restricted in the same ways of "reader symbols", I have to say that every time the discussion about (symbol "foo bar") being valid has come up, the consensus has been that it's just a result of GIGO -- go on with a ml writup if you want official answers
14:27shoepieany vim users know how to correctly indent .clj files using vim-clojure-static?
14:32TimMc,(.newInstance String) ;; hlprmnky: It's easy if you want the nullary constructor.
14:32clojurebot""
14:33hlprmnkytrue, but I actually needed a String constructor
14:34hlprmnkyit’s not so bad, considering, I just don’t have to wander down that deep into the boilerplate mines very often
14:35amalloyhlprmnky: clojure.lang.Reflector/invokeConstructor is easier to use
14:36amalloy,(let [c java.util.ArrayList] (clojure.lang.Reflector/invokeConstructor c (object-array [10])))
14:36clojurebot[]
14:36amalloy(that 10 is the initial capacity, so it still just looks like an empty list
14:36amalloy)
14:36hlprmnky!
14:37hlprmnkythat is indeed much nicer
14:37hlprmnkythanks!
14:44TimMcSo that's if you only care about dynamic dispatch to a constructor, not static dispatch.
14:44TimMchandy
14:47amalloyTimMc: indeed, i think it's the same logic that (Foo. x y z) goes through if you don't hint x/y/z
14:48amalloythe last time i wanted to reflectively invoke a constructor i wanted to do it multiple times, though, so i ended up saving the Constructor handle to reuse it
14:48amalloythe reflector doesn't give you that flexibility
14:48amalloy(if you care about performance, anyway)
14:52upwardindexI’m getting Unsupported major.minor version 51.0 when trying to lein `cljsbuild once`. Google tells me something about not having the right jdk/jre. Has anyone encountered this?
14:55amalloyupwardindex: you're running something compiled against java 7, on a jre 6 or lower
14:55justin_smithupwardindex: what does "java -version" return in your shell?
14:56upwardindexjustin_smith: java version "1.6.0_65" in terminal but in system preferences it says java 1.7something
14:56justin_smithupwardindex: then call the 1.7something version, or fix your path so it is before the 1.6
14:57justin_smithupwardindex: you can explicitly set the java location via an env var or project.clj setting in lein
14:58upwardindexjustin_smith: thank you, I’ll look into that
14:58justin_smithhttps://github.com/technomancy/leiningen/blob/master/sample.project.clj#L259
14:58justin_smithexample in the above link
15:13ToxicFrogHuh.
15:13ToxicFrogSo I can't use :refer :all even for things that will be released as an uberjar, because the warning messages from the compiler can't be supressed and are emitted when it's run from the jar, too
15:15noonianToxicFrog: you might find slamhound helpful; it will automatically figure out which vars you're using and generate a nice require form for you
15:15noonianhttps://github.com/technomancy/slamhound
15:16bendlasToxicFrog: Don't use :refer :all, only acceptable usage is from a repl session how or why should uberjar protect from its perils?
15:17bendlasyeah, slamhound's pretty cool for that
15:18ToxicFrogbendlas: I'm :refer :alling core.typed, so that I get all of the typenames in scope, rather than having an ugly mix of naked type names and t/ prefixed type names.
15:18TimMcbendlas: It is sometimes appropriate.
15:18ToxicFrogHowever, this also brings in core.typed/for et al which generates the shadowing warnings.
15:18TimMcYou can exclude that, I think?
15:18ToxicFrogI was hoping that the requiring would happen entirely during the compilation process, and thus there would be nothing to warn about during runtime when the jar is executed.
15:19ToxicFrogOf course, this doesn't address at all the common case where you want to refer those and quite deliberately shadow the clojure.core versions
15:19ToxicFrogAFAICT, in that case, you're just screwed
15:19TimMcToxicFrog: :refer-clojure :exclude
15:20bendlasToxicFrog: yeah, it would be pretty cool for clojure to be able to compile that way
15:20bendlassimilar to cljs
15:20bendlasmaybe we'll get there one day, with the lean-compile stuff
15:20ToxicFrogTimMc: holy this I did not know about refer-clojure
15:20ToxicFrogThank you
15:24jlongsterdo you have to use a buffer when using a transducer with a channel?
15:31linman32hi i have a clojure compile error.
15:31linman32http://pastebin.com/ZZFaNFFC
15:32linman32the error doesn't seem to point to a specific file though
15:32ToxicFrogWelcome to clojure compile errors: abandon every hope, ye that enter
15:33justin_smith/tmp/form-init3292773767470107555.clj:1:72 is something your toolchain likely created
15:33justin_smithno promises that it is readable...
15:33justin_smiththe :1:72 mean line 1, character 72
15:33stompyjjlongster: I’ve only ever seen it done that way, but I don’t know for sure
15:34linman32the file is no longer there
15:34jlongsterstompyj: I think that's true. reading the source, and it kinda makes sense
15:35justin_smithlinman32: what did you run when you got that error? lein repl?
15:35linman32justin_smith: should i try updating my toolchain? i got leiningen recently. like 3 days ago
15:35linman32justin_smith: yes
15:35justin_smithwas this run from inside a project directory?
15:36linman32yes
15:36justin_smithcan you share your project.clj?
15:36justin_smithI suspect a string where there should be a symbol, in either project.clj or your core namespace
15:37linman32justin_smith: https://github.com/AustinClojure/groops/blob/master/project.clj
15:38justin_smith:init-ns should not be a string, it should be a symbol
15:38justin_smiththat may be the issue
15:38justin_smith(under :profiles / :dev / :repl-options)
15:39justin_smithso try taking out the quotation marks, and running lein repl again - that may just fix it
15:40linman32wow, seems to be working! that was a nice find
15:41caldiarNew to clojure and was wondering if it's considered "proper" clojure to make use of records rather than maps. Or are records/protocols there to make transitioning to clojure easier for people used to object-oriented design?
15:41linman32justin_smith: how did you find it so fast?
15:41justin_smithlinman32: those temp files are created based on the contents of project.clj
15:42justin_smiththe error was string could not be cast to symbol
15:43justin_smithso I looked for strings that should not be strings, it's a small file
15:43justin_smithdouble checked with the lein example project.clj that :init-ns should not be a string
15:43perplexahad some time to read up on reduce+conj \o/
15:44caldiarTo provide some context, I have several entities which can have different behaviors such that a minotaur can move 1 unit at a time while an imp could move 2 units at a time. I was thinking a protocol and records which implement the move method would be best suited for this or if there was a more idiomatic way.
15:44justin_smithcaldiar: you can switch to records if maps are slowing you down in a bottleneck
15:44justin_smitha multimethod can determine behavior from any function on your data
15:44justin_smithalso, multimethods that use keywords can take advantage of multiple inheritence via derive
15:45justin_smith(this is not possible with records)
15:45justin_smithwell, I guess it could be, but it isn't possible with protocols is what I really meant
15:48caldiarone of the ways I'm seeing things done (from the caves of clojure series of articles) is that there's multiple protocols and a record which uses extend-type for each protocol it would like to implement
15:48justin_smiththat's another way to do it
15:48justin_smithprotocols are a pain in the ass in interactive development
15:48mdeboard[IND]Elixir helped me understand protocols in Clojure much better
15:49caldiarmy concern is that I don't want to get into bad habits and wind up having things come back to bite me later
15:49justin_smithmaps upgrade seamlessless to records
15:50caldiaralright, thanks guys
15:53borkdudeI would like to start my clojure app in a Docker container, wait until the server is started and then run tests against that server in the same docker container. My question: can I run test from something like an uberjar which I will add to the container?
15:53borkdudeso basically it all runs in one container
15:54borkdudeand I don't want to install leiningen etc in the image, too much work
15:54justin_smithborkdude: you can use test/run-tests for each test-ns inside an init function
15:55borkdudejustin_smith ah, of course, thanks.
15:55justin_smithyou may want to make sure the test namespaces are compiled into the uberjar, of course
15:55borkdudewill the test code be included in an uberjar?
15:55justin_smithif it isn't, there should be a simple path to make it happen
15:55borkdudejustin_smith hmyeah
15:57justin_smithand its easy to check if those files are in your uberjar - a jar is just a zip with special properties
15:59borkdudejustin_smith right
17:13mikerodI'm wanting to understand the rationale behind this:
17:13mikerod,(coll? {})
17:13clojurebottrue
17:13mikerod,(instance? java.util.Collection {})
17:13clojurebotfalse
17:14mikerodAre there any good links?
17:14mikerod:D
17:14jkjmikerod: well i quess java collections have features that coll doesn't need
17:14jkjlet's see
17:14mikerodjkj: searching has been difficult
17:14mikerodhitting completely unrelated topics
17:15justin_smith,(instance? clojure.lang.IPersistentCollection {})
17:15clojurebottrue
17:15justin_smiththat's what coll tests
17:15mikerodyes, justin_smith I was just shorthand'ing that part
17:15jkjmikerod: momentos. firing up my repl
17:15mikerod,(instance? java.util.Collection [])
17:15clojurebottrue
17:15jkjwhen do we have fast start
17:15mikerodI just see that Clojure chose to view a Persistent*Map as a IPersistentCollection
17:16mikerodbut not as a j.u.Collection
17:16jkj ,(map :name (:members (clojure.reflect/reflect java.util.Collection)))
17:16clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.reflect, compiling:(NO_SOURCE_PATH:0:0)>
17:16jkjoops. it is cljs?
17:16justin_smithmikerod: based on the docs for Collection, it is not used for maps
17:17jkjmikerod: (:bases (clojure.reflect/reflect {}))
17:23mikerodjustin_smith: I don't see the docs that you are referring to for that
17:24mikerodIt makes sense to me that Clj maps are not a j.u.Collection since j.u.Map is not though. I guess I should just look at it that way.
17:25justin_smithhttp://stackoverflow.com/a/2651833/2258453 answer has a quote from the java design documents
17:31mikerodOh, yes I should have looked for that. Thanks justin_smith
17:32mikerodand thanks jkj for the input
18:02razum2um1is there any library to inspect java object - for now i use https://gist.github.com/razum2um/ffaaf90731f27a988141 but maybe someone has better ways?
18:07razum2um1better to say - is there any way to get, say, annotated source from maven (if possible) and show members with descriptions. Or (javadoc) with lucky google is best option?
18:10justin_smith#(apply dissoc % [:exception-types]) is #(dissoc % :exception-types)
18:11justin_smith#(contains? (:flags %) :public) could be (comp :public :flags) in this case
18:11celwellHello, what's a good library (or technique) for running a function every 3 minutes?
18:12Jaoodsleep?
18:13celwellJaood: is that safe? i just don't want to run out of memory after a few days
18:13JaoodThread/sleep
18:13justin_smithcelwell: depends on whether you are using loop / while or simple self call
18:14arrdemBronsa: so does the scheduler buy you anything performance wise?
18:14justin_smithcelwell: for more power (and complexity) there is java.util.Timer which you can use via interop
18:15bendlasrazum2um1: just the other day, I've written a thing that uses reflection to pretty-print java classes: https://github.com/webnf/webnf/blob/master/base/src/webnf/base.clj#L100
18:16bendlasit's turned out pretty nifty for exploring interacting with java objects from repl
18:16razum2um1justin_smith: thanks for feedback ;)
18:17justin_smiththere is also bean, which suffices for some objects (and at least helps with others)
18:17justin_smith,(bean "hello")
18:17clojurebot{:empty false, :class java.lang.String, :bytes #<byte[] [B@1c1e75a>}
18:17razum2um1bendias: could you provide an example of this?
18:18Bronsaarrdem: no, it just automates the pass composition/dependency resolution
18:18arrdemBronsa: :thumbsup:
18:18Jaoodcelwell: I guess using a delay with some time api could be more elegant
18:19dbaschcelwell: that question is pretty generic, it depends on what you want to do and what level of operational reliability you need
18:19dbaschcelwell: e.g. if you don't trust your own code you could use cron to start a jvm every time
18:19razum2um1bendlas: may I mention webnf in https://github.com/razum2um/awesome-clojure under frameworks?
18:20celwelldbasch: I'm running a ring server and need to spawn a 3-minute-interval-called function that gets certain rows from a db and may or may not update those rows.
18:20Bronsaarrdem: I was able to reduce the number of complete tree traversals from 8 to 7 but I doubt it's going to result in a noticeable speedup
18:21bendlasrazum2um1: here http://pastebin.com/CsUGvAy5
18:21arrdemBronsa: yeah that sounds about right.
18:21bendlasrazum2um1: of course!
18:22dbaschcelwell: as long as you don't hold on to the rows so they can be garbage-collected, and you run your jvm with enough heap, you should be fine
18:22bendlasalthough, it's intended to not be a framework, but a set of orthogonal libs that happen to interact well
18:22dbaschcelwell: if you're on linux there's always a chance that the kernel might kill your process, so you may want to have a watchdog script to restart it
18:23celwelldbasch: are you saying that same would be true for the ring server itself? it might just die without auto restarting?
18:23dbaschcelwell: yes, any jvm on linux could die without autorestarting
18:24dbaschcelwell: you can tell the oom killer to ignore a process, but it's usually not the best idea
18:25arrdemdec finite memory machines
18:25celwelldbasch: I'm relatively new to the JVM (coming from PHP). Do you know of any material I can read to learn how to have a reliable ring server. Sorry I guess that's vague. But with PHP I would just let it run until I something messed up and i would restart apache.
18:26razum2um1bendlas: looks nice, maybe extract some fns like that?
18:27bendlasrazum2um1: by 'extract' do you mean 'pack them in a library, so that they can be used independently'?
18:27razum2um1bendlas: pack
18:27bendlasif so, that's what I'm doing with webnf
18:28razum2um1bendlas: they are too different, e.g. hostname and pr-cls
18:28dbaschcelwell: the important thing is to run the jvm with appropriate parameters, and to have a cron job or script to restart it if it dies unexpectedly
18:28bendlasit's basically all the fns, that I kept copy-pasting from project to project
18:28dbaschcelwell: you also want to configure it to run on boot if your machine could lose power or reboot for some reason
18:28razum2um1bendlas: )) yep. saw this in clojure community everywhere
18:29celwelldbasch: thanks for the advice
18:30razum2um1hm folks, why not to join efforts and have one modular project like webnf, but having MORE than 1 contributor. just like active support in ruby land?
18:30bendlasyeah, I'm trying to split them into sub projects tastefully, it's always a balancing act between getting on with my projects while pushing snippets into webnf, and then refactoring webnf itself, e.g. introducing new packages
18:31razum2um1now I see everyone is duplicating some fnsctions with different names or even copypaste them into HIS toolbox library
18:31razum2um1is it really a trend to have *my-own-helper-library* ?
18:31justin_smithno
18:32razum2um1e.g. timbre's author has his lib too
18:32bendlasrazum2um1: yay, I'd be all for it. problem is maintainership in all its facets
18:32justin_smithcheck out flatland/useful for a general set of useful stuff that isn't in core though https://github.com/flatland/useful
18:33razum2um1justin_smith: 6 contributors ;)
18:33justin_smithand they accept pull requests
18:34razum2um1justin_smith: I meant forces are disjoint. compare rails with 2k contributors (of cource, clj is not widly used, but *there ARE more than 6 clojurists)
18:35noonian,(def truthy? (comp not not))
18:35clojurebot#'sandbox/truthy?
18:35justin_smithrazum2um1: I'd say 6/2000 is about the ratio of clojure to ruby users (maybe it is a bit hight actually)
18:35justin_smithnoonian: isn't that what boolean does?
18:36justin_smith,(map boolean [true false nil 1 0 () []])
18:36clojurebot(true false false true true ...)
18:36noonianjustin_smith: heh, i guess so; i didn't know boolean was a core function :P
18:36razum2um1justin_smith: e.g. in golang land there are LOTS of lein/bundler analogs all of them are depending on 1-2 devs. we have lein and it's cool or pain of choice ;)
18:37razum2um1i meant *no* pain of choice ;)
18:38justin_smiththere have been alternatives to lein, but they haven't gone far
18:38nooniani think most clojure libs tend to be smallish and so much easier to maintain by 1-2 people, also tend to get to a point where they work and aren't touched much except for major refactors or api changes
18:38xemdetiasuch is the land of lisp
18:39razum2um1justin_smith: yes and 227 contributors to lein show where the mainstream is. why there is no lein-like "activesupport" what do you think?
18:40justin_smithrazum2um1: for the most part, clojure people hate frameworks and don't use them
18:40razum2um1it doesn't have to be one repo
18:41razum2um1but can be ogranisation
18:41bendlasrazum2um1, justin_smith: so IMO, if we were to have a place where everybody could maintain their favourite helper code, it would nessecarily have to be split into various subprojects with different focus
18:41justin_smithrazum2um1: and if there was a single lib that supplied multibyte strings, internationalization, time zones, testing, etc. for clojure, people would ask why so many different things were in one lib
18:41xemdetiaI thought we already had github /snark
18:41bendlasthat's why i laid out webnf that way from the start
18:41razum2um1bendlas: yes, but I don't see any so far
18:41razum2um1oops, perhaps webnf is it ;)
18:42razum2um1but again, bendlas, you are *alone*
18:42justin_smithrazum2um1: thanks to lein / clojars, we don't need everything to be coming from one organization. It is easy for anyone to share whatever libs they would like to share.
18:43bendlasyeah, ML reactions to new announcements have become increasingly apathetic, last couple of years
18:44razum2um1justin_smith: I didn't mean that, I mean some really mainstream helper lib. like clojure.contrib before, *but* it doesn't have to be single project/repo
18:44noonianit seems like we are somewhat converging in terms of ways to design system with design patterns like stuart sierra's component and libraries building on those ideas like trapperkeeper and modular
18:44bendlasI mean, leiningen + clojars gets you 90% there, the only thing that's really missing are dependency sets to get rid of those ridiculously long :dependency lists
18:44bendlasi.e. webnf.deps/*
18:44razum2um1bendlas: :)
18:44justin_smithrazum2um1: we have a mainstream helper lib. If you want a bigger, more comprehensive one, go ahead and make it I guess?
18:45razum2um1justin_smith: there will be no good since I will be only one, who is using it
18:46justin_smithif it's good enough, other people will use it, if it isn't good enough they shouldn't be using it - I really fail to see what the problem is here
18:47nooniani bring prismatic plumbing into all the project i make now, i think they've done a good job extending the language with small useful functions/macros
18:47bendlasjustin_smith: the problem is, that even for more that good enough code, if it doesn't hit an immediate need (like leiningen did), you have a discoverability problem (i.e. marketing)
18:48razum2um1justin_smith: it starts when I started write class-inspection function and setup a repo for it and some more others, then saw bendlas's webnf, then you… everyone has his own. it dramatically reduces recognizable of other's code
18:48noonianthe ?> and ?>> conditionals for use with the threading macros are really nice
18:49razum2um1justin_smith: I mean to read someone's code with *HIS* helper functions we must read them all too
18:49razum2um1justin_smith: some standard is needed i think
18:49justin_smithhow much of rails code have you read?
18:49justin_smithI mean the underlying code
18:49razum2um1justin_smith: lots and have commits there
18:51bendlasFWIW, i don't think rails is the model we should be aiming for, despite its success
18:51razum2um1and some not accepted PR's since I made gems for that, but it's offtopic
18:51bendlasI try to think more along the lines of the new clojure contrib stuff
18:52bendlassingle-purpose, replaceable
18:52justin_smithbendlas: agreed 100%, just checking if razum2um1 was actually one to read the source for all the libraries used by the libraries he uses
18:52razum2um1bendlas: now I mean some very specific thing: activesupport is *widely* accepted, without rails too, and I read code with it much faster
18:53bendlasOIC
18:54bendlasi think, the excellent platform support of clojure hurts this cause. Most people are just like: 'eh, i can use that java lib'
18:54justin_smithand they are probably better off just using the java lib too, in many cases
18:55bendlastrue\
18:55bjaI don't think I even use very many clojure libraries. Mostly just wrappers for java stuff
18:56razum2um1bja: do you think it's better *even* no to wrap them?
18:57nooniani prefer pure clojure libs to java wrappers if they are available
18:57razum2um1actually I'm late to this party, is this trend still in (wrap java)?
18:57razum2um1noonian: tend to agree
18:58bendlasi'd say yes, but only for stuff whose java impl is excellent
18:58matthiasnhey guys, I am stuck with a problem. I have an application that runs nicely on my mac but when I try to run it on Ubuntu 14.04 (lein run or the uberjar makes no difference) I get the following error: Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :make-writer of protocol: #'clojure.java.io/IOFactory found for class: nil, compiling:(/tmp/form-init5185754411886008906.clj:1:72)
18:58matthiasnDoes anyone have an idea where to look? thanks a lot
18:58noonianwhen there are big java libs that don't need to be re-written people tend to wrap them, like aws java clients for example
18:59rweirweird java errors always make me trash ~/.m2/repos just in case
18:59justin_smithmatthiasn: wait, the uberjar is referring to /tmp/form-intblablahblah?
18:59noonianmatthiasn: when you say it runs fine on your mac did you try running from an uberjar or just in the repl?
18:59bjarazum2um1, it depends on the java library. I go back and forth on whether marceline is an improvement over regular JVM interop for Storm's Trident API
18:59bendlasmatthiasn: thats basically a null pointer exception. Probably from a resource fail, that's not been found on the different platform
19:00matthiasn@noonian on mac either repl, run or uberjar all work
19:00bendlaslol, *resource file
19:01matthiasn@justin_smith: that was when doing lein run
19:01justin_smithmatthiasn: OK, what is the error with an uberjar?
19:01noonianmatthiasn: maybe forgot to check a resource into git or something?
19:01justin_smithalso, the error with lein run points to a file, in /tmp/ that is generated based on your project.clj
19:02matthiasnnoonian: there’s one config file that’s not checked in because of credentials, but it’s there locally
19:02justin_smithmatthiasn: with an identical path?
19:02bendlaslook for stuff that would lead to (clojure.java.io/writer nil)
19:03matthiasnjustin_smith: with uberjar its just: Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :make-writer of protocol: #'clojure.java.io/IOFactory found for class: nil
19:04bendlasdoes it try to write to some OSX specific path like /User/... ?
19:04matthiasnjustin_smith: in the project root
19:04justin_smithyeah, something in there is trying to create something to write output to (a file? a network connection?) and is getting nil
19:04justin_smithmatthiasn: can you share your project.clj?
19:05matthiasnsure: https://github.com/matthiasn/BirdWatch/blob/master/Clojure-Websockets/project.clj
19:05justin_smithmatthiasn: in the ubuntu computer, is there a target/ directory? git won't create it if it doesn't have any checked in files inside it
19:06matthiasnOh I have an idea, let me check
19:07justin_smithalso, "target/%s" may need to be "target/%s/" - at least that is how it is done in the example project.clj
19:08matthiasnfound it :-)
19:08justin_smithwhat was it?
19:09matthiasnso there was a new key in twitterclient.edn for the name of the PID file to write
19:09matthiasnand I did not add that key in the edn file on the server
19:10matthiasnthat was the right pointer with the program trying to write something :-) thanks a lot
19:18phaoHi. I'm curious. Does Clojure have something like CL's loop facility?
19:18phaoAnd... Does Rich Hickey come in here? Hehe
19:18justin_smithphao: not really, there are for and doseq, but we don't use DSLs as much as CL does
19:18phaojustin_smith, Ok. Thanks =).
19:18matthiasn_hmm, got kicked out of my network for the last three minutes or so
19:18matthiasn_thanks for the help, much appreciated
19:18noonianwhat does cl loop macro give you that for doesn't? i'm not trying to be argumentative i just don't have any cl experience
19:18justin_smithphao: actually some uses of "loop" would even be covered by our own loop, or reduce (in combination with reduced for short circuiting), or iterate as well
19:18justin_smithnoonian: it is an embedded language for describing recursion
19:18justin_smith(loop for item in list for i from 1 to 10 do (something))
19:18technomancyCL LOOP can do basically anything
19:18phaonoonian, I do have experience in CL, but not much. It could be just likely that you know more about it than I do.
19:18justin_smith(loop for i from 20 downto 10 ...)
19:18technomancyin clojure you would express it as a series of sequence operations, but in CL you just mush it into a single macro
19:18phaoI was just curious because my belief is the same as technomancy's.
19:18justin_smith(loop for k being the hash-keys in h using (hash-value v) ...)
19:18justin_smithit's almost like cobol
19:19phaotechnomancy, any clues on why loop-ish macros aren't in clojure?
19:19technomancyeven among CL fans loop is pretty controversial because it tries to be english-like instead of being lispy
19:19technomancyphao: you mean why huge english-like macros in general aren't in wide use?
19:19phaotechnomancy, that as well =)
19:19justin_smithright, it is a COBOL like language for describing loops, that just happens to sit in a lisp file
19:19phaojustin_smith, hehehehe
19:20technomancyI would have thought that'd be self-evident. trying to be english-like pretty much always results in weird unpredictable idiosyncracies because english is a crazy language.
19:20phaotechnomancy, I didn't know loop also had these issues
19:20justin_smithbut in all seriousness, the clojure design goals are to make small composible things that combine powerfully, rather than monolithic standalone features
19:20phaoI thought it kept itself to simple syntactical constructions.
19:21technomancyloop is basically its own language... we already have a language that we like for describing sequences; adding another one doesn't make sense
19:21phaojustin_smith, Right. CL seems, to me, to approach the other end of that.
19:21technomancyI'm sure someone has ported it as an exercise though
19:21noonian(loop for i from 1 to 3 sum (* i i)) would be (reduce + (range 1 4)) in clojure
19:21justin_smithphao: https://www.refheap.com/90332 this is a valid usage of the loop macro
19:22justin_smithfrom this page http://www.gigamonkeys.com/book/loop-for-black-belts.html
19:22phaohahahahaha
19:22phaoit looks like those algorithms book pseudo-code
19:22justin_smithnot quite as verbose as COBOL, and not in all caps, but the same "we want to program in english" concept
19:22noonianmost of the examples from here look like they would read better in clojure imo
19:22noonianhttp://www.unixuser.org/~euske/doc/cl/loop.html
19:23nooniancl loop macro for beginners
19:24phaojustin_smith, stuff like this breaks my foundations on believing that there is a logic which controls it all.
19:24arrdemso um... what does this macro _not_ do
19:24justin_smith"it all"?
19:24justin_smitharrdem: solve the halting problem? dunno, maybe it does that too
19:24phaojustin_smith, In this case, what is acceptable or not by the loop, and what it does, and how the macro decides what to do, and many other aspects.
19:25arrdemjustin_smith: if it does I'm handing in my badge
19:25justin_smitharrdem: I am still laughing at the example I pasted in the refheap link above
19:25arrdemjustin_smith: I missed it. repost?
19:25justin_smitharrdem: https://www.refheap.com/90332 this is a valid usage of the loop macro
19:25phaojustin_smith, Oh! THe 'and' tokens combine stuff together.
19:25phaoNow things are starting to make sense.
19:26technomancyit would make a lot more sense if it just used parens like regular lisp
19:26arrdemjustin_smith: we're a lisp. fuckit. lets embed some bash.
19:26arrdem^ what technomancy said
19:26phaotechnomancy, I couldn't agree more =)
19:26justin_smitharrdem: hell, I still maintain it's closest living relative is COBOL
19:26phaotechnomancy, but maybe it's just a learning curve kind of thing, as in once you learn it, you maybe can be productive with it.
19:26arrdemjustin_smith: "living"...
19:27technomancyclojure.core/for is the closest thing to a mini-language in that it supports :when and :let, but they're just a different syntax for things you already know
19:28justin_smithphao: but we can't easily compose new functionality by combining it with other tools
19:28phaojustin_smith, I see.
19:28arrdemI guess my issue with this is while it's a legitimate macro it's almost entirely divorced from the syntactic style of the host language..
19:28noonianyeah, i had no idea for supported :when and :let for months and was doing it all in the body or filtering outside
19:29arrdemwhich aggravates what justin_smith is saying that it doesn't trivially or obviously compose
19:29phaojustin_smith, CL has the notion of a sequence type too, if I'm not mistaken, can't the loop macro work with any sequence?
19:30noonianit just seems like its trying to do too much all so you can do it in a single form
19:30justin_smithphao: in one of the examples I quoted above, it was iterating on the keys / values of a hashtable
19:32amalloyoh boy, is it time to talk about LOOP again?
19:32arrdemno thanks
19:32justin_smith~loop
19:32clojurebotI don't understand.
19:32justin_smith~cl-loop
19:32clojurebotNo entiendo
19:32phaohehehe
19:32justin_smithclearly, we need to rectify this situation
19:33phaojustin_smith, put that link as the output for ~loop
19:33justin_smithclojurebot: loop |is| https://www.refheap.com/90332
19:33clojurebotIn Ordnung
19:34phaohehehehe
19:34rweiris that really truly valid CL?
19:35justin_smithrweir: yeah
19:36justin_smithhere is the formal description, which may be even more daunting http://www.lispworks.com/documentation/HyperSpec/Body/m_loop.htm
19:44clop2hi, new to clojure (from common lisp), going to port an app to get some experience; wondering, does clojure have any syntax mechanism for structure sharing input in its reader, like #1=... style reader macros in lisp?
19:46amalloyclop2: no. it's kinda hard to have such things anyway, in a language that is immutable and strict/eager
19:46SegFaultAXclop2: Clojure doesn't have reader macros, no.
19:47clop2ok thanks, so i guess i need to write a parser, that'll be a good project too
19:47amalloySegFaultAX: he's not asking about user-supplied reader macros, but about one specific one that the CL reader has. clojure certainly has many prepackaged reader macros, like #{...}
19:47SegFaultAXamalloy: Do I need to specify "user-defined" there? I assume the "except for what Clojure does internally" is implied.
19:49amalloySegFaultAX: if i include the "implied" part, then you haven't even attempted to answer the question. "clojure doesn't have user-supplied reader macros" is not an answer to "is there a #1= macro built in"
19:49TEttingerwhat does #1= do?
19:50amalloyTEttinger: it's for printing circular references
19:50amalloy(and then reading them back in as still-circular)
19:50TimMcI think that's called sharp-notation in some JSON supersets.
19:50clop2right, or for simply sharing common subexpressions (that don't happen to be circular)
19:50amalloymore genrally, i guess, it's for capturing shared structure, of which circular references are a special case
19:51TEttingeryou can change the behavior of fns like pr and prn pretty easily, though I don't know how you'd detect shared structure
19:52justin_smithTEttinger: but could you read in a way that made prn actually do the right thing?
19:52amalloyclop2: does CL really use that for non-circular lists? like, if i write (let ((x (cons 1 2))) (list x x)), i don't get a #1= notation
19:52TEttingerjustin_smith, with read-eval, yes
19:53justin_smithahh, of course, read-eval
19:53clop2amalloy: cl can be instructed to print with structure sharing if you bind *print-circle* to t, or custom printers can print it out in other cases
19:53TEttinger,(print "#=(+ 1 1 1)")
19:53clojurebot#=(+ 1 1 1)
19:53clop2amalloy: typically it will only create #= abbreviations for circular objects, I think, but I'm not an expert
19:54amalloyactually even if i write (let ((x (cons 1 2))) (setf (cdr x) x) x) i don't get that pretty notation out of clisp; the interpreter just hangs
19:54clop2amalloy: but for reading back in, you can do, e.g., (+ #1=5 4 #1#) or similar
19:54amalloybut i can't figure out how to set print-circle
19:54amalloyanyway, not really important
19:56clop2this should do it: (let ((*print-circle* t) (x (cons 1 2))) (setf (cdr x) x) (print x) nil)
19:56TEttingerhm, I can't remember if clojurebot allows read-eval
20:11amalloyso guys, i found a funny trick in my old 4clojure solutions. suppose you have 3 objects named x, y, and z, and you want to compute (f x) + (f y) - (f z), but you don't like repeating f. you'd rather use (map f [x y z]) or something like it, and then do the math on the resulting list
20:11amalloyhere is the solution i used, way back then: (- (apply - (map f [z x y])))
20:16justin_smithhah, nice
20:16amalloyfor those following along at home, that converts the problem to -(f(z) - f(x) - f(y))
20:16amalloy- has the funny property that the first item is given a different sign than the rest
20:21TEttinger,(apply - [10 22 55])
20:21clojurebot-67
20:21TEttingerhuh
20:22justin_smith,(reduce - [10 22 55])
20:22clojurebot-67
20:22TEttinger,(reduce - 0 [10 22 55])
20:22clojurebot-87
20:22TEttingerneat trick, amalloy
20:22TEttinger(inc amalloy)
20:23TEttingerlazybot is ded
20:23amalloyhe's been having a rough time recently for some reason
20:23arrdemthe bot is dead long live the bot
20:26dbaschhere's a (stupid) gotcha. What do you expect t and second t to be? https://www.refheap.com/90336
20:27justin_smithwell, locking 128 won't work
20:27justin_smithor won't really do what you expect at least
20:28amalloyyeah, don't lock integers. what kind of wacko thinks he deserves an exclusive lock on a mathematic ideal?
20:28dbaschamalloy: you can happily lock 127 or -128 though
20:28justin_smithwell, at least for 127 you have a single instance
20:28dbaschor anything in between
20:28amalloydbasch: sure, you get lucky with an implementation detail
20:29amalloyi doubt the interning of Long objects between -128 and 127 is part of the jvm spec
20:29amalloy(or the jls)
20:30dbaschamalloy: in fact, the doc for the oracle jvm says they "may cache values outside this range"
20:30clop2does clojure have any haskell/ml-like way to define simple types like, maybe-number ::= number | nil ?
20:30amalloyclop2: no, we don't have ADTs
20:30Guest26510,(reduce -
20:30clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
20:31Guest26510err
20:31dbasch(locking 4 (println "http://www.imdb.com/title/tt1464540/&quot;))
20:31johnnycage,(reduce - '())
20:31clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/->
20:31johnnycagecan I supply a starting value for the accumulator?
20:31amalloy,(doc reduce)
20:31clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...
20:32TEttingerjohnnycage, yes, ##(reduce + 10 [1 2 3])
20:32lazybot⇒ 16
20:33TEttinger(inc amalloy)
20:33lazybot⇒ 167
20:33johnnycageis that the same function? it uses optional argument, or?
20:33johnnycageoverloaded function?
20:33TEttingerstarting values for reduce are very very useful for reduce on strings
20:34TEttingersee in the docstring amalloy called up, ([f coll] [f val coll]) ?
20:34johnnycageyes
20:34TEttingerthat means it can take [f coll] as two args, or [f val coll] as 3 args
20:34TEttingerval is the starting value
20:34johnnycageI realize this. I am just curious how is something like implemented
20:34johnnycage+that
20:34dbasch,(reduce str "can " ["I " "supply " "a " "value?"])
20:34clojurebot"can I supply a value?"
20:35TEttinger,(defn multi ([] "you gotta give me some args!") ([f coll]) (reduce f coll))
20:35clojurebot#<CompilerException java.lang.IllegalArgumentException: Parameter declaration "reduce" should be a vector, compiling:(NO_SOURCE_FILE:0:0)>
20:35TEttinger,(defn multi ([] "you gotta give me some args!") ([f coll] (reduce f coll)))
20:35clojurebot#'sandbox/multi
20:35TEttinger,(multi)
20:35clojurebot"you gotta give me some args!"
20:36TEttinger,(multi + [1 2 3])
20:36clojurebot6
20:36justin_smithdbasch: why not apply str?
20:36johnnycageneat
20:37dbasch,(apply str "they " ["were " "taking " "about " "reduce."]) ; justin_smith
20:37clojurebot"they were taking about reduce."
20:37amalloyyeah, i don't recommend ever using str as the function you're reducing
20:37dbaschtalking that is
20:37justin_smithwe have apply str, string/join, even reduce on StringBuilder if you have to go that way
20:37amalloyit should always be apply (or, better yet, something more suitable like clojure.string/join)
20:38dbaschyes, you don't want to be concatenating strings like crazy
20:38TEttingerjohnnycage, that multiple argument list technique is used heavily by clojure's standard lib, but it hasn't come up too often for me in code I have written. still quite useful.
20:38amalloyjustin_smith: not much point in reducing over a stringbuilder
20:38amalloymight as well hammer on it in place with doseq
20:38justin_smithfair enough
20:42justin_smithand now that I check, yup, of course clojure.string/join is a loop with a StringBuilder in it
20:44johnnycagewhat is apply's relationship with reduce? can we just replace one with the other, always?
20:44dbaschjohnnycage: no
20:44johnnycagetey seem to be interchangeable in many cases
20:44johnnycagethey
20:44justin_smithjohnnycage: well, many functions with varargs are implemented in terms of a two arg function + reduce, so apply invokes reduce internally
20:44dbaschjohnnycage: apply simply converts a collection (or arguments plus a collection) into arguments
20:45justin_smith(in those cases, that is)
20:45johnnycageoh, apply just passes all the elements to the function
20:45justin_smithright
20:46justin_smithand if you look at the source to + for example, it uses the internal clojure.lang.Numbers.add which takes two args, and then uses reduce for the rest of the args
20:46justin_smith(reduce1 which is an optimized reduce in this case, but anyway...)
20:47amalloyi wonder: why is it called reduce1? it reminds me of foldl1 or something, which isn't right at all
20:49justin_smithodd, especially given that reduce* was not taken
20:50justin_smithand that would kind of make sense given things like fn* and let*
20:51dbaschamalloy: because it was June 11, so 1 was the digit of the day. https://github.com/clojure/clojure/commit/3f74c9ff6e9bf8e5e120129ea1c1c7e4719b4dcc
20:52justin_smith(inc dbasch)
20:52lazybot⇒ 10
20:53amalloyhey, who was it who was telling me that it's easy to forgot where the return-type annotation goes? Bronsa? i just found evidence that rich forgets too: https://github.com/clojure/clojure/commit/e354b011 puts them in both places, like (defn ^Foo f ^Foo [x])
20:53amalloy(the second Foo there is entirely ignored afaik)
20:53justin_smithyeah, I think dbasch was asking why the misplacement was not an error
20:54justin_smithit would logically indicate metadata on the params vactor, but how would you even access that...
20:54dbaschI think I disassembled both versions and saw no difference
20:54amalloyjustin_smith: well, it's the correct place to put a primitive typehint
20:54justin_smithoh wow, OK
20:54amalloybut means nothing if you hint with an object type
20:55amalloy(defn square ^long [^long x] (* x x)) avoids boxing
20:56dbaschthe one I found had ^String
20:56amalloyright, those are wrong
21:03johnnycageis there a reduce equivalent that returns a list of all the intermediate results (the value of the accumulator) instead of just the final result?
21:03justin_smithreductions
21:03amalloy,(doc reductiosn)
21:03clojurebotNo entiendo
21:03amalloyboo
21:03justin_smithyou misspelled it
21:03amalloyyeah
21:03justin_smith,(doc reductions)
21:03clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
21:04johnnycagenice thanks
21:04amalloyincidentally, has anyone ever used the first item in the value returned by reductions? i feel like i only ever call it as (rest (reductions ...))
21:06amalloywell, never mind. i just searched all the code i have on the computer, and the one time i used it i didn't call rest
21:15justin_smithamalloy: one of mine was without using rest, the other only had reductions as a comment, and was an excersize blind-rewriting it from scratch
21:21joobuswhat's crackin' clojure clan?
21:25justin_smithworkin on some 4clojure problems
21:25amalloyjustin_smith: you are worse at spelling exercise than i am at spelling privelidge
21:26justin_smithhah
21:27joobusi'm working projecteuler problem 9 in clojure :)
21:28joobusjustin_smith: are you writing them or doing them?
21:28justin_smithdoing them, after I solve them all I will make some up
21:55phaoDoes Rich Hickey come in here?
21:55xeqirarely
22:00kenrestivobar
22:37kenrestivo~seen rhickey
22:37clojurebotGabh mo leithscéal?
22:37kenrestivo,seen rhickey
22:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: seen in this context, compiling:(NO_SOURCE_PATH:0:0)>
22:37kenrestivolazybot: seen rhickey
22:37lazybotrhickey was last seen quitting 65 weeks and 1 day ago.
22:37kenrestivophao: ^
22:46kyunHow to use clojure file as script?
22:47justin_smithkyun: there is a lein plugin for it, or you can just reference the clojure jar and your script, but clojure tends to be awkward for scripting because the core takes a long time to load
22:47brehautslowly
22:48justin_smithhttps://github.com/kumarshantanu/lein-exec lein-exec is probably easiest
22:49kyunOh, I see, thanks.
22:51kyunI think it will faster to scala script:)
22:51TEttingerkyun, nope
22:51TEttingerjvm startup time is slow either way
22:52TEttingerthere's stuff like drip that makes jvm startup time faster for clojure and maybe other languages
22:53amalloyTEttinger: most of the startup time is clojure's fault, not the jvm
22:54amalloybuilding a bunch of vars, compiling your code, and so on
22:54TEttingerright, but scala's compiler is even slower if you just changed the script :)
22:57kyunScala's type system is to too hard for me-_-
22:57TEttingerhttps://github.com/flatland/drip is drip, btw
22:58TEttingerkyun: http://tpolecat.github.io/assets/list.png
22:59justin_smithlol
23:00kyunOh my god.
23:04TEttingererr, https://github.com/ninjudd/drip is newer
23:12izirkuhi all! a noob question perhaps - when different libraries themselves depend on different versions of the same library, what are the implications?...
23:13izirkusome even require different version of Clojure itself. Should one be concerned with it?
23:13TEttingerizirku, that is a common problem and a hard one to resolve
23:14izirkuTEttinger: I'm aware somewhat of not using :aot :all, which supposed to help, but is there anything else? I tried to search the web with...
23:14izirkunot much success on this. Coming from Common Lisp, this is something new to me.
23:14TEttingerwhich libs have different dependency versions?
23:15TEttingerit
23:16TEttingerit's possible you can fork one that needs an older version, update the version it depends on, upload your personal copy to clojars for now (submitting a pull request to the author for later), and depend on your clojars copy or a locally installed version until they are both up-to-date
23:17izirkuTEttinger: for example lib-noir "0.8.9" depends on cheshire 5.3.1, which in turn depends on jackson-core 2.3.1 ...
23:17TEttingerthat's probably a bad approach but I have done it
23:18izirkualso lib-noir "0.8.9" depends on ring-middleware-format "0.4.0" and some more, which in the end depend on jackson-core "2.3.2"
23:18xeqiizirku: `lein deps :tree` should help you identify potential problems. Implications are the libraries erroring or half working at runtime
23:18TEttingerthat's interesting, I wouldn't expect that lib-noir would have that problem
23:19izirkuxeqi: that's exactly where I got the dependency information from
23:20izirkuxeqi: I see the implications :(
23:21TEttingerhm, https://clojars.org/ring-middleware-format doesn't itself depend on jackson-core 2.3.2
23:21izirkuTEttinger: I guess forking could work, but that's a lot of forks :)
23:23izirkuTEttinger: no, not itself, but one of it's dependencies. here is a pastebin of my lein deps :tree http://paste.lisp.org/+32WW
23:25xeqiwow those extra parens are annoying. I thought I had fixed that
23:25TEttingerusing the dep on ([lib-noir "0.8.9" :exclusions [com.fasterxml.jackson.core/jackson-core]]) should be good
23:25xeqiizirku: what lein version?
23:26izirkuxeqi: Leiningen 2.4.2 on Java 1.8.0_11 Java HotSpot(TM) 64-Bit Server VM
23:26xeqiah, that fix didn't come till later
23:30izirkuxeqi: noted, updating now :)
23:30mmitchel_I'm having a problem using this library https://github.com/ring-clojure/ring-session-timeout --- it seems that a session logout, followed very quickly by another request (which updates the session value with a timeout) value, causes the session to continue living -- has anyone experienced this?
23:31mmitchel_The underlying session storage is ring in-memory, which is using an atom
23:32izirkuTEttinger: I did put the :exclude in, will work through the rest. Does the exclude basically tells a package to ignore dependency, ...
23:32xeqimmitchel_: what is a "session logout" ?
23:32izirkuTEttinger: and whatever else version is pulled will be used?
23:32mmitchel_I think the problem is that the delete happens in a swap!, and before it finishes, the timeout middleware gets access to the session data. Then the delete tries removes it, but then the timeout middleware finishes its work and re-populates the session data.
23:32mmitchel_xeqi: a request handler that responds with a {:status 200 :session nil}
23:34xeqiizirku: correct
23:35izirkuxeqi, TEttinger: thank you for your help, much appreciated!
23:39xeqimmitchel_: are the requests overlapping?
23:41mmitchel_xeqi: yes they are
23:44xeqimmitchel_: then I don't think it has to do with atoms/swap. More that both request get the session from the session store. Then whichever writes last "wins"
23:45xeqisimilar ideas, just at a level higher then the underlying session store
23:45mmitchel_xeqi: yeah, i'm not sure what to do here
23:49mmitchel_xeqi: any suggestions?
23:50xeqimmitchel_: what do you expect to happen to the side effecting parts of the second request?
23:50xeqi* want to have happen
23:53xeqifor example, overlapping "logout" and "delete project" requests
23:54mmitchel_xeqi: yeah, good question. I guess I'm hoping "delete" wins -- somewhow
23:55mmitchel_but i guess that can only happen if the delete start, only happens when something else hasn't already got to it
23:56mmitchel_so a blocking delete etc..