#clojure logs

2015-07-23

00:05SeyleriusWould it be appropriate for an API library to use component to manage API config state?
03:10mercwithamouthso what exactly is 'step'?
03:17mercwithamouthan offset i know but the results weren't as expected when i chose... 3 opposed to 2
03:19mercwithamouthahh forgive me....makes since with numbers
03:38ely-sein a macro I want to check whether something is a let expression
03:39ely-seshould I do (if (and (seq? x) (= 'let (first x)))) ?
03:40TEttingerisn't let a macro?
03:40TEttinger,(macroexpand-1 '(let [x 1] x))
03:40clojurebot(let* [x 1] x)
03:40TEttingerhm
03:40TEttinger,let
03:40clojurebot#error {\n :cause "Can't take value of a macro: #'clojure.core/let"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/let, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Can't take value of a macro: #'clojure....
03:41TEttinger,(macroexpand-1 (macroexpand-1 '(let [x 1] x)))
03:41clojurebot(let* [x 1] x)
03:41TEttinger,(macroexpand-1 ~(macroexpand-1 '(let [x 1] x))))
03:41clojurebot#error {\n :cause "Attempting to call unbound fn: #'clojure.core/unquote"\n :via\n [{:type java.lang.IllegalStateException\n :message "Attempting to call unbound fn: #'clojure.core/unquote"\n :at [clojure.lang.Var$Unbound throwArity "Var.java" 43]}]\n :trace\n [[clojure.lang.Var$Unbound throwArity "Var.java" 43]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval95 invoke "NO_SOURCE_FI...
03:41ely-seoh, I see
03:41TEttinger,(macroexpand-1 '(macroexpand-1 '(let [x 1] x))))
03:41clojurebot(macroexpand-1 (quote (let [x 1] x)))
03:41TEttingergah
03:41TEttingernot good with macros no more
03:42dmitrig01let* is a special form
03:42dmitrig01afaik
03:42wasamasanot sure what you expected to see there
03:43wasamasaalso, isn't there a macroexpand-all?
03:46namrasomeone using metric-clojure? getting the following: com.codahale.metrics.Timer$Context cannot be cast to com.codahale.metrics.Sampling
03:47ely-seTEttinger: http://ideone.com/DMHRZr <- it works now
03:47ely-sethanks
03:47namrasample code: http://pastebin.com/7HgtB3St
03:48dmitrig01namra: (tmr/percentiles t) => (tmr/percentiles sql-query-time)
03:53namradmitrig01: com.codahale.metrics.Timer cannot be cast to com.codahale.metrics.Timer$Context :/
03:53namradmitrig01: sry my bad
03:54namradmitrig01: thanks
05:09xificurCI have this project.clj file http://sprunge.us/LbPR . My issue is not with clojurescript but with the fact that when I run lein deps :tree I see a strange dependency tree - http://sprunge.us/PIAK . Where are things like nrepl 0.2.6 or clojure-complete coming from? This is non-trivial for me as a newcomer
05:43echo-area1.8 alphas are released really fast
07:05justin_smithxificurC: those are dependencies for cider, and are injected by the cider plugin
07:05justin_smithand are only present at dev time
07:07xificurCjustin_smith: I see. The nrepl version is outdated though and trying to run cider-connect from emacs to conenct to a running figwheel repl doesn't work because the project is pulling in 0.2.6 while it'd need at least 0.2.7
07:07xificurCis there any way to override that?
07:07justin_smithxificurC: I'm not sure how that works, though I know there is a solution. It's a conflict between leiningen deps and cider deps.
07:07xificurCI just created a project.clj with (defproject abc "0.1.0-SNAPHOST" :dependencies []) and it already depends on nrepl and clojure-complete
07:08justin_smithit should be documented somewhere in the cider project
07:08justin_smithxificurC: yes, the cider plugin should be in ~/.lein/profiles.clj
07:08justin_smiththat's how they tell you to get it at least
07:08justin_smithand the deps from there are always used
07:08xificurCjustin_smith: except I don't have it there
07:08justin_smith(locally, for dev)
07:09justin_smithxificurC: then I have no idea what's going on or where your cider deps are coming from
07:10xificurCjustin_smith: unfortunately that makes 2 of us :)
07:10justin_smithxificurC: how did you add your cider plugin when you were setting up cider?
07:11xificurCjustin_smith: locally into the project.clj's plugins. [cider/cired-nrepl "0.9.1"]
07:11xificurCs/cired/cider/
07:11justin_smiththen that's where the deps are coming from, like I said before, the cider plugin "injects" deps into your project when it is loaded
07:13xificurCjustin_smith: just found this as you noted https://github.com/clojure-emacs/cider#warning-saying-you-have-to-use-nrepl-027
07:16xificurCso it's actually leiningen that pulls those in
07:17justin_smithoh, right. I keep forgetting that lein repl uses clojure complete
07:17justin_smithand of course it uses nrepl
07:20xificurCjustin_smith: that fixes it. Ugh this was very painful
07:20justin_smithxificurC: cider can be kind of a hairball, I gave up on it
07:20xificurCjustin_smith: and what do you use
07:20justin_smithxificurC: inferior-lisp, like a caveman
07:20xificurCis it cider's fault though? It's leiningen that's pulling in a pretty old nrepl
07:22justin_smithxificurC: it's that cider has a very complex and brittle design, that relies on lots of other tooling (in the clojure world and the emacs world) and the brittleness of each of the tooling sets is amplified.
07:22schmirthere's also https://github.com/clojure-emacs/inf-clojure
07:22justin_smithI experienced frequent breakages, and when updating I got yet more breakages.
07:23xificurCthis whole setup is daunting. There's nrepl, there's cider, piggieback, figwheel..
07:23justin_smithin fact, these days I'm doing a distributed system where it's not unusual for me to have 5 or 6 repls open, so it's easier not to have any repls inside my editor itself at all rather then trying to juggle them all
07:23xificurCI don't know who does what
07:23justin_smithxificurC: yeah, there's a lot of tooling going on
07:24xificurCfor a newcomer it's a nightmare
07:24xificurCreading through 3-4 github readmes and wikis
07:28justin_smithxificurC: big picture, people want features, and migrate to the thing that does the most, design be damned. It's kind of natural I guess. But the designs can be kind of creaky around the edges, or not yet stable.
07:30xificurClol so I got cider to connect in emacs and figwheel wiki says I should evaluate (use 'figwheel-sidecar.repl-api) which gives me a FileNotFoundException
07:31justin_smithxificurC: the figwheel repl shouldn't be part of your normal cider repl
07:31justin_smithit's a separate connection (to the js vm rather than the jvm)
07:31justin_smithunless I don't understand what you are doing here....
07:32justin_smithxificurC: if I want figwheel inside emacs I do C-u M-x inferior-lisp<return> lein figwheel<return>
07:32justin_smithunless cider has figwheel tooling now...
07:34noncomdo people using emacs to program clojure use it also to program the other languages when they have to? like java..?
07:34noncomor scala
07:34justin_smithI've done java in emacs, but many people describe doing that as masochistic
07:36noncomso.. emacs is mainly for lisps and c...
07:36noncomi guess..
07:36noncomi also saw python done well...
07:40rarebreedI use it for Python...I'm also using it at the moment for a combined java/clojure project
07:40rarebreedand before, when I used to do c(++) I used it heavily because it integrates with gdb and cscope so nicely
07:41rarebreedand ctags
07:41wasamasaalgernon: you're using hy?
07:41rarebreedoh yeah, and hy too :)
07:41rarebreedgot watch out for hy's lets though...it's more scheme-like
07:42rarebreedalthough no need to letrec or letrec*
07:42algernonwasamasa: yes
07:43rarebreedI know someone who was using emacs for elixir, but he switched to sublime
07:45cflemingjustin_smith: I describe doing Java in Emacs as professional negligence :-)
07:45rarebreedanyone have advice or webpage to point to on how to debug a mixed clojure/java project so that I can step through the java code?
07:45rarebreedI have clojure calling some methods in an object from a java jar in my classpath
07:46rarebreednormally, I c-x c-e to eval my code, which kicks off the call chain that hits the java method
07:46cflemingrarebreed: I think Cursive or CCW are your only options. I don't have a lot of doc, but my Clojure/West talk has some details and lots of demo using Cursive.
07:47rarebreedcfleming: maybe i'll give cursive a swing :)
07:47cflemingrarebreed: You never know, you might like it :-)
07:48rarebreedI do also use pycharm/intellij for python
07:48cflemingrarebreed: https://www.youtube.com/watch?v=ql77RwhcCK0
07:48cflemingOk, it should be pretty familiar then, all their IDEs work in basically the same way.
07:48rarebreedit's not a bad setup...and since this is a mixed java/clojure project, maybe it will be better for me than emacs+cider
07:49rarebreedcfleming: cool, I'll check it out
07:49cflemingYeah, Cursive has really nice interop support now
07:49rarebreedspeaking of cider...anyone notice that sometimes the nrepl-server output buffer doesn't become available?
07:49xificurCjustin_smith: I was trying to do what is listed on figwheel's wiki - https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl
07:50rarebreedsometimes I have to restart emacs and keep trying cider-jack-in...eval my code...and hope the nrepl-server buffer shows up
07:50xificurCjustin_smith: took me 1 hour to find why section 2 is not working. now section 3 (Start Figwheel REPL within nREPL) doesn't work either
07:51justin_smith"The nREPL CLJS landscape is in flux right now, so your mileage may vary"
07:51xificurCeven though figwheel-sidecar is in ~/.m2/ it can't find it in the classpath
07:51xificurCjustin_smith: yeah i know
07:52justin_smithxificurC: just because something is in your local cache, that doesn't mean it's on the classpath
07:52xificurCthese things were in flux 2 years ago as well. Would be nice to finally settle on something :)
07:52justin_smithit needs to be a dep for that (if you are using lein)
07:52xificurCjustin_smith: yes lein
07:53justin_smithyeah, .m2 is where every dep you ever had goes. A project won't see deps from there unless lein sets it up to do so.
07:53xificurCjustin_smith: where could I read through the basic options of {project,profiles}.clj? I'm e.g. not sure what is the difference between deps and plugins
07:54schmirxificurC: the leiningen sample project.clj file
07:54justin_smithxificurC: leiningen has extensive documentation. Plugins are loaded by lein itself while lein runs, deps are available to your app when it runs (usually after lein itself is done)
07:54schmirhttps://github.com/technomancy/leiningen/blob/master/sample.project.clj
07:55justin_smithxificurC: lein is a build tool, it should usually not be part of the picture once your repl or project starts running. Except for the fact that lein decided what your classpath would be etc.
07:55xificurCthanks schmir and justin_smith
07:55justin_smithso a plugin can do things like pre-processing files before your stuff launches, or setting up your classpath.
07:57justin_smithonce that is all set up, it's just your app and its classpath. lein is out of the picture at runtime (caveat for plugins that are long running - but even then it's technically "before your project ran" - even if they short circuit that and your project won't run in that process.
07:57justin_smith)
08:00xificurCadding sidecar to the plugins didn't help
08:02justin_smithif the problem is that the dep is missing at runtime, it should be added to your dependencies
08:02justin_smithunless the plugin is design to inject the dep in a special way
08:06xificurCsoon I'll just use rlwrap and screw it :)
08:07justin_smith xificurC that's what I actually do most of the time
08:08xificurCdeps didn't help either
08:08hellofunkwhy is this:
08:09hellofunk,(= (sort-by min [5 2 6]) (sort-by max [5 2 6]))
08:09clojurebottrue
08:09justin_smithhellofunk: ##(= (min 5) (max 5))
08:09lazybot⇒ true
08:10hellofunki guess the quesion is, why does sorting a vector by max or min in both cases sort it in ascending order?
08:10justin_smith,(sort-by :x [{:x 0} {:x 10} {:x -10}])
08:10clojurebot({:x -10} {:x 0} {:x 10})
08:10justin_smithhellofunk: like I said, (min 5) is the same as (max 5)
08:10justin_smithsort-by doesn't work the way you think it does
08:10hellofunkapparently ot
08:10hellofunk*not
08:11justin_smith(doc sort-by)
08:11clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."
08:11hellofunkperhaps i am confusing a keyfn with a comparator
08:11justin_smithyes, you are
08:11justin_smithyou just want sort
08:12justin_smith"comparing (keyfn item)" - eg. (min x)
08:13hellofunk,(sort #(> % %2) [1 4 2 3])
08:13clojurebot(4 3 2 1)
08:13hellofunk,(sort #(< % %2) [1 4 2 3])
08:13clojurebot(1 2 3 4)
08:14justin_smithhellofunk: you can simplify that ##(sort > [1 4 2 3])
08:14lazybot⇒ (4 3 2 1)
08:15hellofunkright.
08:26xificurCschmir: inf-clojure solution in the figwheel wiki has the same issue, not finding figwheel-sidecar on the classpath
08:39xificurCcan one check the current classpath from the repl?
08:58xtrntr1hi
08:59xtrntr1i have a racket background, looking to join clojure because the racket-to-js compiler is a work in progress
08:59xtrntr1so i thought clojurescript would be nice and learning the jvm
08:59xtrntr1is there anything i should know, jumping from racket to clojure? (pros and cons)
09:02xificurCthat's a pretty broad question. Many design choices are different imho (macro system, immutability, laziness, ...). You should read a book or something to decide
09:03noncomxtrntr1: http://stackoverflow.com/questions/1413390/why-clojure-over-other-jvm-lisps-kawa-armed-bear-or-sisc
09:03noncomxtrntr1: http://stackoverflow.com/questions/11223403/what-are-the-differences-between-clojure-scheme-racket-and-common-lisp
09:03noncomso it's just different
09:03xtrntr1i've already decided to learn clojure, just to play with web apps. i'm more of looking for a little pep talk
09:04noncomone of the biggest pros, if you ask me, is that it runs on the JVM, making the whole java ecosystem available
09:04noncomor javascript in your case. the integration is very good by now, afaik
09:04xtrntr1i have brief experience with the .net framework, but i don't know what's great about the JVM
09:04xtrntr1enterprise-y stuff?
09:05xemdetiaxtrntr1, with clojure you get pretty much everything that's already been built on java
09:05noncomnot really. the VM itself is very fast and friendly, and saying ecosystem, I mean the loads and loads of good-quality libraries
09:05noncomyou can find a library almost for anything you'd think of
09:05noncomand in most cases it will be of a production-grade quality
09:06xtrntr1okay
09:06xtrntr1i'm -new- to web stuff so my questions might sound dumb
09:06xtrntr1but i can write the whole stack in clojure right?
09:06noncomright
09:06xtrntr1html, js and cs
09:07noncomyes
09:07xtrntr1fantastic :) why aren't more languages doing this
09:07xemdetiabecause it's hard
09:08noncomwhen you look at it, a lisp is the only real candidate for such a role.. and other lisps usually don't care about embracing the stuff of today so completely..
09:08noncomit strongly depends on the community also
09:08noncomhere you get a very responsive and up-to-date one
09:08xemdetiajvm and js have good enough communities it is worth building something on top of
09:09xemdetiaso I think that's part of it too
09:09xtrntr1so, how and why did you guys decide to pick up clojure?
09:10xemdetiafor me it is I liked lisps but the ecosystem around most lisps is not very mature or well maintained
09:10noncomas for me, i was a java programmer, then i wanted to go functional, and besides, i always wanted to program in lisp, so i first went scala and then tried various lisps and naturally settled with clojure
09:11noncomfor a java programmer, it is almost impossible to get off the craving for the java ecosystem
09:11xificurCI chose clojure for my next project sicne I love lisps and clojure is the most geared towards real-world usage. Racket is more academic and CL is just cryptic
09:12xtrntr1academic sounds damning
09:12noncomit sounds like a niche
09:12schmirxtrntr1: been a python programmer for years and looked at lots of languages (ocaml, erlang, lua) in order to get away from python. nothing hit the sweet spot like clojure.
09:13kilonxtrntr1: writting the whole thing in a single language is pretty stadard stuff even for unpopular languages
09:13schmirI'll probably explore F# in the future, which I think is also very interesting
09:13kiloni use pharo which is one of the most unpopular languages out there and it does this
09:14noncomtook a look at pharo recently
09:14noncomlooks interesting
09:14schmirsomehow I also managed to get paid for writing clojure code :)
09:15noncomyeah, i use clojure at work too :)
09:15noncomso far, it's just another java library
09:15kilonpharo is great for live coding
09:15Aejaynoncom: Oh you lucky fish!
09:15noncomheheh.. :) they just gave me freedom to write in the language of my choice..
09:16xificurCxtrntr1: I like racket, all I meant is that I think you'll get things done more easily with something that is geared towards real-world usage
09:16noncomkilon: i don't think i'll ever get off lisps, but smalltalk is worth looking into. i wish i had more expertise with it
09:16AejayFor me, an ideal lisp would be one with ADTs and a good type system.
09:17xtrntr1xificurC: i'm just curious, what is a reasonable definition of "geared towards real-world usage" ?
09:17xtrntr1i understand the JVM has tons of popular and up to date libraries, but what kind of essential libraries are racket lacking?
09:17kilonnoncom: i am very new to it myself, i was a python coder, still am, but i was always looking for interactive coding and close integration with ide, pharo fit like a glove for my needs, i use it now for manipulating python :)
09:18lpetitHi there, I’ve found a strange behavior for clojure.pprint. not new (happening with clojure 1.6 as well as clojure 1.7)
09:18kilonbut keep an eye on clojure
09:18lpetithttps://gist.github.com/laurentpetit/74b94bb9c3782d3e4940
09:18xtrntr1i've always heard on the racket mailing list the word "real world" thrown about, but i'll like to know what others consider essential libraries.. :)
09:19lpetitin a nutshell, pretty printing a var is less pretty than printing it ….
09:19xemdetiaxtrntr1, look at stuff like jetty, the crypto libraries that come for free from java, concurrency constructs that we get by being on the JVM that through engineering of clojure 'just work'
09:20xemdetiaI wouldn't say it is as much missing real world libs is just the maturity of libs available, I was doing something with a different lisp a year or two ago and I just couldn't even get the plugin module required to do what I needed it to do to build at all
09:21xemdetiaand since it wasn't popular enough or really maintained actively it would have cost me more time and effort to resolve the issue then use something more well traveled
09:21xemdetiaand that is the common case and not the exceptional case
09:22xemdetiawith clojure it's inverted and having underlying library build problems is the exceptional case and not the common case (ymmv with some clojure libs that wrap those underlying libs)
09:48noncomdoes anyone use quil here?
10:00mmeixtrying:
10:00mmeix,(Math/abs -3)
10:00clojurebot3
10:00mmeix,(Math/pow 2 3)
10:00clojurebot8.0
10:00mmeixseems to work
10:01wasamasawhy does the latter return a float ._____________.
10:01mmeix,(map Math/abs [-2 3 -7])
10:01clojurebot#error {\n :cause "Unable to find static field: abs in class java.lang.Math"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: abs in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to find static...
10:01mmeixumpf
10:02mmeix,(Math/abs -2)
10:02clojurebot2
10:02mmeixhm
10:03mmeix,(map Math/abs [-2 -3])
10:03clojurebot#error {\n :cause "Unable to find static field: abs in class java.lang.Math"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: abs in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to find static...
10:03mmeixmyabe:
10:03mmeix,(map #(Math/abs %) [_2 -3])
10:03clojurebot#error {\n :cause "Unable to resolve symbol: _2 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: _2 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: _2 in this context"...
10:03mmeixgrm
10:03mmeixone can always do
10:04mmeix,(let [abs (fn [x] (max x (- x)))] (abs -3))
10:04clojurebot3
10:05mmeix,(let [abs (fn [x] (max x (- x)))] (map abs [-2 7 -3]))
10:05clojurebot(2 7 3)
10:06mmeix,(Math/pow 2 3)
10:06clojurebot8.0
10:06mmeixgives a float, yes
10:07mmeix,(let [pow (fn [a b] (reduce * (repeat a b)))] (pow 2 3))
10:07clojurebot9
10:07wasamasathat's what I wrote in a fit of rage
10:08mmeix,(let [pow (fn [a b] (reduce * (repeat b a)))] (pow 2/7 3))
10:08clojurebot8/343
10:08mmeixwould only work for pos integers as exp of course
10:09wasamasaright
10:09mmeix,(map #(Math/abs %) [-2 3 -1])
10:09clojurebot(2 3 1)
10:09mmeixah
10:10mmeixwas a typo ^
10:15mmeixtrying:
10:15mmeix,(def abs Math/abs)
10:15clojurebot#error {\n :cause "Unable to find static field: abs in class java.lang.Math"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: abs in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to find static...
10:16mmeix,(defn abs [x] (Math/abs x))
10:16clojurebot#'sandbox/abs
10:16mmeix,(map abs [-1 2 -3])
10:16clojurebot(1 2 3)
10:17lpetit(print #’print)
10:18lpetit,(print #’print)
10:18clojurebot#<ArrayIndexOutOfBoundsException java.lang.ArrayIndexOutOfBoundsException: 8217>
10:18lpetit~(print #’print)
10:18clojurebotIt's greek to me.
10:18mmeix,(defn pow [x y] #(Math/pow y x))
10:18clojurebot#'sandbox/pow
10:18lpetit,(use ‘clojure.pprint)
10:18clojurebot#error {\n :cause "‘clojure.pprint"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: ‘clojure.pprint, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.ClassNotFoundException\n :message "‘clojure.pprint"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :tra...
10:19lpetit,*ns*
10:19clojurebot#object[clojure.lang.Namespace 0x1fb19a1e "sandbox"]
10:19mmeix,(map pow [1 2 3] [2 0 3])
10:19clojurebot(#object[sandbox$pow$fn__116 0x5330a7ec "sandbox$pow$fn__116@5330a7ec"] #object[sandbox$pow$fn__116 0x1f60a19f "sandbox$pow$fn__116@1f60a19f"] #object[sandbox$pow$fn__116 0x112ddd1 "sandbox$pow$fn__116@112ddd1"])
10:19lpetit,(alter-var-root #'clojure.core/print-object
10:19clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:19lpetit (fn [old-print-object]
10:19lpetit (fn [o, ^java.io.Writer w]
10:19lpetit (if *print-readably*
10:19lpetit (old-print-object o w)
10:19lpetit (do
10:19lpetit (when (instance? clojure.lang.IMeta o)
10:19lpetit (#'clojure.core/print-meta o w))
10:19lpetit (.write w "#<")
10:19lpetit (let [name (.getSimpleName (class o))]
10:19lpetit (when (seq name) ;; anonymous classes have a simple name of ""
10:19lpetit (.write w name)
10:19lpetit (.write w " ")))
10:19lpetit (.write w (str o))
10:19lpetit (.write w ">"))))))
10:19oddcullypalease!
10:20oddcullydon't paste code into irc. use refheap or a gist
10:20lpetit,(alter-var-root #'clojure.core/print-object (fn [old-print-object] (fn [o, ^java.io.Writer w] (if *print-readably* (old-print-object o w) (do (when (instance? clojure.lang.IMeta o) (#'clojure.core/print-meta o w)) (.write w "#<") (let [name (.getSimpleName (class o))] (when (seq name) ;; anonymous classes have a simple name of "" (.write w name) (.write w " "))) (.write w (str o))
10:20clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:20lpetit (.write w ">"))))))
10:20sobelso, Var.applyTo or Var.invoke?
10:21lpetit,(alter-var-root #'clojure.core/print-object (fn [old-print-object] (fn [o, ^java.io.Writer w] (if *print-readably* (old-print-object o w) (do (when (instance? clojure.lang.IMeta o) (#'clojure.core/print-meta o w)) (.write w "#<") (let [name (.getSimpleName (class o))] (when (seq name) (.write w name) (.write w " "))) (.write w (str o)) (.write w ">"))))))
10:21clojurebot#object[sandbox$eval254$fn__255$fn__256 0x21085919 "sandbox$eval254$fn__255$fn__256@21085919"]
10:21lpetit*ns*
10:21lpetit,*ns*
10:21clojurebot#object[clojure.lang.Namespace 0x1fb19a1e "sandbox"]
10:21lpetitok so alter-var-root is protected
10:24justin_smithlpetit: your (use 'clojure.pprint) above failed because your client inserts smart quotes
10:24lpetitoh
10:24lpetitmy client is Colloquy
10:24lpetitmy client is colloquy
10:25justin_smithlpetit: also, (print #'print) had a smart quote in it too
10:25justin_smith,(print #'print)
10:25clojurebot#'clojure.core/print
10:26lpetit,*ns*
10:26clojurebot#object[clojure.lang.Namespace 0x7becd536 "sandbox"]
10:26lpetitmy client is colloquy, do you know where the option is to prevent smart quotes insertion?
10:26lpetit,(print *ns*)
10:26clojurebot#object[clojure.lang.Namespace 0x7becd536 sandbox]
10:28justin_smithlpetit: no, I don't
10:28scriptorlpetit: isn't that an osx thing?
10:29scriptorhttp://www.iclarified.com/38772/how-to-disable-curly-quotes-in-mac-os-x-mavericks
10:29lpetit(print #'print)
10:29lpetit,(print #'print)
10:29clojurebot#'clojure.core/print
10:29lpetitwhen I first type the expression in sublime text, then paste it in Colloquy’s input area, things work better
10:30scriptorthat's because sublime probably uses a different widget or something, check out that link
10:30lpetit,(print #'print)
10:30clojurebot#'clojure.core/print
10:30lpetitscriptor: you're my hero, thanks
10:31lpetitSo i cannot alter one of clojurebot's clojure.core vars, too bad :-)
10:32justin_smithlpetit: I don't have the details with me on my work machine here, but amalloy_ showed us a trick for changing the definition for 5 so it would be 2
10:33justin_smithlpetit: you can probably imagine how many things that breaks
10:33lpetit:-)
10:34lpetitWas just trying to install the fix I proposed for getting back human-readable prints for ns and exceptions.
10:38cflemingamalloy_: Sorry for the delay, did you get the debugging working?
10:46wasamasawait, how do I turn a string looking like a number into a number?
10:47TMA,(Long/parseLong "123456")
10:47clojurebot123456
10:47wasamasa.___.
10:50justin_smiththere is also read-string
10:52wasamasathat feels like cheating
10:54lpetitwasamasa: depends on what you want. read-string (or rather read-edn I'd suggest) can also read more sophisticated number representations
10:54lpetit,(read-edn "123456")
10:54clojurebot#error {\n :cause "Unable to resolve symbol: read-edn in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: read-edn in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: read-ed...
10:54lpetit(clojure.edn/read-edn "123456")
10:54lpetit,(clojure.edn/read-edn "123456")
10:54clojurebot#error {\n :cause "clojure.edn"\n :via\n [{:type java.lang.ClassNotFoundException\n :message "clojure.edn"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClassLoader$1 run "URLClassLoader.java" 366]\n [java.net.URLClassLoader$1 run "URLClassLoader.java" 355]\n [java.security.AccessController doPrivileged "AccessController.java" -2]\n [java.net.URL...
10:55lpetit(require 'clojure.edn)
10:55lpetit,(require 'clojure.edn)
10:55clojurebotnil
10:55lpetit,(clojure.edn/read-edn "123456")
10:55clojurebot#error {\n :cause "No such var: clojure.edn/read-edn"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: No such var: clojure.edn/read-edn, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "No such var: clojure.edn/read-edn"\n :at [clojure.lang.Util runti...
10:56lpetit,(clojure.edn/read-string "123456")
10:56clojurebot123456
10:56lpetit,(clojure.edn/read-string "3/4")
10:56clojurebot3/4
10:56lpetit,(clojure.edn/read-string "1.4e10")
10:56clojurebot1.4E10
10:57lpetit,(clojure.edn/read-string "1.1e2")
10:57clojurebot110.0
11:40sveriHi, in my tests I am trying to setup joplin/migrate-db and pass it a path to the migrations "resources/migrators/sqlite" but no matter what I try, I always get this error: Warning, no migrators found! I tried several different paths, with no success (http://pastebin.com/eXYYTs8D)
11:42sverirunning lein joplin migrate from the command line works, btw
11:42justin_smithsveri: inside the jvm process, leave off resources/
11:42justin_smithsveri: because that part is not classpath relative, it's mapped to your classpath
11:43sverijustin_smith: I tried that too, doesn't work either, could it be that the lein test does not include the resources folder?
11:43justin_smithhmm, it should have your resources folder on its classpath
11:43justin_smithyou could always check manually of course
11:44sverihow?
11:44clojurebotwith style and grace
11:44justin_smithhaha
11:44sveri:D
11:45justin_smithsveri: one moment, double checking in my own repl
11:45sverikk
11:46FrozenlockWhat is the equivalent of IPrintWithWriter (cljs) in clojure? I have records for which I'd like to have a custom printer.
11:48justin_smith,(System/getProperty "java.class.path")
11:48clojurebot#error {\n :cause "denied"\n :via\n [{:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkPropertyAccess nil -1]\n [java.lang.System getProperty ...
11:48justin_smithsveri: ^
11:48justin_smithwill work in your repl
11:49justin_smithFrozenlock: print-method maybe?
11:49justin_smithit's a multi-method you can extend
11:49Frozenlockjustin_smith: so I wouldn't place it in the record declaration, just extend it anywhere in my namespace?
11:50justin_smithFrozenlock: well you could extend it anywhere, but it makes sense to do it near the definition of the record
11:50sverijustin_smith: thanks, it exists in the classpath
11:50justin_smithFrozenlock: but yeah, since it's a multimethod it's pretty flexible about where you do it
11:54Frozenlockjustin_smith: hmm.. it works, but not in the repl :-/
11:56FrozenlockWait, nvm, it works now.
11:56FrozenlockThat was weird...
11:56Frozenlockjustin_smith: thank you very much for your help.
11:59justin_smithFrozenlock: np, glad you figured it out
12:24amalloycfleming: no, i gave up and used println instead
12:25cflemingamalloy: Ok, sorry about that - if you have a need to try it again and it doesn't work, let me know
12:25amalloyokay, thanks
12:40Lollypop_is there a cleaner way of writing this? (rest (rest array))
12:41amalloythere are a few. you could simply (drop 2 xs)
12:41Lollypop_ty
12:41amalloyor (nnext xs) is close enough
12:41sobel<3 nnext
12:42sobelcould also use a penultimate fn, but..
12:42sobel(because there's no llast)
12:42amalloy(def llast (comp last butlast)
12:42amalloy)
12:43csd_Is there any way to specify a lazy let? Where a specific binding isnt evaluated until it's needed in the let body?
12:43sobel:)
12:43justin_smith(def llast (constantly ()))
12:43justin_smithcsd_: flatland/useful has that
12:43justin_smithcsd_: also you can do it ad-hoc with delay / deref
12:44csd_oh great idea
12:44csd_thanks
12:44justin_smithcsd_: sometimes promise/ deliver / deref if you need even more flexibility, but usually delay/deref suffic
12:46csd_i'm trying to do a (let [<stuff>] (if (or <any of the stuff>))) and so i just want it to skip evaluation if the or is satisfied
12:46csd_looks like delay will do that
12:46amalloyhuh, promise. i was just thinking the other day about how it's a little awkward to write like (let [[x y] (if foo [a b] [c d])] ...) in some cases, and isn't it nice in imperative languages that you can just have an assignment to x in each branch
12:47amalloyif you really wanted to (though you usually wouldn't), you could do that with a promise: (let [x (promise) y (promise)] (if foo (deliver x a) ....))
12:48Bronsathat's just ugly :(
12:49amalloyyeah, it is
12:49hiredmanor pull the continuation of that binding out as a function and call it from the if cases
12:49Bronsaa volatile would probably be better if using 1.7
12:49justin_smithamalloy: yeah, the conditional assignment is where I end up reaching for promise sometimes. Most people use an atom, but I like to go back and turn atoms into promises if the value will only come in once.
12:50hiredman(let [[x y] (if foo [a b] [c d])] (+ x y)) => (letfn [(f [x y] (+ x y))] (if foo (f a b) (f c d)))
12:50Bronsathat's actually not as bad as it sounded
12:51hiredmanalways use a $10 dollar CS word if you can
12:58hiredmansome day, maybe, if I eat my wheaties and send away the box tops, the compiler might be able to lift fns like that letfn into static methods
13:06Bronsahiredman: your current patch doesn't do this yet, right?
13:06hiredmancorrect
13:06Bronsa(the one for the ticket I can't remember)
13:06hiredmanclj-701
13:06Bronsayou'd need to make sure the fn is never used as a value
13:06hiredmanright
13:07Bronsanot that it would be a terribly complex thing to do
13:07hiredmanand you would need to deal with closed over values
13:07Bronsaright
13:07hiredmanall the things you do for λ lifting
13:07Bronsauh, would you really need to care about closed overs though?
13:07hiredmanand then the jvm would turn around and just re-inline the static method
13:08Bronsaisn't that already taken care by the compiler for normal fns?
13:08hiredmanBronsa: it depends
13:08hiredmanBronsa: if you have a liftable fn, inside a liftable fn, and the inner closes over one of the arguments of the outer
13:59lpetithello
14:00lpetitI want to trick leiningen nrepl so that when its "print" phase of the repl loop works, it's with a specific dyn var bound to a certain value.
14:02lpetitI'm trying to work around repl not printing *ns* correctly. Via :injections I add code to create `clojure.core/*print-in-repl*`, I adapt the code of `clojure.core/print-object` to use it.
14:03lpetitWhat's left is binding `*clojure.core/print-in-repl*` appropriately, e.g. around the call to `print` inside the nrepl server loop.
14:04lpetitany clue on how to do this "externally", e.g. by tweaking the project map from the command line via -- update-in ... tricks ?
14:12gfredericks,(map str ['(1 2 3) ()]) ;; ha
14:12clojurebot("(1 2 3)" "clojure.lang.PersistentList$EmptyList@1")
15:49csd_making a macro to wrap body into a try/catch-- bad idea or fine?
16:29justin_smithany advice about incanter? is it awesome? disappointing?
16:31justin_smithis it mostly useful for vis, or is it still useful as a tool for doing some statistical methods in my app?
16:40sveriHi, does anyone here write tests with clj-webdriver and runs them on a docker machine?
17:07stainno, but that sounds fun!
17:13csd_is it possible to use try/catch in a macro without losing line number info
17:57eriktjacobsenAnyone have a faster / more idiomatic way of filtering a list of maps based on an array of values corresponding to specific field? Such as:
17:57eriktjacobsen(defn filter-map [list-of-maps value-array field]
17:57eriktjacobsen (let [val-set (set value-array)]
17:57eriktjacobsen (filter #(val-set (field %)) list-of-maps)))
17:59amalloywell, it is simpler if you write it more like (filter (comp (set value-array) field) maps)
17:59amalloybut that is the basic shape of things, and you can't really do anything more exciting
18:00eriktjacobsenthat set would only get called once? hmm I see. But it would get called multiple times if I did (filter #((set value-array) (field %)) maps) ?
18:01eriktjacobsenI’m not sure what gets re-run each loop in a map / filter type call.
18:07amalloyeriktjacobsen: you don't need to be sure about that, because you can figure it out based on knowing what functions are
18:09amalloya function's arguments are evaluated every time the function is called, and not again; likewise a function's body. the trick is that (comp (set value-array)) is only called once; it *returns* a function which is called multiple times, but that function has a trivial body: all its interesting state is stored in its lexical closure
18:18turbofailugh. there was some clojure library for doing structural regular expressions, but i can't remember what it was called
18:22amalloyturbofail: http://stackoverflow.com/questions/23119833/a-regex-style-matching-library-for-generic-matching-on-list-items ?
18:27turbofailno, it was something for manipulating regular expressions as data, kind of like SRE for scheme
18:29amalloyoh, so https://github.com/cgrand/regex
18:29turbofailah yeah that was it
18:32turbofailthanks, i was wearing out my backslash key
18:34celwellIs there a way to have a multiline string literal without it inserting \n? I just want to follow the 80 character width.
18:36justin_smithcelwell: one mediocre solutions is (string/join \n ["line one" "line two" ...]) - it's verbose, but at least it indents nicely when you break it up over multiple lines
18:36celwellThat does what I want but it's hideous. Maybe I should make a macro...
18:37celwellactually, sorry that doesn't do what I want. I want no \n
18:37celwellso it would just be ""
18:38turbofailthere's always (str "foo bar baz" "asdf asdf asdf asdf")
18:38justin_smithahh, the string literal is on multiple lines but there are no newlines in the string
18:38justin_smithyeah, do it turbofail 's way, I didn't realize you wanted something that simple
18:38celwellturbofail: yes that's what im currently doing but it's annoying to me
18:39celwellI feel like I shouldn't have to use another function just to avoid long line lengths
18:40turbofailare you objecting to the "expense" of the function call, or to the syntactic overhead?
18:40celwellthe latter
18:40amalloyit would be nice if \<newline> were treated as a line continuation in clojure, but it's not
18:40celwellexactly
18:41celwellMaybe I could overwrite that behavior, but that could have unintended consequences I guess
18:42justin_smithcelwell: (string/replace "........." #"\n *" "") - this allows each line to be indented however you like, and all newlines and leading spaces are removed
18:43justin_smithtrailing spaces are preserved though, if needed
18:43turbofailyou could also define a tagged reader handler that does that transformation, while being terse
18:43celwellHmmm... I this (str ) would be preferrably though
18:43turbofailthough i've basically never used those
18:45turbofailhttp://clojure.org/reader#The%20Reader--Tagged%20Literals
18:55coredih
18:55coredhi
18:56coredare there any web frameworks on clojure ?
18:56coredlooks like the clojure community is not very into web development stuff, as far as I see
18:57justin_smithcored: that's weird, because that's probably the most common usage of clojure in the real world
18:57justin_smithwe mostly don't use frameworks though
18:57coredjustin_smith: I see
18:58justin_smithcored: for a rest service, check out liberator
18:58coredjustin_smith: I've been having this mix feelings about languages lately comming from a Ruby/Rails background and all the limitations that I've found in there. Was thinking in checking other places; have Go/Scala/Clojure in mind
18:58justin_smiththere's also ring/compojure (I prefer to use ring with other routing libs, but compojure is a popular choice)
18:58coredgot it
18:59justin_smiththere's a good book on clojure web development
18:59justin_smithhttps://pragprog.com/book/dswdcloj/web-development-with-clojure
19:00coredoh
19:00corednice
19:00coredthanks
19:01coredI'm reading Living Clojure
19:01coredto learn the language
19:15Frozenlockcored: I'd also invite you to check Yada. The routes-as-data and the ability to generate swagger docs are pretty sweet.
19:16coredFrozenlock: thanks, will do that
19:44spiedenyada looks cool. had been wanting something with swagger support
21:30vas_Hi everyone, i'm trying to run a jar generated with lein jar. However, i get the unusual error "Error: Could not find or load main class clojure.main"
21:33Snovavas_: are you using both -cp and -jar ?
21:34vas_no, I take it I should set the classpath manually with -cp?
21:34Snovaoh. actually yes, that would probably be it. and -jar and -cp are mutually exclusive so stick your own jar onto the end of the classpath and specify your main explicitly.
21:35vas_how do I specify the main explicitly?
21:35Snovajava -cp ... mypackage.mymodule
21:38vas_Hmm okay I will play with it... Sorry if i'm a bit slow, but I make a jar via lein jar, then when i want to run it with java -cp "~/path/to/the.jar" main?
21:39Snovasounds about right. though probably the classpath will be huge
21:39Snovalook into "lein classpath" or "lein uberjar"
21:40vas_Okay, thanks a lot for the pointer!
21:43vas_I'm still not quite sure what the invocation for "main" should look like. I am trying to run a ring application and I have in "disproject" a file handler.clj and in there is a fxn called "app" -> disproject.handler/app ?
21:44Snovavas_: well, you have the app object/function thing, and you'll need a (defn -main) of some sort to start the app. and then you're doing "java -cp ... pkg.module" if the main is pkg.module/main
21:45vas_Snova: Ah, thanks for clarifying.
21:57vas_What is the likelihood that I borked my whole project by playing with the classpath =)?
21:58Snovavas_: how does one play with a classpath?
21:59vas_well just using java -cp ... = persistent changes?
21:59vas_https://www.refheap.com/106892
21:59vas_exhibit A
21:59Snovathat's not persistent at all; just a regular command line option
22:00Snovawell then. you're well beyond me
22:32squeedeeI was explaining quoted lists to a friend, when an example I tried to use gave me a result I did not expect:
22:32squeedee((first `(+ 1 2)) 3 4) => 4
22:32squeedeewhy not 7?
22:34squeedeeI mean i was seriously ready to be wrong about how to use a function pulled from a list, i was not ready for 4.
22:35namrahm someone a clue why i cant conj or assoc the result of the following: (-> (kc/select* db) (wrap-fields params) (wrap-where {(:id rtype) rid}))
22:35namrait returns a map: {:ent {:table tablename, ...}}
22:36namrabut doing (conj v (-> (kc/select* ...)) results in an empty vector
22:37squeedeecollection first?
22:37squeedeeor is v also a vector
22:37namrav is a vector
22:37weebzDoes anyone know how to import a java class in the REPL that isn't from the standard?
22:38namraso i expect the result to be: [{:ent {:table tablename ...}}]
22:39namraweebz: iirc and if you use leininge you can put the .jar into the resources directory, cause that is part of the classpath
22:40namraor add it to the CLASSPATH environment variable
22:41weebzand in an env. var for my shell?
22:41squeedeenamra and I guess you tried using an empty vec in your conj to just provie its not a type problem with v?
22:41namrasqueedee: yup
22:41squeedeefascinating
22:42ghost_runnerClojure is NOT a Lisp.
22:42squeedeethat's nice
22:42namraweebz: either resources dir in your leiningen project or an env var of the shell
22:48EssenceI want to configure the following setup: whenever I enter 'lein repl' on my terminal, it will check whether there's already a connection (checking $PROJECT_ROOT/.nrepl_port or ~/.lein/nrepl_port)... if it exists, connect to it, otherwise just create the server and connect to it
22:48EssenceI checked the options and found nothing like that, and I don't want to make an alias or bash function for all of that... there's any middleware or any other way to achieve this?
22:51weebznamra: so do I just drop the .jar into my resources folder, lein repl, and then call import? require?
22:51weebzI tried both and I'm getting a ClassNotFound
22:52weebzah, just realized there's a lot of jars in subfolders
22:52weebzthat I hadn't copied
22:52squeedeei also dont think you need to require them?
22:52squeedeejust use the interop forms?
22:53namraweebz: http://stackoverflow.com/questions/2404426/leiningen-how-to-add-dependencies-for-local-jars --- the second answer
22:53squeedeenm you can import them
22:58weebzahhhh yiiiiis thank you namra
22:58namraweebz: you're welcome
23:02squeedeeif (first '(+)) returns a symbol, how do i obtain the function that symbol refers to?
23:03chouser(resolve '+) will return the var
23:03chouserderef the var to get the function
23:07squeedeechouser: thanks
23:11justin_smithsqueedee: ##('anything nil :default)
23:11lazybot⇒ :default
23:11justin_smithsqueedee: but maybe you figured that out already
23:12justin_smith,('symbol '{symbol 42} :default)
23:12squeedeeyah right it's a special function invocation, i worked that out once i realised (first `(+)) returned a symbol
23:12clojurebot42
23:16squeedeesometime i wish clojure had less syntactic sugar like that.. just to make it easier to reason about.. even tho I realise it makes some things more long winded
23:17justin_smithyou can pry ##(:k {:k :OK}) out of my cold, dead, codebase
23:17lazybot⇒ :OK