#clojure log - Feb 27 2016

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

0:00 macrolicious: well, in my lein created project root, I have a src directory, and in that, a seesaw directory, with what I assume to be needed in that

0:00 hiredman: no, you shouldn't have anything like that

0:00 macrolicious: hiredman: well, I'm trying to run the simple calculator app with 'lein run -m calculator.core'

0:01 hiredman: if you tell lein you depend on seesaw, you should not have seesaw source in your project, lein will make it available for you

0:01 macrolicious: hiredman: ah ok… so, I assumed lein would pull down seesaw and put it whereever-it-should-be… but then when that approach threw the file-not-found-error I tried to put it there manually

0:03 hiredman: macrolicious: what does your project.clj look like?

0:08 macrolicious: here it is: http://pastie.org/private/uxnlrtez7fdxwegt97ai8g

0:10 hiredman: have you cleaned out the seesaw stuff you put in src yet?

0:12 do that, make sure you saved those files, and run 'lein run -m calculator.core' again

0:13 that paste isn't all one file is it? you included project.clj and src/calculator/core.clj in the same paste right?

0:14 macrolicious: it is all one file ;-|

0:14 hiredman: so delete the whole project, run lein new … again

0:15 then install the 'tree' command if you don't have it, then run it, and you'll see the directory structure of a lein project

0:15 project.clj directs the build

0:15 code goes in src/

0:16 macrolicious: ok… was about to share the tree output, but pastie is throwing a 503… I'll run lein new again...

0:16 hiredman: no, don't

0:16 macrolicious: ok

0:16 hiredman: the tree outfit is for your benefit

0:16 output

0:16 macrolicious: ok

0:18 hiredman: lein does allow you to put arbitrary clojure code in project.clj (beyond the defproject form which describes the build) but you should never do that

0:19 the execution context of any code in project.clj is not what you want (which is why it could not find seesaw)

0:23 macrolicious: gotcha… rerunning everything in a new lein app...

0:41 hiredman: dependencies working now! yay! thanks ;-)

1:29 getting a new error which cites a blank offending symbol: http://codepad.org/PvIQx2Jr

1:32 Integer?

1:33 amalloy: macrolicious: i would check your input file for weirdo characters like  

1:33 macrolicious: ok… tried that by opening in vim and using ':set list' which didn't show anything… what's a better way to look?

1:35 amalloy: well, one thing you could do is retype the offending line by hand, since you know you won't be adding weird characters

1:36 if that doesn't help, i don't really know what's going on

1:36 macrolicious: amalloy: I'll retype it

1:37 amalloy: dpeg pls. i don't play on these experimental branches to deal with player ghosts

1:39 oops

1:39 wrong channel there

1:39 macrolicious: lol… I was thinkng I had breached some protocol...

1:40 amalloy: unless you are dpeg in disguise, you're doing fine

2:16 tolstoy: Do people use "tabs" instead of spaces much anymore? In any coding?

2:17 amalloy: makefiles

2:17 and there are still people who prefer it to spaces, in stuff like C/java/python, although i think they are a minority

2:17 tolstoy: Well, yeah, but ... I seem to be working with people who do it with CSS and gulp.

2:18 Yeah, aside from taste issues, it's not so nice with Github, less, etc, etc.

2:18 Or Emacs with "untabify" on save, or whatever it is I have going

2:19 whitespace-cleanup? Something like that.

2:22 rhg135: I once pressed my tab key and then got yelled at. Maybe we need to not default to that.

2:22 TEttinger: amalloy: it could be neat to have a "player ghost" in a programming context. an isolated track of execution based on an earlier run, possibly with ghost-like highly-limited side effects

2:23 especially for tests

2:23 like a "ghost" running an earlier version

2:24 see? it wasn't totally the wrong channel

3:52 Nvoid: ls

6:17 vivekramaswamy: Hello All, a quick question regarding cider-repl on emacs when I use the function (read-line) on the repl, the repl is able to take my input and then just hangs, do I need some special key to return from the function

7:47 justin_smith: vivekramaswamy: the repl's *in* is not directly connected to your emacs - nrepl is a socket repl and CIDER is deciding what to send to the repl. If you need things like read-line it's frankly simpler to use inferior-lisp or inf-clojure, if there's a trick to make it work with CIDER I don't know of it

8:27 vivekramaswamy: jutin: thank you for your reply

11:21 arkh: ,(clojure.set/union nil #{1})

11:21 clojurebot: #error {\n :cause "clojure.set"\n :via\n [{:type java.lang.ClassNotFoundException\n :message "clojure.set"\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...

11:23 justin_smith: ,(require 'clojure.set)

11:23 clojurebot: nil

11:23 arkh: ,(clojure.set/union nil #{1})

11:23 clojurebot: #{1}

11:24 arkh: thank you

11:24 justin_smith: np

11:24 arkh: ,(update-in [] [:a] (clojure.set/union #{1}))

11:24 clojurebot: #error {\n :cause "Key must be integer"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Key must be integer"\n :at [clojure.lang.APersistentVector assoc "APersistentVector.java" 345]}]\n :trace\n [[clojure.lang.APersistentVector assoc "APersistentVector.java" 345]\n [clojure.lang.APersistentVector assoc "APersistentVector.java" 18]\n [clojure.lang.RT assoc "RT.java" 792]\n [...

11:25 justin_smith: arkh: too many parens

11:25 ,(update-in [] [0] clojure.set/union #{1})

11:25 clojurebot: [#{1}]

11:25 justin_smith: also :a is not a valid index in a vector

11:25 ,(update-in {} [:a] clojure.set/union #{1}) ; perhaps you wanted this

11:25 clojurebot: {:a #{1}}

11:26 arkh: oh - whoops. I did

11:27 also, parens around latter update-in args was the thing hanging me up - thanks

11:28 justin_smith: arkh: yeah, update-in and swap! are examples of functions that use less parens that you might expect - you just keep tacking things on almost as if it were backwards forth

12:02 inhortte: Hello. I'm using boot in a cljs project with a clj backend. This line: (task-options! serve {:handler 'martenblog.handler/app :reload true}} lets my clj app (using compojure) serve content via the server, but how do I get "/" to point to my generated "app.js" from my cljs? It resides in /target/js but I can only serve things from /resources. Is there anything like ring.middleware.resource/wrap-resource that will let me serve m

12:03 justin_smith: inhortte: what I do is add resources/public/app.js to my clean targets, and then tell the cljs compiler to output to that location

12:04 that way uberjar bundling works properly etc.

12:06 inhortte: justin -> being an ameteur, can you give me an example? :)

12:06 justin_smith: inhortte: I use leiningen, not boot, these are just leiningen configs

12:06 :clean-targets and :cljsbuild

12:07 I just assume boot has similar options for which files get auto-cleaned and where cljs build output can go

12:07 inhortte: ok. I suppose there will be boot equivalents, or I can write something in clojure in build.boot.

12:07 justin_smith: yeah

12:08 inhortte: Ok. I just got it working by making symbolic links after the compile, but automagically is always better.

12:08 gfredericks: generating generators is trippy

12:08 inhortte: Thanks for the kick in the brain. I'm off to try.

12:08 justin_smith: gfredericks: yeah sounds like something where shrooms would help

12:10 gfredericks: weird to debug too

12:10 justin_smith: inhortte: there should be some kind of :compiler key for the cljs config for a build, and then that can use an :output-to key that tells it where the file goes, if it's anything like the leiningen config (and I don't know why they would make them arbitrarily different, these are clojurescript compiler options after all)

12:10 gfredericks: once again, shrooms

12:11 inhortte: justin -> all right. it is possible. thanks again.

13:55 tolstoy: In cljs, is there a way to "apply" to a goog.closure method? (apply goog.string.format "..." ["a", "b"])?

14:03 justin_smith: tolstoy: isn't there a thing in the js interop that does that?

14:05 tolstoy: should just be (.apply goog.string.format (cons "..." ["a", "b"])) ? or do you need to turn the arg list into a js array for that to work...

14:10 hmm, format is unhappy about templates when I try that...

14:34 tolstoy: Yeah. I as mainly interested in shortening the name, but a proper require fixed that.

16:34 justin_smith: I just went through my cljs replacing some callbacks with core.async, and the results are so nice

17:09 gfredericks: ,(def cool-map {Double/NaN 42})

17:09 clojurebot: #'sandbox/cool-map

17:10 gfredericks: ,(= cool-map cool-map)

17:10 clojurebot: true

17:10 gfredericks: ,(= cool-map (into {} cool-map))

17:10 clojurebot: false

17:10 gfredericks: ,(= cool-map (-> cool-map (assoc 1 2) (dissoc 1)))

17:10 clojurebot: false

17:10 justin_smith: ,(= (into {} cool-map) (into {} cool-map))

17:10 clojurebot: false

17:10 gfredericks: ,(= cool-map (with-meta cool-map {1 2 3 4}))

17:10 clojurebot: false

17:10 justin_smith: cool map, bro

17:11 gfredericks: NaN-as-map-key is the only scenario where I've been able to get this to happen

17:11 I don't know what the expected behavior is or why

17:11 justin_smith: it's also the only one I know of

17:11 gfredericks: it doesn't happen for sets

17:11 justin_smith: well, NaN isn't equal to itself, but sometimes clojure short-circuits that test because object identity, right

17:11 gfredericks: yeah I'm imagining that's the implementation explanation

17:12 just don't know if it's the correct behavior

17:12 hyPiRion: equality is hard

17:12 gfredericks: I feel like the first two should have the same answer, whichever answer it's supposed to be

17:12 so it feels like a bug

17:12 I bet there's a 4-year-old ticket about this somewhere

17:13 test.check found this for me (thanks, test.check!)

17:13 I guess I'll just tweak the test to not test this case

17:14 I don't see any tickets when searching for NaN on jira

17:15 puredanger: do you know if this is a bug? (let [x {Double/NaN 42}] (not= (= x x) (= x (into {} x))))

17:15 ,(let [x {Double/NaN 42}] (not= (= x x) (= x (into {} x))))

17:15 clojurebot: true

17:17 gfredericks: actually I guess this is in the same category as other NaN comparisons

17:18 ,(let [x [Double/NaN]] [(= x x) (= x [Double/NaN])])

17:18 clojurebot: [true false]

17:19 gfredericks: ⇑ so I guess everything's already weird about NaN comparisons

17:19 puredanger: disregard

17:20 hiredman_: gfredericks: isn't that almost certainly an array map vs. hash map thing?

17:21 gfredericks: hiredman: ⇑ I just showed similar behavior with a vector

17:21 notostraca: ,"(+\u180E1\u180E1\u180E1)"

17:21 oh, no lazybot?

17:21 clojurebot: "(+᠎1᠎1᠎1)"

17:21 notostraca: clojurebot I mean

17:21 gfredericks: hiredman: I think it must be the identical? check giving "bad" results

17:22 irctcaaa: test

17:22 test1

17:23 I'm assuming this channel is distinct from Slack's #clojure channel?

17:23 gfredericks: irctcaaa: yep

17:24 notostraca: ,(+᠎1᠎1᠎1)

17:26 ~ping

17:29 TEttinger: ,(+᠎1᠎1᠎1)

17:30 are messages coming in at a limited rate for anyone else?

17:30 I suppose I'm not sure why I asked that since I won't see a response

17:31 hiredman: something odd is going on with freenode

17:31 TEttinger: definitely.

17:32 clojurebot appears netsplot

17:34 hiredman: clojurebot is actually offline, and timing out trying to connect to freenode, from the same server I am running my irc client on

17:35 will_sm: I used boot for a school project, wish I had used lein

17:36 anyone no a tool that I can use in boot to generate documentation for my code?

17:36 know*

17:42 nberger: Didn't use it, but it seems like https://github.com/funcool/boot-codeina could be what you are looking for

17:43 TimMc: TEttinger: How can you tell? It's a low traffic time for the channel anyhow.

17:43 (re: limited rate)

17:45 TEttinger: TimMc: because I only saw 7 messages come in when I sent a message myself, in big batches

17:51 TimMc: interesting

18:17 pilne: i wonder if i could teach lisp to improvise a musical passage on the fly in real time with an input of only the backing tracks....

18:18 justin_smith: pilne: easier if the backing tracks are high level data, but both have been done

18:19 that is, both backing track as raw PCM from a DAC and backing track as event data eg. MIDI

18:19 pilne: midi would be pretty easy to accomplish as an in

18:19 but drat

18:19 lol

18:20 justin_smith: pilne: an interesting thing is that a lot of the stuff you have to do to make an improvising program work is similar to low level UI code (eg. doing UI without any UI library doing it all from scratch), eg. it's all about how humans perceive timings and how humans distinguish events, and simulating that stuff in code

18:20 eg. how far apart to readings have to be before humans think they are actually two things and not just one jiggly thing?

18:21 *two readings

18:22 pilne: that's true... pattern matching based on time separation

18:22 iiiiinnnnnnteresting

18:22 justin_smith: and "far apart" has multiple dimensions - time, space, and quality

18:22 pilne: i'd stroke my goatee right now if i still had it

18:22 justin_smith: haha

18:22 pilne: it still might be a fun experiment

18:22 justin_smith: so it's not just time sepration, other qualities of the signal suffice as well, and all add up to a "differentiation factor" that takes them all into account

18:23 pilne: well, no might, just feels odd to recreate what has already been done (probably better than I could too)

18:23 i kinda figured the immutable and concurrency would make it easy to reap huge dividends there

18:23 in clojure

18:23 justin_smith: it's a fascinating field

18:23 if you have the hardware to back it up and make it happen in real time, yeah

18:24 DSP in real time isn't always so simple

18:24 pilne: yeah, i'd probably stard with reading from pre-recorded midi

18:24 *start, because my hardware isn't ancient, but it isn't a workstation

18:24 justin_smith: definitely easier - the midi already decided a bunch of those thresholds for you

18:24 pilne: leveraging the gpu for parallelization sounds like a fun challenge too

18:25 justin_smith: to use a term you might also recognize from image processing, the "feature detection" has already been done

18:25 pilne: because ideally i'd like it to somewhat analyze (not just store) what it has already done.

18:25 justin_smith: similar to parsing a structured thing like an svg and analyzing shapes vs. parsing a jpeg and analyzing shapes

18:26 pilne: i don't do much image processing, but i've heard it in the tutorials my gf has listened too.

18:27 justin_smith: yeah, I just mention it because the concerns are remarkably similar, but if you don't know image processing either that's neither here nor there

18:27 pilne: i'm more of a data/math/abstract/crypto/wierd-shit guy

18:27 i understand it on an abstract level though :) so it did help

18:28 justin_smith: well I am sure you can still imagine how hard it would be to take a jpg (a matrix of pixel values) and decide where objects start and end

18:28 pilne: yeah

18:28 justin_smith: and people's intuition of how hard that is tends to be closer to the mark compared to audio, for some reason

18:29 pilne: i can kinda understand that, most of us are quite visual in learning :)

18:29 justin_smith: like, people ask for the audio equivalent of "photoshop plugin that removes girls from a crowd scene with one button click" as if that was a reasonable thing

18:29 (eg. plugin that automatically isolates instruments or sound sources)

18:30 pilne: unless everything is on a physically separate track on the medium they are providing... LOL

18:30 but.. i've spent a long time around sound/physics in my academia and hobbies

18:30 so i might have a leg up on the average person

18:33 and that is true i was thinking the real time feed would have separate inputs for each "section" that it would be improvising on top of in order to let the computer have more of a "feel" for what is going on

18:34 my gut just told me that something with concurrency, immutable data (for both pass-through and concurrency), and stronk makros would make it "easier"

18:35 that or it wants more sushi

18:38 justin_smith: pilne: oh man I've been on a low calorie diet for the last couple of weeks (health and stuff, you know) and it's basically just a constant angry message coming from my gut saying "WHY ARE YOU TRYING TO STARVE TO DEATH" haha

18:38 it's good though, one learns to ignore it eventually

18:38 pilne: yeah... i need to get over my garfield-inspired fear of dieting and just start again.

18:38 justin_smith: pilne: nothing good can be Garfield inspired.

18:39 pilne: i've been on this fucking rollercoaster too many times lol

18:39 garfield taught me that diet is just die with a t

18:39 and reinforced that lasagna is life (i had an italian grandmother lol...)

18:41 justin_smith: oh, lasagna is just fine, it's just that the healthy portion for a human who is not in heavy weight training or running marathons is actually kind of tiny

18:41 anyway this has nothing to do with clojure, sorry

18:41 pilne: yeup... but before i can get back to powerlifting, i need to get back in decent shape, nah... i'm tangential as all heck IRL too

18:56 WickedShell: I'm getting an error that is kinda blowing my mind. 'Exception in thread "LWJGL Application" java.lang.ClassCastException: swiftgcs.gui_helpers.PanelItem cannot be cast to swiftgcs.gui_helpers.PanelItem' PanelItem is a defrecord, why could a PanelItem not be cast to itself?

19:14 pilne: WickedShell-: i do not know why that would be happening, but i saw something similar happening to someone in c the other day, the resolution had to do with the constructor

19:16 WickedShell: pilne, I'm struggling to reproduce it which is driving me crazy. I've seen this problem twice out of 100 runs, which is making debugging it really diffiicult... I'll check my constructors, thanks

19:19 pilne: it doesn't even happen all the time??? that would be frustrating, is there anything else those 2 runs have in common?

19:19 that do not occur in the others?

19:20 WickedShell: Seems to be the first time I call it within that context, but nothing else.

19:21 amalloy: WickedShell: you're reloading some of the files in your program but not others, probably

19:21 WickedShell: amalloy, just in terms of between runs? (using lein, without having turned on direct compilation)

19:21 amalloy: no, like from in your repl

19:22 WickedShell: amalloy, I totally reastart the repl everytime I change source :P

19:22 To hard to keep all the different threads callbacks updated for changes on the GUIj

19:22 amalloy: i would be that about 98 times out of 100 you do that

19:22 and then 2 times out of 100 you run into that error

19:23 WickedShell: if the repl is restarted I'm not sure how thats happening? (I'm sure that I'm missing what you're trying to tell me)

19:24 amalloy: i'm telling you the only way i've ever seen anyone get an error with a record being unable to be cast to its own type is when the file containing the record has been reloaded at runtime, but some other file that depends on it hasn't been

19:25 WickedShell: right but I don't ever reload at runtime, at least not by any command I do

19:31 justin_smith: WickedShell: there's middlewares that will try to reload your stuff - I know of nothing in clojure that causes that error except bad reload state

19:31 maybe something calls load-file for some stupid reason?

19:31 WickedShell: any idea what middleware can cause that?

19:32 I have no calls to load-file anywhere in my code, so it would have to be in middleware somewhere

19:33 justin_smith: cider.nrepl.middleware.refresh/wrap-refresh - unless it's poorly named I assume it is there to reload code

19:33 https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/refresh.clj

19:34 WickedShell: Hmm as far as I'm aware I'm not using cider... (just the default nrepl which I thought was different)

19:34 justin_smith: WickedShell: yeah you'd probably know if you were using cider, just a tricky place auto-refresh could sneak in

19:35 rhg135: I'm pretty sure cider does no reloading automatically

19:36 justin_smith: rhg135: sure, but it has a plugin that can do so and WickedShell does not think he is reloading any code, and he has a bug that is only caused by code reloading

19:36 rhg135: my code- are usually in a non-loadable state so that'd be a nogo

19:36 justin_smith: as far as I know...

19:36 rhg135: oh

19:36 WickedShell: well and I know that from me hitting lein repl to the bug none of the source was modified

19:37 justin_smith: hmm

19:37 oh, the other cause of that is not running lein clean

19:37 lein does bad caching sometimes

19:37 it's super annoying

19:38 so one part of your code is seeing an old aot / cached artifact for a file, and another gets the newly loaded code

19:38 even if the source is identical, it creates two classes with the same name

19:38 leading to errors like the above

19:38 WickedShell: my deps :tree if that helps: http://pastebin.com/LNJE4trg

19:38 justin_smith, thats all I can think of to do

19:38 rhg135: I aliased leinrepl to `lein do clean, repl`

19:38 WickedShell: I actually removed direct linking except for release builds as it caueses lein to loose its mind

19:39 amalloy: rhg135: that sounds awful

19:39 WickedShell: I guess I'm going to move back to lein clean; lein repl everytime and accept that it takes ~45 seconds to launch after any change :P

19:39 amalloy: stop AOT-compiling stuff, if you don't want stale classfiles

19:39 rhg135: amalloy: so is constant wtf stack traces

19:40 aot deps...

19:40 not like I launch it often

19:40 WickedShell: AOT is there for uberjar mostly I can move that into the release build only... not sure why I moved it out of the release into the normal one

19:44 justin_smith: WickedShell: my favorite thing is to make a tiny namespace, turn on aot for that namespace only, and make sure it has no explicit deps other than clojure.core. Then in the namespace you implement whatever methods you need so the java junk can call you (whether that's the startup/shutdown stuff for jsvc or just a -main), and inside the -main you can do a require / resolve / call of your actual real startup code, none of which gets aot compiled

19:45 (defn -main [& args] (require 'my-real.ns) (apply (resolve 'my-real-ns/-main) args))

19:45 that -main doesn't even need to be called in any app code, so staleness never hits you during dev

19:46 WickedShell: Would I have to AOT any proxy's?

19:47 justin_smith: WickedShell: you only need to AOT the things that java is calling directly

19:47 and that trick short-circuits all recursive AOT

19:47 just make sure that namespace only does the require at runtime and not in the ns decl

19:48 WickedShell: That's why I'm worried about the proxy's as I have to pass them to java listeners

19:48 justin_smith: passing them is fine!

19:48 this is only for things that java calls directly without us calling the java stuff first

19:48 creating and passing a proxy to some method will work as usual

19:48 unless you mean you are passing the classname of the proxy to the java command

19:49 I think the word I was looking for here was "entry point" - you only need your entry point to be aot

19:51 bbl

20:37 gfredericks: is anybody equipped to run a line of cljs for me real quick to make sure I'm not crazy?

20:37 (in an up-to-date version preferably)

20:46 I think I've convinced myself it's a bug

20:47 hash gives NaN for NaN & both infinities, one of the consequences of which is if you put any of those 3 values in a set you get a stack overflow

21:11 justin_smith: gfredericks: my little (println "Hello world!" (into #{} [NaN])) prints the same thing to the js console as the equivalent clojure would to the terminal

21:12 gfredericks: tested this to -- Hello world! #{NaN Infinity}

21:12 gfredericks: cljs version is 1.7.228 - currently the default from the mies template

21:15 amalloy: why should hashing to NaN cause a stack overflow? i'd expect some other error

21:15 clojurebot: Pardon?

21:15 amalloy: you know what you heard, clojurebot

21:38 will_sm: (+ 1 2)

21:38 clojurebot: 3

21:58 justin_smith: gfredericks: now that I saw your jira, yeah, the version in your code does throw

22:00 https://gist.github.com/noisesmith/84f5b099d868d55d784f

22:03 I also just updated with the stack trace

Logging service provided by n01se.net