#clojure logs

2013-11-16

00:14justin_smithit can be done in a middleware https://github.com/mikejs/ring-gzip-middleware
00:30ddellacostaany Clojure books available in French?
00:30ddellacostanot sure how to figure this out
00:30ddellacostawas hoping Clojure Programming (http://www.clojurebook.com/) was, but don't see anything about it on their site
00:57logic_progis core.async moving clojure towards erlang?
01:00justin_smithlogic_prog: it isn't the same kind of actor model you have with erlang
01:00justin_smithand it is a direct translation of the go language go blocks
01:00justin_smithname and all
01:02justin_smithalso, it is not part of the language as far as I can tell, but a good example of syntntax and feature extension via a library
01:39amalloysritchie, justin_smith: mikejs/ring-gzip-middleware is quite outdated. i have a fork that's more modern, and apparently there's another fork under rm-hull whose quality i know nothing of
01:47Lajjla,(symbol? (symbol "I worship his spaces"))
01:47clojurebottrue
01:47LajjlaAim_Here, my god.
01:47LajjlaYou are everywhere.
01:49bitemyappLajjla: I worship his Shadow?
01:49Lajjlabitemyapp, certainly.
01:49LajjlaBut mostly testing if Clojure still has tht big
01:59bitemyapp`cbp: ggs
01:59`cbpggs
02:02bitemyapp`cbp: that was intense.
02:03`cbpheh
02:21arrdembitemyapp: sorry I kinda crapped out on you there, how'd it go?
02:24bitemyapparrdem: I cannot describe it without using words and concepts that will offend and alienate everybody in this channel.
02:25bitemyapparrdem: longest TW: [...] in the history of mankind.
02:25bitemyapparrdem: suffice it to say, we went like 1 and 4 or 5
02:26arrdembitemyapp: ouch. oh well.
02:26bitemyapparrdem: pffft, no big deal.
02:27bitemyapparrdem: thanks for sticking out that game despite technical difficulties.
02:27arrdembitemyapp: no problem. the wifi's been kinda sketch here for a few months but it's never been that bad. I've learned better than to duck out in MOBAs if I can avoid it :P
02:30arrdemok. goodnight, world.
04:04notofiHi guys, I made my first open source project on github. If somebody could review it would be nice, its a 2 dimensional grid data structure for clojure: https://github.com/damn/grid2d
04:17echo-areaHow can I refer fns defined with defmethod in :use?
04:20echo-areaHmm, those don't seem to be needed
04:36addisadenGood morning :)
04:37addisadenIs there a live-stream of the clojure conj?
05:12ohcibihi I have a function that calculates the square root of a number with a given precisiion and I want to test that.. how to round doubles in clojure? note that I want to round doubles and not create rounded string representations (which might be localized and are thus potentially confusing '.' and ',')
05:17TEttingerohcibi, there's (doc with-precision)
05:17TEttinger(doc with-precision)
05:17clojurebot"([precision & exprs]); Sets the precision and rounding mode to be used for BigDecimal operations. Usage: (with-precision 10 (/ 1M 3)) or: (with-precision 10 :rounding HALF_DOWN (/ 1M 3)) The rounding mode is one of CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UP, DOWN and UNNECESSARY; it defaults to HALF_UP."
05:17TEttingerbut that's for BigDecimals
05:19ohcibiTEttinger: yes, I read that... but I dont see how this applys to single numbers? I tried (with-precision 3 (* 1M 1.14353345)) to round to 1.144 but it just prints out the whole number
05:19TEttinger,(with-precision 3 (* 1M 1.14353345))
05:19clojurebot1.14353345
05:20TEttingerweird
05:20ohcibiindeed
05:20TEttinger,(with-precision 3 (* 1M 1.14353345M))
05:20clojurebot1.14M
05:20ohcibioO
05:20TEttingerneed to both be bigdecimals
05:20TEttingerthere's ##(doc *')
05:20lazybot⇒ "([] [x] [x y] [x y & more]); Returns the product of nums. (*) returns 1. Supports arbitrary precision. See also: *"
05:22ohcibihmm... but thats not actually convenient... I just want to round the return value of a function... dont want to mess up with the implementation
05:22TEttingerright.
05:22TEttingersimple way...
05:25TEttinger,(let [precision 5 num 0.123456789 mult (Math/pow 10 precision)] (/ (int (* num mult)) mult))
05:25clojurebot0.12345
05:25TEttingerohcibi, will that work?
05:27ohcibiTEttinger: I was thinking about a mathematical solution.. thanks
05:27TEttingeryou can decrement the precision if you want the correct number, sorry about that
05:27ohcibii'll just use 1000 8-))
05:28ohcibiits just for the tests... dont need a convenience function actually
05:28TEttingerheh much better
05:28TEttingerbecause it turns out this does not limit total places, as with-precision does -- only places after the decimal point
05:28TEttingerwhich might be what you want?
05:30ohcibiits exactly what I want.. i have this sqrt-function that calculates the sqrt with a certain precision and I want to test the result, problem is the result is not rounded to the precision so I cant compare to e.g. 1.141 for sqrt(2)
05:30TEttingergreat, glad my mathematical incompetence found a correct result by accident <_<
05:30ohcibi8-)
05:49wei___anyone know a good way to read java properties files into clojure?
05:49wei___would be nice if I could set them as environment variables on startup
06:15Glenjaminwei___: https://github.com/weavejester/environ
06:15wei___thanks, I am using environ. wanted to extend it to read properties files
07:19ohcibihi, I have a littel problem with the shorthand syntax #(%) for (fn) statements: i want to create tuples [a a] out of a set #{a b c d}, i was thinking about (map #([% %]) myset) but that doesnt work because it trys to call [% %] as a function of course... do I have to use (fn [x]) syntax here or can I do it somehow with the shorthand syntax?
07:20wei___ohcibi: try vector
07:20ohcibi#(vector [% %])?
07:21poppingtonicHey
07:21wei___#(vector % %)
07:21wei___or (vec [% %])
07:22ohcibiwei___: thanks
07:23poppingtonicI'm trying to select a link from within a webpage: http://refheap.com/20944
07:23poppingtonicCan anyone tell me why this isn't working?
07:23poppingtonicIncanter, enlive.
07:24poppingtonicThe url is http://data-sorcery.org/book-recommendations/
07:27poppingtonichttp://refheap.com/20945
07:29TEttingerohcibi, there's also (fn [a] [a a])
07:29TEttingerpoppingtonic, how are you calling load-data ?
07:31poppingtonicTEttinger: (def book-data (load-data book-url)). which gets me an Incanter dataset.
07:32poppingtonicsee http://refheap.com/20945
07:33TEttingeryeah, I just didn't see that in there
07:34poppingtonic:) If I do (dataset colnames rows) at the end of load-data, it works. I'd like to include the links to the books as well, which is where my knowledge of css selectors fails.
07:37poppingtonicTEttinger: `headers` isn't necessary.
07:41TEttingerpoppingtonic, I don't think you need href, that's part of one <a> tag, not its own tag
07:43poppingtonicyeah, so the selector is the problem, right? How do I select the link string, though?
07:43TEttingerhm, '[[:a (attr? :href)]​] might work
07:43TEttingerhttps://github.com/cgrand/enlive/wiki#selectors
07:43TEttingerwhich, yes, I did not guess on my own
07:44poppingtonicto extract it so I can include it on its own row, next to the book it points to
07:44poppingtonicHm, lemme check it out. I've been looking at dnolen's tutorial
07:48poppingtonicThank you, TEttinger. I'll run with it and see how it works out.
07:48TEttingerno prob
07:48TEttingerI've only used selectors via seesaw for swing, I've never run into the CSS "a[href]" either
07:49TEttingerso I have no clue if it will work
07:50poppingtonicOne of these days, I'm gonna have to take a long walk...
07:54johnmintonHello - can I download the HTML Clojure library docs that are on the website anywhere?
07:58TEttingerjohnminton, I believe they're on github, let me check
07:59TEttingerhttps://github.com/clojure/clojure/tree/gh-pages
08:05johnmintonTEttinger: thanks
08:06TEttingerno problem, it used to say github in the url
08:06TEttingerso i guessed it still was there
08:37ohcibidoes midje's roughly not work with floating point? i tried (fact 3 => roughly 2 0.5) and it says true
09:09thorbenroughly is a function - try "(fact 3 => (roughly 2 0.5))"
09:24TimMcTrying to run 'lein trampoline repl', I got "The repository system is offline but the artifact reply:reply:jar:0.2.1 is not available in the local repository."
09:24TimMcI have an internet connection, and 'lein repl' works fine...
09:24TimMc(Hmm, taking this to #leiningen.)
09:24technomancywait, midje is CL's LOOP?
09:27TimMc(Answer: I had ":offline? true" in the project. *sigh*)
10:10patrkrishi. does anyone here have experience getting Vaadin up and running with Clojure?
10:11s_kilkpatrkris , I've never heard of Vaadin, just took a look at its site now. what does it do exactly?
10:12patrkrisit's a UI framework for creating web applications
10:12patrkrisDatomic Console apparently uses it
10:12patrkriswhich got me interested
10:14s_kilksounds sweet. as for getting it running with Clojure, I'd imagine you could do the clojure-java interop manually as a last resort. it might be worth asking the datomic console guys how they got it working.
10:15patrkrisyes
10:15patrkristhe examples I've found requires writing an web.xml in WEB-INF and setting up a servlet (http://codebrickie.com/blog/2013/02/12/using-vaadin-7-with-clojure/)
10:16patrkrisI'm not too familiar with Java and HTTP servlets
10:16patrkrismost of the stuff I've done has been with Compojure and Jetty, where I've been able to avoid learning about web.xml and serlvets
10:16s_kilkyeah, i get the feeling that working with Vaadin might be a bit more low-level than Compojure. good luck :)
10:17patrkristhanks :)
10:19s_kilkis there anything you want to do in Vaadin that could not be done in (for example) Compojure and AngularJS?
10:20patrkrisprobably not
10:20s_kilkActually, I've just had a look at the Vaadin demo pages and they do look fantastic
10:20patrkrisyeah
10:21patrkrisit seems like a well-liked framework, and since the Datomic guys chose it, it must be good ;)
10:25xuserits as something pedestal aspires to be
10:26boccatoIm trying to configure a rev proxy for a ring web site, i wanted it to map from /tst to / but I cant understand how to make ring generate the right urls.
10:27patrkrisxuser: does pedestal contain an UI framework also?
10:28justin_smithpatrkris: if you run lein ring uberwar, it generates the WEB-INF and web.xml
10:28justin_smithyou just drop that into the container and it serves your code as an app
10:28justin_smith(the uberwar has all the stuff in it tomcat needs)
10:29boccatoIve read some things on the net about setting :context or :path-info, anyone know if it is the way to go?
10:29patrkrisjustin_smith: I don't really use a container. I was hoping to be able to do something as simple as `lein ring server` and have that run whatever is needed for me to get Vaadin running on localhost
10:29justin_smithdon't run lein on production
10:30justin_smithat the very least do lein jar and run java -jar on the server
10:30justin_smith*lein uberjar
10:30justin_smithahh but yes to try in locally...
10:30patrkrisjustin_smith: right now I'm just trying to learn Vaadin, not run anything in production ;)
10:31patrkrisand I was hoping to sidestep running a container
10:31patrkrisbut I have to admit I don't know much else than starting a Jetty-server with either lein-ring or through the Jetty adapter's API
10:33justin_smithlooking at that site, I am wondering about generating an uberwar, then unzipping and tweaking the web.xml
10:34justin_smithrunning an uberwar in tomcat is as simple as renaming it to ROOT.war, putting it in /var/lib/tomcat7/webapps/ and restarting tomcat
10:34justin_smiththis all depends on how much vaadin really needs the container functionality
10:35patrkrisjustin_smith: I have to warn you: most of the web development I have done is on Windows in ASP.NET, so I don't know anything about Tomcat
10:35justin_smithmaybe this codebrickie guy just doesn't know how much easier making an uberwar is
10:36patrkriscould be. I'll try to look into that at least. but for development and exploring, do you see any way to just run a simple Jetty-like webserver and try Vaadin off of that?
10:37justin_smithoh, I think the issue is vaadin is not something that would play well with ring, so you can't use the ring automation
10:37patrkrisah
10:38justin_smithhttps://github.com/tlipski/appengine-magic-vaadin just saw this
10:38patrkriswould using a servlet container require that I recompile everytime I want to see a chance and exclude me from experimenting with a running application from a REPL?
10:38patrkristhanks
10:38justin_smiththat project I just linked puts vaadin into a ring context
10:39justin_smithpatrkris: you can run a repl from inside a war running inside tomcat
10:39justin_smithyou can load new code in that repl
10:40patrkrisokay
10:40justin_smithbut appengine-magic-vaadin may be a better way to do this stuff - we'll need to check out their model
10:40justin_smithok, appengine-magic-vaadin creates an uberwar
10:41justin_smithso yeah, you'll want to look into nrepl.server for starting an nrepl inside the app container
10:41justin_smithit is not hard to do at all
10:41justin_smithbut sadly this stuff is all very JAVA and very ENTERPRISE
10:41justin_smithnot friendly for hack and reload interactive development for the most part it seems
10:42patrkrishehe, yeah, enterprise indeed
10:43justin_smithok, going more into their readme, looks like you can just run ring in the normal way
10:43patrkrishmm... better read this: https://vaadin.com/book/-/page/getting-started.maven.html
10:44justin_smiththis is why frameworks are so annoying
10:44justin_smithif it was just a lib/middleware it would not be this complex
10:46patrkrisI agree
10:46patrkristhe middleware concept in ring is so easy to understand and use
11:02xuserpatrkris: don't think so but I guess it should be in their plans
11:36tupihello. trying to run clojure [imagej] batch mode scripts, in particular using cron. it complains that it can not set/use the DISPALY variable, any hints? i tried export DISPLAY=127.0.0.1:0.0 and export DISPLAY=localhost:0.0, but no success so far
11:39justin_smithtupi: there is a headless option for the jvm iirc
11:39justin_smithif you aren't showing the image but just manipulating it, you can do things headless and it won't need to care about DISPLAY
11:39justin_smithalso, not that if it does need DISPLAY, it will need the right permissions to access your display
11:40justin_smithbut what if it runs while you are not logged into X for example?
11:40tupijustin_smith: i know about the headless, it is fine if i manually run the script in a terminal. however, triggering the script in a crontab does not work
11:40justin_smithtupi: a terminal will see DISPLAY
11:40justin_smithtest it in a console
11:40justin_smithor while not logged into X at all
11:41tupijustin, tested, it does not work, that is exactly what i am saying
11:41tupiyou can try a crontab scripty yourself, you'll see
11:41tupiso any one knows the solution ?
11:41justin_smithare you running with -Djava.awt.headless=false
11:42justin_smithtupi I run clojure on machines that don't even have X11 installed
11:42tupijustin now let me paste the command here
11:42justin_smitherr true
11:42justin_smithI mean true :)
11:42tupijustin, it is not clojure, it is java and imagej ...
11:43justin_smithOK
11:43justin_smithcan I see a paste of your jvm args?
11:43tupijava -cp clojure.jar:ij-core.jar clojure.main ../measures/me-step2.3.clj \
11:43tupi "/usr/lpdi/projects/octave/ocom/measures/tests" \
11:43tupi "mefiji" \
11:43tupi "png"
11:44justin_smithsee, that is clojure!, anyway do java -Djava.awt.headless=true ...
11:44justin_smithjust insert that arg, that should make it no longer look for display
11:44tupiok, i will try now, and let you know, tx
11:48justin_smithit looks like imagej is by default a GUI app, so I hope what you want actually makes sense without the GUI part
11:48tupijustin it does, our scripts do not open any image/dialog...
11:48justin_smithcool
12:05tupijustin_smith: that worked fine, many tx
12:05justin_smithwoohoo my quad tree is working
12:05justin_smithhttp://i.imgur.com/nz0mxLx.png
12:05justin_smithlight grey is quads created but not occupied, dark with white outline is created and occupied
12:06justin_smithall done without interop, so I can use it in clj or cljs
12:06tupifun! where is the code ?
12:06justin_smithit will be on noisesmith/quad-tree
12:06justin_smithI just got the basics working, so it isn't all up yet
12:06justin_smithI still need to do walking, collision detection etc.
12:07justin_smithjust have the data structure plus filling in the data structure recursively at this point
12:07justin_smithwhich was the hard part :)
12:07tupiwhen ready send me an email david at altosw dot be with the link of the code if that is ok with you of course ...
12:09justin_smithoops I forgot to create the repo
12:09justin_smithlol
12:09justin_smithwhat I have now will be up in a moment, then you can bookmark the repo for checking later
12:12justin_smithOK, it is up now https://github.com/noisesmith/quad-tree
12:12tupigreat tx
12:12justin_smithnot quite there yet, but you can check back, and what I have now may still be interesting
12:12tupii'll look at it when i have some time ...
12:13justin_smithanalemma for the svg output (which lets me use inkscape to debug my code - see if each quad has the boundaries I expect in its xml svg object)
12:13justin_smithand also of course just see if the output looks right :)
12:38justin_smithif anyone was trying out the quad-tree example in the README, I just pushed a namespace I had forgotten to commit, and without it the code did not work
12:39justin_smithis there an automated test for whether my code requires interop? I would like to be able to ensure I am not hitting code paths that would fail in cljs in a simple way
12:49Glenjamincan you just run your tests on cljs?
12:49justin_smiththat may be the best way to do it, yeah
12:50justin_smithis there a formula for that? I assume making a clojurescript project and then running the tests under node.js?
12:50Glenjamini have no idea i'm afraid
12:51justin_smithhttps://github.com/cemerick/clojurescript.test looks like this is the ticket
13:01amacdougallAs long as we're talking about ClojureScript testing, has anyone managed to set up asynchronous or functional tests in pure ClojureScript? All the examples I see in clojurescript.test, Purnam, and so on all seem to focus on traditional synchronous input->output functions -- but most webapps have a lot more going on.
13:03Glenjamini think i've seen an example of using mocha with clojurescript somewhere
13:04amacdougallI've been dithering about it for a while now... since testing isn't my area of expertise to begin with, I'm reluctant to try to be a pioneer here. Might be wisest to just use a JS test framework, but that means explicitly establishing a JS surface your test code can operate on.
13:04Glenjaminyou can do it the other way
13:04Glenjaminuse interop to call the test framework
13:05Glenjaminthis sounds interesting https://groups.google.com/forum/#!topic/clojure/ZyM9SANi2Ig
13:05amacdougallI hadn't really considered that, but actually it might be a good way to go.
13:06amacdougallInteresting, I'll check those out. Good link!
13:06Glenjaminmocha and chai are what i use when doing pure-js, the interfaces are fairly simple
13:07amacdougallI like simple.
13:08amacdougallI'm making a single-page webapp as a hobby project, and I just want a basic level of tests to affirm that things work. Doesn't have to be a multi-browser test-on-change behemoth.
13:09amacdougallJust "after I put this value in this channel, does this event occur before the timeout?"
13:11Glenjaminyeah, mocha should let you do that
13:11Glenjaminit's node-flavoured, so you'll call a callback to indicate when your test is "done"
13:13amacdougallFlexible! This could be just the ticket.
13:35coventry2Anyone know what fogus's patagonia project is about? (I came in late to his talk.)
14:30arohnerwith prismatic/schema, is there a way to specify "this map can have more keys than I've listed", without enumerating all possible optional-keys?
14:31arohneraha, yes
14:31arohnerThere can also be a single additional key, itself a schema, mapped to the schema for corresponding values, which applies to all key-value pairs not covered by an explicit key.
14:43derphello
14:44bitemyappderp: derp
14:44derpis there a way to change the definition of a defn- from the repl?
14:47justin_smithderp: you can use ns or in-ns to switch to that ns, and then redefine from there
14:48derpaha thnx
14:50RaynesYou can also use alter-var-root if you're feeling frisky.
15:23justin_smiththe debug svg output as I work on my quad tree implementation is a great way to accidentally create 1980's new wave pop album covers http://i.imgur.com/JPucKQA.png
15:23justin_smith(that's a quad tree with five rectangular regions marked)
15:25bitemyappjustin_smith: nifty
15:43danneuoh man, that sign bit on BigInteger sometimes. such tricky
17:21satshabadwhat's the best way to remove an item at a particular index from a vector? and for a sequence?
17:22satshabadif feel like (dissoc [2 4 6 8] 0) should work...
17:22satshabad,(dissoc [2 4 6 8] 0)
17:22clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentMap>
17:24satshabadwould this be the best answer? http://stackoverflow.com/a/1395274
17:27augustllooking for an embeddable KV-database for an app that is supposed to be self-hosted. Only really need bytes as keys and bytes as values, I guess. Any suggestions? :)
17:41creeseLately, I've been writing validators for APIs, and then I realized... "This has got to be a solved problem." What do you all use?
17:58justin_smithsatshabad: you may need to loop and set each index starting at position n to be the value at the next index after it
17:58justin_smithsatshabad: I don't think vectors support insertion directly
17:59satshabadI was expecting this (dissoc [2 4 6 8] 0) to eval to '(4 6 8)
17:59justin_smithwith a cons / list you should be able to replace the preceding cons with the following
17:59justin_smithsatshabad: I don't think it is build that way at all
17:59satshabadyesh it's not
18:00satshabadI did something else any way
18:00satshabadworked out better
18:03hyPiRion,(require 'clojure.reflect)
18:03clojurebotnil
18:19concurIs there any reason running "lein test" should return "Tests failed." and nothing else?
18:19concurit should be telling me *which* tests failed
18:19concurbut it doesn't
18:22hiredmanconcur: if you call (System/exit 1) somewhere, maybe
18:22concurI don't
18:23concurI'm using a thread pool
18:23hiredmanconcur: do you call something that does?
18:23concurI shouldn't be
18:24concurcould an uncaught exception possibly be the culprit?
18:25hiredmanconcur: unlikely
18:26gfredericksconcur: is the failure happening on another thread?
18:26hiredmanyou can get weird behaviour from fixtures that swallow exceptions sometimes
18:26concurI'm not sure where the failure is happening
18:26gfredericksconcur: _can_ failures happen on other threads?
18:26concurit gives no details
18:27gfrederickssince you're using a thread-pool the first thing I'd try is to use bound-fn for all the thread pool jobs
18:27concuractually, the assertions are happening after the thread pool is finished
18:27hiredman"I'm using a thread pool" is also not very descriptive
18:28concurlol
18:28concurI'm using a thread pool made by calling java.util.concurrent/Executors.newFixedThreadPool()
18:28concur(defn dopool
18:28concur "Executes a function over a collection using a fixed thread pool"
18:28concur [func coll threads]
18:28concur (let [thread-pool (pool threads)
18:28concur func-coll (for [item coll]
18:28concur #(func item))]
18:28concur (doseq [results (.invokeAll thread-pool func-coll)]
18:28concur (.get results))
18:28concur (.shutdown thread-pool)))
18:29hiredman"I'm using a threadpool(to hang on to results so they don't get gc'ed when I run benchmarks)"
18:29hiredmanconcur: pastebin next time please
18:29concursorry
18:29hiredmanI doubt that has anything to do with it
18:30meoblast001hiredman: in concur's defense, while switching through my idling channels, i was quite pleased to see some lisp code
18:30concurI used the same function for something else, and that worked fine
18:30concurso I'm not using the pool incorrectly
18:30hiredmanwhat happens if you comment out everything, put in (deftest t-foo (is nil))
18:33concurRan 1 tests containing 1 assertions. 1 failures, 0 errors. Tests failed.
18:33hiredmanok, so now uncomment out things until that goes away
18:34m_mHi. I am searching major, well documented, still active web framework for clojure. Can you give me some clues ?
18:34concurI know which test is failing
18:35hiredmanconcur: but you wonder about the lack of output, the above has more output than you said you saw
18:35concuryeah
18:35concurbut until I added a new test
18:35concurit was producing the expected output
18:35concurand saying there were no failures
18:35hiredmanthat is not what you said
18:36concurwhat did I say?
18:36hiredman11:21 < concur> Is there any reason running "lein test" should return "Tests failed." and nothing else?
18:36concurthat's what it does now
18:36concurnow that I've added this new test, that's all it returns
18:36concurbefore, it was working fine
18:37concursorry if I was unclear
18:40concuractually, what I said was a little incorrect
18:41concurit does say "Testing rwl.core-test"
18:41concurand it executes a couple println's I put in there
18:41concurand after that it says tests failed
18:41concurbut gives no details
18:58kEND_has anyone mapped vim-fireplace key mappings for evil mode emacs? I'm looking for some good evil key mappings to interact with the repl in evil mode
18:59kEND_fireplace is great, but I'm pairing with seasoned emacs user
19:10ziltikEND_: Cider is great and it's for emacs. There's no reason to use fireplace in Emacs.
19:12kEND_zilti: not trying to. I'm a long time vim user and want a good couple of vimish key mappings to execute cider. cider is in the house. ;-)
19:16seangroveUhg, I've forgotten how to require a new lib in clojurescript from the repl
19:17seangroveDo you just change the ns statement and re-eval? Seems to work. I remember some command was supposed to be more straightforward, but can't find it now.
19:35seangroveIs it a good idea to extend ISeqable onto a goog.iter.Iterator in cljs? Or inherently a bad idea?
19:43amalloyseangrove: i would guess bad, assuming that an Iterator is mutable
19:43seangroveamalloy: It is, that's my concern
19:43amalloyeg, consider clj-jvm: ##(seq (.iterator []))
19:43lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.APersistentVector$2
19:44amalloyinstead, there's ##(iterator-seq (.iterator []))
19:44lazybot⇒ nil
19:44amalloy&(iterator-seq (.iterator [1 2 3])) would be clearer, i guess
19:44lazybot⇒ (1 2 3)
19:46amalloythe difference is that you can't accidentally pass some mutable thing into a function that expects a sequence; you have to go a little out of your way to converty
19:46seangroveThat seems fair to me; make it explicit
19:47seangrove(inc amalloy) ;; thanks as always
19:47lazybot⇒ 78
19:59seangroveIs this try/catch form wrong for cljs? https://www.refheap.com/8c2297c31c80f698be309c15e I'm getting this error when using the code: TypeError: Expecting a function in instanceof check, but got Error: StopIteration
20:47amalloyseangrove: it looks to me like StopIteration is a value of some kind, rather than a constructor/prototype/class
21:00amalloyyeah. cljs catch clauses want a class specified, whereas StopIteration is a singleton defined as Error('StopIteration')
21:00amalloythere might be a catch* or something in cljs that lets you catch arbitrary things, i dunno
21:49gfredericksthere was a long discussion about that recently
21:49gfredericksI think the concensus was to move to (catch :default ...) but I doubt that effects current releases
21:50gfredericksI know dnolen removed the ability to catch everything at some point but I don't know whether that got as far as a release
21:53bitemyappRaynes: ring ring muddafakka
21:53bitemyappCompilerException java.lang.IllegalArgumentException: No matching method : parseXmlFragment, compiling:(hickory/core.clj:115:11)
21:53Raynesbitemyapp: This is from laser?
21:54bitemyappRaynes: yessir, pairing with a friend right now.
21:54bitemyappRaynes: https://github.com/Raynes/laser/issues/30 relephant?
21:54bitemyappRaynes: http://i.imgur.com/zZiGhot.jpg
21:54Raynesbitemyapp: What version of laser specifically?
21:55bitemyappRaynes: lein try '[[me.raynes/laser "1.1.1"] [clj-http "0.7.7"]]'
21:57devinus_can anybody recommend me some web frameworks?
21:57Raynesbitemyapp: Well, the fix is to manually include the right version of hickory (whatever is newest and under my groupid).
21:57RaynesIn your project.clj. It'll override laser's.
21:57bitemyappdevinus_: We're generally opposed to things like Rails, but Luminus should get you going: http://www.luminusweb.net/
21:57RaynesI'll have to push a new version of the 1.1.1 line to fix it later.
21:58devinus_bitemyapp: is luminus still actively maintained?
21:58bitemyappI don't think I can do an exclusion in lein try, sadface. I'll have to make a project.clj
21:58bitemyappdevinus_: uh, yeah. The author of Clojure Web Development made Luminus.
21:58bitemyappdevinus_: it doesn't really need a lot of maintaining, it's just a template for best practices with Clojure web apps, there's not *that* much to it.
22:00bitemyappRaynes: thank you for the quick answer :)
22:00RaynesApologies for not realizing this was an issue until now.
22:00bitemyappRaynes: why do you have your own version of hickory?
22:00RaynesI somehow thought the issue was resolved.
22:00Raynesbitemyapp: I forked it to make some changes that the maintainer wasn't particularly interested in.
22:01bitemyappRaynes: I don't think santiago is interested in much of anything, so that's fair :)
22:02RaynesWell, it wasn't like any animosity or anything.
22:02bitemyappSure
22:02RaynesWe didn't have a lengthy argument about it or anything :P
22:02bitemyappRaynes: he's too chill for that.
22:07bitemyapptrptcolin: thanks for tweeting stuff from the Conj, it's helping me to be less miserable about it :)
22:07trptcolinbitemyapp: hey, my pleasure.
22:18SegFaultAXI wish I could have made it to conj this year. I had a family engagement though that made it impossiburu. :(
22:38grncdr,(and (= 1 2) (print "hm"))
22:39clojurebotfalse
22:39grncdris that idiomatic? or is (when (and …) (side-effect)) preferred?
22:39grncdrI have more than 1 condition anyways, so I need the (and ...)
22:41amalloygrncdr: when is better
22:41grncdrok
23:04zeebrahi'm using cider or nrepl or slime or whatever it's called now. I remember there was a way to insert a ns definition quickly. can someone remind me how?
23:15bacon1989Hello
23:15bacon1989i'm interested in learning clojure, and I have a few questions
23:15bacon1989I downloded the clojure package, and it runs and everything
23:15bacon1989but where should I place my clojure file in order to make it system wide?
23:16swarthyI suggest using leiningen to work with clojure.
23:16swarthybacon1989: http://leiningen.org/
23:16bacon1989swarthy: thank you
23:17bacon1989i saw that in the tutorial, and I guess I should get it a gander
23:17swarthyBasically clojure is a java archive, so it is a bit odd to work with. Leiningen makes it very easy.
23:17swarthyonce you have leiningen, you just go to the directory you want to run it from
23:17swarthyand type 'lein new my-app'
23:17swarthythen cd into my-app
23:17swarthyand you are ready to go
23:18amacdougallIn fact, I haven't really heard of anyone NOT using leiningen.
23:18swarthyyou certainly could I guess, but it would be a lot more work
23:20bacon1989so should I be placing the clojure.jar file anywhere on my path?
23:20coventryzeebrah: Do you mean insert the ns form of the current buffer into the repl? C-c M-n.
23:20swarthybacon1989: leiningen will actually download everything you need for you
23:20amacdougallIf you're using Leiningen, you won't even need to get the clojure jar itself.
23:20bacon1989wow nice
23:20amacdougallLeiningen handles all dependency management... even the dependency on Clojure.
23:21zeebrahcoventry: i meant inserting a skeleton ns declaration
23:21amacdougallbacon1989: In fact, in your project.clj file, you'll declare a Clojure version. The project templates used by "lein new" will auto-include this.
23:21amacdougallJust check out project.clj once it's been generated.
23:21bacon1989does leinegen also work for clojurescript?
23:22bacon1989kk
23:22amacdougallAbsolutely. There's a plugin called lein-cljsbuild. You get it by just adding a declaration to project.clj and then leiningen handles the rest.
23:22amacdougallYou may be starting to see a pattern.
23:22bacon1989that's amazing
23:22amacdougallLeiningen is one of the best build tools I've ever seen.
23:22bacon1989I think I just wet myself
23:23zeebrahtrying to translate a piece of code from sicp - https://www.refheap.com/c48c08c45c1b85732fd45a9b1 -- have trouble calling the iter function recursively
23:23amacdougallDon't wet yourself. Leiningen handles dependencies, but you'll have to get your own Depends.
23:24swarthyzeebrah: you should look at loop/recur
23:24swarthyits best to use that when writing recursive functions
23:25RaynesWell.
23:25zeebrahswarthy: yeah i will, but i'm just transliterating faithfully first
23:25Rayneszeebrah: You can replace the 'iter' call with 'recur' and it should work.
23:26zeebrahRaynes: oh that's cool. Thanks!
23:26Rayneszeebrah: You want to use 'recur' because Clojure doesn't have tail call optimization and recur gets around that. However, if you really needed an anonymous function to call itself by name, define it like (fn iter [] ..)
23:27Pupnikdoesn't it stop being anonymous when you give it a name
23:28RaynesNo.
23:28RaynesYou can't refer to that name outside of the body of the function.
23:29zeebrahbtw have I got the local definitions right by using let? in scheme it was two defines at the top of the function
23:29RaynesNaming anonymous functions like this has no effect on their anonymity, makes them clearer in stacktraces, and allows the function to call itself recursively outside of the tail position.
23:29zeebrahRaynes: very interesting, thanks again :)
23:31bacon1989lighttable is pretty slick!
23:32bacon1989this is probably going to make learning clojure super easy
23:47paomianhello
23:47paomian(def a {:a 1 :b 2})
23:47paomian(defn b [& code] (merge a code))
23:47paomian(b {:c 3})
23:48paomianClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry clojure.lang.APersistentMap.cons (APersistentMap.java:42)
23:48paomianwhy
23:48technomancypaomian: get rid of &
23:49paomianbut the code is not must be needed
23:51technomancypaomian: (defn b ([] a) ([code] (merge a code)))
23:51paomiantechnomancy: nice
23:52grncdrI'm having difficulty figuring out how to do without mutable references
23:52swarthygrncdr: in what context?
23:52grncdrthis one: https://www.refheap.com/20962
23:52grncdrbasically, I want to reference the same data 2 different ways
23:53grncdrand be able to (assoc …) once
23:54grncdrwhich I know is fundamentally at odds with immutable data structures… so I'm looking for the "right" way to structure that data
23:54swarthyInstead of state being a flag, think more in terms of transformations.
23:54swarthyso: date -> new form of data -> new again -> final 'state'
23:54swarthydata*
23:55swarthyeach arrow is a function
23:55swarthysorry if that is vague
23:55grncdrit's a bit vague ;)
23:55swarthylol
23:55grncdrit's ok, I think the thing I'm having a problem with is fairly concrete
23:55grncdrlike, the concepts make sense...
23:56grncdrbut doing this one particular operation (in the paste I referenced up there) seems ugly/unwieldly to me
23:56swarthyFrom what I read, when you feel that way you are likely taking the wrong approach.
23:56technomancydevn: linky: https://github.com/ato/clojars-web/issues/83
23:59grncdryeah, that's why I asked here ;)
23:59Raynestechnomancy: I'll see your (defn b ([] a) ([code] (merge a code))) and raise you a (defn b [& [code]] (merge a code))