#clojure logs

2014-10-12

00:00squeedeeoic
00:00squeedeeboy had to think about that
00:01squeedeethats multiply.
00:01justin_smithright - composed of N additions :)
00:01squeedeeSo im not 'dumb', but learning a new language, the jargon and domain around the language certainly slows me down
00:02squeedeeon top of that, 4mg of hydromorphone every 3 hours
00:02justin_smithright, anyone who knows clojure, having gone through a less impaired process, will understand that
00:03justin_smithalso, I have been teaching myself haskell, so I feel your pain (the mental half...)
00:03squeedeei started on haskell last week
00:03squeedeewent 'nahhhh' and came back to clojure
00:03squeedeeand not because i find it any more mentally challenging, i just find it really ugly
00:37caternin an alternate world, #haskell
00:38catern"i started on clojure last week", etc.
00:52devasiainstead of mapping a function to a list of values, how do I map a value to a list of functions?
00:52justin_smith((juxt inc dec) 1)
00:52justin_smith,((juxt inc dec) 1)
00:52clojurebot[2 0]
00:53justin_smith,(map #(% 1) [inc dec])
00:53clojurebot(2 0)
00:59devasiajustin_smith: thank you!
00:59justin_smithnp
01:00justin_smith,((apply juxt [inc dec]) 1)
01:00clojurebot[2 0]
01:00justin_smithas you see, it is actually possible to use juxt even if the functions arein a collection
01:00justin_smiththough map is better if you need laziness
01:01justin_smith,(map #(% 1) (map #(fn [x] (* x % %)) (range 10)))
01:01clojurebot(0 1 4 9 16 ...)
01:23kenrestivoplaying around with manifold... looking for a way to convert a stream back to a core.async channel, doesn't appear to be any way to do it, it's a one-way trip from channel -> stream
01:28justin_smithkenrestivo: what about using stream->seq
01:28kenrestivolocks up my repl real good :-
01:29justin_smithalso, there is an extension of Sinkable for channels https://github.com/ztellman/manifold/blob/master/src/manifold/stream/async.clj#L157
01:29kenrestivoi guess that's a blocking operation :-/
01:29nooniankenrestivo: it looks to me like you should be able to do (let [c (chan), sink-chan (->sink c)] and c will get values from the stream
01:29noonianhttps://github.com/ztellman/manifold/blob/master/src/manifold/stream/async.clj
01:29kenrestivook, will try that, thanks
01:32kenrestivoone more dumb question: is there any kind of standard way to turn an inputstream into a channel?
01:33kenrestivothis was a naive attempt, didn't work: https://www.refheap.com/91606
01:34dagda1_what does the arrow mean in this method declaration defn- options->jsparams
01:35nooniandagda1_: its just part of the name, usually used to denote converting things into different forms of data
01:35noonianits not special syntax
01:35dagda1_noonian: so it is jut a convention
01:35noonianyup
01:35dagda1_k, thanks
01:35nooniannp
01:37justin_smith,(let [-crazy'?-‽-name☃ 42] -crazy'?-‽-name☃)
01:37clojurebot42
01:37justin_smith,(def 💩 "Scala")
01:37clojurebot#'sandbox/💩
01:38noonianlol
01:38justin_smith,💩
01:38clojurebot"Scala"
01:38justin_smithsorry, that was immature
01:39kenrestivowhat is that char? it shows up as a question mark inside a diamond
01:39kenrestivoirssi doesn't do unicode, i guess
01:39justin_smith"pile of poo"
01:39kenrestivooh, the famous U+PILEOFPOO
01:39Jaoodkenrestivo: works for me in irssi
01:40Jaoodcheck your terminal encoding
01:40scottjkenrestivo: are you running screen?
01:40kenrestivoyes
01:40scottjkenrestivo: someone the other day said that was the problem for them
01:41kenrestivoi can't imagine runnign irssi without screen. but yeah, it might need special tweezing to do unicode properly
01:41kenrestivohttp://savannah.gnu.org/bugs/?26723
01:42kenrestivobug open since 2009 :-0
01:42justin_smithwith my current setup the symbol won't actually print, but I can insert any unicode based on its name / see the name of a unicode whether it prints or not (erc inside emacs)
01:44Jaoodfunny how it shows with a brown color
01:44amalloyfwiw, my client renders most silly characters okay, but not the three-byte supplementary characters like the ones justin_smith is always typing
01:44Jaoodamalloy: what client are you using?
01:45amalloypidgin, baby's first irc client
01:45Jaoodoh man
01:46Jaoodstill active surprisingly
01:47amalloyi used it when it was still gaim
01:48Jaoodamalloy: are you on linux? last time I heard it was being replaced by empathy in gnome
01:48justin_smithoh, gaim became pidgin? I remember using it for a short time when it was still gaim
01:49kenrestivoi still use it occasionally for jabber, and probably still have yahoo and ao-hell accounts in its account list somewhere
01:49amalloykenrestivo: yeah, i find it convenient to have my irc, aim, and google talk all in one client
01:50kenrestivofor linux i think it's the most mature/featureful of the chat clients.
01:50kenrestivolast i checked anyway
01:50amalloyJaood: i am not a willing upgrader
01:50amalloyif it worked eight years ago, it probably still works now
01:52Jaoodamalloy: did that with bitlbee :) had irc, gtalk and msn in irssi
01:52JaoodBitlBee brings IM (instant messaging) to IRC clients. It's a great solution for people who have an IRC client running all the time and don't want to run an additional MSN/AIM/whatever client.
01:52amalloysure, and that's fine too
01:54Jaood*looked
01:55Jaoodwhatapps has taken over the world
02:07justin_smithI just checked, my phone version is just one version too old for whatsapp
02:08justin_smiththe fact that they even support symbian is surprising
02:08Jaoodjustin_smith: yeah, that was the key to their success, platform support
02:10Jaoodand the no setup necessary
02:36dagda1_can anyone explain what when-let is doing here (when-let [{:keys [tabId changeInfo tab]} (<! ch)]
02:38amalloydagda1_: why don't you try explaining it, and someone will fill in the bits that are missing or wrong
02:39dagda1_amalloy: it is destructuring what is taken from the channel?
02:39amalloythat is certainly a true statement
02:40dagda1_amalloy: but why is it using when-let, why would it be null?
02:40amalloywhen do channels return nil?
02:41dagda1_amalloy: ok so it might return nil
02:42numbertenis there a literal for the byte array class?
02:42numberten[B doesn't seem to work >.>
02:43ambrosebsnumberten: try "[B"
02:43amalloythere aren't literals for any classes at all, numberten: String is a symbol which, when *evaluated*, produces the class java.lang.String, not a literal Class itself
02:44amalloydepending on the context in which you are trying to use this, there are different ways to get at the class of a byte array
02:44numbertenalright
02:44numberteni've just been using
02:44numberten,(type (byte-array ""))
02:45clojurebot[B
02:45numbertenbut it seems kinda hacky :)
03:43kenrestivowait... whatsapp just got bought for... 19 BILLION dollars?
03:46TEttingernumberten: bytes?
03:46TEttinger,(bytes [0 1 2])
03:46clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to [B>
03:46TEttinger,(bytes (byte-array[0 1 2]))
03:46clojurebot#<byte[] [B@1dd98e>
03:47TEttinger,(bytes (int-array[0 1 2]))
03:47clojurebot#<ClassCastException java.lang.ClassCastException: [I cannot be cast to [B>
03:47TEttingerhm
03:47TEttingerI know you can type hint with ^bytes
04:59jphxso, how can i replace "a b" to "a\ b" ?
04:59jphxi'm working with file paths with spaces in them
05:16By_Toris this the problem you're running into:
05:16By_Tor,(clojure.string/replace "a b" #" " "\\ " )
05:16clojurebot"a b"
05:21TEttinger,(clojure.string/replace "a b" #" " "\\\\ " )
05:21clojurebot"a\\ b"
05:21TEttingerhm
05:21TEttingerI'm guessing clojurebot escapes what it prints
05:21TEttinger##(clojure.string/replace "a b" #" " "\\ " )
05:21lazybot⇒ "a b"
05:22TEttinger##(nth (clojure.string/replace "a b" #" " "\\ " ) 1)
05:22lazybot⇒ \space
05:22TEttinger##(nth (clojure.string/replace "a b" #" " "\\\\ " ) 1)
05:22lazybot⇒ \\
05:25By_TorI think it's the replace fn
05:25By_Tor,(println "\\ A")
05:25clojurebot\ A\n
05:25jphxhehe
05:25jphxyep, i've had this headache
05:25jphxi can use replace to get "a\\ b" but not "a\ b"
05:25jphxthat's as far as i got
05:26TEttingererr, \\ probably is the \ you want
05:26TEttinger##(nth (clojure.string/replace "a b" #" " "\\\\ " ) 2)
05:26lazybot⇒ \space
05:26jphxtouch "a\ b" ; ls "a\\ b" doesn't work
05:26TEttinger##(vec (clojure.string/replace "a b" #" " "\\\\ " ))
05:26lazybot⇒ [\a \\ \space \b]
05:26jphxtet, let me try that out
05:32By_Tor,(apply str [\a \\ \space \b])
05:32clojurebot"a\\ b"
05:33By_Torit doesn't like a single backslash, lol
05:36TEttingerBy_Tor, it just prints single backspaces like that
05:37By_Torah yes, I think you're right
05:37By_Tor,(println (apply str [\a \\ \space \b]))
05:37clojurebota\ b\n
05:38TEttingersince it also escapes newlines (it can't print them in a one-line IRC message)
05:39PhonatacidHi. Im trying to use state monads with clojure.algo.monads. After a do-monad statement, I get a [result new-state] vector. If the last step in my domonad stmt is a fetch-val, the returned value ends up as 'result' in my vector. How can I get this result from outside a domonad stmt elegantly, i.e. without applying 'first' to this returned vector ?
06:16kenrestivothe real fun is when you have to do regexps in elisp \\\\\\\\\\\
06:34LauJensenGents, I've written a small cljs app, which compiles fine with "lein cljsbuild once", but evaling something like (defn ^:export test []) in Lighttable breaks with "Unexpected identifier". Im on the latest versions of both LT and CS - Anybody know whats up?
06:39TEttinger,(defn ^:export test [])
06:39clojurebot#<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)>
06:39TEttinger,(defn test [])
06:39clojurebot#<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)>
06:40TEttinger,(defn test1 [])
06:40clojurebot#'sandbox/test1
06:40TEttinger,(defn ^:export test1 [])
06:40clojurebot#'sandbox/test1
06:40TEttingerhuh4
06:40TEttingerI didn't know you could omit the body
06:40TEttinger,(test1)
06:40clojurebotnil
06:45weihow do you use the [com.facebook/react "0.11.2"] dependency? do you have to do anything more than putting it in the project.clj file?
06:46LauJensenIts not very useful to know :)
06:48weiLauJensen: why not?
06:49TEttinger~Om
06:49clojurebotIt's greek to me.
06:50TEttinger~om
06:50clojurebotTitim gan éirí ort.
07:05dysfunooh, i've just discovered a neat trick. #(= some-var %) can be shortened to #{%}
07:06dysfuner #{some-var}
07:11Gina97ciao
07:11Gina97!list
07:31sveriHi, I have a jenkins running and a job that runs lein midje configured to produce junit reports in target/surefire-reports. I see that the job runs lein midje, without any error, but it does not generate the junit reports, any ideas why that may be? I moved that jenkins instance to different server, before I moved it that junit generation did work and I don't have a clue what might be different now
07:32sverirunning lein midje from the console as the jenkins user works as expected -l.-
07:33engblomIs fireplace still the a plugin most vim-users should use?
07:34engbloms/a //
07:36dysfunsveri: that sounds more like a jenkins question to be honest. it might be seeing a different environment, for example. i've had some interesting jenkins adventures in the past
07:39sveridysfun: hm, jenkins user might say its something clojure related, it's hard to tell what exactly is wrong -.- whatever, which build server do you use now?
07:40dysfunostensibly jenkins, but i don't get paid for clojure work so most of my code is only being tested while i work on it
07:41dysfuni do have some stuff being tested using midje under jenkins though
07:53sverihm, any problems with it?
07:53john2x_how do I use lein-ancient on my profiles.clj file?
08:32borkdudewhere can I find a kind of timeline of what came when in clojurescript?
08:33borkdudeJune 2011: first version of clojurescript.
08:33borkdudewhat other interesting marks in time are there? ;)
08:37gfredericksAugust 2017: support for method_missing
08:38borkdudelol
08:47RhainurI've been working on the problems at 4Clojure for a bit, and I'm getting a bit worried about code readability
08:47RhainurI feel like if I came back to this code after a few months I'd have no idea what was going on in there
08:48AimHereComment it
08:51LauJensenGents, I've written a small cljs app, which compiles fine with "lein cljsbuild once", but evaling something like (defn ^:export test []) in Lighttable breaks with "Unexpected identifier". Im on the latest versions of both LT and CS - Anybody know whats up?
09:00hellofunkwith compojure.handler/site how does it work that a #'var can be passed, as well as just the unquoted var, and both work? most clojure functions don't allow you to swap one for the other. for example (keys #'some-map) fails
09:08dagda1why is :keys used in this (destructuring when-let [{:keys [added removed]} (<! ch)]
09:09hellofunkdagda1 what is taken off the channel is no doubt a map, thus you are binding to items in the map
09:10dagda1hellofunk: so :keys must be used to get items from a map?
09:10hellofunkthere areother ways, but the :keys form is a map destructuring form as a shortcut to access map data
09:11hellofunklookup "clojure destructuring" -- it is like a mini language to help make stuff like this more effecint. it is not necessary to use it, but it makes code tighter
09:12mearnshdagda1: :keys helps avoid repetition
09:12dagda1thanks
09:15mearnshdagda1: https://www.refheap.com/91612
09:16dagda1mearnsh: that completely clears it up, thanks
09:16mearnshnp
10:55clj-learnersometimes in clojure functions source they have multiple arity calls instead of just using [& args], why is that? (ex: complement source https://www.refheap.com/91614)
10:56Bronsaclj-learner: efficiency reasons
10:56Bronsaclj-learner: apply and & have some overhead
10:56Bronsaclj-learner: so the most used arities are unrolled
10:56clj-learnerok, that makes sense
10:57hellofun`with compojure.handler/site how does it work that a #'var can be passed, as well as just the unquoted var, and both work? most clojure functions don't allow you to swap one for the other. for example (keys #'some-map) fails
10:57clj-learnerthanks
10:57Bronsaclj-learner: it's not something you should to in your code btw, that's a micro optimization
11:14technomancyhellofun`: it only works for functions
11:14technomancyvars call their contents when called
11:15justin_smith,(#'+ 1 1)
11:15clojurebot2
11:15hellofun`technomancy you mean for function arguments that are passed var names?
11:15hellofun`oh, not arguments, actual functions themselves
11:15justin_smithhellofun`: eventually, that function is placed in the calling position - that's when it has to work
11:15justin_smithand it does
11:16hellofun`interesting
11:16justin_smith,((fn [x] (x 1 1)) #'+)
11:16clojurebot2
11:16justin_smithI pass in a var, it gets called
11:17hellofun`so the var is not evaluated at compile time, but rather at runtime?
11:17hellofun`i'm curious behind the scenes how (+ 1 1) differs from (#'+ 1 1) -- at which point does the #'+ become +
11:18technomancyhellofun`: you're passing a var around; they are first-class at runtime
11:18technomancyits contents aren't looked up till it's called
11:19hellofun`that's interesting. for example (def a 5) and then (+ #'a 1) does not work, I wonder why it is different for a function. there is an extra level of lookup with all functions?
11:22justin_smithhellofun`: I think it's more that var implements IFn
11:23justin_smith,(isa? (type #'+) clojure.lang.IFn)
11:23clojurebottrue
11:23justin_smithand implementing IFn means you can be called like a function
11:23hellofun`ah, that's quite cool
11:23pdkdoes clojure have #' now
11:23zwerwhat is #'? I thought I was in #lisp for a second.
11:23justin_smith,'#'+
11:23clojurebot(var +)
11:23hellofun`yes #' is a way to quote a var and have it namespaced automatically
11:24justin_smithnot namespaced automatically
11:24justin_smithany more than anything else is
11:24hellofun`justin_smith 'a vs #'a -- the latter adds the namespace
11:24hellofun`actually, that was a bad example
11:24justin_smith,'#'a
11:24clojurebot(var a)
11:24hellofun`'a is not a var
11:24justin_smithnope
11:25justin_smith` namespaces, maybe that's what you are thinking of
11:25hellofun`i am confusing it with backquote
11:25hellofun`my bad
12:34gfrederickshi.
12:37mmeixji
12:37mmeixhi
12:38justin_smith∿∿∿∿∿∿∿∿∿∿
12:39gfredericksanybody know of a jvm library that does exact arithmetic with algebraic numbers?
12:39mmeix{I'm to much a newbie to answer that question}
12:40mmeixI would like to see rational number support in cljs though :-)
12:40gfredericksI made a library for that
12:40mmeixah!
12:40gfredericks$google github gfredericks clj-numerics
12:40lazybot[gfredericks/four · GitHub] https://github.com/gfredericks/four
12:40gfredericksthat is not it
12:40gfrederickshttps://github.com/gfredericks/cljs-numbers
12:41mmeixI'm plannung on wtiting some music software, and that would be really handy to have
12:41mmeixthanks for the link!
12:42gfredericksnp
12:43Bronsajustin_smith: were you waving at gfredericks there? :)
12:43gfredericksBronsa: oh no I bet he was
12:44justin_smithBronsa: indeed!
12:44justin_smithit was a sine wave
12:44gfredericksa sign wagv
12:44Bronsa(inc justin_smith)
12:44lazybot⇒ 90
12:45gfrederickswhat a joke to make right before I ask about algebraic numbers
12:45Bronsathat was pretty good
12:47arrdemBronsa: random branfiring... I can replace half this shit by just aliasing tejvm/-emit and redefining select methods, right? https://github.com/oxlang/oxcart/blob/master/src/main/clojure/oxcart/emitter/jvm/emitter.clj
12:47arrdemBronsa: just seeing your activity in the last few days and thinking about minimizing bit rot
12:47arrdemalso maybe breathing life back into that...
12:48arrdembah multimethods are mutable
12:49gfredericksexcept for their dispatch function :P
12:49Bronsaarrdem: yeah
12:49arrdemwhy on earth is this the case... an immutable multimethod and a swap! on the var would work fine T_T
12:50Bronsaarrdem: want to talk about extend implemented via alter-var-root? :P
12:50arrdemBronsa: you have my axe
12:51Bronsa(also why is alter-var-root not alter-var-root!, I mess this up everytime)
12:51arrdemBronsa: because it was alter-var-root first and name changes are breaking
12:51Bronsa(defn alter-var-root [& args] (println "DEPRECATED") (apply alter-var-root! args))
12:51arrdemyeah that's what I'd do too, but neither of us is Rich so...
12:52arrdemdamnit I was motivated for a minute there and now all I see is warts again
13:04vladh_Hey guys. Just a quick question - in a namespace, is it bad practice to initialize variables and call functions when the namespace is loaded? Or should I have some mutable variables which are initialized when functions in the namespace are called from the outside?
13:05arrdemvladh_: imperative initialization using load time code execution is usually bad news bears
13:05vladh_arrdem: thought so, but isn’t mutability bad too?
13:05arrdemvladh_: sure, but I personally find mutability excusable in some situations. we've spent what... eighty years? developing cleaver mutable algorithms. we'd be fools to discard them out of hand.
13:06arrdemvladh_: IMO you want some sort of (construct-state) function that builds a _value_ with all your state in it, and then you pass that around everywhere rather than binding those mutable bits to say dynamic vars or atoms.
13:06justin_smithvladh_: something that requires a stateful initialization, will be a pain in the ass as soon as a client wants to of them if it is global - consider making a "factory"
13:07arrdem^ justin_smith use the f word but same idea
13:07justin_smiths/to/two
13:08arrdemEx. (let [connection (connect-to-db config)] (run-query connection "SELECT * FROM USERS;"))
13:08arrdemrather than having a connection var that you swap or whatever
13:09vladh_arrdem: that makes a lot more sense than just mutating the value in the namespace - thank you!
13:09vladh_justin_smith: thank you as well
13:17mmeixVery basic question: how do I create a map out of a vector of keys with a default val for each, for example [:a :b] --> {:a [] :b []} ?
13:17bbloom,(into {} (map vector [:a :b] (repeat [])))
13:17clojurebot{:a [], :b []}
13:18mmeixah - thanks!
13:18bbloommmeix: but you may not actually need to do that if you're going to operate on the map later with update-in or whatever, you can also use something like fnil
13:18bbloom,(update-in {} [:x] (fnil inc 0))
13:18clojurebot{:x 1}
13:19luxbockfnil is a very handy tool to have
13:19mmeixI'm trying to solve http://www.4clojure.com/problem/63 and maybe just need a tiny hint ...
13:19arrdemfnil is the top function I underuse
13:19mmeix(thanks for fnil tip)
13:21mmeixWhich brings me to a typical beginnner's problem: finding the right functions out of the big vocabulary of Clojure
13:22bacon1989Hey guys, i'm trying to structure my project so that it incorporates tests
13:22bacon1989I made a separate folder in my source folder called test, and created a sub-namespace called database with a file core.clj
13:23mearnshmmeix: kibit can help a bit
13:23bacon1989src-clj/test/database/core.clj , (ns test.database.core (:use clojure.test)) (deftest (is (= 5 4)))
13:23luxbockbacon1989: are you using leiningen?
13:23bacon1989luxbock: yeah
13:23bacon1989I run lein test, and it won't find this test
13:23bacon1989if I run (run-all-tests)
13:23bacon1989no problem
13:24justin_smithbacon1989: it looks for tests under test/... not src/... by default
13:24bacon1989justin_smith: yeah, I figured, but I couldn't get it to work under tests/, it complained about missing files
13:24Bronsa(inc fnil)
13:24lazybot⇒ 1
13:24Bronsano love for fnil :(
13:24bacon1989i'll try looking throuhg the lein docs
13:24gfredericks((fnil inc 0) fnil)
13:25justin_smithbacon1989: if you have src/myproj/core.clj the test should be in test/myproj/core-test.clj
13:25justin_smithbacon1989: not in the same src/, and not in src/tests/ - unless you reconfigure to look for tests there I guess
13:26bacon1989justin_smith: yeah, my project is a clojure+clojurescript project, so i've been changing things around
13:26bacon1989i figured lein test would also do what (run-all-tests) does, but I guess not
13:27justin_smithbacon1989: run-all-tests is called by lein test
13:27arrdem(inc gfredericks)
13:27luxbockmmeix: I don't know if this is the best way to solve that problem but I would use reduce wrapped in a function
13:27lazybot⇒ 92
13:27gfredericksbacon1989: I think run-all-tests only works because you've already loaded the test file manually
13:27gfredericksleiningen doesn't know to load the file since it doesn't know where it is
13:27justin_smithbacon1989: but run-all-tests only works if the namespaces with the test definitions are loaded first
13:27justin_smithrun-all-tests does not namespace loading at all
13:28bacon1989hmm I see
13:29justin_smithbacon1989: the issue here is telling lein how to find your test namespaces.
13:29mmeixluxbock thnx
13:29bacon1989yeah, i'm trying to find the project.clj example, where it shows all of the different options available
13:29bacon1989so I can go change the tests folder
13:32justin_smithhttps://github.com/technomancy/leiningen/blob/master/sample.project.clj#L277
13:32justin_smith:test-paths
13:33bacon1989yeah, I just found it :P
13:33bacon1989thanks
13:33bacon1989i'm probably going to try and get clojurescript tests working as well, hopefully that's not too difficult
13:34arrdemtechnomancy: if I wrote a way to add profile based dependency replacement, would you take it?
13:34bacon1989justin_smith: that did the trick, thanks
13:35justin_smithcool
13:39mmeixfnil is a cool beast indeed, I'm just learning
13:40arrdemwas there a hack somewhere for finding multiple aliased files on the classpath? So say finding all resources "/manifest.ed"
14:05gfrederickshugod: is it purely a coincidence that my lein 2.5.0 does not use the repl profile and you have post-2.5.0 commits messing with repl profiles?
14:06justin_smitharrdem: iirc I saw amalloy_ show a snippet for doing that - maybe it had something to do with iterating over all the the items in the classpath and asking each one for the resource?
14:08gfredericksI'm trying to do (System/exit 0) in my repl init code and for some reason this hangs
14:08justin_smith(shutdown-agents)
14:08gfredericks(not-very-related to my prior statement)
14:08gfredericksjustin_smith: bah of course I bet that's it
14:08gfredericksor actually
14:08gfredericksit might be a timeout in the leiningen process
14:08ogdennis anyone able to help me come up with an enlive selector?
14:09gfredericksit quit hanging quicker than 60sec I think
14:10ogdennI need to select all inputs with a name that is one of a set of names
14:12ogdennI basically need the selector predicate (attr-in :attr-name #{possible values})
14:22gfredericksnew user profile tactic for keeping the classpaths & deps trees clean
14:22gfredericksinstead of :plugins [[lein-try "0.4.1"]]
14:22gfredericksdo :aliases {"try" ["with-profile" "+lein-try" "try"]}
14:23gfredericksand make a separate profile called :lein-try with the plugin
14:24borkdudelein plz <alias> is nice, but it would be nice if the alias would also work with lein try :)
14:24borkdudelein plz add <alias> I mean
14:24borkdudewhat a co-incidence, I didn't see gfredericks talk about lein try
14:25justin_smithnow we need lein kthx
14:28borkdudeuuh... https://www.refheap.com/91622
14:30ogdennAgh, sorted. Need to use (apply attr-has :attr-name possible-values) just incase anyone is interested.
14:44gfredericksoh man trying to figure out this leiningen repl profile problem is spooky
14:45gfredericksanybody know if this is a reasonable thing for a leiningen plugin to do? https://github.com/greglook/whidbey/blob/master/src/whidbey/plugin.clj#L28-47
14:48hyPiRiongfredericks: Better to create the profile :whidbey.plugin/profile and merge it into the project map.
14:48gfrederickshyPiRion: "merge it into the project map"?
14:49gfredericksI'm getting super weird results using this
14:49gfredericksespecially if I put my own :repl profile in ~/.lein/profiles.clj
14:50gfredericksI will get only one of the two repl profiles active at any point, but different ones depending on how I start the repl
14:50gfredericks`lein repl` is different from `lein with-profile +user repl` even though the difference between the two should be a noop
14:50gfredericksI will have to figure out again how to build my own lein to debug this
14:50hyPiRiongfredericks: like, enable through merging (-> project (assoc-in [:profiles ::profile] my-profile) (leiningen.core.project/add-profiles [::profile]))
14:51gfrederickswell I think what the plugin is trying to pull off here is not not have its code "enabled" unless the :repl profile is also
14:52hyPiRionhrm
14:54gfrederickswhat's the easiest way to build and/or run a custom leiningen?
14:57gfrederickshey it's easy
14:57gfredericksjust edit the leiningen source and run the bin/lein script in the project instead of the normal installed one
14:58hyPiRiongfredericks: yeah, but you'd have to bootstrap and compile first
14:58gfredericksI bootstrapped; did not compile
14:58gfredericksit's still running the custom code
14:58hyPiRiongfredericks: right, but it'll blow up if you try to search
14:58gfredericksif I try to what
14:58gfredericksis leiningen a search engine?
14:59justin_smiththat sounds like a jaden smith tweet
14:59hyPiRiongfredericks: `lein help search`
15:01gfredericks:aliases {"hepl" ["help"]}
15:02gfrederickshyPiRion: I stopped using lein search after like a year ago when it seemed to never ever return
15:02hyPiRiongfredericks: I don't use it either
15:03gfredericksso my guess is going to be that the profile merging is happening before the middleware is running
15:03gfrederickswait I take it back
15:04gfredericksurm
15:06gfrederickshyPiRion: would the whidbey middleware be bad because it can shadow an existing :repl profile from profiles.clj?
15:07gfredericksit seems to expect that any existing :repl profile is in the :profiles key of the project, but I'm thinking that's not the case for ~/.lein/profiles.clj
15:07gfrederickspresumably those are in the metadata somewhere
15:08hyPiRionno, they should be in the project map
15:08hyPiRionpretty sure at least
15:12gfrederickshyPiRion: I'm looking around this call: https://github.com/technomancy/leiningen/blob/master/src/leiningen/repl.clj#L285-287
15:12gfredericksbeforehand my profiles.clj :repl profile is not in the project proper, but it is in the project's metadata under [:profiles :repl]
15:12gfredericksafterward it is in the project proper and appears to have clobbered the whidbey stuff
15:14hyPiRiongfredericks: There has been some new functionality popping into profile merging, not sure what profiles-with-matching-meta does (although I guess it fetches the ones with ^:repl tagged).
15:14gfredericksso I'm going to just conclude this isn't a supported way to customize leiningen and whidbey should do something else
15:15gfredericksI bet there's not a real downside to just modifying the project map directly
15:15gfredericksor calling merge or something
15:17gfredericksI need to write myself a lein plugin for deploying a random commit of a random project to clojars under a fork group-id
15:20gfrederickshah calling merge gets me a stack overflow
15:36amalloyjustin_smith, arrdem: no, you're thinking of someone else
15:38gfredericksfun use of dynamic vars -- preventing recursion: https://github.com/gfredericks/whidbey/blob/c380535d08b40737c3c452dc6ee05170a2a49a7d/src/whidbey/plugin.clj#L28-39
15:39louissmitHi all, I’m new to clojure and wondering about the identity functions in reducers: https://gist.github.com/louissmit/4ec16497e74bc07da012
15:39louissmithere it never calls the identity function of the reducing function while it should do that for every partition, right?
15:47mi6x3mhey clojure, I am writing a macro defexample taking 4 parameters
15:48mi6x3mtitle description show-src? and form
15:48mi6x3mso an examle looks like
15:48mi6x3m(defexample "foo" "boo" true/false (println "bla"))
15:48mi6x3many better way to structure the arguments?
15:48mi6x3mor this one is good enough
15:54gfredericksum
15:54gfredericksmi6x3m: "better" according to what? it's not clear what you're trying to accomplish
15:55mi6x3mgfredericks: create a semantically more intuitive way then setting up meta data on my example constructors manually :)
15:55mi6x3ma example is actually a defn with ^{:example {:title "foo" :desc "boo" :show-src? true/false}}
15:57gfredericksyou missed the name of the var then, eh?
15:57gfrederickssame as the title?
15:57mi6x3mgfredericks: you are right, it was supposed to be (defexample simple-example "foo" "boo" true/false form) but this is arguably better than the manual meta....
16:00gfredericksit's at least less prone to keyword typos
16:00mi6x3mgfredericks: true, but still ugly
16:01gfredericksyou can also write a function that adds stuff aftewards
16:02gfredericks(defn set-example-data [the-var title desc ...])
16:03mi6x3mgfredericks: hm? using a defn?
16:04gfredericksyeah, it would just call alter-meta! on the var
16:04gfrederickslook ma, no macros
16:05mi6x3mgfredericks: but ma, then the example and it's meta would be split. nah i'll just use the ugly macro
16:05mi6x3mwho'll be there to see
16:05mi6x3moh, it's open source, myeah
16:11gfredericksit's surprisingly difficult to alter nrepl's default printing behavior cleanly
16:13amalloymi6x3m: the problem with (defexample blah "foo" "boo" whatever else) is that you have a bunch of positional arguments that all look the same, and it's easy to forget which is which
16:13amalloytaking a map of options somewhere in there would help a lot, by placing reminders in the user's code: (defexample blah {:thing "foo" :message "boo" :cleanup? false} form)
16:18mi6x3mamalloy: yes in the end that's what's going to happen
16:18mi6x3mI just can't bear the thought of having named arguments with macros
16:19mi6x3m(defexample blah :title "foo" :desc "boo" :show-src? true form) perhaps
16:19mi6x3mok i'm off thanks everyone :)
16:43mxr1o1hi
16:43mxr1o1so i have a bit of embarrasing question..
16:44gfredericksput more parens on it
16:44mxr1o1my code is built as a hierarchy of functions where top level functions call other functions and they call more functions
16:44mxr1o1the questions is about writing tests
16:45mxr1o1writing tests is a requirement of the project
16:45mxr1o1now, i wonder how should i approach it
16:45mxr1o1would it be a good practice to test _every_ function?
16:45mxr1o1or should I only test the highest level (end to end) functions?
16:46asQuirreLmxr1o1, I would test all the public functions in each namespace
16:46gfrederickswhat do you have to test to be confident that it's working and that you can refactor it without unknowingly breaking anything?
16:46mxr1o1or rather only the lowest level functions..
16:46amalloy(inc gfredericks)
16:46lazybot⇒ 93
16:47mxr1o1gfredericks: i guess to be "confident" i have to test each and every function
16:47mxr1o1...
16:47mxr1o1or what?!
16:47mxr1o1:)
16:47mxr1o1(inc inc)
16:47lazybot⇒ 11
16:48asQuirreL(doc inc)
16:48clojurebot"([x]); Returns a number one greater than num. Does not auto-promote longs, will throw on overflow. See also: inc'"
16:48gfredericksmxr1o1: well if you can test the higher level functions and infer that your code is working from that...
16:49asQuirreL(deref 'gfredricks)
16:49gfredericksmxr1o1: I feel like the answer becomes obvious once you're not testing just because you're supposed to, and are instead testing because you want an automated way to check that the code works the way it's supposed to
16:49mxr1o1gfredericks: but then.. comes a new programmer, removes the top level functions and writes something different using the bottom more generic functions - which don't have tests - maybe in the process he even changes some of these generic functions..
16:50mxr1o1i.e regression..
16:50gfredericksmxr1o1: and then your tests break with "these top level functions no longer exist", so that programmer will be able to tell that he needs to think things through
16:50gfredericksI don't think "someday the code might be restructured so that these tests become valuable" is a good reason to write tests today
16:51cheaterhi
16:51gfrederickshello
16:51cheateri'm trying to understand this transducers library and i've got this function that takes transducers and runs them on a list
16:51mxr1o1gfredericks: yeah.. i tend to agree - otherwise this testing orgy feels like a waste of time after a certain threshold..
16:52cheater(this is in haskell)
16:52gfredericksmxr1o1: tests aren't free
16:52cheaterand it ends up looking like this: (ftrans (t1 . t2 . t3)) [1..5]
16:53cheaterand it looks to me like ftrans applies t1, then t2, then t3 to the list... however that's the opposite direction as if you'd do (f1 . f2 . f3) [1..5]
16:53cheaterwhy is that so?
16:53mxr1o1gfredericks: sure.. i'm trying to resolve the best practice of this where tests give more value than they cost to write/maintain
16:53cheaterare transducers somehow contravariant or something like that?
16:54Bronsacheater: http://clojure.org/transducers
16:54Bronsacheater: "Composition of the transformer runs right-to-left but builds a transformation stack that runs left-to-right (filtering happens before mapping in this example)."
16:54cheaterBronsa: yeah, but why is that?
16:57platz cheater because the outer transducer 'wraps' the inner transducer
16:57Bronsacheater: https://www.youtube.com/watch?v=6mTbuzafcII&amp;t=25m30s
16:58cheaterplatz: hmm..
16:58platzso the outer one gets eval'd first, but it's just returning a closure which wraps the inner one
16:58cheaterplatz: makes sense kind of
16:58platzso the data actually gets run through the inner one first
16:59platzit's just normal function composition
16:59platzbut made to look wierd because all of the closure returning
16:59kenrestivokind of like ring handlers in a way
17:07cheaterplatz: hmm
17:08platzcheater: http://youtu.be/6mTbuzafcII?t=25m30s
17:08cheaterplatz: Bronsa just linked to that
17:16cheaterthanks for the help guys
17:16cheatercya!
17:33justin_smithhiredman: were you the one that had a code snippet to get multiple resources with the same path from the classpath?
17:36rurumateI'm confused about this stack trace: https://www.refheap.com/91623. Why does it come to Compiler.java:6361 twice? Why does the analyzeSeq call succeed the first time, but not the second. Anyone?
17:38tavoeEasy question. How do I check what my present working directory is with clojure?
17:38justin_smith,(.getCanonicalPath (java.io.File. "."))
17:38clojurebot#<SecurityException java.lang.SecurityException: denied>
17:38tavoethank you. Cool
17:39justin_smithrurumate: just guessing - it's recursing, "(x y)" analyzes fine, it's getting the contents of "x" that blows up
17:40rurumateI don't know how to debug clojure. It's not a lein project. How to start a repl?
17:41justin_smithrurumate: it's much easier with lein, but you can get a repl with java -jar your.clojure.version.jar
17:42rurumateok but how to debug the java parts, like Compiler.java?
17:43rurumatehow did rich do it, did he use a debugger or what
17:43justin_smithI think he used eclipse or idea
17:50rurumatemicrypt: just trying to find out things about the compiler, from the repl. Making it go boom, like (nil 5), creates interesting stack traces, but how to see more exactly what's happening? I don't like the thought, but maybe will have to use eclipse soon
17:55rurumatethis would be the java version: (clojure.lang.Compiler/eval (clojure.lang.RT/readString "(nil 5)"))
17:56rurumateso that's a java program, it can be debugged. it seems there is no other way
18:04rurumatewhere are the unit tests in clojure core?
18:04gfredericksyou mean these? https://github.com/clojure/clojure/tree/master/test/clojure/test_clojure
18:05rurumateso they are all in clojure? that means, rich has been developing the java code, using a clojure repl?
18:06rurumateI'm looking for tests for the java parts specifically, like LispReader and Compiler
18:07gfrederickswhy can't you test those from clojure?
18:08rurumatedunno, have to look at it first
18:09rurumateit's just I would expect to find more java unit tests, because at first there is only java, can't test from the repl while developing the repl
18:09gfredericksit's not too hard to bootstrap a lisp
18:10gfredericksand writing tests in java is somewhat unpleasant
18:10rurumateyes, but what about bugs? also Compiler.java has some 8000 lines of code
18:10gfredericksI'm sure it didn't at first
18:10rurumateisn't is bad style to let it grow so large?
18:11gfredericksprobably
18:12rurumatehow would I start a repl to hack these tests? there's no project.clj
18:12gfredericksgood question
18:13gfredericksif you just want to play with the tests using a released version of clojure, you could um
18:13gfredericksI don't imagine you use cider or fireplace or anything?
18:14rurumateI would like to make experimental changes to the java code too, it's ok to restart the repl, but a real emacs repl would be nice
18:14rurumateyes cider
18:14gfredericksokay well with cider you can just open any of those test files and start evaling things
18:14rurumatereally? doesn't it need to connect to a repl server first?
18:16gfredericksplaying with the java code is trickier
18:16gfredericksyou can start a minimal repl from a compiled jar
18:16gfredericksstarting an nrepl server would be more work
18:16gfredericks(for the former, run the clojure.main class)
18:17rurumateok, I see. I think I will just write some JUnit tests for now
18:19justin_smithgfredericks: wait, are you saying cider can work with a direct repl not using nrepl / sockets?
18:19rurumatereally I'd like to see the workflow rich used when writing this
18:20gfredericksjustin_smith: nope
18:21oskarkvrurumate I might not have understood what you meant, but https://github.com/zcaudate/vinyasa#reimport
18:21rurumateoh my. there's not even junit in the pom.
18:23rurumateoskarkv: yes that looks cool, I will look into it
18:23slesterany ideas for finding the largest contiguous shared substring given two strings? I'm totally stumped. :(
18:25rurumateslester: have you tried brute force yet?
18:25oskarkvslester http://en.wikipedia.org/wiki/Longest_common_substring_problem
18:25micryptrurumate: Thanks for your help.
18:26slesterrurumate, nope, I was trying to find an idiomatic way to do it
18:26slesteroskarkv, oh! nice! I didn't think to check Wikipedia
18:27oskarkvslester i just googled what you said, more or less :P
18:27slesteroskarkv, well, I'll blame startpage then, all I found was rosetta code that had shared noncontiguous substrings
18:27oskarkvhehe
18:28justin_smithsuffix tree building is more straightforward to do in clojure than dynamic programming (since our default data types are immutible)
18:48gfrederickslol elisp is weird
18:49gfredericksI'm using defadvice to monkeypatch things and it works exactly the opposite of doing alter-var-root in clojure -- running defadvice has no immediate effect, but once you go eval the original function the monkeypatch becomes active
18:50cflemingHi all - I'm using with-redefs in my tests. I just switched my tests to run on the Swing EDT and with-redefs no longer seems to be taking effect - any ideas why?
18:51cflemingThese tests worked previously, I can now debug and I see the original functions being called.
18:56justin_smithcfleming: that's weird - and it only happens in that specific thread?
18:57cflemingjustin_smith: It seems to. But it's not like the EDT is magic or anything.
18:57cflemingjustin_smith: Actually, perhaps I spoke too soon. Since I just ported all my tests to the EDT, I don't know if it would also happen on other threads - I do know it used to work.
18:59justin_smith right, just wondering if you tried the same tests in a normal thread, that would potentially narrow down the issue
18:59cflemingThere seem to be some problems with with-redefs and concurrency, but they're mostly around multiple threads binding the same vars simultaneously
18:59justin_smithit could be an error introduced by refactoring (which would be less scary and baffling)
18:59cflemingUnfortunately un-porting them is non-trivial.
18:59cflemingAn error in my code?!?!
18:59justin_smithwhat about just making the thread a parameter?
18:59cflemingInconceivable.
19:00cflemingWell, it's tricky - I can't pass the thread in as a parameter since to execute on the EDT I have to use invokeLater
19:01justin_smitha runner abstraction?
19:01cflemingI could pass in a function which abstracted that, though.
19:01cflemingI'll take a look - it's tricky because this is all set up in test fixtures.
19:03ben_vulpesdoes aset-byte not alter the underlying byte array?
19:04ben_vulpesi'm doing (let [inits (byte-array 12)] (aset-byte inits 0 (byte 0xF9)) inits) and getting back an apparently bare array of bytes (all 0's)
19:04justin_smith,(let [a (byte-array (map byte [1 2 3 4 5]))] (println (into [] a)) (aset-byte a 1 (byte 42)) (println (into [] a)))
19:04clojurebot[1 2 3 4 5]\n[1 42 3 4 5]\n
19:07Bronsacfleming: http://sprunge.us/UAiV?clj might be what's happening
19:08Bronsacfleming: i.e. if you're using the redefed value in a different thread, the with-redefs might be restoring the previous var root before your thread gets to deref the var
19:08cflemingBronsa: I'm not quite sure what I'm looking at there.
19:08cflemingAh, right.
19:09Bronsacfleming: the easy fix is to await the termination of the other thread before exiting the with-redefs
19:09justin_smithright, you want to call with-redefs inside the other scope
19:09justin_smithor that...
19:09cflemingBronsa: That could be the case since the call to the redef'ed function happens in a Swing invokeLater - however I thought that was executed immediately when called from the EDT.
19:10cflemingIf anything, I would have expected problems like that previously, when this code was not run from the EDT and cross-thread issues definitely come into play.
19:11Bronsacfleming: dunno, just sleep for a bunch of ms before exiting with-redefs and see if the problem goes away :)
19:12Bronsain my repl even without sleeping, (with-redefs [+ 2] (future (reset! a +))) sets a to #'+ instead of 2
19:12cflemingOhhh, looks like I was wrong - that's almost certainly what is happening - thanks.
19:12Bronsanp
20:09corecodemy instaparse grammar is amazingly slow
20:09corecodei wish i knew why
20:09tavoeIf I want to do http routing in clojure, I think the cannonical tools are "ring" and "compojure". Where can I find directions on using those tools? I'm finding lots of unfinished documentation, but nothing actionable. It's driving me a bit batty
20:10weavejestertavoe: The Ring and Compojure sites have wikis of documentation. Presumably you’ve found that not enough or confusing?
20:13ambrosebscorecode: have you checked it for ambiguities?
20:14corecodei am trying to
20:14corecodethere seem to be internal ones, or at least there were
20:14corecodebut it is difficult to find them
20:17mikefikestavoe: LispCast has a video covering Ring and Compojure
20:17amalloycorecode: my experience has been that anything you can do with instaparse is quite slow, but you can try profiling it to see what's taking all the time
20:18tavoemikefikes: thank you. I probably shouldn't have asked. I just need to take a step back, breath, and move more slowly.
20:20mikefikestavoe: I've felt the same way. It'd be nice if there were books covering some of these libraries.
20:20corecodeamalloy: :/
20:21tavoemikefikes: It seems like a lot of the tutorials I find were written ~2011, and the libraries have changed since then.
20:21raspasovthere is this project which a nice starting point for a whole suite of libs for Clojure dev, especially web development https://github.com/priyatam/ringo
20:24raspasovtavoe: I've also found the http-kit documentation page to have good examples for Compojure integration http://http-kit.org/server.html
20:28ben_vulpeshow would i assert that an argument to a function is of class [B in a pre-map?
20:29weavejesterben_vulpes: I think you have to do something like: (def byte-array-class (class (byte-array [])))
20:30weavejesterben_vulpes: (instance? byte-array-class x)
20:31ben_vulpes,(= (Class/forName "[B") (class (byte-array 10)))
20:31clojurebottrue
20:31ben_vulpesyikes
20:31ben_vulpesmwell thanks weavejester
20:31weavejesterI would not have expected that to work :)
20:32ben_vulpesi don't know what to expect anymore, but that seems fine for now
20:33dbasch,(= (str (class (byte-array [1 2 3]))) "class [B")
20:33clojurebottrue
20:33dbaschugly though
20:33ben_vulpesthat's probably safer.
20:34ben_vulpeser
20:34ben_vulpeshang on
20:34ben_vulpesmaybe i'll just use the class of the output of byte-array
20:34ben_vulpesthe output of (class (byte-array 0))
20:34ben_vulpesstill, kinda floppy.
20:37raspasovyou know about {:pre [] :post []} construct?
20:45ben_vulpesyeah, and using it raspasov.
20:45sineerf
20:47corecodehmm, my java regex pattern produces a stack overflow
20:48corecodemaybe i don't know how java does its regex parsing
20:50raspasovben_vulpes: are you developing a type checker of some sort?
20:53gfredericksis there something I'm supposed to set in my project.clj so that `lein deploy` goes to clojars?
21:04gfrederickscorecode: you're building a regex programmatically?
21:08corecodeno
21:08corecodei'm just trying to find the speed issue in my grammar
21:09corecoderegexp matching all takes 10 ms, regexp matching all command-by-command takes 10 ms (now without stack overflow), regexp matching command + instaparse doing the repetition = 160 ms
21:10corecodethat's a lot of overhead
21:10ben_vulpesraspasov: that'd be far over my pay grade :P
21:10ben_vulpesraspasov: no, i just want a little bit of rigidity around function inputs and outputs.
21:11raspasovhaha ok :)
21:11raspasovyea, makes sense
21:11ben_vulpesi played with haskell for the past three weeks and now all new functions that i write come complete with :pre conditions at the very least :D
21:11ben_vulpes,(.toByteArray (bigint 60002))
21:11clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: toByteArray for class clojure.lang.BigInt>
21:12dbasch,(.toByteArray (biginteger 1))
21:12clojurebot#<byte[] [B@c9bbcb>
21:12dbasch,(class (bigint 1))
21:12clojurebotclojure.lang.BigInt
21:13dbasch,(class (biginteger 1))
21:13clojurebotjava.math.BigInteger
21:14ben_vulpesthanks, dbasch
21:16ben_vulpes,0x0000ea62
21:16clojurebot60002
21:16ben_vulpesman
21:16ben_vulpesi have no idea what i'm doing
21:17ben_vulpesi think that i want to write a function that takes in bigintegers like 60002 and then returns a byte array that will serialize to 62ea0000 over tcp
21:17corecodeintbuffer
21:17corecode?
21:19corecodeor does biginteger serialize like you want?
21:23dbaschjava bigintegers can have arbitrary length
21:23dbaschintegers and longs are fixed
21:23dbasch4 and 8 bytes respectively
21:25ben_vulpesit looks like using .putInt into a bytebuffer and then getting the contents of that bb into a buf will work
21:25ben_vulpesbut it's the wrong endianness
21:25ben_vulpes:(
21:25ben_vulpesoh well, pick it up again later i suppose
21:26corecodeyou can change the endinaness of a buffer
21:26corecodejava with binary data sucks
21:27ben_vulpesso im learning
21:33yediis there a function to replace all occurrences of a specific substring in a string to to a different string
21:34corecodeclojure.string/replace
21:40corecode:/ this regexp is way faster than the parser... i might have to write a parser manually :(
22:02TEttingerwell clojure just helped me solve the NPR sunday puzzle
22:03TEttingerName a certain country. Change one letter in its name to a new letter and rearrange the result to name another country's capital. Then change one letter in that and rearrange the result to name another country. What geographical names are these?
22:09yedicorecode: ty btw, im pretty dumb
22:16squeedeejustin_smith: thanks again man. I really like this solution https://github.com/squeedee/lsystem/commit/04fa8e077b8f13e9d9fad80be24e55608b76c8e0
23:57havenwoodjust a silly aside, but a Ruby FizzBuzz with Transducers: https://gist.github.com/havenwood/c5c5b48bd96b77bea53d