#clojure log - Jul 23 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:05 Seylerius: Would it be appropriate for an API library to use component to manage API config state?

0:06 * Seylerius just learned about component.

3:10 mercwithamouth: so what exactly is 'step'?

3:17 an offset i know but the results weren't as expected when i chose... 3 opposed to 2

3:19 ahh forgive me....makes since with numbers

3:38 ely-se: in a macro I want to check whether something is a let expression

3:39 should I do (if (and (seq? x) (= 'let (first x)))) ?

3:40 TEttinger: isn't let a macro?

3:40 ,(macroexpand-1 '(let [x 1] x))

3:40 clojurebot: (let* [x 1] x)

3:40 TEttinger: hm

3:40 ,let

3:40 clojurebot: #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....

3:41 TEttinger: ,(macroexpand-1 (macroexpand-1 '(let [x 1] x)))

3:41 clojurebot: (let* [x 1] x)

3:41 TEttinger: ,(macroexpand-1 ~(macroexpand-1 '(let [x 1] x))))

3:41 clojurebot: #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...

3:41 ely-se: oh, I see

3:41 TEttinger: ,(macroexpand-1 '(macroexpand-1 '(let [x 1] x))))

3:41 clojurebot: (macroexpand-1 (quote (let [x 1] x)))

3:41 TEttinger: gah

3:41 not good with macros no more

3:42 dmitrig01: let* is a special form

3:42 afaik

3:42 wasamasa: not sure what you expected to see there

3:43 also, isn't there a macroexpand-all?

3:46 namra: someone using metric-clojure? getting the following: com.codahale.metrics.Timer$Context cannot be cast to com.codahale.metrics.Sampling

3:47 ely-se: TEttinger: http://ideone.com/DMHRZr <- it works now

3:47 thanks

3:47 namra: sample code: http://pastebin.com/7HgtB3St

3:48 dmitrig01: namra: (tmr/percentiles t) => (tmr/percentiles sql-query-time)

3:53 namra: dmitrig01: com.codahale.metrics.Timer cannot be cast to com.codahale.metrics.Timer$Context :/

3:53 dmitrig01: sry my bad

3:54 dmitrig01: thanks

5:09 xificurC: I 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

5:43 echo-area: 1.8 alphas are released really fast

7:05 justin_smith: xificurC: those are dependencies for cider, and are injected by the cider plugin

7:05 and are only present at dev time

7:07 xificurC: justin_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

7:07 is there any way to override that?

7:07 justin_smith: xificurC: I'm not sure how that works, though I know there is a solution. It's a conflict between leiningen deps and cider deps.

7:07 xificurC: I just created a project.clj with (defproject abc "0.1.0-SNAPHOST" :dependencies []) and it already depends on nrepl and clojure-complete

7:08 justin_smith: it should be documented somewhere in the cider project

7:08 xificurC: yes, the cider plugin should be in ~/.lein/profiles.clj

7:08 that's how they tell you to get it at least

7:08 and the deps from there are always used

7:08 xificurC: justin_smith: except I don't have it there

7:08 justin_smith: (locally, for dev)

7:09 xificurC: then I have no idea what's going on or where your cider deps are coming from

7:10 xificurC: justin_smith: unfortunately that makes 2 of us :)

7:10 justin_smith: xificurC: how did you add your cider plugin when you were setting up cider?

7:11 xificurC: justin_smith: locally into the project.clj's plugins. [cider/cired-nrepl "0.9.1"]

7:11 s/cired/cider/

7:11 justin_smith: then that's where the deps are coming from, like I said before, the cider plugin "injects" deps into your project when it is loaded

7:13 xificurC: justin_smith: just found this as you noted https://github.com/clojure-emacs/cider#warning-saying-you-have-to-use-nrepl-027

7:16 so it's actually leiningen that pulls those in

7:17 justin_smith: oh, right. I keep forgetting that lein repl uses clojure complete

7:17 and of course it uses nrepl

7:20 xificurC: justin_smith: that fixes it. Ugh this was very painful

7:20 justin_smith: xificurC: cider can be kind of a hairball, I gave up on it

7:20 xificurC: justin_smith: and what do you use

7:20 justin_smith: xificurC: inferior-lisp, like a caveman

7:20 xificurC: is it cider's fault though? It's leiningen that's pulling in a pretty old nrepl

7:22 justin_smith: xificurC: 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.

7:22 schmir: there's also https://github.com/clojure-emacs/inf-clojure

7:22 justin_smith: I experienced frequent breakages, and when updating I got yet more breakages.

7:23 xificurC: this whole setup is daunting. There's nrepl, there's cider, piggieback, figwheel..

7:23 justin_smith: in 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

7:23 xificurC: I don't know who does what

7:23 justin_smith: xificurC: yeah, there's a lot of tooling going on

7:24 xificurC: for a newcomer it's a nightmare

7:24 reading through 3-4 github readmes and wikis

7:28 justin_smith: xificurC: 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.

7:30 xificurC: lol 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

7:31 justin_smith: xificurC: the figwheel repl shouldn't be part of your normal cider repl

7:31 it's a separate connection (to the js vm rather than the jvm)

7:31 unless I don't understand what you are doing here....

7:32 xificurC: if I want figwheel inside emacs I do C-u M-x inferior-lisp<return> lein figwheel<return>

7:32 unless cider has figwheel tooling now...

7:34 noncom: do people using emacs to program clojure use it also to program the other languages when they have to? like java..?

7:34 or scala

7:34 justin_smith: I've done java in emacs, but many people describe doing that as masochistic

7:36 noncom: so.. emacs is mainly for lisps and c...

7:36 i guess..

7:36 i also saw python done well...

7:39 * algernon uses emacs everything (c, java, clojure, python, hy, shell, html, css, text/markdown, email, erlang, haskell, etc)

7:40 rarebreed: I use it for Python...I'm also using it at the moment for a combined java/clojure project

7:40 and before, when I used to do c(++) I used it heavily because it integrates with gdb and cscope so nicely

7:41 and ctags

7:41 wasamasa: algernon: you're using hy?

7:41 rarebreed: oh yeah, and hy too :)

7:41 got watch out for hy's lets though...it's more scheme-like

7:42 although no need to letrec or letrec*

7:42 algernon: wasamasa: yes

7:43 rarebreed: I know someone who was using emacs for elixir, but he switched to sublime

7:44 * algernon only leaves Emacs for browsing, and some $work tools that fail to integrate with anything.

7:45 cfleming: justin_smith: I describe doing Java in Emacs as professional negligence :-)

7:45 rarebreed: anyone 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?

7:45 I have clojure calling some methods in an object from a java jar in my classpath

7:46 normally, I c-x c-e to eval my code, which kicks off the call chain that hits the java method

7:46 cfleming: rarebreed: 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.

7:47 rarebreed: cfleming: maybe i'll give cursive a swing :)

7:47 cfleming: rarebreed: You never know, you might like it :-)

7:48 rarebreed: I do also use pycharm/intellij for python

7:48 cfleming: rarebreed: https://www.youtube.com/watch?v=ql77RwhcCK0

7:48 Ok, it should be pretty familiar then, all their IDEs work in basically the same way.

7:48 rarebreed: it's not a bad setup...and since this is a mixed java/clojure project, maybe it will be better for me than emacs+cider

7:49 cfleming: cool, I'll check it out

7:49 cfleming: Yeah, Cursive has really nice interop support now

7:49 rarebreed: speaking of cider...anyone notice that sometimes the nrepl-server output buffer doesn't become available?

7:49 xificurC: justin_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

7:50 rarebreed: sometimes I have to restart emacs and keep trying cider-jack-in...eval my code...and hope the nrepl-server buffer shows up

7:50 xificurC: justin_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

7:51 justin_smith: "The nREPL CLJS landscape is in flux right now, so your mileage may vary"

7:51 xificurC: even though figwheel-sidecar is in ~/.m2/ it can't find it in the classpath

7:51 justin_smith: yeah i know

7:52 justin_smith: xificurC: just because something is in your local cache, that doesn't mean it's on the classpath

7:52 xificurC: these things were in flux 2 years ago as well. Would be nice to finally settle on something :)

7:52 justin_smith: it needs to be a dep for that (if you are using lein)

7:52 xificurC: justin_smith: yes lein

7:53 justin_smith: yeah, .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.

7:53 xificurC: justin_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

7:54 schmir: xificurC: the leiningen sample project.clj file

7:54 justin_smith: xificurC: 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)

7:54 schmir: https://github.com/technomancy/leiningen/blob/master/sample.project.clj

7:55 justin_smith: xificurC: 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.

7:55 xificurC: thanks schmir and justin_smith

7:55 justin_smith: so a plugin can do things like pre-processing files before your stuff launches, or setting up your classpath.

7:57 once 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.

7:57 )

8:00 xificurC: adding sidecar to the plugins didn't help

8:02 justin_smith: if the problem is that the dep is missing at runtime, it should be added to your dependencies

8:02 unless the plugin is design to inject the dep in a special way

8:05 * xificurC trying deps

8:06 xificurC: soon I'll just use rlwrap and screw it :)

8:07 justin_smith: xificurC that's what I actually do most of the time

8:08 xificurC: deps didn't help either

8:08 hellofunk: why is this:

8:09 ,(= (sort-by min [5 2 6]) (sort-by max [5 2 6]))

8:09 clojurebot: true

8:09 justin_smith: hellofunk: ##(= (min 5) (max 5))

8:09 lazybot: ⇒ true

8:10 hellofunk: i guess the quesion is, why does sorting a vector by max or min in both cases sort it in ascending order?

8:10 justin_smith: ,(sort-by :x [{:x 0} {:x 10} {:x -10}])

8:10 clojurebot: ({:x -10} {:x 0} {:x 10})

8:10 justin_smith: hellofunk: like I said, (min 5) is the same as (max 5)

8:10 sort-by doesn't work the way you think it does

8:10 hellofunk: apparently ot

8:10 *not

8:11 justin_smith: (doc sort-by)

8:11 clojurebot: "([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."

8:11 hellofunk: perhaps i am confusing a keyfn with a comparator

8:11 justin_smith: yes, you are

8:11 you just want sort

8:12 "comparing (keyfn item)" - eg. (min x)

8:13 hellofunk: ,(sort #(> % %2) [1 4 2 3])

8:13 clojurebot: (4 3 2 1)

8:13 hellofunk: ,(sort #(< % %2) [1 4 2 3])

8:13 clojurebot: (1 2 3 4)

8:14 justin_smith: hellofunk: you can simplify that ##(sort > [1 4 2 3])

8:14 lazybot: ⇒ (4 3 2 1)

8:15 hellofunk: right.

8:15 * xificurC removes cider from profiles

8:26 xificurC: schmir: inf-clojure solution in the figwheel wiki has the same issue, not finding figwheel-sidecar on the classpath

8:39 can one check the current classpath from the repl?

8:58 xtrntr1: hi

8:59 i have a racket background, looking to join clojure because the racket-to-js compiler is a work in progress

8:59 so i thought clojurescript would be nice and learning the jvm

8:59 is there anything i should know, jumping from racket to clojure? (pros and cons)

9:02 xificurC: that's a pretty broad question. Many design choices are different imho (macro system, immutability, laziness, ...). You should read a book or something to decide

9:03 noncom: xtrntr1: http://stackoverflow.com/questions/1413390/why-clojure-over-other-jvm-lisps-kawa-armed-bear-or-sisc

9:03 xtrntr1: http://stackoverflow.com/questions/11223403/what-are-the-differences-between-clojure-scheme-racket-and-common-lisp

9:03 so it's just different

9:03 xtrntr1: i've already decided to learn clojure, just to play with web apps. i'm more of looking for a little pep talk

9:04 noncom: one of the biggest pros, if you ask me, is that it runs on the JVM, making the whole java ecosystem available

9:04 or javascript in your case. the integration is very good by now, afaik

9:04 xtrntr1: i have brief experience with the .net framework, but i don't know what's great about the JVM

9:04 enterprise-y stuff?

9:05 xemdetia: xtrntr1, with clojure you get pretty much everything that's already been built on java

9:05 noncom: not really. the VM itself is very fast and friendly, and saying ecosystem, I mean the loads and loads of good-quality libraries

9:05 you can find a library almost for anything you'd think of

9:05 and in most cases it will be of a production-grade quality

9:06 xtrntr1: okay

9:06 i'm -new- to web stuff so my questions might sound dumb

9:06 but i can write the whole stack in clojure right?

9:06 noncom: right

9:06 xtrntr1: html, js and cs

9:07 noncom: yes

9:07 xtrntr1: fantastic :) why aren't more languages doing this

9:07 xemdetia: because it's hard

9:08 noncom: when 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..

9:08 it strongly depends on the community also

9:08 here you get a very responsive and up-to-date one

9:08 xemdetia: jvm and js have good enough communities it is worth building something on top of

9:09 so I think that's part of it too

9:09 xtrntr1: so, how and why did you guys decide to pick up clojure?

9:10 xemdetia: for me it is I liked lisps but the ecosystem around most lisps is not very mature or well maintained

9:10 noncom: as 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

9:11 for a java programmer, it is almost impossible to get off the craving for the java ecosystem

9:11 xificurC: I 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

9:12 xtrntr1: academic sounds damning

9:12 noncom: it sounds like a niche

9:12 schmir: xtrntr1: 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.

9:13 kilon: xtrntr1: writting the whole thing in a single language is pretty stadard stuff even for unpopular languages

9:13 schmir: I'll probably explore F# in the future, which I think is also very interesting

9:13 kilon: i use pharo which is one of the most unpopular languages out there and it does this

9:14 noncom: took a look at pharo recently

9:14 looks interesting

9:14 schmir: somehow I also managed to get paid for writing clojure code :)

9:15 noncom: yeah, i use clojure at work too :)

9:15 so far, it's just another java library

9:15 kilon: pharo is great for live coding

9:15 Aejay: noncom: Oh you lucky fish!

9:15 noncom: heheh.. :) they just gave me freedom to write in the language of my choice..

9:16 xificurC: xtrntr1: 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

9:16 noncom: kilon: i don't think i'll ever get off lisps, but smalltalk is worth looking into. i wish i had more expertise with it

9:16 Aejay: For me, an ideal lisp would be one with ADTs and a good type system.

9:17 xtrntr1: xificurC: i'm just curious, what is a reasonable definition of "geared towards real-world usage" ?

9:17 i understand the JVM has tons of popular and up to date libraries, but what kind of essential libraries are racket lacking?

9:17 kilon: noncom: 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 :)

9:18 lpetit: Hi there, I’ve found a strange behavior for clojure.pprint. not new (happening with clojure 1.6 as well as clojure 1.7)

9:18 kilon: but keep an eye on clojure

9:18 lpetit: https://gist.github.com/laurentpetit/74b94bb9c3782d3e4940

9:18 xtrntr1: i'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.. :)

9:19 lpetit: in a nutshell, pretty printing a var is less pretty than printing it ….

9:19 xemdetia: xtrntr1, 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'

9:20 I 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

9:21 and 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

9:21 and that is the common case and not the exceptional case

9:22 with 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)

9:48 noncom: does anyone use quil here?

9:59 * wasamasa can't believe there's no abs or expt in clojure

10:00 mmeix: trying:

10:00 ,(Math/abs -3)

10:00 clojurebot: 3

10:00 mmeix: ,(Math/pow 2 3)

10:00 clojurebot: 8.0

10:00 mmeix: seems to work

10:01 wasamasa: why does the latter return a float ._____________.

10:01 mmeix: ,(map Math/abs [-2 3 -7])

10:01 clojurebot: #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:01 mmeix: umpf

10:01 * wasamasa hides in a corner

10:02 mmeix: ,(Math/abs -2)

10:02 clojurebot: 2

10:02 mmeix: hm

10:03 ,(map Math/abs [-2 -3])

10:03 clojurebot: #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:03 mmeix: myabe:

10:03 ,(map #(Math/abs %) [_2 -3])

10:03 clojurebot: #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:03 mmeix: grm

10:03 one can always do

10:04 ,(let [abs (fn [x] (max x (- x)))] (abs -3))

10:04 clojurebot: 3

10:05 mmeix: ,(let [abs (fn [x] (max x (- x)))] (map abs [-2 7 -3]))

10:05 clojurebot: (2 7 3)

10:06 mmeix: ,(Math/pow 2 3)

10:06 clojurebot: 8.0

10:06 mmeix: gives a float, yes

10:07 ,(let [pow (fn [a b] (reduce * (repeat a b)))] (pow 2 3))

10:07 clojurebot: 9

10:07 wasamasa: that's what I wrote in a fit of rage

10:08 mmeix: ,(let [pow (fn [a b] (reduce * (repeat b a)))] (pow 2/7 3))

10:08 clojurebot: 8/343

10:08 mmeix: would only work for pos integers as exp of course

10:09 wasamasa: right

10:09 mmeix: ,(map #(Math/abs %) [-2 3 -1])

10:09 clojurebot: (2 3 1)

10:09 mmeix: ah

10:10 was a typo ^

10:15 trying:

10:15 ,(def abs Math/abs)

10:15 clojurebot: #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:16 mmeix: ,(defn abs [x] (Math/abs x))

10:16 clojurebot: #'sandbox/abs

10:16 mmeix: ,(map abs [-1 2 -3])

10:16 clojurebot: (1 2 3)

10:17 lpetit: (print #’print)

10:18 ,(print #’print)

10:18 clojurebot: #<ArrayIndexOutOfBoundsException java.lang.ArrayIndexOutOfBoundsException: 8217>

10:18 lpetit: ~(print #’print)

10:18 clojurebot: It's greek to me.

10:18 mmeix: ,(defn pow [x y] #(Math/pow y x))

10:18 clojurebot: #'sandbox/pow

10:18 lpetit: ,(use ‘clojure.pprint)

10:18 clojurebot: #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:19 lpetit: ,*ns*

10:19 clojurebot: #object[clojure.lang.Namespace 0x1fb19a1e "sandbox"]

10:19 mmeix: ,(map pow [1 2 3] [2 0 3])

10:19 clojurebot: (#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:19 lpetit: ,(alter-var-root #'clojure.core/print-object

10:19 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:19 lpetit: (fn [old-print-object]

10:19 (fn [o, ^java.io.Writer w]

10:19 (if *print-readably*

10:19 (old-print-object o w)

10:19 (do

10:19 (when (instance? clojure.lang.IMeta o)

10:19 (#'clojure.core/print-meta o w))

10:19 (.write w "#<")

10:19 (let [name (.getSimpleName (class o))]

10:19 (when (seq name) ;; anonymous classes have a simple name of ""

10:19 (.write w name)

10:19 (.write w " ")))

10:19 (.write w (str o))

10:19 (.write w ">"))))))

10:19 oddcully: palease!

10:20 don't paste code into irc. use refheap or a gist

10:20 lpetit: ,(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:20 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:20 lpetit: (.write w ">"))))))

10:20 sobel: so, Var.applyTo or Var.invoke?

10:21 lpetit: ,(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:21 clojurebot: #object[sandbox$eval254$fn__255$fn__256 0x21085919 "sandbox$eval254$fn__255$fn__256@21085919"]

10:21 lpetit: *ns*

10:21 ,*ns*

10:21 clojurebot: #object[clojure.lang.Namespace 0x1fb19a1e "sandbox"]

10:21 lpetit: ok so alter-var-root is protected

10:24 justin_smith: lpetit: your (use 'clojure.pprint) above failed because your client inserts smart quotes

10:24 lpetit: oh

10:24 my client is Colloquy

10:24 my client is colloquy

10:25 justin_smith: lpetit: also, (print #'print) had a smart quote in it too

10:25 ,(print #'print)

10:25 clojurebot: #'clojure.core/print

10:26 lpetit: ,*ns*

10:26 clojurebot: #object[clojure.lang.Namespace 0x7becd536 "sandbox"]

10:26 lpetit: my client is colloquy, do you know where the option is to prevent smart quotes insertion?

10:26 ,(print *ns*)

10:26 clojurebot: #object[clojure.lang.Namespace 0x7becd536 sandbox]

10:28 justin_smith: lpetit: no, I don't

10:28 scriptor: lpetit: isn't that an osx thing?

10:29 http://www.iclarified.com/38772/how-to-disable-curly-quotes-in-mac-os-x-mavericks

10:29 lpetit: (print #'print)

10:29 ,(print #'print)

10:29 clojurebot: #'clojure.core/print

10:29 lpetit: when I first type the expression in sublime text, then paste it in Colloquy’s input area, things work better

10:30 scriptor: that's because sublime probably uses a different widget or something, check out that link

10:30 lpetit: ,(print #'print)

10:30 clojurebot: #'clojure.core/print

10:30 lpetit: scriptor: you're my hero, thanks

10:31 So i cannot alter one of clojurebot's clojure.core vars, too bad :-)

10:32 justin_smith: lpetit: 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:33 lpetit: you can probably imagine how many things that breaks

10:33 lpetit: :-)

10:34 Was just trying to install the fix I proposed for getting back human-readable prints for ns and exceptions.

10:38 cfleming: amalloy_: Sorry for the delay, did you get the debugging working?

10:46 wasamasa: wait, how do I turn a string looking like a number into a number?

10:47 TMA: ,(Long/parseLong "123456")

10:47 clojurebot: 123456

10:47 wasamasa: .___.

10:50 justin_smith: there is also read-string

10:52 wasamasa: that feels like cheating

10:54 lpetit: wasamasa: depends on what you want. read-string (or rather read-edn I'd suggest) can also read more sophisticated number representations

10:54 ,(read-edn "123456")

10:54 clojurebot: #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:54 lpetit: (clojure.edn/read-edn "123456")

10:54 ,(clojure.edn/read-edn "123456")

10:54 clojurebot: #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:55 lpetit: (require 'clojure.edn)

10:55 ,(require 'clojure.edn)

10:55 clojurebot: nil

10:55 lpetit: ,(clojure.edn/read-edn "123456")

10:55 clojurebot: #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:56 lpetit: ,(clojure.edn/read-string "123456")

10:56 clojurebot: 123456

10:56 lpetit: ,(clojure.edn/read-string "3/4")

10:56 clojurebot: 3/4

10:56 lpetit: ,(clojure.edn/read-string "1.4e10")

10:56 clojurebot: 1.4E10

10:57 lpetit: ,(clojure.edn/read-string "1.1e2")

10:57 clojurebot: 110.0

11:40 sveri: Hi, 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:42 running lein joplin migrate from the command line works, btw

11:42 justin_smith: sveri: inside the jvm process, leave off resources/

11:42 sveri: because that part is not classpath relative, it's mapped to your classpath

11:43 sveri: justin_smith: I tried that too, doesn't work either, could it be that the lein test does not include the resources folder?

11:43 justin_smith: hmm, it should have your resources folder on its classpath

11:43 you could always check manually of course

11:44 sveri: how?

11:44 clojurebot: with style and grace

11:44 justin_smith: haha

11:44 sveri: :D

11:45 justin_smith: sveri: one moment, double checking in my own repl

11:45 sveri: kk

11:46 Frozenlock: What is the equivalent of IPrintWithWriter (cljs) in clojure? I have records for which I'd like to have a custom printer.

11:48 justin_smith: ,(System/getProperty "java.class.path")

11:48 clojurebot: #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:48 justin_smith: sveri: ^

11:48 will work in your repl

11:49 Frozenlock: print-method maybe?

11:49 it's a multi-method you can extend

11:49 Frozenlock: justin_smith: so I wouldn't place it in the record declaration, just extend it anywhere in my namespace?

11:50 justin_smith: Frozenlock: well you could extend it anywhere, but it makes sense to do it near the definition of the record

11:50 sveri: justin_smith: thanks, it exists in the classpath

11:50 justin_smith: Frozenlock: but yeah, since it's a multimethod it's pretty flexible about where you do it

11:54 Frozenlock: justin_smith: hmm.. it works, but not in the repl :-/

11:56 Wait, nvm, it works now.

11:56 That was weird...

11:56 justin_smith: thank you very much for your help.

11:59 justin_smith: Frozenlock: np, glad you figured it out

12:24 amalloy: cfleming: no, i gave up and used println instead

12:25 cfleming: amalloy: Ok, sorry about that - if you have a need to try it again and it doesn't work, let me know

12:25 amalloy: okay, thanks

12:40 Lollypop_: is there a cleaner way of writing this? (rest (rest array))

12:41 amalloy: there are a few. you could simply (drop 2 xs)

12:41 Lollypop_: ty

12:41 amalloy: or (nnext xs) is close enough

12:41 sobel: <3 nnext

12:42 could also use a penultimate fn, but..

12:42 (because there's no llast)

12:42 amalloy: (def llast (comp last butlast)

12:42 )

12:43 csd_: Is there any way to specify a lazy let? Where a specific binding isnt evaluated until it's needed in the let body?

12:43 sobel: :)

12:43 justin_smith: (def llast (constantly ()))

12:43 csd_: flatland/useful has that

12:43 csd_: also you can do it ad-hoc with delay / deref

12:44 csd_: oh great idea

12:44 thanks

12:44 justin_smith: csd_: sometimes promise/ deliver / deref if you need even more flexibility, but usually delay/deref suffic

12:46 csd_: 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:46 looks like delay will do that

12:46 amalloy: huh, 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:47 if 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:48 Bronsa: that's just ugly :(

12:49 amalloy: yeah, it is

12:49 hiredman: or pull the continuation of that binding out as a function and call it from the if cases

12:49 Bronsa: a volatile would probably be better if using 1.7

12:49 justin_smith: amalloy: 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:50 hiredman: (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:50 Bronsa: that's actually not as bad as it sounded

12:51 hiredman: always use a $10 dollar CS word if you can

12:58 some 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:06 Bronsa: hiredman: your current patch doesn't do this yet, right?

13:06 hiredman: correct

13:06 Bronsa: (the one for the ticket I can't remember)

13:06 hiredman: clj-701

13:06 Bronsa: you'd need to make sure the fn is never used as a value

13:06 hiredman: right

13:07 Bronsa: not that it would be a terribly complex thing to do

13:07 hiredman: and you would need to deal with closed over values

13:07 Bronsa: right

13:07 hiredman: all the things you do for λ lifting

13:07 Bronsa: uh, would you really need to care about closed overs though?

13:07 hiredman: and then the jvm would turn around and just re-inline the static method

13:08 Bronsa: isn't that already taken care by the compiler for normal fns?

13:08 hiredman: Bronsa: it depends

13:08 Bronsa: if you have a liftable fn, inside a liftable fn, and the inner closes over one of the arguments of the outer

13:59 lpetit: hello

14:00 I 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:02 I'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:03 What's left is binding `*clojure.core/print-in-repl*` appropriately, e.g. around the call to `print` inside the nrepl server loop.

14:04 any clue on how to do this "externally", e.g. by tweaking the project map from the command line via -- update-in ... tricks ?

14:12 gfredericks: ,(map str ['(1 2 3) ()]) ;; ha

14:12 clojurebot: ("(1 2 3)" "clojure.lang.PersistentList$EmptyList@1")

15:49 csd_: making a macro to wrap body into a try/catch-- bad idea or fine?

16:29 justin_smith: any advice about incanter? is it awesome? disappointing?

16:31 is it mostly useful for vis, or is it still useful as a tool for doing some statistical methods in my app?

16:40 sveri: Hi, does anyone here write tests with clj-webdriver and runs them on a docker machine?

17:07 stain: no, but that sounds fun!

17:13 csd_: is it possible to use try/catch in a macro without losing line number info

17:57 eriktjacobsen: Anyone 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:57 (defn filter-map [list-of-maps value-array field]

17:57 (let [val-set (set value-array)]

17:57 (filter #(val-set (field %)) list-of-maps)))

17:59 amalloy: well, it is simpler if you write it more like (filter (comp (set value-array) field) maps)

17:59 but that is the basic shape of things, and you can't really do anything more exciting

18:00 eriktjacobsen: that 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:01 I’m not sure what gets re-run each loop in a map / filter type call.

18:07 amalloy: eriktjacobsen: you don't need to be sure about that, because you can figure it out based on knowing what functions are

18:09 a 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:18 turbofail: ugh. there was some clojure library for doing structural regular expressions, but i can't remember what it was called

18:22 amalloy: turbofail: http://stackoverflow.com/questions/23119833/a-regex-style-matching-library-for-generic-matching-on-list-items ?

18:27 turbofail: no, it was something for manipulating regular expressions as data, kind of like SRE for scheme

18:29 amalloy: oh, so https://github.com/cgrand/regex

18:29 turbofail: ah yeah that was it

18:32 thanks, i was wearing out my backslash key

18:34 celwell: Is there a way to have a multiline string literal without it inserting \n? I just want to follow the 80 character width.

18:36 justin_smith: celwell: 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:36 celwell: That does what I want but it's hideous. Maybe I should make a macro...

18:37 actually, sorry that doesn't do what I want. I want no \n

18:37 so it would just be ""

18:38 turbofail: there's always (str "foo bar baz" "asdf asdf asdf asdf")

18:38 justin_smith: ahh, the string literal is on multiple lines but there are no newlines in the string

18:38 yeah, do it turbofail 's way, I didn't realize you wanted something that simple

18:38 celwell: turbofail: yes that's what im currently doing but it's annoying to me

18:39 I feel like I shouldn't have to use another function just to avoid long line lengths

18:40 turbofail: are you objecting to the "expense" of the function call, or to the syntactic overhead?

18:40 celwell: the latter

18:40 amalloy: it would be nice if \<newline> were treated as a line continuation in clojure, but it's not

18:40 celwell: exactly

18:41 Maybe I could overwrite that behavior, but that could have unintended consequences I guess

18:42 justin_smith: celwell: (string/replace "........." #"\n *" "") - this allows each line to be indented however you like, and all newlines and leading spaces are removed

18:43 trailing spaces are preserved though, if needed

18:43 turbofail: you could also define a tagged reader handler that does that transformation, while being terse

18:43 celwell: Hmmm... I this (str ) would be preferrably though

18:43 turbofail: though i've basically never used those

18:45 http://clojure.org/reader#The%20Reader--Tagged%20Literals

18:55 cored: ih

18:55 hi

18:56 are there any web frameworks on clojure ?

18:56 looks like the clojure community is not very into web development stuff, as far as I see

18:57 justin_smith: cored: that's weird, because that's probably the most common usage of clojure in the real world

18:57 we mostly don't use frameworks though

18:57 cored: justin_smith: I see

18:58 justin_smith: cored: for a rest service, check out liberator

18:58 cored: justin_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:58 justin_smith: there's also ring/compojure (I prefer to use ring with other routing libs, but compojure is a popular choice)

18:58 cored: got it

18:59 justin_smith: there's a good book on clojure web development

18:59 https://pragprog.com/book/dswdcloj/web-development-with-clojure

19:00 cored: oh

19:00 nice

19:00 thanks

19:01 I'm reading Living Clojure

19:01 to learn the language

19:15 Frozenlock: cored: I'd also invite you to check Yada. The routes-as-data and the ability to generate swagger docs are pretty sweet.

19:16 cored: Frozenlock: thanks, will do that

19:44 spieden: yada looks cool. had been wanting something with swagger support

21:30 vas_: 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:33 Snova: vas_: are you using both -cp and -jar ?

21:34 vas_: no, I take it I should set the classpath manually with -cp?

21:34 Snova: oh. 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:35 vas_: how do I specify the main explicitly?

21:35 Snova: java -cp ... mypackage.mymodule

21:38 vas_: 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:39 Snova: sounds about right. though probably the classpath will be huge

21:39 look into "lein classpath" or "lein uberjar"

21:40 vas_: Okay, thanks a lot for the pointer!

21:43 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:44 Snova: vas_: 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:45 vas_: Snova: Ah, thanks for clarifying.

21:57 What is the likelihood that I borked my whole project by playing with the classpath =)?

21:58 Snova: vas_: how does one play with a classpath?

21:59 vas_: well just using java -cp ... = persistent changes?

21:59 https://www.refheap.com/106892

21:59 exhibit A

21:59 Snova: that's not persistent at all; just a regular command line option

22:00 well then. you're well beyond me

22:32 squeedee: I was explaining quoted lists to a friend, when an example I tried to use gave me a result I did not expect:

22:32 ((first `(+ 1 2)) 3 4) => 4

22:32 why not 7?

22:34 I 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:35 namra: hm 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:35 it returns a map: {:ent {:table tablename, ...}}

22:36 but doing (conj v (-> (kc/select* ...)) results in an empty vector

22:37 squeedee: collection first?

22:37 or is v also a vector

22:37 namra: v is a vector

22:37 weebz: Does anyone know how to import a java class in the REPL that isn't from the standard?

22:38 namra: so i expect the result to be: [{:ent {:table tablename ...}}]

22:39 weebz: iirc and if you use leininge you can put the .jar into the resources directory, cause that is part of the classpath

22:40 or add it to the CLASSPATH environment variable

22:41 weebz: and in an env. var for my shell?

22:41 squeedee: namra and I guess you tried using an empty vec in your conj to just provie its not a type problem with v?

22:41 namra: squeedee: yup

22:41 squeedee: fascinating

22:42 ghost_runner: Clojure is NOT a Lisp.

22:42 squeedee: that's nice

22:42 namra: weebz: either resources dir in your leiningen project or an env var of the shell

22:48 Essence: I 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:48 I 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:51 weebz: namra: so do I just drop the .jar into my resources folder, lein repl, and then call import? require?

22:51 I tried both and I'm getting a ClassNotFound

22:52 ah, just realized there's a lot of jars in subfolders

22:52 that I hadn't copied

22:52 squeedee: i also dont think you need to require them?

22:52 just use the interop forms?

22:53 namra: weebz: http://stackoverflow.com/questions/2404426/leiningen-how-to-add-dependencies-for-local-jars --- the second answer

22:53 squeedee: nm you can import them

22:58 weebz: ahhhh yiiiiis thank you namra

22:58 namra: weebz: you're welcome

23:02 squeedee: if (first '(+)) returns a symbol, how do i obtain the function that symbol refers to?

23:03 chouser: (resolve '+) will return the var

23:03 deref the var to get the function

23:07 squeedee: chouser: thanks

23:11 justin_smith: squeedee: ##('anything nil :default)

23:11 lazybot: ⇒ :default

23:11 justin_smith: squeedee: but maybe you figured that out already

23:12 ,('symbol '{symbol 42} :default)

23:12 squeedee: yah right it's a special function invocation, i worked that out once i realised (first `(+)) returned a symbol

23:12 clojurebot: 42

23:16 squeedee: sometime 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:17 justin_smith: you can pry ##(:k {:k :OK}) out of my cold, dead, codebase

23:17 lazybot: ⇒ :OK

Logging service provided by n01se.net