#clojure logs

2012-09-18

00:00mpan,([1 2] 2)
00:00clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
00:00mpan,('(1 2) 2)
00:00clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn>
00:03xeqi&(map [1 2] [0 1 2])
00:03lazybotjava.lang.IndexOutOfBoundsException
00:03xeqi&(map [1 2] [0 1])
00:03lazybot⇒ (1 2)
00:45mpanhow can I map a seq of xs to a seq of [index x] according to index in seq?
00:46mpanis there a shortcut besides generating range and pulling out nth?
00:47amalloy&(map list (range) '(a b c))
00:47lazybot⇒ ((0 a) (1 b) (2 c))
00:48mpanthank you!
01:13Sgeo,(range)
01:13clojurebot(0 1 2 3 4 ...)
01:13SgeoCool
01:13Sgeo&(map vec (range) '(a b c))
01:13lazybotclojure.lang.ArityException: Wrong number of args (2) passed to: core$vec
01:13Sgeo&(map vector (range) '(a b c))
01:13lazybot⇒ ([0 a] [1 b] [2 c])
01:33blrandelRaynes: hey, I was just curious - are there likely to be tutorials/guides for using the 'pinot' libs with Noir at some point?
01:33blrandelwould be great to see a sample app that pulls everything together, both client and serverside
01:34blrandelibdknox: guess I should probably be asking you too :)
01:45l1x,(reduce #(assoc %1 %2 (inc (%1 %2 0))) {} '(a b b c c c))
01:45clojurebot{c 3, b 2, a 1}
01:45l1xcan somebody explain this?
01:48shokyl1x: which part troubles you
01:48l1xfirst i dont understand what inc does
01:49shokydid you read the docs?
01:49shoky,(doc inc)
01:49clojurebot"([x]); Returns a number one greater than num. Does not auto-promote longs, will throw on overflow. See also: inc'"
01:49l1xi mean in this (inc (%1 %2 0))
01:49shokydo you know that maps are functions of their keys?
01:50shoky%1 is the map supplied to reduce
01:50shokyer to the reducer function
01:50l1xoch ok
01:50l1x%2 comes from the coll?
01:50shoky%2 is the current item which also servers as the key in the map being created
01:50shokyyes
01:50shokyserves*
01:51l1xok
01:51shokyand the 0 is returned if the key is not found, meaning we're adding a new key right now
01:52raek_take a look at the function with other variable names: (defn step [m item] (assoc m item (inc (get m item 0))))
01:52l1x,(inc ({2 1} 2 0))
01:52clojurebot2
01:53l1x,(inc ({1 0, 2 0, 3 0} 2 0))
01:53clojurebot1
01:53raek_this could also be written as (defn step [m item] (update-in m [item] (fnil inc 0)))
01:54l1xshoky: thanks i think i am getting it now
01:54l1xpretty awesome
01:54shokynp
01:54raek_(reduce step {} '(a b c)) is the same as (step (step (step {} 'a) 'b) 'c)
01:54shokyindeed
01:55l1x, (assoc {1 0, 2 0, 3 0} 2 (inc ({1 0, 2 0, 3 0} 2 0)))
01:55clojurebot{1 0, 2 1, 3 0}
01:55l1xthis is what is happening ^
01:56shokythere won't be zero values in the map
01:56shokybecause for a new key, we add (inc 0)
01:56shokywhich is 1
01:56l1xyeah of course, it is just for me for easier understanding
01:57l1xthanks a lot
01:57shokykk
01:57shokyyer welcome. im a clojure noob myself, you're the first person i've helped with a problem. so thanks also ;P
01:59l1xheheheheh
01:59l1xi guess many clojure noobs around, the popularity is increasing sharply
02:00l1xit was a total accident for me, i have decided to learn lisp just to improve my coding skills and somebody hit me with a clojure book at the very same time
02:00l1xbut this is totally insane
02:00l1xthis language is just perfect
02:01shoky;]
02:09yankovdamn, anyone knows if clojure group is moderated? posted a long post there and it didn't show up..
02:10dhofstetyankov: it's moderated for new members, see https://groups.google.com/group/clojure/about
02:11yankovdhofstet: oh, thx. phew..
02:11tomoj"Waiting on whether Clojure becomes a JSON superset." wat?
02:11tomojrelated to edn?
03:13mpanis iterate not tail recursive?
03:15mpanI'm confused by taking the nth of the result of iterate
03:15mpanthe source doesn't suggest I'd get a stack overflow but I do?
03:16tomoj&(nth (iterate inc 0) 1e7)
03:16lazybot⇒ 10000000
03:19mpanis there an alternative I could try for "f applied n times to x"?
03:19mpanjust to see if that or something else is the issue?
03:21mpan&(reduce (fn [a b] (+ 1 a)) 0 (range 1e7))
03:21lazybot⇒ 10000000
03:22mpanwonder if that one would work
03:24SgeoThe source for lazy-seq mentions fn* but I can't find it
03:28SgeoHmm
03:28SgeoSo, bound-fn* uses a with-bindings* thing
03:28SgeoThis... could be useful in my rethinking of algo.monads
03:31mpanswitching nth of iterate for the reduce-based thing worked
03:31mpanbut I'm still curious why, because nth seems to discard as it goes along, right?
03:35Sgeowith-bindings* could prove... useful to me
04:06SgeoIn Hiccup, why is it specified that, "Additionally, the ID must always come first, so div#foo.bar would work, but div.foo#bar would not."
04:07Sgeo"Hiccup is intelligent enough to render different HTML elements in different ways, in order to accommodate browser quirks:"
04:07SgeoWhat happens with elements that Hiccup doesn't recognize
04:09augustlSgeo: probably renders them like normal XML
04:11kralnmaste
04:12clgvgood morning
04:15callenbut seriously
04:15callenwhat is the fucking deal with parsing xml in Clojure?
04:15callenit has the same goddamn semantic structure as S-expressions, it should be ace at this.
04:16clgvcallen: still struggling with it?
04:16calleninstead I'm bashing my head into a bloody stump against the walls of clojure.data.zip.xml
04:16callenclgv: yes, and raging myself to death.
04:16callenI'll refheap it.
04:17callenhttps://www.refheap.com/paste/5129
04:17callenclgv: ^^
04:17callenzx is clojure.data.zip.xml
04:17callenwhich is what I saw in sie examples.
04:18clgvI did not use that lib yet.
04:19callenmapcat-chain...cond...text...yes I know some of these words...
04:19callenI vaguely remember using mapcat on 4clojure.
04:19hoeck1callen: what about: (zx/xml-> zipped first :dwml :version) ?
04:20hoeck1callen: zip is generally excellent at navigating throug trees
04:20callenjava.lang.NullPointerException: null
04:20callenhoeck1: nice try sport.
04:20callenhoeck1: NPE though.
04:20callentesting other "queries" using the same first function, no dice so far.
04:21callenincidentally, passing it second instead of first returns () for all queries
04:21calleninstead of the null pointer exception
04:21callenthe raw data structure is in that refheap I pasted, you can try it yourself.
04:21callenand know my horrors.
04:22callenI'm going to rename Clojure to Clothulhu for the raw terror and hatred it has made me experience, but I cannot pry myself from its spell.
04:22hoeck1ah, [[:dwml {:version ...}]], so its: (-> .... first second :version)
04:22callenjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
04:22SgeoWhat's the difficulty?
04:22callen(I have nrepl open and at the ready)
04:22tomojcallen: is that the zipper?
04:22callenSgeo: XML parsing.
04:22callentomoj: is what the zipper? the exception?
04:22tomojthe raw data structure in your paste
04:23callenpost-zipped tree.
04:23SgeoSo, each vector's first element names the element, second is attributes, third is contents
04:23SgeoSorry, not third. rest, I assume
04:23callenzipped == (zip/xml-zip (tagsoup/parse-string test_body))
04:23callen^^
04:23callenthen!
04:23callenfor my next trick...
04:24callenuser> (zx/xml-> zipped first :dwml :version)
04:24callenNullPointerException clojure.zip/branch? (zip.clj:73)
04:24callenwalla, no more pencil.
04:24callenjust a dead henchman.
04:24callenriddle me that, bats.
04:24Sgeonil must die.
04:24SgeoThat's the riddle.
04:24SgeoNull and nil are horrible and evil
04:24callenI'm certainly in the mood to declare the death of things
04:25callenbut considering you're in the channel for a dynamically typed language, grumbling about nulls, Nones, nils, voids, etc is a bit like chucking a boulder in a glass house.
04:25callenthe Scala and Haskell fascists are down the hall, and probably more successful at parsing XML than I presently am.
04:26callenright well uh
04:26calleneven if wasn't an NPE, it'd be a type-error
04:26SgeoI'm mostly interested in Clojure because of the macros
04:26callenwhich is equally unhelpful at present
04:26hoeck1callen: could you please paste a pprint of the (zx/xml-> zipped) call?
04:26callenI have been
04:26callenrepeatedly.
04:26callen08:20 < callen> user> (zx/xml-> zipped first :dwml :version)
04:26callen08:20 < callen> NullPointerException clojure.zip/branch? (zip.clj:73)
04:26SgeoAnd the somewhat large community around it
04:26callenwould you like me to quote myself quoting myself?
04:26SgeoAnd the niceness of changing code at run-time
04:27callenSgeo: ah yes the siren song of macros.
04:27callenSgeo: once you get past the whole gensym thing, it gets a lot more sane than you might expect.
04:27callenwhich is frankly, a sticking point for Schemers because they're big babies.
04:27hoeck1callen: without the trailing :first :dwml :version
04:28callenuser> (zx/xml-> zipped :dwml :version)
04:28callen()
04:28SgeoI can't say if Scheme macros might be better or easier, because, unlike CL-style macros, I flat out do not understand Scheme macros.
04:28SgeoCL-style macros are conceptually easy.
04:28callenhoeck1: bro, I have like, 100 repl lines of getting Unit() tossed at me.
04:28callenhoeck1: of a multitude of :blah combinations
04:28tomojhow did you create that zipper?
04:28callenthat's not the answer. trust me.
04:28callenI've also pasted that ;_;, h/o
04:28callen(def parsed (tagsoup/parse-string test_body))
04:28callen(require '[clojure.zip :as zip])
04:28callen(def zipped (zip/xml-zip parsed))
04:28callen(require '[clojure.data.zip.xml :as zx])
04:28SgeoAlthough I do want to yell at Hickey for sticking with CL's insane idea for not making a ... "real" version so to speak of ` and ~
04:29SgeoAs in, there's no quasiquote and unquote forms... at least that I know of
04:29hoeck1callen: zippers are different from clojure datastructures, eg: http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip
04:29callenSgeo: honestly man, the macros in Clojure are more sound than Template Haskell anyway.
04:29callenSgeo: I wouldn't sweat it.
04:29Sgeocallen, I'm not sweating anything
04:29callenhoeck1: and the...takeaway...is?
04:30callentomoj: ^^ see above?
04:30tomoj(z/next z) throws an exception
04:30tomoj..that shouldn't happen
04:30hoeck1callen: so maybe (zx/xml-> zipped zip/down zip/left) et cetera are your friends
04:30callentomoj: now do you know why I've dubbed it clothulhu!?
04:31callenhoeck1: yeah uh, I'm not manually traversing the layers of the tree.
04:31callenhoeck1: that's fucking stupid.
04:31tomojcan you paste the xml? (not in here)
04:32callenthat's like going herp['derp'][0][0][1].textNODE[1][0][2] willynilly in python
04:32callenfuck. that.
04:32callentomoj: yes, h/o
04:32callentomoj: https://www.refheap.com/paste/5130
04:32SgeoI've done code like that in Tcl
04:32callentomoj: that's the clojure string of the http body returned by the REST XML endpoint.
04:32callenSgeo: Tcl people are psychotic.
04:33callenSgeo: EVAL ALL THE THIIIIINGS
04:33SgeoMostly because I couldn't get a sufficiently new version of some XML library into my environment
04:33callenSgeo: I'm seeing a pattern.
04:33callenone that deeply horrifies me.
04:33SgeoWhat, that I've explored a lot of languages?
04:33callenno, that XML is a fucking curse in every language.
04:33callenwho the hell is responsible for that anyway? Tim Bray?
04:34tomojhuh
04:34callenyour huh worries me.
04:34tomojwhat is tagsoup?
04:34callentomoj: it's gov't generated XML, if that comforts you.
04:34tomoja clojure wrapper?
04:34tomojI get a very different zipper using clojure.xml/parse
04:34callentomoj: the XML parser I had to use that worked, whereas the clojure.xml parser, I kid you not, choked on this XML and threw an exception.
04:34callenwhen I tried to use clojure.xml/parse it failed.
04:34tomojI get no exception with that xml
04:34callenwhat in the mother...hrm. h/o
04:35callentomoj: clojure.lang.Compiler$CompilerException: java.net.MalformedURLException: no protocol: %3C?xml%20version=%221
04:35callentomoj: that's what I get.
04:35callenwhen I attempt (def newparsed (clojure.xml/parse test_body))
04:35tomoj(doc clojure.xml/parse)
04:35clojurebotTitim gan éirí ort.
04:35callenthe bot appears to have demons.
04:36tomojif you pass xml/parse a string, it thinks it's a filename
04:36callenoh jesus fucking christ
04:36callenwhy can't I pass the dumb bastard a goddamn string?
04:37SgeoI wonder if passing it a data: URI would work? </dumbhacks>
04:37tomojapparently because that's the way the sax interface in java is
04:37callenthat is horrid. why the hell wouldn't an XML parser take a static string?
04:37callenkgjnel;ksgnertgkl;te
04:37callene. fucking. gads.
04:38SgeoIt's Java.
04:38SgeoDon't expect it to make sense
04:38tomojwell, how'd you get a string?
04:38callenI just...want to pass a string...to a textual function...
04:39calleneven Haskell got this right by allowing you pass String, Text, ByteString, or run a streaming parser all in the same place.
04:39callentomoj: a URL, but it may not always be a GET
04:39SgeoByteStrings are not text, don't treat them as such.
04:39callentomoj: in the case where it's not a GET, xml/parse will not work.
04:39callenSgeo: yes yes, I know.
04:39callenI need to be able to acquire the string separately and pass it to clojure.xml/parse
04:39SgeoIt should be a simple amount of Java interop
04:40Sgeohttp://stackoverflow.com/questions/837703/how-can-i-get-a-java-io-inputstream-from-a-java-lang-string
04:40Sgeouh
04:40Sgeohttp://www.koders.com/java/fid0A51E45C950B2B8BD9365C19F2626DE35EC09090.aspx
04:40SgeoThat's... a bit much
04:40tomoj(clojure.java.io/input-stream (.getBytes "<foo></foo>"))
04:40callenyou make me hate life.
04:40callenor rather, Java makes me hate life.
04:40tomojI don't know what you mean about xml/parse not working with GET
04:40callenSgeo: holy---
04:40callentomoj: invert that statement.
04:40callentomoj: it doesn't work if I need to do a POST with a POST body.
04:41tomojwhy not?
04:41callenI already have it working for the GET, but I'd rather just do the HTTP request separately.
04:41Sgeotomoj, why does that need to be .getBytes?
04:41Sgeo,(clojure.java.io/input-stream "Hello")
04:41clojurebot#<SecurityException java.lang.SecurityException: denied>
04:41Sgeo&(clojure.java.io/input-stream "Hello")
04:41lazybotjava.security.AccessControlException: access denied (java.io.FilePermission Hello read)
04:41Sgeooh
04:41callenwell, it worked.
04:41tomojsame reason, basically
04:41callen(clojure.xml/parse (clojure.java.io/input-stream (.getBytes test_body)))
04:41Sgeo,(clojure.java.io/input-stream (.getBytes "Hello"))
04:41clojurebot#<BufferedInputStream java.io.BufferedInputStream@76e47eb7>
04:41callenI'll see if I can extract the data.
04:42SgeoWait.
04:42SgeoA string is not a series of bytes.
04:42callenSgeo: here's a real mind-twister for you
04:42callenSgeo: Java is UTF-16
04:42elzibubUTF-8, no? Only some characters are wide
04:43tomojcallen: if you are getting the xml from an http request, you should be able to get an input stream for the body. maybe you already know this, I still don't know what you mean about POST
04:43callenelzibub: Java originally used UCS-2, and added UTF-16 supplementary character support in J2SE 5.0.
04:43callentomoj: lets put it aside for now, the getBytes hack is working.
04:43Sgeoelzibub, translation: A character is two bytes wide unless it's four bytes.
04:43callentomoj: thank you for your help so far. I'm continuing along.
04:43callenSgeo: thank you for the moral support :)
04:44Sgeo:)
04:44Sgeo,(clojure.java.io/input-stream "data:text/text,blah")
04:44callensigh, son of a bitch
04:44clojurebot#<SecurityException java.lang.SecurityException: denied>
04:44callenthe structure is different, but the zipper still isn't working and is throwing NPEs again.
04:46callenhey uh, Sgeo tomoj...
04:46callenhttps://github.com/clojure/data.xml you know this has parse-str for XML right?
04:46callenand it works fine?
04:47callenseemingly?
04:47callen(def parsed (clojure.data.xml/parse-str test_body))
04:47tomojcool
04:47SgeoI have not had any need to parse XML in Clojure yet
04:47callendespite that, still getting NPEs
04:48callengjn;ekrjsg
04:49callenparse-str is what the internal clojure code uses.
04:49tomoj(zx/attr z :version)
04:49callenI knew I wasn't crazy.
04:50callentomoj: that's the first thing that's returned something.
04:50tomoj(zx/xml1-> z :dwml) searches for the inner dwml in "<dwml><dwml></dwml></dwml>"
04:51tomojyou are already there, no need to search
04:52tomojalso (zx/xml1-> z :version) looks for <dwml><version></version></dwml>
04:52callentomoj: what if I want it to search to arbitrary depths and return all tags that have a particular name?
04:52callenlike <Temperature></Temperature>
04:52callenand return a list of everything that had that tag name.
04:52callentag=?
04:53tomoj(tag= :foo) is the same as just :foo inside xml->
04:53callendoesn't return anything though.
04:54callenI think it elided information.
04:54callenno wait, I found :temperature
04:54callen(#clojure.data.xml.Element{:tag :temperature, :attrs {:type "maximum", :units "Fahrenheit"
04:54callenuser> (zx/xml-> z :temperature)
04:54callen()
04:55tomojyou have to descend
04:55callenthat's what I asked
04:55callenhow do I get it to exhaustively search the tree and return all tags matching a name?
04:55callenthat's what my Python code does, trivially.
04:55tomojsometimes I'll do (zx/xml-> z dz/descendants :temperature)
04:56tomojdz is clojure.data.zip
04:56callenit's not clear to me that it did anythign other than return everything.
04:57tomojthat's because it's a zipper, you got a seq of locs back
04:57tomojif you want the nodes do (zx/xml-> z dz/descendants :temperature z/node)
04:57callentomoj: you do appreciate how much simpler this is in Python, yes?
04:57tomojno. easier, maybe.
04:57callenwait, what's z? clojure.zip?
04:58tomojyeah
04:58callenthat worked.
04:58augustlis lazytest still maintained? Nothing seems to have happened since 2012
04:58augustl2010*
04:59callentomoj: easy is pretty important
04:59callentomoj: having to overcome all this to do what I was able to reproduce in Python in about 2 minutes (not exaggerating) is a bit extreme.
04:59callenreally have to make my language/technology decisions based almost 100% on time and virtually nothing else.
04:59callenso even if Clojure is more elegant, or in your world, simpler, it still leaves me with lost time.
05:00callenthere's got to be a better way than this.
05:00augustlcallen: easy is only important when you're new to something :)
05:00callenaugustl: I was perfectly productive in Common Lisp.
05:00callenthat's how I came to Python.
05:00augustlclojure is pretty different from most other lisps though
05:01callenI don't see how that's true.
05:01augustlI personally don't find easy to be that important. The phase of getting to know something is finite
05:01callenit's at the opposite end of the spectrum of Emacs Lisp.
05:01callenaugustl: I did like 50 exercises in 4clojure and I'm still strugging here.
05:01augustlthen I spend the rest of my life knowing it
05:01callenstruggling.
05:02augustlsure, Clojure hard to learn, I've programmed clojure full time for almost 3 months now and I'm still learning new things every day
05:03callen54 exercises in 4Clojure.
05:03callen(I just checked)
05:03augustlcallen: in here we all use this definition of "easy" btw ;) http://www.infoq.com/presentations/Simple-Made-Easy
05:03callenstill data.
05:03callennada*
05:03ambrosebsHas anyone been informed if their Clojure Conj 2012 talk was accepted?
05:03augustlambrosebs: I haven't
05:03callenaugustl: I'm fully familiar with the reference, that's why I'm all the more contemptuous of it.
05:03callenRich Hickey is a genius, you guys parroting him however smart he may be, isn't.
05:04callenif you had come to this conclusion on your own, or were otherwise providing feedback that wasn't a restatement of his talk I'd take you more seriously.
05:04callenthis is worse than Common Lispers quoting Norvig.
05:04callenoi vey.
05:04augustlcallen: you seem to be quite upset..
05:04callenaugustl: Actually I just find cargo-cultish engineering behavior upsetting.
05:04pyrhhoso, only newton is allowed to talk about gravity?
05:05callenno, but simply restating the title of his paper on gravity over and over doesn't constitute useful discourse either.
05:05ambrosebsaugustl: Neither. Would love to know soon ..
05:05augustlcallen: the use of the word "easy" is very thoughtful on my part at least, not sure what makes you think everyone else here is using it without any thought.
05:05pyrhhocallen: fair enough
05:05callenso can we put the strawmen aside and speak from our own minds?
05:05callenaugustl: the last 5 minutes?
05:06augustlcallen: now you're just being "angry person on the internet", this isn't very productive
05:06callenaugustl: and longer term, just general exposure to the Clojure community bothers me.
05:06callenwhen I first encountered Hickey on here, he was SUPER cool and very helpful
05:06callenthen you guys trundled in and now all I hear about is SIMPLE MADE EASY and DATOMIC
05:06callenmeanwhile, back in reality-land, parsing xml takes two separate days of labor to even get results back
05:06tomojI don't find upsetting your refusal to consider anything besides your immediate convenience when making your language/technology decisions (if you can call that "engineering behavior")
05:06callenlet alone finish the job.
05:07callenyou speak about immediate convenience as if this is something to be shown derision
05:07callenthe hell is wrong with you?
05:07callenWhat do you think software and engineering are?
05:07augustlcallen: I never said that easy is bad, I just said that I generally prefer long-time benefits over immediate ease of use
05:07callenIt's about saving human time and creating leisure where there was none before.
05:07callenit's about sacrificing silicon, and steel, and concrete for the sake of the human mind and soul.
05:07callenand you scorn "easy"?
05:08callenSo toss your dishwasher out the window
05:08tomojah, I see, you're nuts or trolling :)
05:08callenforsake graphical user environments
05:08callentomoj: no, just burnt out and insanely angry with the ridiculousness of what it took to get XML parsing.
05:08callenthese are legitimate, serious *usability* issues that bear addressing and inspecting.
05:09calleninstead you scorn them as noobie problems.
05:09augustlcallen: for what it's worth, I was able to parse xml after about an hour of effort
05:09callentotally naive.
05:09tomojI don't have scorn
05:09callenaugustl: thanks, fuck you. the whole channel pitching in couldn't do it in an hour
05:09callenaugustl: so you're smarter than their combined intellect.
05:09callenaugustl: I was here for a couple hours last night, four different people attempted and failed, then tonight (just now)
05:10augustlmy xml was pretty small, perhaps that's what makes your case more difficult
05:10callennice try, ego-man.
05:20sunkencityrylehI
05:26sunkencityrylehWhoops. I'm trying to use a java library "[net.sourceforge/barbecue "1.0.6d"]" but no version of it is available in the default maven repos. How can I add extra repos? Would it be possible to add a jarfile to a lein project some other way? Or can I specify extra maven repos somehow?
05:26tomojsunkencityryleh: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L161
05:26sunkencityrylehtomoj: thanks!
05:26clgvsunkencityryleh: if you do not find that jar in any repository, you can push it to clojars under your private group-id
05:28sunkencityrylehclgv: ok tnx!
05:30augustlis there a way to create an "else" or "catch all" for a multimethod?
05:32clgvaugustl: there is dispatch for :default
05:32augustlso just (defmethod foo :default ...)?
05:32clgvyes.
05:33augustlthanks
05:46tomojhuh, never noticed nthnext
05:53mpenetis there a way to read a string as clojure data from clojurescript (at "runtime"), ex as a response to an ajax request?
06:03SgeoWhat if I want a two-dimensional zipper?
06:04mpenetnevermind there is cljs.reader/read-string, I was induced in error trying to pass it a js Object and not its str representation
06:09luxbockwwww.clojuredocs.org looks like a great site for browsing the documentation for a newbie like me, lots of examples
06:09luxbockthanks to whoever runs it
06:18naegluxbock: but it does not feature the the newest version of clojure, 1.4
06:19luxbockoh
06:20naegluxbock: you'll have to use this one then: http://clojure.github.com/clojure/ provides all you need, beside the examples :/
06:20naegalso, see here: https://groups.google.com/forum/?hl=en&amp;fromgroups=#!topic/clojure/d-YF4jnECUQ
06:20luxbockexamples are what I crave
06:21clgvluxbock: you can still use it. examples in 1.3 should work in 1.4 as well
06:21naegluxbock: I'm mostly using the docs on github and whenever I'm not fully understanding something, I use clojuredocs to look at examples of 1.3 (some functions are not present though, like mapv)
06:24luxbockI asked about this eariler but couldn't find an answer yet
06:25luxbockI'm using Emacs with nREPL with clojure-mode on
06:26naegluxbock: it's not like i want to advertise it, but have you tried using the lighttable playground? As a newbie it was a lot easier for me to use than emacs. It shows data flow through your functions, etc.
06:26luxbockhow do I run the clojure-mode buffer in the REPL? I tried C-c C-k but that gives me a load of errors
06:29luxbockyeah I tried it but I prefer Emacs
06:31casionluxbock: m-x clojure-mode
06:33Raynesluxbock: Yeah, clojuredocs is still plenty relevant for 1.4.
06:33casionyou can generate your own clojuredocs for 1.4 easily, I have it locally
06:33RaynesNobody cares about mapv.
06:33Raynes;)
06:33naeg:o
06:33naegI actually use it quite frequently :P
06:34luxbockcasion, that just enables clojure-mode doesn't it? I'm trying to get the code I have typed up in the buffer to run in the REPL
06:34casionohh
06:34naegcasion: how did you generate your own?
06:34Raynesluxbock: Information about those loads would be helpful.
06:34luxbockbut I'm not sure if I'm using the wrong hotkey or if there's something wrong with my setup
06:35casionnaeg: I just took https://github.com/jafingerhut/clojure-cheatsheets and ran it locally
06:35casionthat gives essentially the same info
06:35casionminus the contrib-y stuff
06:36casionluxbock: if c-c c-k is giving you errors, then you have a top level form that's fubar
06:37luxbocksorry, what does that mean?
06:37casionthe code you're trying to load is bad in some way
06:38casionread the error message to get a clue as to what is
06:38casionjaedong playing this morning, woo!
06:38casionshit, wrong window
06:40luxbockI tried running (println "Hello world!")
06:40luxbockand I get the following:
06:40luxbockhttp://pastebin.com/LNvrXn4y
06:41casionthat's all you have in the file?
06:42luxbockyeah, I tried to make it as simple as possible to make sure the code is valid
06:42casionafaik, that error usually means a misplaced parens somewhere
06:42casiondoes it work in the repl?
06:42luxbockyes
06:43luxbockit's only when I try to run it from the core.clj file that things go wrong
06:43casioncan you paste the core.clj
06:43casionto refheap
06:43casion(I get yelled at when I use pastebin)
06:43mpanis there a strategy to keep track of and verify the format of complex arguments to a function?
06:43luxbockit's just one line
06:44mpanfew times now I've lost major time because I was passing my functions something structurally really wrong
06:45luxbockthere's nothing else besides: (println "Hello world!")
06:46luxbockmust be something wrong with my Emacs configuration
06:49casionluxbock: seems to be an issue with your project
06:49casiondid you remove the (ns …) line?
06:50luxbockfrom the core.clj file? I never had one there
06:50casionhow did you make the project?
06:50luxbockwith leiningen
06:51casionuh.. hmm
06:51casionlein new project-name ?
06:51luxbockyup
06:51casionthat's odd
06:52luxbockdo I need to declare (ns ) somewhere for it to work?
06:52casiontry again, you should have something like https://www.refheap.com/paste/5135
06:53casion^ first try of rayne's refheap.el :D
06:53luxbockstill run into the same problem
06:54casionis core.clj empty still?
06:55luxbockwell it has the code that you gave me in it
06:56casionI have to go for an hour, I'll try and help more when I get back
06:56casionI'm sure someone more competent can step in anyway :)
06:56luxbockthanks!
06:56luxbockI'm cheering for Jaedong as well
06:56casionyou watching code A atm?
06:56luxbockyeah
06:56casionhot damn
06:56casioncousin just showed up to watch it with me ;)
06:56casionthose roro games were awesome
06:56clgv"code A"?
06:56casionanyway, I'll be back when it's done :)
06:57luxbockI just opened up the stream when you mentioned Jaedong, had forgot that he was playing today
06:57casionclgv: starcraft 2 tournament in korea
06:57casiongomtv.net
06:57clgvah ok
06:57luxbockalright thanks for trying. I think there's a chance it could be something really silly as I'm a complete newbie with both Emacs and Clojure
06:59clgvluxbock: does it work from "lein repl"?
06:59luxbockif I just type it in the repl rather than running the file?
07:00clgvluxbock: no. on commandline in your project, start up a repl via "lein repl" and then load the namespace and try toexecute the function
07:01clgvif that works you can be sure that it's the emacs setup, I think
07:02luxbockyeah that works
07:02luxbockor actually
07:03clgvso you gotta find a tutorial to setup emacs properly or someone here that knows how to do that
07:03luxbockplaintest.core=> (foo "Blah")
07:03luxbockCompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in t
07:03luxbockhis context, compiling:(NO_SOURCE_PATH:1)
07:04clgvcan you paste the complete file, e.g. on refheap.com?
07:04luxbocksure
07:04clgvwith path and filename in the project please
07:06luxbockhttps://www.refheap.com/paste/5136
07:07clgvwell your namespace does not fit to your path+file - similar to java in clojure namespace my.project.core has to be in file src/my/project/core.clj
07:08clgvluxbock: seems you need some clojure basics: tutorial or book - your choice ;)
07:08luxbockI tried changing it to (ns helloworld.core) but that didn't work either
07:08luxbockyeah I'm going through a book at the moment, but I guess I haven't got to the right chapter yet
07:09clgvluxbock: jump ahead if there is a chapter on leiningen ^^
07:09luxbockalright
07:09luxbockwhat should my (ns ) be saying?
07:10clgvwhat is your filepath? src/helloworld/core.clj?
07:10luxbockyeah
07:11luxbockI'm going through Programming Clojure, doesn't appear he talks about Leiningen
07:11clgv"src/helloworld/core.clj" => (ns helloworld.core)
07:11clgvluxbock: edition 2?
07:11luxbockno, this is the first one
07:11clgvyeah. there is no leiningen chapter.
07:11luxbockmakes sense, there's a chapter on namespace but I haven't got to that yet
07:12clgvbut namspace name and file path correspondence is a plain clojure thing anyway
07:14luxbockalright, I'll get back to reading
07:14luxbockthanks for the help
07:16clgvluxbock: be careful, there is a bunch of outdated stuff in the first edition of that book as well, e.g. #^String for type hinting a string, and some more
07:17clgvluxbock: but for learning the basics it serves well, I think
07:18luxbockok
07:23aibhow is :dependencies in defproject in lein resolved? I see an element like [org.clojure/clojure "1.4.0"] - how does this tell lein what to download?
07:25clgvaib: it's using that info to search the given repositories (without configuration maven.org and clojars.org)
07:26aibI see. thanks
07:26clgvthe format means [groupid/artifactid version]
07:27aibbah, now I'm more confused because there are 3 "lwjgl"s in clojars... and that's just the groupid, I think
07:28clgvaib: what does the libs website tell you as official groupid?
07:29aibnothing :/
07:30arkxaib: http://www.lwjgl.org/wiki/index.php?title=LWJGL_use_in_Maven
07:30clgvaib: I'd take that one: http://search.maven.org/#artifactdetails|org.lwjgl.lwjgl|lwjgl|2.8.4|jar
07:30aibah, maven. I'd searched for "Clojure"
07:30clgv[org.lwjgl.lwjgl/lwjgl "2.8.4"]
07:40mindbender1A crazy thought came to me that all functions are object-oriented
07:40naegin what sense?
07:41mindbender1they woek on particular kinds of objects
07:41mindbender1*work
07:41naege.g. a number is not (necessarily) an object
07:42naegat least not an object in the sense of OOP
07:42mindbender1then what is a number
07:42naega primitive value
07:42mindbender1*value*
07:43mindbender1an object is a *value* too
07:43naegbut not a primitive one
07:43mindbender1to me a value is an object
07:43naegI think there are programming languages out there which treat numbers as objects
07:43naegnot in the sense of OOP
07:44naegyeah, Ruby is one of them
07:44mindbender1a number has a type
07:44mindbender1so it is an object
07:46mindbender1you can take a function that's meant for a specific type number and apply it to another
07:46mindbender1*can't
07:46naegan object is in OOP refers to an instance of a class. hence, when integers are not class (unlike in e.g. ruby), a simple number is no object
07:47hughfdjacksoni'm not sure that i buy that
07:47hughfdjacksoninstance of a class, i mean
07:47mindbender1hughfdjackson: which one
07:47mindbender1ok
07:47mindbender1cos I don't too
07:47hughfdjacksoni know people argue about OOP and its definition all the time, but .. take JS for instance
07:47naegyeah, there it's about prototyping
07:47mindbender1prototyping is just an implementation detail
07:47hughfdjackson:p i always lose a lot of my day when i try to find a satisfactory definition
07:48mindbender1just like mixin is
07:48hughfdjacksonmindbender1: well, when the prototypal inheritance is object-to-object, then you lose classes :p so you can't define OOP by classes
07:48naegbut I guess the "historical OOP" invented by alan kay, is about classes (I'm not sure though)
07:48mindbender1hughfdjackson: I don't
07:48hughfdjacksonmaybe :) i think the unifying part of OO is sharing data and behaviour in the same namespace
07:49hughfdjacksonand that that gets passed around as the main unit of information *and* manipulation
07:49mindbender1my point is programming is mostly about thhe same thing
07:49hughfdjacksonpackaged together
07:49naegwhat primitive values like numbers, do not in clojure and most other languages
07:49hughfdjacksonmindbender1: you're right, there's lots of parallels
07:49hughfdjacksonand trying to unpick the *real* differences is really fun and informative n.n
07:50mindbender1even when I read heavily jargonized text I keep focus on the object
07:50naeghttp://c2.com/cgi/wiki?AlanKaysDefinitionOfObjectOriented => "Every object is an instance of a class (which must be an object)."
07:51mindbender1I certainly don't have to agree with whatever that link has to say
07:51hughfdjacksonnaeg: :D well, that's very interesting
07:51mindbender1because time and again experts have been proven to be wrong
07:51naegthat's just the "historical OOP" I was talking about before
07:51hughfdjacksonmindbender1: i'm not sure you can prove someone wrong on this ground
07:52mindbender1I'm not trying to
07:52hughfdjacksoni mean.. you can assign a term to anything you like; if that's what he wants to assign it to..
07:52naegalan kay was the person who "invented" oop. but it changed A LOT since then. alan even said that what most "oop languages" are today is not what he actually meant
07:52hughfdjackson:D however, i'd contend it's no longer the most useful definition, given the plethora of similar languages that take a different approach to create their objects
07:52mindbender1I'm just saying that functions are object oriented
07:52hughfdjacksongiven my personal definition of that, i don't think i can agree
07:52mindbender1because they still have to deal with instances
07:52naegmindbender1: then what does object oriented mean in this context? it's not about OOP then
07:53mindbender1naeg: ^^
07:53hughfdjacksonbecause functions live in a seperate namespace to the data that's passed around to manipulate
07:53mindbender1even according to your definition
07:53hughfdjackson:p although clojure may do some things differently in this regard at its roots
07:54naeghughfdjackson's definition before seems to fit most OOP languages today (but is not what alan kay intended)
07:55hughfdjacksoni'd happily rename my definition to 'objecty' if there's objection ;)
07:55hughfdjacksonit seems to be the most important difference between functional and OOP to me
07:55hughfdjacksoncould well be wrong!
07:56hughfdjacksoncan't hang about to find out though, i've got a job to go to
07:56hughfdjackson:) ciao
07:56naegcu
07:56mindbender1I think the idea of functional programming was one of reducing complexity
07:57mindbender1in that the number of types are drastically reduced
07:57mindbender1because we mostly have associative types
07:57mindbender1andd a few others
07:57xak466hi, im writing some code that validates input from a form, and saves it to the database if the input is valid. at the moment, i am doing it like this
07:57xak466(if (validate-title params) (if (validate-url params) (save-to-database params) (validate-url params)) (validate-title params))
07:57naegI'm not sure whether you are right here, quite new to clojure/FP
07:58mindbender1xak466: try it at a repl
07:59clgvxak466: you dont like that layout?
07:59xak466(if (validate-title params) (validate-title params) (if (validate-url params) (validate-url params) (save-to-database params)))
07:59xak466sorry, mistype
07:59xak466so the validate-* functions return nil if it passes
07:59clgvxak466: what is the question/problem?
07:59xak466and returns {:error "bad url"} if it fails
07:59xak466my question is, is there a nicer way to do it
08:00xak466rather than nesting (if's
08:00clgvxak466: you could do (keep #(% params) [validate-title, validate-url ...])
08:01casionluxbock: :(
08:01aibdo I need to do something extra to get :native-dependencies working in command line lein or CCW?
08:02xak466clgv: thanks. just reading up on (keep
08:03xak466clgv: will (keep evaluate the whole list or stop once the first non-nil value is returned?
08:03clgvaib: there was something with a special format for native jars. you have to consult the leiningen docs.
08:04casionluxbock: any luck in the interim?
08:04clgvxak466: keep = (remove nil? (map ...))
08:05aibclgv: they're hard to consult. though I just remembered there's #leiningen and I don't need to bother people here
08:05clgvright ^^
08:05aibsorry, this is all very new for me
08:09xak466clgv: i think i found what i was looking for. (first (drop-while #(= nil (% params)) [validate-title validate-url save-to-database]))
08:09clgvxak466: ah. I would have separated the save-to-database from the validity checks
08:10clgvxak466: that way you can report all errors and communicate semantics
08:11xak466clgv: ahh.. i see what you're getting at
08:11xak466clgv: in that case, the keep would be more sensible
08:12xak466clgv: as you can see, i was trying to abort at the first error encountered
08:12xak466clgv: but i think your solution is better
08:13clgvxak466: "report all" or "report first" depends on your use case. but I would not mix save-to-database in there
08:14xak466clgv: yup that too
08:16dhofstetis it good coding style to use many forward declarations?
08:17clgvdhofstet: I doubt that. as far as I have seen you only use them when they are really needed
08:19dhofstetclgv: thanks, seems I'm still too used to read source files from top to bottom ;-)
08:53aibhow do I call a function in another file? (ns project.core) (defn foo "foo" [x] (+ x 1)) - (ns other.file) (project.core.foo 5) ?
08:54ro_styou need to require it in your ns decl
08:54aib(:require project.core) ?
08:55gfredericks(ns other.file (:require [project.core :as core])) (core/foo 5)
08:55ro_st(ns other.file (:require [project.core :as core]) (core/foo 5)
08:55ro_st+)
08:55ro_st:)
08:55ro_staib: also, clojurebook.com or http://java.ociweb.com/mark/clojure/article.html
08:56mpenetibdknox: ping
08:56ro_stthis is a language that rewards experimentation, but you do need to do your homework too
08:59HodappI find it rather interesting how in Lisp-ish languages, a lot of the standard practice is that one will generate and pass around functions as readily and as easily one might do something like a branch or a variable initialization in another language
08:59chouserThat's the original meaning of "functional programming"
09:00HodappIs it? I thought it varied a bit from that
09:00casionthat's pretty much the only thing people seem to agree on in the varying definitions of 'functional programming'
09:01madsyHodapp: In Lisp dialects like Scheme, lambda functions are used to build more high level constructs. It's one of the main building blocks
09:02HodappWell, it does also seem to also apply to languages like Ocaml and Scala that are very non-Lispy, but are functional
09:02Hodappmadsy: I've not worked with Scheme much but I did get this idea, and likewise for Scala which I've worked with a bit
09:03madsyHodapp: SICP is a great book if you want som aha-moments.
09:03Hodapplike it's not a "feature" or even a design pattern, it's just how you do things
09:03madsyhttp://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_start
09:03chouser"Functional programming" has come to imply more than that, such as pure functions, immutable collections, and even pattern matching. But at the very least you have to be able to create and pass around functions.
09:03HodappI do need to get through SICP. I'd like to get some folks to watch the Sussman lectures on it.
09:04aibro_st: sorry, it's just hard to sift through all these tutorials looking for Clojure-only stuff
09:04HodappThe Android APIs do make ready use of anonymous functions and closures, but only to the extent that clunky Java allows it
09:04Hodappso it ends up as an approximation with interfaces that are instantiated on-the-fly as inner classes
09:05ro_staib: no need for apology. i'm just trying to give you the best path to happy clojurin'
09:05Hodappchouser: I do have to say, Scala's pattern matching is kind of magical.
09:06Hodappchouser: I don't know anything about writing parsers, but once I read a little bit about BNF and looked at Scala's parser combinators, I found it amazingly simple to put together a fairly complex parser with it.
09:06chouserpattern matching can be quite nice. It seems odd to call it "functional programming", but whatever. Clojure has core.match which works quite nicely.
09:07HodappI'll have to check that out.
09:09HodappI just find it interesting, after working too much at a jorb where imperative object-oriented programming is the norm, to see how many of those structures just collapse and go away when I employ something like Clojure, even not knowing it too well.
09:10chouserfunctional languages love parsers -- clean data in and out, pure functions operating on it, trees that beg recursion...
09:10Hodappchouser: indeed.
09:11Hodappchouser: At some point I came to the realization that I'd basically replaced an existing C++ parser, 5K-6K lines long, with about 100 lines of Scala.
09:11casionHodapp: the tradeoff is that if you're not careful you can end up with incredibly 'powerful' functions that take you hours to reinterpret when you go to look at the code later
09:12casionsomewhat analgous to ending up with 20 generations of inheritance in a large c++ project
09:13Hodapphmm, yeah
09:13casionI've already ended up confusing myself with the clever 3 liners that do an equivalent of 40 lines of java code which are so tempting to write
09:13HodappI've tried to keep things pretty clear
09:14casionperhaps I'm more disposed to that from writing low-level C stuff usually
09:14casionwhere I usually can interpret my cleverness later ;)
09:14Hodapphah, yeah
09:14HodappI still write plenty of low-level C
09:14Hodappprobably more once my TI Stellaris Launchpad boards arrive
09:15casionI'm waiting for my next project to try the stellaris boards
09:15casionI'm still waiting for a turkey arm board that I can use
09:15casionrolling your own is such a massive pain
09:16HodappI used a Procyon for awhile from Teho Labs
09:16ejacksonwhere does nrepl in emacs send exception/assertion messages ?
09:16Hodappjust uses StellarisWare & CodeSourcery
09:16Hodappthe Raspberry Pi also is quite nice, though you can't really treat it the same as a lot of ARM boards
09:17casionI got a PI and I hate it
09:17casionthe documentation is worse than awful
09:17casionit's one thing to have lacking documentation, but half the pi docs are just wrong
09:18HodappI've rather liked mine for what I'm doing; it replaced that Stellaris board, a JTAG controller, an FTDI Basic, and a separate PC for talking to the Stellaris board
09:18mwcampbellApologies for posting the same thing twice on the Google Group. I didn't mean to be obnoxious; I thought my first post had been silently ignored.
09:18Hodappbut that's a fairly narrow area
09:19casionI don't know enough about linux to figure out the pi on my own
09:19casionI just want docs with correct info
09:19casionnot a bunch of "It worked like this in the alpha… but it doesn't do that anymore, so ignore all this info, kthxkai"
09:20Hodappthis is part of what annoys me about things like this
09:20Hodappso much of what goes on is documented in spotty message boards, not websites or even Wikis
09:20casionwell AVR is documented super well, mostly because of arduino
09:21HodappI had the same complaint about some Android custom ROMs
09:21casionand if you're going to design your own board and write your own firmware, arm is great...
09:21casionbut once you have and OS forced on you, everything seems to goto shit
09:22Hodapphmmmm
09:22Hodappand all the alternative OSes - RISC OS, WebOS, possibly Android and FirefoxOS - are all quite alpha right now
09:24casionmeh, I just use my own
09:24Hodappfor my Procyon board I didn't have any OS; for the RPi project I did, I benefitted from having Linux there and just hacking on the low-level parts I needed
09:25casionit's nearly invariably easier for me to just write my own firmware and a basic OS than spend time learning something that has 500 features I don't need, and doesn't implement what I do need
09:26Hodappbut Linux did get in my way. On the Procyon I could time down into 20-30 ns with no trouble; on the RPi trying to delay reliably resulted in a minimum of about 130 usec
09:27casionthat is terrible
09:27Hodappluckily it was just SPI that I needed (had to bit-bang it, spidev didn't do what I needed because my device wasn't speaking proper SPI but something SPI-like) so I didn't need reliable clocking
09:27Hodappjust had to be able to drive my data line and my clock line in sequence
09:28casioncouldn't you write your own interrupt delay on the pi?
09:28casionor is that somehow not possible
09:28HodappI was trying to do this mainly in userspace
09:29uvtcMade some updates to the colorized irc logs at http://www.unexpected-vortices.com/clojure/irc-logs/index.html . Now repeated messages by the same user don't show the nick over and over. Also other style improvements. Note though, it only gets updated when I need to read logs. :)
09:29casionyou should easily be able to get 2-3ns delay with that chip
09:29casion130usec is just… D:
09:30casionyeah, 3ns, 2 clocks minimum
09:30chouseruvtc: nice. You're aware of the logs I maintain?
09:31uvtcchouser: At http://clojure-log.n01se.net/ ? Yes.
09:31chouserok, just checking. Yours look good.
09:31ro_st(assoc chouser :irc-logs (css uvtc))
09:31uvtcchouser: Actually, looking at those made me realize I was repeating the same username over and over for messages by the same nick.
09:32ro_stlooks great! very readable
09:32uvtcCool, thanks, ro_st.
09:33ro_stno disrespect to chouser, of course :-)
09:34uvtcchouser's are no doubt more up to date. Mine currently aren't being updated automatically --- only when I go to read irc logs. :)
09:35ro_stthen he does have a distinct advantage, yes
09:36babilenuvtc: You should at least indicate which timezone you use or use a standard one such as UTC (which would make the most sense IMHO)
09:37uvtcbabilen: I'm grabbing the logs from http://www.raynes.me/logs/irc.freenode.net/clojure/ . He seems to be 2 hours ahead of me...
09:38uvtcWait, no, behind.
09:38babilenuvtc: (That is exactly what I mean -- There are also people from other places than (location Raynes) in this channel, so :)
09:38babilen)
09:39uvtcOk, lessee, what timezone is that...
09:40Hodappcasion: you could readily get delays of that sort if you don't have normal Linux in the way
09:40babilenuvtc: I still think that the best way to deal with this would be to normalise timestamps to UTC, but meh ...
09:40casionexactly ;)
09:40Hodappcasion: some folks recommend Linux with realtime patches, but meh
09:43uvtcbabilen: oh, yuck. Me no like daylight savings time...
09:46babilenuvtc: UTC is always UTC
09:56fckwHi there.
09:57fckwI am currently learning Clojure and got a simple question.
09:57casionand then...
09:57chouserfckw: go for it
09:59fckwI have a very simple, single-threaded program including a variable "book" which is supposed to hold a seq of books.
09:59fckw(def books ())
09:59fckwI have a function "create-book" taking title, author etc. and returns a new book (basically a struct-map).
10:00fckwThen I simply want to store the new book in books. I used the cons function.
10:00fckwBut after having it called, books is still empty.
10:00cshellwhat are you cons'ing it to?
10:00chousercons returns a new list
10:01fckwOh, dear. Maybe that's the problem.
10:01chouserif you want to store that new list back in books, you have to explicitly ask for that
10:01clgvfckw: you have to use an atom for books if you really want to store them in that global variable
10:01casioncons returns a new seq, it doesn't mutate it
10:01madsyfckw: Remember, data in Clojure is immutable. Either return the new copy, or use an atom or similar.
10:01fckwSo, if I don't want to use an atom or a ref, how would I do it?
10:01chouserfckw: yes, an atom or altering the var will work, but you are right to explore another path.
10:02fckwWhat exactly do you mean by "altering the var"?
10:02chouserit is easy when learning clojure to fall back on mutable refs instead of doing the hard work of thinking how to do things immutably
10:02madsyfckw: You need to use a ref or atom *somewhere* if you want to alter states. Or else all you have is "let", which is constant once set.
10:03chouserfckw: I mean using the alter-var-root function. But if you want to *learn*, don't do that (at least not yet)
10:03madsyfckw: The tricky part is to figure out what the minimum amount of mutability you need is.
10:03fckwAt the moment it's all single threaded.
10:03madsyfckw: (almost) Always make functions pure if you can.
10:03fckwSo really no need for atoms and refs.
10:03chouserfckw: instead of having the goal of changing "book", think about what you want to do with that new list you created with cons, and just do that next step.
10:03casionfckw: that's not why they're suggesting it
10:04fckwWell, what I want to do in the future is writing the new books to a database.
10:04fckwBut until this is set up, I'd like to keep them in some sort of global var.
10:05fckwWhere I also can delete them again.
10:05chouserhm. mutable state.
10:05casionare there steps in between adding the books that disallow you from holding on to the books seq?
10:05cshellfckw: I think if you follow chouser's advice and try to work with it in an immutable way, you'll learn much mroe
10:06cshellfckw: rather than do it the java way
10:06fckw;) @cshell: That's what I'm trying to figure out.
10:06fckwI'm just a little confused at the moment.
10:06casionfckw: you could post your code
10:06fckwOk, wait a sec.
10:06fckw> (def books ())
10:06madsyfckw: Remember, you can use "let" as much as you want
10:07fckw(defstruct book
10:07chouserfckw: embrace that feeling of confusion. The transition from imperative to functional programming causes confusion for a while, so if you're feeling that, you're on the right path. :-)
10:07fckw> (defn create-book
10:07fckw> (defn save-book [coll book]
10:07cshellfckw: try pastebin or refheap :)
10:07casionuse refheap :)
10:08ejacksoni'm attempting to change the function called for the #inst reader macro
10:08fckw@chouser: I've done some Haskell years ago.
10:08ejacksonbut I'm hitting brick walls to left and right
10:08chouserfckw: oh, well then you'll be fine! Clojure's much easier.
10:08fckwI love Clojure just right now, it's so much cooler than Java and Haskell.
10:08fckwBut I still am confused right now.
10:09fogusejackson: Did you trying to rebind the *data-readers* map with binding?
10:09ejacksonI've tried dynamically rebinding *data-readers*, data_readers.clj etc. I can get the reader working in the repl, but when I make a call to sql, what is passed back up to me seems to use the default
10:09fogus:-)
10:10ejacksonhehe, yeah, and in the repl its fine
10:10ejacksona la: (binding [*data-readers* {'inst #'clj-time.coerce/to-date-time}] (read-string "#inst \"2012-01-01\""))
10:11ejacksonbut if I wrap the binding around a function that goes off and gets data from the db, I get back #inst " ..... "
10:11BahmanHi all!
10:11fogusejackson: what is the type that you're returning?
10:12fckw@madsy: let is only valid during method call, no?
10:12fckwBut I would like to change "books" (like a closure).
10:13ejacksonfogus: what I'm getting back is map, one of the keys of which reports a type of java.sql.Timestamp and is printed like #inst "2012-01-02T13:54:08.000000000-00:00"
10:13BahmanI have several modules which deal with database queries and such. I want to seamlessly and without changing the existing code, add exception handling and logging to the functions. Is it possible?
10:13BahmanPerhaps redefining defn?
10:13ejacksonso I think whatever came back from SQL just went through the default reader
10:14fogusejackson: Clojure provides a default print-method for j.sql.TimeStamp that prints #inst "..."
10:14fckwchouser: If cons creates a new list, then I obviously can reassign it to the existing books variable.
10:14fckwAnd overwrite it.
10:14fogusejackson: https://github.com/clojure/clojure/blob/master/src/clj/clojure/instant.clj#L227
10:15clgvfckw: that's "redefining" then ;)
10:15chouserfckw: you can, but that's an imperative style.
10:15fckwchouser: So what'd be better instead?
10:16chouserfckw: pass that new list to a function that does whatever needs to be done next.
10:16fckwchouser: I understand. But how do I then write for instance a test case which requires a state?
10:16fogusejackson: You could also bind the inst reader to clojure.instant/read-instant-timestamp
10:16ejacksonfogus: Yes. But what is it a Timestamp ? I'm expecting it to be a joda Datetime.
10:17ejacksonsorry, "why is it a Timestamp"
10:17fckwchouser: Do I really HAVE to fall back on refs and atoms, although the test case would be single threaded?
10:17chouserfckw: why would a test case require state?
10:17chouserfckw: but in short, yes.
10:18chouserfckw: Clojure doesn't provide much by way of thread-unsafe mutation
10:18ejacksonfogus: i thought (binding [*data-readers* {'inst #'clj-time.coerce/to-date-time}] ....) would do that for me
10:18fogusejackson: The default Clojure inst reader would return a j.u.Date, so maybe something else is happening
10:18ejacksonfogus: aaaaah.
10:18chouserfckw: but using an atom isn't hard, you're just finding this channel reluctant to give you answers in that direction, thinking we're doing this for your own good. :-)
10:19ejacksonfogus: nice catch, thank you. The function goes through CQL, so perhaps its playing silly games inside there.
10:19fogusCould be
10:19ejacksonthanks for that.
10:19fogusnp. Let me know what you find
10:20fckwchouser: I just think there is some important insight that I haven't got yet.
10:20fckwchouser: So either passing the var books along the function arguments, or make it a ref/atom then?
10:21chouseryes, almost: either pass the *value* books along as a function argument, or make it a ref/atom.
10:21fckwchouser: It cannot be done in a "closure" style, like changing a global somewhere in my functions (as for instance in JavaScript)?
10:22casionfogus, chouser: since you're both here, tjoc has been a huge help to me more so than any other source. part 3 has been a massive breakthrough for me. Thanks for writing it :)
10:22chouserfckw: yes, you can use a closure, but the things you close over are still immutable so no "changing"
10:23chouserfckw: keep asking yourself why you want to change a thing, and try to do something else instead.
10:23fckwchouser: Thanks. I'll try some stuff. Maybe come back to it.
10:23chouserfckw: if your project really is centered around a classic database, this kind of thinking will probably more difficult.
10:25chouserfckw: if you're using a var to simulate a mutable database until such time as you put a real database there, that may be reasonable. In which case you just need (def book (atom ())) (swap! book cons :new-book)
10:25fckwchouser: That's exactly my purpose here. All other vars are local only inside functions.
10:26fckwchouser: I'll try it with ref/atom then.
10:27chouserfckw: but if you're trying to learn the Clojure way of doing things, you might find the problems on 4clojure.com to be more helpful. A CRUD db app is almost inherently imperative.
10:27chousercasion: thanks, that's very kind.
10:28fckwchouser: In the end I want to write a Web-App. I want to use Clojure less because of the FP capabilities, but more because of the DSLs.
10:28fckwchouser: And I am aware that using a DB inherently means having state and thus losing the full strength of FP.
10:29chouserfckw: come for the macros, stay for the immutability. You wouldn't be the first. :-)
10:29fckwchouser: But also using map and reduce are great things I really miss in Java.
10:30fckwchouser: I also looked into Scala a bit, but was not really satisfied. It just did not feel as clean as Clojure.
10:30foguscasion: Thanks!
10:30chouserfckw: consider datomic to extend the FP further into the database.
10:31ejacksonfogus: Its confirmed - I'm a pinhead. The value never goes through the reader as a string, so reader literals just don't apply. Of course, if I were to spin the map through some a (comp read-string pr-srt) I could force the issue in a silly way :D
10:31fckwchouser: Thanks for the hint. I'll have a look into datomic. My original goal is to follow this approach: http://www.hackers-with-attitude.com/search/label/programming
10:32fckwchouser: See the presentations on that page. They use Google Closure, FP-style Javascript on the client and Clojure DSLs on the Server. All data handled is JSON. No XML or the like.
10:33fckwchouser: And as a DB they use Google Key-Value-Stores.
10:33fckwchouser: Nice design, I think.
10:36chouserinteresting.
10:39fckwOk, I'll be gone for some time. Maybe be back later. Thanks, guys.
10:44rabblerSo, I've tried to figure it out, but I just can't seem to find any docs on how to connect a Lein REPL to a nRepl server. I have the server up and waiting, but what do I need to do something like "lein nrepl localhost:8888". Are there any URLs you can point me to? Is it possible to do this?
10:46andrewmcveighrabbler: lein repl :connect hostname:8888
10:47rabblerI've tried that and I just realized that I have 1.7 of lien.
10:47rabblerlein.
10:47rabblerhah!
10:48andrewmcveighrabbler: Ah, I can't say I've tried it on < lein 2.
10:49rabblerI think it only works on 2, as per the nrepl statement. hah.
11:14FrozenlockWhat would be the best 'functional' way to simulate a system? Is there some example available?
11:17bsbutlerFrozenlock: I assume by system you mean a physical system?
11:17FrozenlockYeah sorry for my lack of precision. Let's say I'm trying to represent a simple spring (F= -kx)
11:19FrozenlockOr a ball falling in a vacuum. Surely there's some example of that?
11:20bsbutlerFrozenlock: https://github.com/giorgidze/Hydra perhaps?
11:20bsbutlerI would think some mixture of Dataflow and Constraint/Logic programming but I'm far from my expertise re: simulation
11:21FrozenlockIt's not in clojure :-/
11:22FrozenlockBut I'll take a look anyway, thanks.
11:23pandeiroi would like to build a webapp that is a collection of a few small independent http services; my concern is having to use a JVM instance for each of these. is there any way around this?
11:24clgvpandeiro: huh, why would you? if you implement these services as libs you should be able to set them up in a single jvm
11:25pandeiroclgv: i guess i am not seeing how to organize the project and deploy it very clearly
11:26Hodappclgv: indeed, is this not the basis of servlets and the like?
11:26pandeiroi guess i need to finally learn what servlets are
11:26pandeiroso far i have been using jetty with everything i do
11:27pandeiroand it is one webapp : one jetty instance
11:27pandeirobut the current thing i am working on has several parts that i thought could be broken into their own services, rather than one monolithic webapp
11:27clgvpandeiro: organization depends if you want to explicitly wire those services in the main programm or if you want to have some plugin like behavior with implicit automatic setup
11:28joegallo_long story short: a servlet is a function that takes an http request and http response and uses data in the one to bang on the other. but, of course, since it's java there can't just be a function, so it's an interface and an abstract super class and all that jazz.
11:29pandeirojoegallo_: i like jazz but not that kind of jazz
11:29Hodappjoegallo_: It can't be a single function; it has several points of entry.
11:29clgvpandeiro: I do not think that you have to learn servlets for that
11:29joegallo_sure sure, there's an init and a destroy and all that, but in the end it boils down to doService.
11:29pandeirowhat i really want is for each component of the app to be its own mini compojure app
11:29joegallo_iirc
11:30pandeiroi have even thought about going with node instead for these components b/c i feel like the node processes would be very cheap compared to jvm+jetty instances
11:30clgvpandeiro: well then you probably should go for a plugin like approach. this way you get reusable "main program" that loads the plugins and sets up the routes
11:30Hodapppandeiro: you should only need one JVM though
11:30weavejesterpandeiro: What do you mean? A normal Compojure app is effectively a collection of smaller apps...
11:31pandeiroweavejester: Hodapp: clgv: right i think i am just confusing myself here
11:31pandeiroi can manage each 'service' as a diff project
11:31pandeiroand then have one app project using them as libs
11:31clgvyep
11:32weavejesterYes, or put them in the same project under different namespaces, depending on how different they are.
11:32pandeirosure ok
11:32pandeirobut then the tradeoff is saving resources but creating a single point of failure
11:32pandeiroi meant to phrase that as a question but failed
11:32clgvany link to a description how to do ssl communication between two processes painlessly in java or clojure (even better)???
11:32lazybotclgv: Oh, absolutely.
11:33weavejesterWell… how you divide an application up depends on the application.
11:33Hodappclgv: In Java it should Just Work(tm)
11:33Hodappif your certs check out okay
11:33weavejesterBut so long as each part is separated, it's easy to turn a single app into several.
11:33clgvHodapp: how? what classes to use?
11:33pandeiroweavejester: right. it is hard when you lack the experience you would need to make that decision well. :)
11:34pandeiroweavejester: meaning break it out into multiple jvm instances if need be?
11:34weavejesterpandeiro: How else would you remove a single point of failure?
11:35pandeiroweavejester: sure, i get it
11:35weavejesterpandeiro: The more you divide up your application the more robust it becomes. Start with namespaces, then projects, then processes, then machines, then regions.
11:36Hodappweavejester: That's not automatically true, and frequently it's blatantly false.
11:36pandeiroweavejester: great, thanks. by namespaces, you been top-level?
11:36weavejestere.g. a really robust app would be distributed across several processes on several machines in several different data centers (i.e. regions to use the AWS terminology)
11:37pandeiros/been/mean
11:37weavejesterHodapp: Obviously you can have a distributed app that is still fragile
11:37weavejesterHodapp: But you can't have a robust app that isn't distributed.
11:38Hodappweavejester: This doesn't mean that dividing it up automatically makes it more robust.
11:38pandeirootoh, can a smallish linode instance handle several jvm instances?
11:38Hodapppandeiro: I'd say yes.
11:39weavejesterHodapp: No, but it's something you need to do if you want a robust process. Depending on how "robust" you need it to be.
11:39weavejesterHodapp: My guess is that most apps could make do with a couple of servers behind a load balancer.
11:39weavejesterHodapp: Maybe less.
11:40clgvHodapp: so where to start for learning how ssl communication in java is done?
11:40weavejesterpandeiro: By namespaces, I just mean that the different parts of the app should be loosely linked. The most connections between them, the harder it will be to separate them out later on.
11:41Hodappweavejester: Loose coupling also can enforce overabstraction and necessitate communications channels, which is not automatically a good thing.
11:41weavejesterHodapp: In what way?
11:42Hodappweavejester: Every layer of abstraction is another point of failure. Every layer is another possible hindrance to understanding of the whole.
11:43jro_(reduce or [nil "a"]) Can't take value of a macro: #'clojure.core/or: are there other ways to solve this than (reduce #(or %1 %2) ...)
11:43Hodappweavejester: N.B. Alan Perlis's epigram #20: "Wherever there is modularity there is the potential for misunderstanding: Hiding information implies a need to check communication."
11:44jkkramerjro_: (some identity [nil "a"])
11:45weavejesterHodapp: I'm not really talking about layers of abstraction here, any more than functions could be considered layers.
11:45cshell_Is there something similar to extend-protocol for extending a Java Interface?
11:45weavejesterHodapp: It's more a horizontal separation; each web service stands alone as a useful tool.
11:46jkkramerweavejester: hey, I'm having trouble getting codox to include defmultis. do you know off-hand whether it's known to (not?) work with them?
11:46ejacksoncshell: i think it will work on interfaces actually
11:46jkkramerweavejester: they definitely have :doc metadata, and show up in ns-publics called from the repl
11:46cshell_ejackson: that's what I was thinking but I'm getting an error that it's not a protocol
11:46weavejesterjkkramer: I can't recall offhand. I know it needs some work done on protocols and methods. I haven't had the time to sort it out.
11:46ejacksoncshell_ must be wrong then :)
11:47cshell_ejackson: thanks though :)
11:47jkkramerweavejester: k thanks. I'll send a pull request if I figure it out
11:48jro_jkkramer, thanks. But, can I pass a macro as a function somehow, without writing an anonymous function?
11:48ejacksoncshell_: if i read http://clojure.org/protocols right then you can use extend to extend an interface to a protocol
11:48jkkramerjro_: nope
11:49ejacksoncshell: right at the bottom
11:49jkkramerjro_: macros operate at compile time. trying to pass them around at runtime doesn't make sense
11:50Hodappweavejester: Fair enough. I just take issues with principles that result in horrible horrible horrible lasagna code when applied dogmatically in OOP, but this does look a bit different.
11:50cshell_ejackson: I believe that means that I can extend a protocol to a java interface
11:51weavejesterHodapp: Definitely :) - web services should be split up (if possible) in a way that minimizes connections, not create more of them
11:51cshell_ejackson: I'm trying to pass a Java interface in to the first argument to extend-protocol
11:51weavejesterHodapp: Ideally you should be able to split out a web service without creating any more connections. Just change a local call for a remote one.
11:52weavejesterHodapp: More difficult than it sounds, of course
11:52Hodappweavejester: Ideally, but at least two research papers have demonstrated why this only goes so far.
11:53ejacksoncshell: i'm not sure how that would work, but I'm java-ignorant :)
11:53weavejesterHodapp: How so?
11:53Hodappweavejester: One, I think from Sun Microsystems, talked about how the notion resurfaces every decade or so that if you just define some kind of interface, you can just do RPC and it all will magically work remotely just as well as locally.
11:54weavejesterHodapp: Right, but I think in Clojure we have an advantage over other languages in that regard. Most languages maintain the fiction that accessing data is instantaneous, but Clojure has the idea of derefing
11:55cshell_ejackson: I'm not sure either :)
11:55weavejesterHodapp: When you deref something in Clojure, the implication is that it's only correct for a particular instance in time.
11:55weavejesterHodapp: Same principle applies to remote calls - a HTTP GET is effectively a deref with higher latency.
12:02Hodappweavejester: Two papers to check out that discuss this:
12:02Hodapphttp://hodapple.com/files/papers/Critique%20of%20RPC%20Paradigm%20-%20AST.pdf from Andy Tanenbaum of Linux-sucks fame
12:02Hodapphttp://hodapple.com/files/papers/Note%20on%20Distributed%20Computing%20-%20Waldo_%20Wyant_%20Wollrath.pdf from Sun
12:03weavejesterHodapp: Those look like they're criticizing the RPC model (at least the first one does by the first few paragraphs), but I'm talking about about something a little different
12:06nkozathere also an RPC critique from Steve Vinoski, of CORBA fame
12:06Hodappnkoza: haven't read that one
12:07HodappThese papers, though, apply to a great many cases where it's not called RPC or seen as such
12:07nkozaHodapp: for example, http://www.infoq.com/presentations/vinoski-rpc-convenient-but-flawed
12:08weavejesterHodapp: It seems to me as if there's a fundemental difference between the RPC-based approach and a resource-based approach.
12:09weavejesterRPC is about remotely calling a function
12:09weavejesterResources are about getting the past value of a remote identity.
12:11Hodappweavejester: Why I sent these was what you said with "Just change a local call for a remote one." and I spoke of papers that said this approach only goes so far.
12:11weavejesterHodapp: I mispoke. Or didn't explain myself very well.
12:12Hodappnkoza: Have you watched it? Should I?
12:12jro_Why primitive operations like or and and are macros instead of functions?
12:13nkozaHodapp: I have read some documents from Steve Vinoski but that was the first link I found, google for "steve vinoski rpc"
12:13weavejesterHodapp: I mean more that you can replace a local identity with a remote identity.
12:13Hodappjro_: For one thing, because otherwise, short-circuit evaluation isn't possible.
12:13Hodappjro_: A macro does not evaluate its arguments
12:13weavejesterHodapp: I didn't mean call a remote function, but admit I kinda made it sound that way :)
12:15jro_I see. And in a form (defn f [& rest] ...) rest is not lazy?
12:17weavejesterjro_: It could be lazy, I believe.
12:19jkkramer,(apply (fn [& args] (take 3 args)) (repeat :foo))
12:19clojurebot(:foo :foo :foo)
12:31jro_,(and false (repeat true))
12:31clojurebotfalse
12:31cheezeylol
12:32jro_I got it :-)
12:41octagonhi, is there a function f in clj such that (f [g h ...] [x y ...]) => [(g x) (h y) ...]?
12:42aniero,(map + [1 2 3] [4 5 6])
12:42clojurebot(5 7 9)
12:42anierooh, i misread. hm.
12:43cgag((juxt g h ...) [x y ...]) is [(g x) (h y) ...] isn't it?
12:43Bronsa4no
12:43cshell_Isn't it just x?
12:43cshell_no y?
12:43octagon((juxt f g ...) x) => [(g x) (h x) ..]
12:44cgagaah sorry
12:44cshell_yeah
12:44Bronsait's [(g [x y ..]) (h [x y ..]) ..)
12:44Bronsa]
12:44octagonoh right
12:44anierohmm, what about (map apply [x y..] [g h...])
12:44octagonhttps://gist.github.com/3743782 is what i have so far
12:45aniero,(map apply [+ -] [1 1] [1 1])
12:45clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
12:46octagonit works, i was just thinking that there must be something in the API that already does that
12:46anieroaw.
12:46cvkemsound like (vect (map #(%1 %2)) [ g h ..] [x y z]))
12:46octagoncvkem: i want it to be variadic
12:46technomancyyou would want to map funcall, but clojure doesn't have funcall
12:47octagontechnomancy: (partial apply apply) is suspect :)
12:47technomancy,(let [funcall (fn [f & args] (apply f args))] (map funcall [+ -] [1 1] [1 1]))
12:47clojurebot(2 0)
12:47technomancy
12:47technomancyheh
12:47octagontechnomancy: that's interesting actually
12:48octagontechnomancy: that's better than my spec, seems like you have (defn zip-apply [fns & argvecs] ...)
12:49octagonwhere (zip-apply [f g ...] [r s ...] [t u ...] ...) => [(f r t ...) (g s u ...) ...]
12:50technomancyfuncall is weird. I always feel like I shouldn't want it, but sometimes I do.
12:51octagoni think it's totally legit
12:52cvkemdoes anyone now whether (eval ...) just interprets a tokenized list, or does it actually compile? (I guess it doesn't)
12:52technomancyyeah I always just associate it with gross lisp-2-isms
12:52technomancyguilt by association I guess
12:52technomancycvkem: clojure doesn't have an interpreter
12:53cvkembut taking the same string and passing is to (eval ...) or to (load-string ...) sometimes results in a diffent outcome. .... which puzzles me.
12:54technomancycvkem: load-string is completely different
12:54technomancyload-string invokes the reader
12:55technomancyeval just compiles a given form
12:55cvkemtechnomancy: that is correct. In order to use (eval .. ) you have to first tokenize the sting with a push-back-reader.
12:56technomancycvkem: well, there's different ways to do it. the point is eval takes a form.
12:56cvkemIf they both should give the same result then I guess I skrewed up my tokenizer. ... that explains the difference
12:56cvkemCorrect. I pass in a single form.
12:56technomancyload-string is probably just (comp eval read-string)
12:57technomancywell except read-string assumes a single form
12:57cvkemHowever, if the load-string solution is the better (and certainly more compact solution) I'll take tat one.
12:57cvkemThat is correct. I had to split in separate forms and eval each of them individually. ... I'll throw out my old code.
12:58TimMccvkem: What are you using it for?
12:58cvkemTimMc: I'm developing a pentaho bi-server plugin that allows me to program my data-processing directly in clojure.
12:58cvkem... and mix the code with sql-code for data access.
13:02octagontechnomancy: thanks for your help, check it out: https://gist.github.com/3743782
13:02technomancyfancy =)
13:42lotiagreetings all. when declaring a future, can I set the timeout when declaring the future? or does it have to be done when derefing the future?
13:44cemericklotia: futures and other dereferenceables don't have timeouts; they all have their own semantics as to what and when a blocking deref call will return
13:44cemerickThe timeout you can provide to deref is local to that fn call, and doesn't impact the reference that you're deref-ing.
13:58duck11232lotia: if you're looking for something like timeouts for futures, lamina has wait-for-result that'll do pretty much what you want
14:10weavejesterI've written a blog post on routing in Compojure
14:10weavejesterhttp://www.booleanknot.com/blog/2012/09/18/routing-in-compojure.html
14:10weavejesterDoes anyone think it's worth publisizing?
14:13duck11232weavejester: nice little guide. Seems like that should be in the compojure wiki
14:14weavejesterduck11232: I'll link it from the wiki. How's that? :)
14:14jcromartiethe ONE mistake I make more than anything else: def instead of defn
14:14duck11232that works. I can see a lot of ring newbies getting a lot of help from that
14:15jcromartierecursive conversion of XML DOM node to Clojure map? nailed it… except for the defn
14:15duck11232jcromartie: it's always something like that, isn't it. Akin to the missing semicolon
14:16weavejesterjcromartie: You could change your highlighting to have defn and def look different? :)
14:43abalonei wrote a cljs lib. and i have some js that uses it. is there a way i can get an optimized version of the cljs lib that has the fns i want to call? that is, how do i tell the optimizing step about my regular js file?
14:43TimMcexterns, I think...
14:43TimMcErr, wait -- that's the opposite.
14:43ohpauleezabalone: You want to ^:export your cljs functions if you want to use them unmunged in JS code.
14:44abaloneah
14:44ohpauleezif you want to use the JS functions in your CLJS code, you need to create and externs file for them
14:44amalloywell, the closure guys would tell you to include your js file in the optimizing-compiler step, probably. then you don't need externs
14:45ohpauleezabalone: An example: https://github.com/shoreleave/demo-shoreleave-solr/blob/master/src/findit/client/main.cljs#L17
14:45abaloneamalloy: how do i do that? and do you mean externs? or export?
14:45ohpauleezamalloy: He wants to go in the other direction
14:47abalonethe js part is a codemirror keymap for my bastardization of paredit and the cljs part is where i do the scanning for what i want
14:47amalloyohpauleez: it should be possible to run the closure compiler on both the generated js and his by-hand js, right? i don't think it's necessarily wrong to go in "this direction"
14:48amalloyyou don't need exports if you can get closure to munge both sides at the same time
14:49ohpauleezIn the past, I haven't had positive experiences with the closure compiler and non-closurized JS code
14:50ohpauleezbut yes, if you pulled both into the same project, you could avoid the need to export. That said, export is a great way to get third-party interop in the direction we're talking about
14:51abalonesilly question: would that mean i compile all of codemirror with amalloy's suggestion? that can't be what he means
14:51abaloneI think i'll export
14:51amalloyright, export is probably easier; i don't have a lot of experience and didn't think it through. but it should be possible without afaik
14:51octagontechnomancy: final version: (def zip-apply (partial partial map #(apply %1 %&)))
14:55patchworkHey #clojure, I have a lengthy question that I chose to type into stackoverflow rather than type it all here: http://stackoverflow.com/questions/12483083/clojure-ring-how-can-i-integrate-my-clojure-app-with-a-java-build-process-that
14:55cvkemHow do I check a variable exists but does not have a root binding?
14:55cvkem The sniplet (= #"Unbound: #'user/X" (str X)) works but is far from elegant.
14:55abalonecvkem: is it bound?
14:55patchworkBasically I am trying to integrate a ring app with a maven build process that is out of my control
14:55patchworkand wondering where to start with that
14:55abalonecvkem: i mean ,(doc bound?)
14:56patchworkHas anyone built ring apps directly with maven that would have insight into this?
14:56abalone~(doc bound?)
14:56clojurebotgitdoc is http://github.com/Lau-of-DK/gitdoc/tree/master
14:56weavejesterpatchwork: Lein doesn't use Maven under the hood except for managing dependencies (and then only a few functions AFAIK)
14:56cvkemabalone: that needs to be it.
14:57hiredman(doc bound?)
14:57clojurebot"([& vars]); Returns true if all of the vars provided as arguments have any bound value, root or thread-local. Implies that deref'ing the provided vars will succeed. Returns true if no vars are provided."
14:58patchworkweavejester: Aha, so is this a hopeless endeavor then?
14:58weavejesterpatchwork: My guess is that your best approach would be to add Leiningen as a development or build dependency and call it directly.
14:58michaelr`hello
14:58weavejesterpatchwork: Presumably Maven has a way for running a Java class with a main method?
14:58patchworkweavejester: That would be great
14:58patchworkweavejester: I assume so, possibly as a plugin
14:59patchworkI don't know much about maven at the moment, taking a kind of crash-course approach at the moment
14:59Sgeoweavejester, may I ask why, in Hiccup, when determining id and class from a symbol's name, you require the id to come before classes?
15:00weavejesterpatchwork: Perhaps http://mojo.codehaus.org/exec-maven-plugin/usage.html
15:00technomancypatchwork: I think you can get a pom out of lein that will use clojure-maven-plugin but I don't know the details.
15:00technomancyhugod might know
15:00weavejesterSgeo: Because it was easier to write a regex given that constraint, and I never got around to correcting it
15:01SgeoAh
15:01patchworktechnomancy: That sounds perfect. If I could generate the right pom it could all just be taken care of.
15:01patchworkSo there is a maven plugin for clojure, thanks
15:11duck11232https://github.com/talios/clojure-maven-plugin
15:20jcromartieI added :dev-dependencies [[ring-serve "0.1.1"]]
15:20jcromartieand then ran: lein deps
15:20jcromartiebut it never downloads ring-serve
15:21weavejesterjcromartie: Are you using Lein 2 by any chance?
15:21jcromartieI'd imagine
15:21weavejesterjcromartie: Check with "lein version"
15:21jcromartieyes
15:21jcromartielein 2.0.0-preview10
15:23weavejesterIn Lein 2 :dev-dependencies was removed in favor of profiles and plugins
15:23weavejesterDependencies for your project you only want in dev mode now look like:
15:23weavejester:profiles {:dev {:dependencies [[ring-serve "0.1.1"]]}}
15:24weavejesterPlugins (i.e. anything that extends Leiningen itself) are under :plugins
15:24weavejestere.g.
15:24weavejester:plugins [[lein-ring "0.7.5"]]
15:24jcromartieor should I install an older version of Leiningen
15:25jcromartieI guess I'll stick with 2
15:27jcromartieI like profiles/plugins
15:30patchworkHmm… I tried using the lein :pom-addition directive, but my additions are not being output in the pom. Has that directive not been released yet?
15:31patchworkPossibly I can build a cutting edge version of lein
15:32ro_stohpauleez: any luck?
15:32ohpauleezro_st: Haven't started on it yet, but I'll get to it within an hour or so
15:32ro_stohpauleez: no pressure, btw. just curious :-)
15:33xeqipatchwork: I think that came out in -preview8 or -preview9
15:33ohpauleezno problem! Thanks for reporting the bug
15:33ro_stgot -plenty- to do before i need to be testing in those browsers
15:33ohpauleezno idea it even existed
15:33ro_stdon't use Safari? :-)
15:33ro_stor Opera
15:33jcromartieweavejester: tell me: what version string should I use for ring-jetty-adapter… I tried to go off of ring's own project.clj but 1.2.0 does not exist
15:33ro_sti only managed to get rid of goog-jar today :-|
15:33ro_stfinally.
15:34patchworkxeqi: Is there a standard way to install a preview release?
15:34ro_stonly preview releases are available for lein2
15:34jcromartie1.1.5 works
15:34ro_sthttps://github.com/technomancy/leiningen#installation
15:34jcromartieI guess 1.2.0 is internal?
15:39amalloy(do (do (do x) (do y) (do z))) ;; my macros like to hum while they work
15:42jcromartieso ring-serve is incompatible with the latest ring-jetty-adapter I guess
15:52no7hingthat awkward moment after you dismantled the engine looking for a problem and it actually was the steering wheel
15:53no7hinganybody else had stark performance problems when using compojure contexts (and matching for a number) ?
15:53no7hingurls look like /(numerical user id)/action
15:54no7hingwarn-on-reflection is on but only for my own code -.-
15:55ro_sttried replacing the id with a static default and comparing?
15:55ro_st./34/:action vs /:id/action
15:55ro_sterk
15:55ro_st./34/:action vs /:id/:action
15:56no7hingnot yet
15:56no7hingi had i benchmarking handler at the end of the handler list
15:56no7hingapparently it took quite a while to arrive there
15:58weavejesterjcromartie: The latest is 1.1.5. You can find out by looking at the README or in Clojars.
15:58no7hinglike so https://www.refheap.com/paste/5148
15:59no7hingi was cleaning up code, moved the benchmarking handler from "/" to it's own route and to the bottom of the handlers
15:59weavejesterno7hing: There shouldn't be any performance problems… The strings are pre-compiled into regexes
15:59ro_stno7hing: using aleph? for websockets?
15:59weavejesterno7hing: So it should be pretty fast
15:59no7hing@ro_st: no web sockets; just SSE
16:00no7hing@weavejester: as soon as i comment out the context block it goes from 10k rps to 22 k rps
16:00ro_stsse?
16:00clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
16:01no7hingserver sent events, basically chunked transfer
16:01ro_stoh, ok
16:01no7hingto have a push-(only) channel to the client
16:01no7hingthat works through firewalls
16:01weavejesterno7hing: Well, the context is altering the request map, while the other routes just match against it.
16:01ro_sti'm dead keen to do websocket stuff with clj
16:01no7hingoh
16:01weavejesterno7hing: Compare a couple of map gets and a regex compare against the additional overhead of updating a request map...
16:01no7hingmaybe it's aleph who doesn't like that
16:02weavejesterno7hing: I can see it taking twice as long
16:02no7hingcan/can't ?
16:02weavejesterCan
16:02ro_stshort answer: don't use contexts
16:02weavejesterUpdating the request map probably takes as long as matching the URI and request method
16:02weavejesterro_st: Um, well, not really...
16:02ro_stun-DRY your route definitions
16:02no7hingi arrived at the same conclusion just right now :D
16:03no7hingdamn
16:03no7hing:)
16:03weavejesterYou can always unroll to improve performance
16:03weavejesterBut it's a tradeoff
16:03ro_stsorry, i should have contextualised (hah) that, weavejester: if you want the performance gain
16:03weavejesterro_st: Okay, then I agree with you :)
16:04jkkramerweavejester: looks like defmultis not showing up in codox is a clojure bug. Calling defmulti more than once obliterates the metadata on the var, which seems to happen by the time codox gets ahold of it
16:04no7hingdefinitely want that performance
16:04weavejestercontext adds a :context and :path-info key to the request, and I'd guess that takes as much time as a map read and regex over a short string
16:04no7hinghaving a friendly competition with workmates & their jruby server
16:04weavejesterIn theory a static routing table would be even faster.
16:04casionisn't jruby fairly slow?
16:05weavejesterjruby's meant to be faster than c ruby in some cases
16:05no7hingyes, that's why i left my weapon of choice in the closet: erlang
16:05no7hingi can feel it's smugness staring at my back :D
16:06casionlast I looked at benchmarks, jruby was on average an 10-15x slower than clojure
16:06weavejesterPersonally performance of web servers doesn't worry me too much :)
16:06no7hingit *kind* of matters for us
16:06no7hingbut not the overall benchmark
16:07ro_stthe bottleneck is usually in the app <-> db roundtrip
16:07no7hingthat's actually operations & development speed
16:07no7hingha, we're stateful
16:07no7hinghence erlang
16:07casioncbg still has clojure being way faster than jruby… which isn't saying much, but it's something
16:07weavejesterYou could probably speed things up further by removing any middleware you don't need.
16:07casionmedian 19x faster
16:07aperiodicno7hing: grammar pedantry: it's is a contraction of "it is"; the possessive form is "its"
16:08no7hingdammit
16:08no7hingi thought i wouldn't make those mistakes
16:08weavejesterThe compojure.handler/site function adds a lot of middleware you might not need.
16:08weavejesterSo manually adding the middleware you want could speed things up further.
16:08ro_staperiodic: if i want to say that this case has a fault, is it this case's fault or this cases fault?
16:08naegI'm trying to do conways game of life in core.logic - how could I "iterate" over all the given cells (to determine for each cell whether it's alive in the next generation)
16:08casioncase's
16:09aperiodicro_st: the former. it inverts the usual rule, which is why it's so easy to get wrong
16:09ro_stno wonder i feel uncomfortable all the time.
16:09no7hing@weavejester: only adding favicon bouncer, json params and error handling
16:09casionthough if you have more than 1 case, it's the cases' fault
16:09weavejesterno7hing: That's pretty minimal.
16:09naegoh, nevermind my question
16:10aperiodicweavejester: how would i get a site handler with *no* middleware?
16:10no7hingplus resources & not found, but that doesn't count
16:10weavejesteraperiodic: Just don't use compojure.handler/site
16:11no7hingi want a t-shirt with "Un-DRY your routes!" on it
16:11weavejesteraperiodic: (defn handler [req] {:status 200, :headers {}, :body "Foo"}) is the simplest handler
16:11weavejesterno7hing: Hearing that makes me wince :/
16:11no7hinghaha sry
16:11weavejesterIt's okay
16:12weavejesterI think that's made up my mind about Hiccup anyway
16:12aperiodicweavejester: so can i just use the routes i defined with defroutes as a handler?
16:12ro_stfor or against?
16:12ro_sthiccup.
16:12weavejesterFor Hiccup 2.0 I'm going to make return a clojure.xml DOM, which will be slower than strings, but more flexible.
16:12weavejesteraperiodic: Right. That's all they are after all.
16:12ro_stso for, then :-)
16:14ro_sthiccup is clj only, right? no cljs?
16:14weavejesteraperiodic: I put together a blog article on Compojure routing today, as it happens: http://www.booleanknot.com/blog/2012/09/18/routing-in-compojure.html
16:14weavejesterro_st: Yes, but there's an equivalent project with the same syntax called Crate I think
16:14emezeskero_st: There is a semi-decent port of hiccup to cljs called crate
16:14emezeskero_st: And a few others ports that are less than semi-decent
16:14ro_stoh, awesome
16:15ro_sti'm using enfocus / enlive but sometimes you don't want to go through the .html hopscotch
16:15ro_sthiccup is awesome for 'quick n easy'
16:15aperiodicweavejester: i saw that; it was very helpful to me, as someone who only started using compojure this past weekend
16:15weavejesteraperiodic: Awesome
16:16ro_stlooks like a great article on clojure, actually.
16:16weavejesteraperiodic: Really, compojure.handler/site should be called something like wrap-default-site-middleware
16:16ro_sthow to use it well
16:16weavejesterA lot of Compojure functions I might rename if I could start again.
16:16weavejesterLike routes might be cascade
16:16weavejesterAnd I'd probably get rid of defroutes...
16:16jcromartieweavejester: yeah, I never use defroutes
16:16aperiodicweavejester: yeah, i will cop to just copying that out of the example because i didn't know what it did but it was important-seeming
16:17ro_st+1 for less macros
16:17ro_sthate not being able to (apply) sometimes
16:17no7hingi'm using defroutes; something absurdly wrong with it?
16:17weavejesterA lot of the functions in Compojure were named four years ago, and since then I've gotten a little better :)
16:18weavejesterno7hing: Nope
16:18weavejesterno7hing: But (defroutes x y z) is just (def x (routes y z))
16:18amalloyi like defroutes, personally, and i generally don't like defx macros. but maybe that's just because i found out about it before i knew about routes
16:18weavejesterno7hing: In retrospect, the macro isn't really needed. It obscures the functionality a little for not much gain in conciseness.
16:19no7hingah ok
16:20emezeskeweavejester: It saves some indentation, which can be nice
16:20weavejesteremezeske: That's true :)
16:20weavejesterI might also have called the "routes" function "cascade" instead
16:20ro_stalso, defroutes hilights differently, which helps to draw attention to the fact that something particular is happening
16:21amalloyugh. if (def x (routes x y z)) is too indented, your routes are probably not very well abstracted/named
16:21weavejesterBecause "routes" is really a very general function
16:22emezeskeI just hate any extra indentation. I despise the idiomatic Clojure indentation rules.
16:22ro_st-irks amalloy- weavejester: it's the maybe monad!
16:23weavejester(defn routes [& rs] (fn [req] (some #(% req) rs))
16:23weavejester(defn cascade [& fns] (fn [& xs] (some #(apply % xs) fns)))
16:23amalloyro_st: no it isn't
16:23ro_stphew. i was worried i got that right by accident
16:24casionevery time someone says monad in this channel, I die a little inside
16:24SgeoA lot of things aren't the Maybe monad. Including the thing that clojure.algo.monads calls maybe-m, as in the Maybe monad.
16:24casionsgeo should show up soon now
16:24amalloycasion: for me it's just when Sgeo says it
16:24casionoh.. there he is
16:24casionlol
16:25Sgeoamalloy, :( sorry, what am I doing wrong?
16:25amalloySgeo: saying the same thing about monads over and over: you're complaining about them and not trying to fix them. if you don't like them, file a bug report (as i understand you have), and either fix them or don't use them
16:28abaloneoh. is there a way for cljs to return a complex value like [1 2] such that regular js can take it apart *if the cljs has been minified* ? my concern is that the js would not be able to say cljs.core.nth since that will be munged and that's cljs that i don't have control over (and can't export)
16:29duck11232abalone: could you return a standard js array?
16:29abalonei could if i knew how :)
16:29abalonedo you know how?
16:29amalloyabalone: dnolen has some lib that exports versions of the common cljs functions to js
16:30amalloyhttps://github.com/swannodette/mori
16:30abaloneamalloy et al: thanks! will look into it
16:30duck11232(array 1 2) returns a js array
16:30dnolenabalone: it's pretty simple and you can do this yourself w/ ^:export. pull requests to mori welcome too if you see something missing.
16:31carksgeo check this approach out : https://gist.github.com/3745638
16:32ro_stduck1123: 4 months of cljs and i only learn that now
16:32carkSgeo: lots of macro work to put on top of that
16:32duck11232I do a lot of js interop. My code is littered with js-obj and array calls
16:34abaloneduck11232: so array works out of the box without mori?
16:34Sgeocark, cool
16:35SgeoAlthough I didn't look at it that closely yet, I think I don't quite understand deftype as well as I should
16:35duck11232abalone: yep. It's nice because it emits a standard literal array, no excess calls
16:36SgeoAh, so return knows what to do because it's passed what it needs as an argument
16:36carkSgeo: that's where you need some macro magic akin to what's in algo.mona
16:36carkd
16:39SgeoHow do Functors and Applicatives fit into this model?
16:40tickingam I correct taht there is no def- ?
16:40carkthey could be additional protocols that you add to your deftypes
16:41dnolenticking: yes
16:41tickingdnolen, hm any Idea why not? When creating functions with partial this seems pretty usefull, or am I missing a idiomatic concept there?
16:41carkSgeo: don't make me do it, i just made this because it was tickling me. I really don't have the time =)
16:41SgeoIn principle though, all monads should be functors, although I guess the macros could take care of that
16:42SgeoAh, ok
16:42abaloneduck11232: if i want to check equality on something that returned (array 1 2) in cljs, (= (array 1 2) (myfn args)) doesn't seem to work. should it? if not what should i say instead?
16:42carkSgeo: feel free to take this code and do something with
16:42carkSgeo: or take a different approach entirely
16:43dnolenticking: ^:private is useful for documentation - it's really ns that controls visibility.
16:43antares_Welle 1.3.1 is released with a pretty nasty bug fixed: http://blog.clojurewerkz.org/blog/2012/09/19/welle-1-dot-3-1/
16:45tickingdnolen, ah k, but yeah thats pretty mutch what I used it for so far, signalling helper functions you're not supposed to call ^^
16:46weavejesterIn principle, do people think bad user data should be handled by an exception, or a return value of some kind?
16:47carkSgeo: you can do functors by defining a protocol for it with a fmap method (fmap [self f])
16:48carkSgeo: then add it to the Just and Nothing deftypes
16:48ro_starent' exceptions bad for performance?
16:48Sgeocark, sure, but I shouldn't need to add it to Just and Nothing manually
16:48weavejesterI'm more interested in correctness than performance.
16:48no7hingweavejester: inside the app we throw an exception, but the client get's a 200 back with an error in the body
16:48no7hingthe/our apps
16:48carkSgeo: yes you do, how do you think haskell does it ?
16:49weavejesterno7hing: That sounds kinda un-RESTful :)
16:49no7hingflash clients :p
16:49weavejesterAh :)
16:49no7hingbut i like the concept
16:49weavejesterI was thinking about how to abstract a http resource
16:49carkSgeo: there must be some place with an instance declaration : instance Function (Maybe a) where ..
16:49carkFunctor*
16:49Sgeocark, Haskell doesn't support what I want, but in theory it should be doable from just knowing the monad definition
16:50carkyou got it backwards
16:50weavejesterI don't hugely like the approach taken by Liberator.
16:50carkit's because Maybe is a functor that it can also be a monad, not the other way around
16:50Sgeofmap f a = do x <- a; return (f x)
16:51no7hingi made the mistake and googled for liberatpr
16:51no7hing
16:51no7hingliberator
16:51weavejesterno7hing: https://github.com/clojure-liberator/liberator
16:51no7hinginteresting first result
16:51no7hinghttp://www.liberator.com/
16:51no7hingnsfw
16:52Sgeocark, yes, all monads are functors, but for all monads, each monad can be described as a functor in the same way
16:52S11001001Sgeo: also liftM
16:53weavejesterI was thinking about the minimum set of functions required to define a RESTful resource…
16:53Cheironis it stable enough to use for production?
16:53CheironI mean https://github.com/clojure-liberator/liberator
16:53weavejesterderef / put! … maybe validate as well for checking the data
16:53Cheironis it stable enough to use for production?
16:54weavejesterCheiron: It seems to be fairly stable. It depends on how critical your production is I guess.
16:54carkSgeo: anyways who cares how you need to define stuff manually, that's not like you'll be creating 20 monads for every project
16:55Cheironwhat is its selling points over bishop?
16:58duck11232abalone: You'll have to use one of the methods for testing js array equality. http://stackoverflow.com/questions/3115982/how-to-check-javascript-array-equals
16:59duck11232js arrays are simple, hence not as cool
17:00weavejesterCheiron: Not sure :)
17:00Cheironfair enough :)
17:00abalonehttp://stackoverflow.com/questions/3115982/how-to-check-javas\
17:00abalonecript-array-equals
17:00abaloneoops
17:00abalonethanks!
17:01duck11232(defn arr= [a b] (not (or (< a b) (> a b))))
17:01abalonehm. ok
17:01Cheironany new web framework that I might missed? (I know about Noir, compojure, moustache, conjure)
17:01weavejesterCheiron: Only Noir and Conjure are really web frameworks
17:01abalonedidn't know arrays could be sorted/compared like that
17:02duck11232That seems rather dirty, but seems to work
17:02abalone(> work dirty)
17:02Cheironclojurebot: para que la vida
17:02clojurebotClojure ranked #21 on 8/14/2009
17:11duck11232abalone: if you read all the comments on that SO question, there are some issues with that solution.
17:12duck11232(defn arr=2 [a b] (= (seq a) (seq b)))
17:13abaloneduck11232: ok. thanks again!
17:13hiredman,(pl (↕map (replicate 3 (↕apply vector $ (↕map range $ 10 inc · inc · inc) call · ⌽* $ 10 · call · (⌽+ -2) map)) shuffle))
17:13clojurebot([20 50 40 80 70 ...] [50 10 30 100 70 ...] [70 80 10 20 40 ...])
17:14hiredmanI recalled it's been a while since I ran pl in here
17:14blrandelhiredman: are you enjoying your time on earth so far? (what was that? O.o)
17:15hiredmanpl is a macro I wrote years ago that does rewriting of expressions based mostly on unicode prefixes
17:16blrandelbased on APL?
17:17hiredman,(macroexpand '(pl λx x))
17:17clojurebot(do (fn [x] x))
17:17hiredmannot really based on anything
17:17blrandelneat
17:21hiredmanhttps://github.com/hiredman/odds-and-ends/blob/master/functional.clj
17:22jcromartieI guess the only way to talk XML and JSON in an HTTP API backed by an XML document is to have an intermediate format
17:22jcromartielike, my database is literally an XML document
17:22jcromartieand queried via XPath
17:22jcromartiebut I might as well parse things into records and leverage cheshire for JSON, and something more custom for XML
17:22jcromartiebut there's nothing as smooth as JAXB
17:23jcromartieI say "smooth", of course
17:25duck11231jcromartie: Are you, by any chance, using eXist for your db?
17:25jcromartieno, it's literally an XML file
17:26jcromartiea single XML file with a simple list of items
17:26duck11231ahh. I used to use eXist quite a bit, but I never tried using it from Clojure
17:28jcromartieI think the answer is to parse the XML into an intermediate format before sending it back as either JSON or XML (again?)
17:28jcromartieor I dunno
17:28jcromartieno
17:32patchworkHmm… can I use :pom-addition to nest some xml inside of the build section, or is it only for project level additions?
17:41blrandelis anyone aware of any good lightweight alternatives to Drools for decision/rule engines?
17:42blrandelwould imagine core.logic would be useful for implementing something along those lines
17:44gtrak`anyone ever use yguard to shrink a bunch of AOT stuff? is it a viable option?
17:49aibwhat's the idiomatic way for a game/processing loop? (when (not [complicated set of quit conditions]) [loop code]) or is (def runLoop true) (when runLoop ...) ok?
17:50aibor perhaps (defn run-loop? ...) ?
17:54aperiodicaib: i'd define a should-quit? predicate that takes the current game state, which is i think what you mean by your last option
17:56aibaperiodic: yep, thanks. and the game state would be in a global symbol? (something defined with def?) this is my first attempt at doing anything substantial in an "impure" functional language
17:57aiboh, nope since when can pass it the game state. sorry
17:57gfredericksblrandel: core.logic is pretty specific/focused; I'd be very hesitant about using it for something like business rules
17:58antares_ohpauleez: hey
17:58ohpauleezantares_: How's it going! I still have all the notes from our last conversation. I just got swamped with day job work
17:59antares_ohpauleez: I wanted to ask if there is any progress on this. There are more and more people who give up: https://twitter.com/ieure/status/248165536985403392
18:00antares_and I had to file issues what really should have been a clojure-dev post, but I cannot post there
18:00thorbjornDXis there a way to do type coersion in a let statement? i.e. (let [[a (int b) c] myvec] [a b c])
18:01aperiodicaib: all the game logic and everything should be pure; you should only need to bring in state (in an atom or some refs) when you're writing the frontend code that interacts with the user to run an instance of the game
18:02blrandelgfredericks: ok, will keep that in mind.. I'm just looking for an alternative to drools/jess really, to build a clinical inference engine
18:02ohpauleezantares_: Looking over all of this now. I think everyone agrees the system could be better and that it's not answering all the possible needs.
18:02antares_ohpauleez: "could be better" is a very polite way to put it
18:03antares_ohpauleez: ok, nevermind, I see there were not discussion with The Elders
18:04ivanso, what's the deal with negative indices?
18:04ohpauleezantares_: I'll post the notes from our talk as soon as I get a second (sometime this week)
18:04ohpauleezand we can get the ball rolling on taking the first steps to something better
18:04antares_ivan: that's the problem, nobody really says, the person who submitted the patch has been working on getting it in for over 1 month
18:04ivanis there a design evil with numbers below 0, or just interop stuff, or consistency stuff?
18:05antares_only to hear some mumbling back and give up
18:08ohpauleezantares_: We're just growing out of the old system, that's all. This happens on nearly every open source project.
18:08ohpauleezWe'll get to a new system, with new approaches to evolving the core and the ecosystem
18:08technomancyexcept I submitted this same enhancement over 2 years ago
18:09antares_ohpauleez: you, sir, is probably a hopeless optimist
18:09aperiodici've had a bug report regarding an outright lie in the gen-class docstring open for nearly two months now, and there's been absolutely no activity on it
18:10ohpauleezantares_: I don't think so. I believe in proactively working towards something better and I have a lot of larger open source project experience under my belt
18:11ohpauleezClojure has an amazing community
18:11ohpauleezand a process that hurts good ideas, innovation, and improvements
18:12antares_ohpauleez: the phrase you are looking for is "alienating the most active contributors"
18:12ohpauleezIt needs adjusting and through the power of community and patience, it'll get there
18:12ohpauleezit should have happened probably a year or more ago
18:12antares_ohpauleez: yeah, if something is broken is The Elders don't care, call for patience
18:12ohpauleezantares_: The solution will not come about from needlessly negative comments. That I can tell you with certainty
18:13ohpauleezantares_: And you are hurting the cause by continuing that line
18:14antares_ohpauleez: yeah, only cheerleading works when everybody around is giving up :)
18:14dnolengfredericks: not sure I agree but I haven't looked closely enough at Prolog-style rules solutions to say much more.
18:15antares_ohpauleez: sorry for wasting your time, I now have a comlpete picture of how hopeless the situation is
18:15dnolenblrandel: it something worth trying - would appreciate feedback along those lines.
18:15ohpauleezSo please refrain from such language. No one, not even "The Elders" disagree with you. But to date, no one has put together ideas down, and created a plan. The only progress took place when Andy Fingerhut stood up to take responsibility for focusing screening efforts.
18:15ohpauleezantares_: The situation isn't hopeless and you're certainly not wasting my time
18:17blrandeldnolen: datalog looked like it might support my use-case, but I need to investigate more
18:18ohpauleezWe can continue to all say, "This process is broken. I'm leaving" or be more proactive and say. "This process is preventing X from happening. How can we successfully make X happen, and prevent this from happening in the future"
18:19ohpauleezantares_: The notes from the last conversation are the start. I'm currently dropping the ball by not posting them. I will. I think they're good ideas. But continuing to be negative isn't going to change anything
18:20antares_ohpauleez: are you seriously expecting people who spend 1 month trying to get an obvious patch in to say that?
18:20technomancywell, it could help the overall ecosystem if people start contributing to places where their efforts actually make a difference
18:20antares_that's hopeless optimism I was referring to
18:21antares_ohpauleez: people will say "fuck clojure/core, I will stop using clojure" or "I will work on projects where my contributions are at least considered"
18:21blrandelwhat in your opinion are some of those places technomancy?
18:21cgagtechnomancy: I want to start contributing, where is that?
18:21dnolenblrandel: definitely - though if you're talking about the contrib datalog there hasn't been much development activity on that for a long time. it's relatively slow last I checked.
18:21blrandelright :/
18:21ohpauleeztechnomancy: I think they do that already and I think the community is responding to that.
18:21dnolenblrandel: but there's also datomic and that's quite zippy
18:22blrandelhmm, wasn't aware of that, will check that out dnolen thanks
18:22clojurebotthanks for your suggestion, but as usual it is irrelevant
18:22antares_ohpauleez: and maybe that's wrong and all, but you cannot change people. Clojure already has the reputation of alienating contributors, over and over.
18:22ohpauleezI'd love to see a clojure-incubation led by the community
18:22blrandeldnolen: wait, the database engine?
18:22dnolenblrandel: yes
18:22Cheironcmiles74: Hi, here?
18:22cgagclojure-incubation?
18:22aibaperiodic: how does this look? https://gist.github.com/3746298
18:23technomancyblrandel: at the risk of sounding self-serving: https://github.com/technomancy/leiningen/issues?labels=Newbie&amp;milestone=&amp;page=1&amp;state=open
18:23dnolenblrandel: but the datalog query system can work on in memory collections, so that might be enough for you.
18:23ohpauleezantares_: Again, that's not optimism, that's just the desire to see things get better. People are discouraged, yes. Some core people who have been here a long time are getting discouraged. My point still holds - no one has proposed a concrete set of ideas and potential first steps
18:23blrandelhuh, I hadn't even considered an approach like that
18:23technomancyblrandel, cgag: clojars is another good one; maybe clojuresphere too if you like graph problems
18:23antares_ohpauleez: eh? everybody is saying at least 2 things that are the same
18:24antares_accept CAs over email
18:24antares_move to github
18:24antares_end of story
18:25cgagleiningen was on my list, i figured even if i didn't contribute it's such a core part of the ecosystem i want to understand the internals a bit
18:25antares_then everybody will be able to post to clojure-dev to ask questions and it won't be so irritating to iterate on small changes like in the ticket above
18:25antares_maybe people won;t get so angry as the result
18:25technomancyclj-http/cheshire are really good about accepting patches too
18:25antares_and will be able to get answers about why their patch has been rejected
18:26antares_I think about 7 or 8 clojurewerkz.org projects have contributors beyond the core team
18:26antares_people just showed up with issues or pull requests
18:26antares_some were rejected, most were merged
18:26antares_I don't know a single person who was angry in the end
18:27antares_people added entire features for us
18:27xeqiI started contributing to lein cause technomancy was known to accept patches, there was a clear goal of replacing maven-ant-tasks, and there were tests to tell me if I broke stuff
18:27aperiodicaib: how does should-quit? work? the fact that it doesn't take an arg makes me nervous
18:28antares_all because we are not requiring to mail a piece of paper, submit a patch to JIRA and then ignoring it for months
18:28ohpauleezantares_: I love the ClojureWerkz stuff, but the scope and impact of those projects is very different than that of Clojure
18:28aibaperiodic: oh yeah, I haven't started with the game state yet. it only checks for Display/isCloseRequested (lwjgl magic) and Keyboard/isKeyDown
18:28antares_ohpauleez: it does not matter, contributors come or go for the same reasons
18:29aperiodicaib: other than that, though, looks like a solid start (though i'd switch the (if (not ...))) to an (if-not ...)
18:29antares_ohpauleez: data.json and so on are definitely comparable to clojurewerkz, yet contributing to them is not any easier
18:29aperiodicaib: on the general topic of writing games in clojure, i'd highly recommend checking out steve losh's caves of clojure series, if you haven't already
18:29dnolentechnomancy: not to belittle lein, it rocks - but comparing a 1600 LOC Clojure project to Clojure itself - a codebase of pretty intense complexity @ 50K LOC Java + Clojure doesn't make much sense.
18:29technomancydnolen: some parts of clojure are more complicated than others
18:30antares_dnolen: why does LOC count matter?
18:30aibaperiodic: huh, didn't even know about if-not :) I was more worried about loop-let-recur, haven't used any of them before :)
18:30dnolentechnomancy: antares_: scope + impact
18:30technomancyyou want to explain why it should be so difficult to change clojure.test when rich himself says he doesn't even write tests?
18:30dnolenas was already well said by ohpauleez
18:30antares_dnolen: did you see the issue above?
18:30antares_dnolen: its scope is 20 lines of code + 30 lines of tests
18:30technomancyhow many people use clojure.test outside leiningen?
18:30aibaperiodic: oh yeah, I've been (read-only) through that. for now I just want framerate-independent movement. in fact, this won't be a game but an infinite animation
18:30ohpauleezagreed, if we want to draw comparisons, we should look at Scala project management, perhaps Python management
18:30dnolenantares_: rhickey doesn't want negative indices for subs as far as I can tell - there's an older ticket for that.
18:31antares_dnolen: yet he has been asked to update it for 1 month, then rejected w/o clear explanation
18:31dnolenantares_: pre-existing rejected ticket
18:31ohpauleezScala has a core team, and a single creator. A large community and a separate build tool. They are further down the road than us. How did they cope?
18:31technomancydnolen: I'm all for a high bar for things like the persistent data structures implementation, but applying it across the board is nonsense
18:31aperiodicaib: hmmm... have you taken a look at quil?
18:31antares_dnolen: well, there still was no explanation
18:31dnolentechnomancy: well there's always Common Lisp ;)
18:32Cheironhow to check the mime type of a file in clojure?
18:32ivan"Or, if you insist, I'll just reject it now because a) IMO it's goofy, b) you can make your own function that works that way c) we don't get a free ride from j.l.String, d) it begs the question of negative indices elsewhere..."
18:32antares_Cheiron: google for pantomime
18:32ohpauleeztechnomancy: I agree with that. In Linux, I was a Janitor (cleaned code, fixed docs, etc) - that path was low barrier and there was a separated gate-keeper for that whole project
18:33Cheironantares_: thanks!
18:33ohpauleezWe already have a few set of actions items from the last talk. We have to spend some time (as a community) looking at comparable projects (Python, Scala) and refine those ideas
18:33ivanpreviously http://dev.clojure.org/jira/browse/CLJ-688
18:34aibaperiodic: nope. I've seen penumbra, but I'm deliberately reinventing the wheel here, to experience a genuine need for macros and other trickery. then I'll look at libraries such as quil and penumbra and see how simpler they've solved all my problems
18:34ohpauleezAlso note the process isn't working poorly across the board
18:34ohpauleezI think CLJS development is awesome. Changes into the contribs are also awesome
18:34XCommeXorglubSo
18:35XCommeXorglubfrom what I have been told TCO pretty much isn't compatibile with the JVM permision model
18:35XCommeXorglubAs in, it'll most likely never be in the JVM, is this true?
18:35casionhave there been any language projects as large as clojure that have outright failed, or just faded away?
18:35technomancythe only contrib I've had an easy time with is nrepl, and that's because I bug cemerick about it on IRC directly instead of going through jira
18:35technomancyalso because I ask for features and he just implements them rather than me needing to submit a patch =D
18:36gtrak`casion: did we hit critical mass?
18:36cemericktechnomancy: I hear JIRA is a 40-man in the next release. Better suit up. :-P
18:36casionXCommeXorglub: java 8 is supposed to have TCO, it's about 80% done it seems
18:37ohpauleeztechnomancy: Right, there's a key example and a full story of a better experience
18:37ohpauleezWhat's working there?
18:37gtrak`how many folks used smalltalk?
18:37XCommeXorglubcasion, scweet, gimme links
18:37ohpauleezI'd say having a dedicated gatekeeper/owner for that section
18:37ohpauleezI think that helps a lot
18:37casionXCommeXorglub: https://blogs.oracle.com/jrose/entry/tail_calls_in_the_vm http://openjdk.java.net/projects/mlvm/subprojects.html
18:37technomancyohpauleez: what's working is it totally bypasses the contribution pipeline
18:38antares_Cheiron: apparently, "pantomime" returns a lot of irrelevant results. here it is: https://github.com/michaelklishin/pantomime, take a look at http://clojurewerkz.org for a few more useful libs.
18:38cemerickApparently the weekly CA/contrib convo hit early this week? :-P
18:39ohpauleeztechnomancy: We need to me introspective than that. What is it about THAT specific experience that makes it work. How it is working? How is it working better than something else? Can that model be uniformly applied to all areas of CLojure
18:39ohpauleezcemerick: yes, yes it did
18:39blrandeloh cemerick, just bought a copy of Clojure Programming for my kindle, really enjoying it, thank you.
18:39cemerickblrandel: And thank you, glad you're enjoying it. :-) Make sure to leave a review when you have a chance.
18:40blrandelsure thing :)
18:40casiongtrak`: did smalltalk 'die' ? it was standardized I thought
18:40ohpauleeztechnomancy: I think part of it is having an owner that's trusted with a section/piece/lib - that works great in other cases as well (not to put dnolen on the spot, but CLJS and core.logic)
18:40XCommeXorglubcasion, schweet
18:40Cheironantares_: thanks :)
18:40antares_ohpauleez: if you are all about productive actiosn, how can I post my thoughts on the process w/o having access to clojure-dev?
18:40casionschweet?
18:40XCommeXorglubOne more thing though ##(symbol? (symbol "I worship his shadow"))
18:40lazybot⇒ true
18:40ivanhuh "On the other hand, IBM's JVM for version 1.3 purrs along without a problem, indicating that it does transform the code [do TCO] in this way."
18:40blrandelcasion: not if you ask my son, he really enjoys programming in Scratch, which runs in a Squeek VM afaik
18:40XCommeXorglub==
18:40gtrak`casion: ah, I guess that doesn't count then
18:40XCommeXorglubSomeone file that bug report.
18:40ohpauleezantares_: you can post them on the standard mailing list
18:41hiredmanhttps://twitter.com/fakerichhickey/status/248093894208786433 speaking of dnolen
18:41casionblrandel: I use supercollider and objc everyday almost, as far as I'm concerned smalltalk is alive and well :)
18:42blrandelcasion: I've been meaning to have a play with Overtone
18:42antares_ohpauleez: I don't see any contribution discussions there but ok
18:43casionblrandel: I couldn't get into overtone :( it seemed neat until I started to realize I was learning an implementation of a language that I'm learning on a platform that has a designated language that I already know well
18:44ohpauleezantares_: You're going to catch more flies with honey - if you want my notes to post, I'll email them to you. But no one is going to get very far (or get this off on the right foot) with a heated, negative post
18:44blrandelyeah, I'd imagine if you were already familiar with supercollider it wouldn't provide that much value
18:45casionsupercollider is already rather functional, so I've yet to see much benefit in making a clojure-based language for scsynth
18:45antares_ohpauleez: at this point, I don't really care, it's just sad to see really good developers give up. If I end up posting anything, I almost certainly will try to be reasonably polite.
18:45casionand I like the syntax, but maybe that's a draw for some people
18:46ohpauleezantares_: I will post by Friday. If you prefer, I can post in the standard mailing list (or cross-post)
18:46cemerickoh no, is the process thing on HN again?
18:46CheironI'm unable to download bishop and pantomime, is it because I'm using lein 1.x ?
18:46gtrak`casion: I think from what I've seen, the benefits are from the embedding... use other libs at the same time, not just supercollider
18:47cemerickoh, old thread. Whew.
18:47antares_ohpauleez: I am sure there will be many people interested in reading your proposal
18:47casiongtrak`: that would be neat, I never noticed any examples of that when I looked
18:47casiondo you know of anything specific off hand?
18:47gtrak`there were some neat visuals at clojure/west using javafx
18:47aperiodicquil + overtone is pretty sweet
18:48gtrak`maybe it was quil, actually
18:48gtrak`or say you want to generate notes with a core.logic program
18:48ohpauleezantares_: I'll post on the standard mailing list then, so we can open it up for comment. Let's just try to police ourselves and keep things civil :) I also want to dig up relevant history on Python and Scala as well as break down how each of their processes work
18:50ivanthe Python process is all about killing Python 2 and wasting everyone millions of dollars
18:50ivanClojure is doing much better than that
18:50gtrak`oh god, is anyone using python 3 yet?
18:50aperiodiccasion: https://github.com/overtone/mini-beast
18:50thorbjornDXprint("Django isn't")
18:50ivanthe next release of Ubuntu ships only with Python 3 and Canonical is funding some ports
18:51gtrak`aperiodic: wow
18:51casionaperiodic: hmm, I didn't realize you could use overtone like this
18:52casionI wonder if I can use clojure-vst with it
18:52casionthat'd be a bit interesting, if not completely useless
18:52aperiodicclojure-vst?
18:52casionhttps://github.com/dwu/ClojureVST
18:52gtrak`if only SC had a clojure eval...
18:53casionwait, I think that's the wrong project..
18:53casionno, that's correct it seems
18:54aibaperiodic: one last thing. what data type would you recommend my game state be? I could simply use a []-list (vector?) but being used to strong typing (not to mention Herculean typing, a la Haskell) I'm bound to make mistakes. I could start with named members, e.g. gstate.player.velocity
18:55cemerickJust in case anyone's lurking and spooked by the dustup: I actually think things are at a pretty decent equilibrium w.r.t. Clojure's dev process, etc. Not that I think that everything's roses, but there's certainly no disastrous descent or anything either.
18:55aperiodicaib: in general, the answer to 'what data type would you recommend' is 'a map'
18:55aibI was going to use {:a 1 :b 2} until I came across defrecord and deftype by chance
18:56emezeskeaib: Instead of gstate.player.velocity you might use (get-in gstate [:player :velocity])
18:56antares_aib: records are maps
18:56antares_aib: with a few exceptions, that is
18:56emezeskeaib: You almost certainly want to start with the map, and only use defrecord if there's some very good reason that the map isn't good enough
18:56antares_aib: so you can start with just maps and use a record once you settle on some state model
18:57aibI see. well, get-in looks friendly enough
18:58carkand its friend update-in, don't forget about it !
19:03blrandelthorbjornDX: Django 1.5 is shipping with experimental python 3 support
19:05thorbjornDXblrandel: ah, yeah I've heard about preliminary support. Django was one of the real 2->3 hangups for many people
19:06blrandelthorbjornDX: absolutely, yeah
19:13blrandelwow, mini-beast looks, well, beast.
19:14blrandeland has reminded me that I really need to get off my arse and fix my juno-106.
19:23thorbjornDXwhoops, I accidentally had an infinite sequence in my list comprehension, and I tried to pprint it
19:23ivanhopefully your REPL supporting interrupting
19:23ivansupported
19:24thorbjornDXivan: it did, I'm using vimclojure and I just c-c'd the terminal with the fg process
19:25tomojwould it be very difficult to give cljs locals clearing?
19:50mebaran151I'm writing a quick webapp in clojure and clojurescript and have finished almost all the pieces; the last part is securing most of it with SSL; I have successfully gotten the server to load my ssl cert but now all my noir routes return 404 for ssl. Is there something I have to fix to make the routes from defpage match SSL routes?
19:53xeqimebaran151: did you add :jetty-options {:ssl? true} to your noir.server/start call?
19:53mebaran151xeqi: yep and I have the ssl working
19:54mebaran151the only thing left is to get my defpage routes to run
19:54mebaran151right now if I hit a route via https, it returns 404, whereas if I hit it via http, it works
19:54hiredmannoir may not register the handler for ssl correctly
19:54technomancyoften ssl is easier to handle with an nginx frontend
19:55technomancyit's certainly better-documented
19:55mebaran151for the next app, I'll probably write it on top of compojure directly, but for now, I'd like to see if I can get it to register the routes properly
19:55mebaran151technomancy: I'd use nginx, but I'm required to deploy to windows :(, which is actually great for Jetty
19:55technomancygotcha
19:55mebaran151but I got all the ssl stuff working (java keystore, etc, etc, etc,)
19:56mebaran151I just need to get my noir apps to register under ssl too
19:56mebaran151*noir routes
19:57hiredmanmebaran151: have you restarted your repl recently?
19:59mebaran151I think so
20:01hiredmanlooks like the noir code should pass the options right through and the jetty adapter shoudl pick them up
20:01mebaran151I jus tkilled all my java processes; but it doesn't look like it worked
20:24Sgeodeftype is good for situations where I want to have a ... sentinal type that gets treated specially by some function, right?
20:25SgeoAnd things that aren't it just get treated, say, passed through normally
20:26SgeoCertainly makes more sense to me than a map with a certain key, since user code could easily accidentally make such a map... I think
20:27mebaran151woot; https is working, I had some middleware that returned nil on https which seems to have triggered the 404
20:27carkdeftype is like creating a class in java, but you only can add methods from a protocol to it
20:27carkdeftype is *actually* creating a java class
20:27tomojSgeo: if all you need is a sentinel, you can just use (Object.)
20:28mebaran151Sgeo: the lispy way to put together a sentinel would be using a gensym
20:28SgeoWell, my sentinal type may need to wrap another value
20:29tomojah, right, then like Reduced
20:30tomojin clojurescript that is (deftype Reduced [val] IDeref (-deref [o] val))
20:33Hodapphmm, so if I do, (defstruct foo :a :b :c), and I also have (defn bar [arg1 arg2 {:keys [a b c]}] (blahblahblah)), is there any way I can combine these two definitions so that the function is expecting keyword arguments defined in 'foo'?
20:34Hodapphmm, I guess I don't actually need a struct
20:34dnolenHodapp: and defstruct is deprecated
20:34Hodappit is?
20:35carkdnolen: supposedly
20:35dnolenHodapp: use deftype/record
20:36cark(defn bar [arg1 arg2 & {:keys [a b c}]) is real keyword arguments
20:37Hodappcark: what's what I put? optional args?
20:37carkyou call it like so : (bar 1 2 :a 12 :b 25 :c 32)
20:39Hodappcark: if I do it like that, can I also pass in a map in place of all those keywords?
20:39carknope, that's why not many people use it this way
20:40Hodappahh, so only the way that I gave (non-keyword args, whatever it's called) lets me pass in a map that way?
20:40SgeoThere's no way to apply it?
20:40Sgeo,(identity 1 2)
20:40clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$identity>
20:40carkit is possible to pass a map with apply
20:41Hodappwell, this is more for ease of use than anything
20:41Hodappso perhaps I'll just stick with optional args
20:41carkdomething like (apply bar 1 2 (concat my-map)) ; untested
20:41Sgeo,(apply (fn [& {:keys [a b c]}] a) {:a 5})
20:41clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: [:a 5]>
20:41cark,(concat {:a 1 :b 2})
20:41clojurebot([:a 1] [:b 2])
20:41carkhum nope
20:41cark,(apply concat {:a 1 :b 2})
20:41clojurebot(:a 1 :b 2)
20:42Sgeo,(apply (fn [& {:keys [a b c]}] a) (apply concat {:a 5}))
20:42clojurebot5
20:42Sgeo,(doc concat)
20:42clojurebot"([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."
20:42cark(apply bar 1 2 (apply concat my-map))
20:42carkthat's rather ugly and pretty slow
20:43Sgeo,(apply (fn [& {:keys [a b c]}] a) (seq {:a 5}))
20:43clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: [:a 5]>
20:43gfredericksTimMc I think always argues for mapply
20:44cark,(doc mapply)
20:44clojurebotI don't understand.
20:44cark,(clojure.repl/doc mapply)
20:44clojurebotCool story bro.
20:44gfrederickshe argues because it doesn't exist :)
20:44carkoh ok =)
20:44gfredericksbut he wants it to
20:44carkgfredericks: still would be slow
20:44gfredericksah sure
20:45gfredericksit's more from a code-friendliness perspective than a perf one
20:46carki find that it's often not what i want tho
20:46carksometimes you want to pass that map to some other sub-function
20:47carkthen you're annoyed
20:47carksame thiong with update-in kind of functions
20:47carkthing*
20:53TimMc,mapply
20:53clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: mapply in this context, compiling:(NO_SOURCE_PATH:0)>
20:53TimMcurgh
20:54gfredericksclojurebot: mapply?
20:54clojurebotYou could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))
20:54TimMc~mapply
20:54clojurebotYou could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))
20:54FrozenlockI want to play a little with local storage. Is there some clojurescript example?
20:54TimMcSorry, I'm apparently about 5 lightseconds away over here.
20:55dnolenFrozenlock: no but the api is prette simple (.setItem js/localStorage ...) (.getItem js/localStorage ...) etc
20:55Frozenlockdnolen: yet again you show me the path, thank you very much :)
20:56hiredmangoogle closure has some local storage wrapper stuff, which annoyingly doesn't include storage events
20:56mpanhey guys, I have an algorithm that relies on evaluating a function against a data set and making some decisions, but when I swap the function out to something simpler, the overall runtime takes 10x+
20:57mpan(it's a genetic algorithm and I'm swapping out the fitness function for one of a similar form)
20:57hiredmanhow many times are you calling it?
20:57mpansame as before
20:57casioncan you post the functions?
20:57hiredmanmost likely you are swapping in un-jitted code for jitted code
20:58hiredman(or the "simpler" function isn't)
20:59mpanhttp://pastie.org/4750865 I swap out obj-euclid (euclidean distance) for obj-min-horiz (x component distance)
20:59hiredmanthat also depends on how you are "switching"
20:59mpanI pass the obj-fn in along with the code; should I paste the code that runs it?
21:03hiredman*shrug* if you really want to know, use a profiler, but this code will most likely be slower than it could be due to various bits of allocation (boxing/unboxing/generating seqs)
21:03mpanI suppose I have my results, so I'll save my profiling for after the assignment deadline
21:03mpanany recommendations on which?
21:04mpanreducing the params a lot made it run in less time than the deadline
21:04Sgeo,((fn [^String x] x) 5)
21:04clojurebot5
21:04hiredmanwhich profiler?
21:04SgeoUh
21:04mpansure, or which such tool
21:04Sgeo,((fn [^Int x] x) "Foo")
21:04clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Int, compiling:(NO_SOURCE_PATH:0)>
21:04emezeskempan: Are you sure that the different distance function doesn't affect how the algorithm runs, e.g. ultimately causing more work to be done?
21:04hiredmanvisualvm (or jvisualvm) works
21:04Sgeo,((fn [^Integer x] x) "Foo")
21:04clojurebot"Foo"
21:05SgeoUm.
21:05SgeoWhy is Clojure acting a little bit special here?
21:05Sgeo</offensive-comments>
21:05mpanemezeske: that's what I keep suspecting, except the design of the alg is that it only operates on the relative rankings of vals returned by the fitness fn
21:06dnolenSgeo: type hints are only for optimization - not enforcement.
21:06mpanso very soon after I calc the fitness, I lose it, and I get back to my previous case of just some permutation of [1, n)
21:06casionthey are called type hints, not type directives after all
21:06hiredmanpt1 and pt2 seem to be 2 element vectors, and you'll be boxing and unboxing everytime you pull numbers out, do math, and put numbers back in
21:06mpanthey are, and is there an alternative to that?
21:06Sgeodnolen, but some things, such as choosing which function to use in certain cases, uses type hints
21:06casionhiredman: both functions will unbox the same though
21:07hiredmancasion: sure
21:07hiredmancasion: I am speaking broadly about all the code
21:07emezeskempan: Can you measure the number of e.g. iterations in some tight loop of the algorithm to rule that out?
21:07dnolenSgeo: what cases are you thinking about?
21:08mpanI precalculate the #iterations, and it's the same calc for either objective
21:08casionmpan: try a manual abs and see what happens
21:08casionI suspect it will be faster
21:09mpanthe other one does have a sqrt, though
21:09Sgeodnolen, um, hmm. I think with reify? I don't remember
21:09hiredmanmpan: you can do something like (long (pt1 0)) which will make all your math go faster
21:09mpanhiredman: I'd lose my data that way though
21:09casionhiredman: sqrt is always cast to double anyway
21:09hiredmanoh, these are doubles
21:09hiredmanwell (double ...)
21:09hiredmancasion: it doesn't cast
21:09casionand for magnitudes over a certain size, Math/abs does some really weird shit
21:09casionhiredman: yes, bad term
21:10mpanwait, they're already doubles?
21:10dnolenSgeo: not true. In the case of reify / deftype / defrecord those aren't type hints - but marking protocols or JVM interface implementations.
21:10mpanwhat does calling explicit (double... ) change?
21:10ZULTiNATORClojure does not support multiple value continuations except packaging them in some container does it?
21:10hiredmanmpan: yes, but putting (double ...) around it lets the compiler know the value you are getting out is a double
21:11mpanah, the hinting?
21:12hiredmanyou may be able to do something with a custom type and protocol, I forget if you can hint a deftype's fields as primitives
21:12mpanI need to move the output data away and then I'll test this
21:13hiredman(defprotocol Doubles (^long a [_]) (^long b [_])) (deftype DoublePair [^long one ^long two] Doubles (a [_] one) (b [_] two))
21:14hiredmanusing a vector-of :double would be nice, but I think accessing the value would still box
21:16mpanis this the type of case that warning on reflection solves? someone mentioned previously that was a part of achieving performance
21:16casionI'm testing it here and euclidian distance is running faster by about 33%
21:17casionblergh
21:17casionugh, too late.
21:17hiredmanmpan: no, it won't
21:17casioneuc distance is slower by 33%
21:17hiredmanfor this case I doubt you would get any warnings
21:21casionmpan: in obj-min-horiz, do you need to use that 0.0?
21:22mpancasion: not sure, but the elements I'm reducing over are going to be double-valued
21:23aibis there a more beautiful syntax for multiple nested update-in statements to change multiple things at once?
21:23casionare the values in the pairs doubles already?
21:23gfredericksaib: I'd think -> could compose those nicely?
21:23casionif they're ints, you could reduce with 0, and wrap it with double
21:23casionthat would be significantly faster
21:24mpanthey're definitely doubles
21:24gfredericks,(-> {:a {:b 4} :c {:d 3}} (update-in [:a :b] inc) (update-in [:c :d] dec))
21:24clojurebot{:a {:b 5}, :c {:d 2}}
21:25aibah, didn't know clojure had ->
21:26aibwhat's it called?
21:26gfredericksthreading macro I think
21:26gfredericksalso see ->>
21:26aperiodicthread-first, as opposed to ->>, which is thread-last
21:26gfredericksI always pronounce them hrrng and mrrhoo
21:27aperiodicgfredericks: in hrrng, the stress is on the r, or the g?
21:27aibso it's practically the bind operation for the identity monad?
21:28gfredericksaib: well it's all syntactic
21:28gfredericksaperiodic: r definitely
21:31mpanon that topic, any particular resource you guys would recommend for learning what a monad is and how it is useful?
21:31Hodappdecisions, decisions... the input is basically a tree that needs to be transformed, and I'm pondering whether to just have the elements in this tree be functions to transform the tree
21:31carkhttp://www.haskell.org/haskellwiki/Monad_tutorials_timeline
21:32Hodappor to just write something else to handle this and let the tree happily exist on its own
21:32mpanall right thanks for that
21:32amalloympan: i don't think it matters much which tutorials you read; you won't get it until you've spent months, reading one occasionally, and then the last one you read will suddenly make sense and you'll think it's great
21:32mpanand thank you guys for helping me with the weird performance issue
21:32mpanamalloy: I've been told I will eventually reach that point regarding continuations
21:32mpanhopefully sooner not later
21:34amalloympan: personally for me, those articles were http://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/ and to a lesser extent http://www.haskell.org/haskellwiki/Monads_as_Containers - but again, don't assume they'll be the ones that make sense to you
21:34cgagi think reading the articles in a hammock is supposed to speed it up
21:34xeqiI like http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
21:38xeqi$google monadic parser combinators
21:38lazybot[Monadic Parser Combinators - Nottingham ePrints - University of ...] http://eprints.nottingham.ac.uk/237/1/monparsing.pdf
21:39xeqialso my go to paper for showing how they might be useful ^
21:40amalloyparser combinators are pretty deep - i wouldn't start anywhere near there
21:40mpanthe other side of the question I'm wondering is, how do other languages deal with the use-cases that some language might use monads for?
21:43aibmpan: extensive if checks for the Maybe monad seems to be a standard in C
21:44xeqithey don't have the same strongly typed + purely functional attributes as say haskell, so they don't have to. also the patterns monads can hide can seem normal, so alot of times they just don't try
21:46xeqiI've heard Linq is similiar, but never done c#
21:48Sgeo$join ro_st Sorry, my explanation may have been inaccurate. join alone isn't sufficient, you also need fmap (think map) and still need return. I think.
21:48lazybotSgeo: It is not the case that you don't not unhave insufficient privileges to do this.
21:49Sgeo$mail ro_st Sorry, my explanation may have been inaccurate. join alone isn't sufficient, you also need fmap (think map) and still need return. I think.
21:49lazybotMessage saved.
21:57aibis there a shorthand for (fn [_] 42) ?
21:57Sgeoconstantly
21:57Sgeo,((constantly 42) "Hi there")
21:57clojurebot42
21:57Sgeo,(doc constantly)
21:57clojurebot"([x]); Returns a function that takes any number of arguments and returns x."
21:58aibnice, thanks
21:58SgeoYou're welcome
22:09qubit[01]sorry for the dumb question, whats the clojure package manager called ?
22:09qubit[01]if i wanted to search for a clojure csv lib for example
22:11qubit[01]also does anyway use counterclockwise with leinengen ?
22:11HodappI currently am, but I only have for a few days
22:12xeqiqubit[01]: if you are using lein, `lein search` might help; or visit clojars.org or search.maven.org
22:13qubit[01]clojars thats what I was looking for, does lein search clojars ? I couldnt find anything for csv stuff
22:13winterfroststromwhois winterfroststrom
22:14xeqiyes, though I'm not surprised about not finding anything, I'd just use one of the java libraries
22:17SgeoI searched Maven, there's a Clojure thing
22:17Sgeohttps://github.com/clojure/data.csv
22:18Sgeo"Reads CSV-data from input (String or java.io.Reader) into a lazy
22:18Sgeosequence of vectors."
22:19SgeoUh, isn't it typically a bad idea to form lazy structures on the back of I/O?
22:19SgeoUnless forcing it won't in fact cause I/O
22:22biscarchcan anyone help me out with this monger/noir code?
22:22biscarchhttps://www.refheap.com/paste/5152
22:22biscarchseems to be a bson/json encoding issue
22:23biscarchjava.lang.Exception: Cannot generate { "_id" : { "$oid" : "4fa9b58da8c93381147a160a"}
22:25qubit[01]more stupid questions , following https://github.com/clojure/data.csv , I run lein deps, then lein run, I get Could not locate clojure/data/csv__init.class or clojure/data/csv.clj on classpath: , compiling:(foo.clj:1) -- what am I missing ?
22:26qubit[01]biscarch, good to know youre working with mongo, thats my next step :)
22:26UrthwhyteSuper generic question I'm sure you're sick of, but what's a good starting off point for web dev with Clojure?
22:26xeqiqubit[01]: whats your project.clj look like?
22:26biscarchUrthwhyte: I'm using noir
22:27qubit[01]xeqi, http://pastebin.com/f7zcPaZJ
22:27qubit[01]xeqi, doh, I see it
22:27biscarchqubit: hah, I'll try to gain some experience for ya then ;)
22:27xeqiUrthwhyte: compojure or noir for routing, hiccup or stencil for templating
22:27Urthwhytexeqi: Any preference one way or the other? I've seen more about noir
22:27Urthwhyteand more positive things, it seems!
22:28xeqiI prefer compojure, less magic
22:28Urthwhyteoh?
22:28xeqior really.. less global variables and easier to use middleware; if your just starting noir will be fine for awhile
22:28UrthwhyteI thought compojure was more in the vein of Rails and Noir closer to sinatra?
22:29UrthwhyteI really haven't done much more than keep my eye on this channel though
22:29xeqicompojure is close to sinatra; noir is kinda inbetween. I think there was a project called conjure that was suppose to be rails like, but died
22:30Sgeo,(Integer/parseInt "abc")
22:30clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "abc">
22:30UrthwhyteOK, I'll check out noir and see how I get on
22:30UrthwhyteCheers
22:30UrthwhyteStill have plenty of "Programming Clojure" to read through before I really dive in anyhow
22:34Urthwhyteand VimClojure works with terminal vim as well as MacVim/GVim, correct?
22:34xeqiI've seen it work through tmux
22:35cgagi've only ever tried to use it through terminal
22:35SgeoAm I allowed to have more opinions about Monads?
22:36cgagjust tried it with gvim and it seems to work fine
22:36SgeoI don't think Maybe is actually that useful in Clojure. In a dynamically typed language, Either could easily fill that role, since if you don't want information about the error, you could just give a Left with nil
22:36qubit[01]Urthwhyte, is that the new clojure book ?
22:36Urthwhytequbit[01]: yup
22:37UrthwhyteFigured I'd try the newest book I could find and then run through SICP
22:37Urthwhyteif I was still having trouble
22:37SgeoSICP is written for Scheme
22:37UrthwhyteI'm aware
22:38UrthwhyteI've done it before, in Scheme. Problems are still easily done in Clojure
22:38SgeoAh
22:38SgeoI really should get around to running through it at some pont
22:38Sgeopoint
22:40UrthwhyteIt's great :)
22:40UrthwhyteHighly recommended
22:41biscarchThese autodocs are sweet
22:43Khazcontains? is just ...
22:44xeqi~contains
22:44clojurebotcontains is gotcha
22:44xeqi~contains?
22:44clojurebotcontains is gotcha
22:44xeqihmm, I thought it had something to say about that
22:44Khazand he said
22:44Khazit's a gotcha
22:45Sgeo,(doc contains?)
22:45clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
22:45SgeoAh
22:45Khaz,(contains? [:foo :bar] :foo)
22:45clojurebotfalse
22:46Khaz,(contains? [:foo :bar] 0)
22:46clojurebottrue
22:46Khaz:P
22:46Sgeo,(doc fund)
22:46clojurebotNo entiendo
22:46Sgeo,(doc find)
22:46clojurebot"([map key]); Returns the map entry for key, or nil if key not present."
22:47Sgeo,((comp not empty?) (filter #(= % :foo) [:foo :bar])
22:47clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
22:47Sgeo,((comp not empty?) (filter #(= % :foo) [:foo :bar]))
22:47clojurebottrue
22:47Sgeo,((comp not empty?) (filter #(= % :baz) [:foo :bar]))
22:47clojurebotfalse
22:47SgeoI'm sure there's an easier way
22:48SgeoAnd I do know that compliment exists, I just didn't feel like using it
22:48xeqi&(some #{:foo} [:foo :bar])
22:48lazybot⇒ :foo
22:48xeqi&(some #{:wha} [:foo :bar])
22:48lazybot⇒ nil
22:48Sgeo,(doc some)
22:48clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
22:48KhazSgeo: you mean an easier way to check if a coll is empty ?
22:49SgeoAn easier way to see if a collection contained an item
22:53Khaz;(contains? (set [:foo :bar]) :bar)
22:53tos9Why does lein repl take so long to start up in a fresh dir without a project.clj or anything? I assume it's going out and downloading clojure, but can I get it to spew some progress info while it does so?
22:53metellus,(contains? (set [:foo :bar]) :bar)
22:53clojurebottrue
22:53xeqitos9: how long is long?
22:54Khaz,(contains? (set [:foo :bar]) :foo)
22:54clojurebottrue
22:54tos9xeqi: user=> 4.74 real 5.37 user 0.90 sys
22:54Khaz,(contains? (set [:foo :bar]) :qux)
22:54clojurebotfalse
22:54Hodapphmm, perhaps I should not even be trying, but I'm seemingly unable to pair :as and :or in a function's argument list
22:57xeqi&(let [{:keys [a b c] :or {:a 0 :b 1} :as point} {}] [[a b c] point])
22:57lazybot⇒ [[nil nil nil] {}]
22:57amalloyxeqi: :or {a 0 b 1}
22:58xeqi&(let [{:keys [a b c] :or {a 0 b 1} :as point} {}] [[a b c] point])
22:58lazybot⇒ [[0 1 nil] {}]
22:58xeqiamalloy: thanks
22:58xeqiHodapp: ^ though notice the :or part does not end up in the :as part
22:58xeqineed a merge for that
23:00HodappI was trying to accomplish something along the lines of default values for what goes into the symbol which :as points to
23:01HodappI suppose 'merge' is of great use there
23:01xeqi&(let [{:keys [a b c] :as point} (merge {:a 0 :b 1} {:a 3}) ] [[a b c] point])
23:01lazybot⇒ [[3 1 nil] {:a 3, :b 1}]
23:44loliveirahow do I do Integer.class in clojure?
23:48tomojdnolen`: think we can do locals clearing in cljs?
23:49tomojloliveira: use it?
23:49tomojyou mean, refer to it?
23:50tomoj&(class Integer)
23:50lazybot⇒ java.lang.Class
23:53loliveiratomoj: yes. i'd like to call the following restfb function: facebookClient.fetchConnection("me/friends", User.class)
23:54loliveirathe 2nd parameter is generic
23:54loliveirai'm getting: java.lang.IllegalArgumentException: No matching method found: fetchConnection for class com.restfb.DefaultFacebookClient
23:55loliveirabut fetchConnection exists.
23:55loliveirahttp://restfb.com/javadoc/com/restfb/FacebookClient.html
23:57loliveirathat is the way i'm trying to call it: (.fetchConnection fb "boobs" (class Post))