#clojure logs

2012-11-13

00:00amalloydangit, brainproxy, it's hard to even tell you what filterM's arg/return types are without haskell type notation, and iirc you don't know any haskell
00:01RaynesGive him a less in Haskell type signatures.
00:01RaynesIt isn't that hard.
00:02Rayneslesson
00:03amalloywell, filterM has type: filterM :: (a -> m Bool) -> [a] -> m [a]. so it takes a list of Things, and a way to turn a Thing into a boolean wrapped in a monadic value, and produces a list of Things wrapped in a monadic value
00:04RaynesDon't quit your day job.
00:04amalloychoke on a bucket of slugs
00:06mattmossamalloy: He doesn't know Haskell. He's also on the phone at the moment, so give him a few to get back to you.
00:07amalloyare you two in the same room?
00:08mattmossHe's in the next room, but his voice isn't... soft. ;)
00:08ToxicFrogI'm saving "choke on a bucket of slugs" for later, thanks.
00:11amalloyToxicFrog: well, i toned it down a bit for #clojure. google for sebastian droge if you're interested in the original
00:11ToxicFrogI'm familiar with the original, but I like this version
00:12amalloyenjoy, then!
00:12RaynesThat's strange.
00:12Raynesmattmoss: Where are you people?
00:13mattmossRaynes: brainproxy and I share an apartment. In fact, I work for him. St Louis
00:13RaynesThat's pretty hot.
00:13RaynesI mean, cool.
00:13mattmosso_O
00:16Raynesmattmoss: Are you wanting to stop reading after you get to a certain line?
00:16RaynesAlso, sorry for the innuendo. I'm that kind of person.
00:17mattmossRaynes: I want to start up a server, see that a certain line of output has passed (to know the server is fully initialized), run some other code against the server, then send input to the server/process to cleanly shutdown the process.
00:17mattmossRaynes: No worries. ;)
00:18mattmossRaynes: I'm trying let-programs, but I get the same results... it's basically hanging in there somewhere. If I add :background, then the program returns a future immediately, but that future never realizes.
00:18RaynesReason I was asking is because conch.sh will always consume all output and will hold it in memory, so you have to be careful if it's going to be dumping a lot of stuff you don't care about. You don't have to read it all, but it stays in memory until you do.
00:19RaynesIt's hanging with {:seq true}?
00:19RaynesIf so, are you doing this at the repl and trying to print the seq?
00:20mattmossYes to hanging with :seq true. Yes, at repl.
00:21mattmossAs to consuming output... there shouldn't be too much, and I can deal with that.
00:22mattmossI'll try to not dump the seq to the repl immediately, see if it doesn't hang.
00:23mattmossOkay, ya, that seems like the issue.
00:23RaynesYeah, if you try to print the seq you wont see any output at all until the whole program is done.
00:23RaynesYou can do something like (take 2 ..).
00:23mattmossRight....
00:24mattmossCool, looks good. I'll rewrite my stuff using that and try the whole again. Thanks!
00:25brainproxymattmoss: are you listening to my phone conversations again??
00:25lazybotbrainproxy: What are you, crazy? Of course not!
00:25brainproxyfor shame
00:25mattmossI have a love/hate relationship with laziness. :)
00:25RaynesHope it works. If not, open an issue with some code that breaks and I'll try to sort it out.
00:25mattmossbrainproxy: Yes. Yes I am. I can't help not.
00:26mattmossRaynes: Thanks.
00:26brainproxyamalloy: no worries, tbh filterM is a bit of distraction at this moment, but I'll get to it
00:26brainproxyRaynes: i agree, i need to learn me some Haskell
00:26Raynesbrainproxy: Haskell was my first language, but I hadn't used it until a week ago for like 4 years. So much fun now that I'm not stupid.
00:26Rayness/stupid/as stupid/
00:26brainproxyin fact, I've started in on the "learn you a haskell..." book, but still in the early parts of the book
00:27RaynesI skipped to the typeclass chapter and read up through monads.
00:27RaynesI'm like king of the Haskells now.
00:27brainproxy:p
00:28RaynesLook, I wrote some JSON parsing code that makes use of applicative functors and liftM: https://www.refheap.com/paste/6612
00:28RaynesObviously I win all future contests.
00:31mattmossget-drunk, lol
00:40brainproxyso satisfies? is only for protocols? is there a similar test for interfaces?
00:43dnolenbrainproxy: instance?
00:43brainproxyinstance? is the way to go?
00:43brainproxydnolen: cool, thanks
00:43dnolenbrainproxy: satisfies? is also a performance killer on Clojure JVM - use wisely.
00:44brainproxydnolen: there use will only come into effect when a certain runtime flag is set
00:44brainproxyi.e. one which is for dev purposes, not prod code
00:44brainproxyso should be okay
00:44brainproxybut thanks for the tip
00:56Raynesmattmoss: Bahaha, I suck at names.
00:56mattmosslol
00:58mattmossSo... one last Q. It seems that the lazy-seq of the process output can't be released until the process is finished, correct? Because of the queue-stream stuff....
00:59RaynesReleased?
00:59mattmossSo,... I can (take 5 ...) to get the first five lines, but a subsequent (take 5 ...) will get me those same 5 lines.
00:59RaynesYes, of course. It isn't a queue.
00:59RaynesThere is a queue underneath the hood. I should probably expose it somehow, if I don't already.
01:00mattmossRight. Just making sure my head is on straight.
01:00mattmossI'm using the :verbose option so I can feed the input and shut the process down cleanly.
01:01mattmossWhiel still watching the output
01:01RaynesFWIW, if things don't work it's because I haven't actually used this library for anything yet and thus you're currently a Guinea pig.
01:02mattmossWell, I didn't see many other options aside from clojure.java.shell and conch, and the former wouldn't accomplish any of this.
01:02RaynesI want conch.sh to be the go-to library for this, so thanks for working with it.
01:04RaynesAnyways, in case you're wondering why I'm doing all the queue crap behind the scenes, it's because Java is the devil and the process API does not allow you to read unread data from a process if that process has been destroyed, so for timeouts to work properly and allow you to get any data you haven't yet consumed after the process is destroyed you have to make sure you process that output in real-time. So I queue it up and you get a lazy-seq of
01:04Raynes that queue.
01:04RaynesIf the process gets killed and there is unread output, you can get at it with conch.sh.
01:05Raynesmattmoss: Also, http://amoffat.github.com/sh is where the whole concept comes from.
01:05RaynesIn case you were curious.
01:05mattmosscool
01:08Raynesmattmoss: Also sorry for shoving it down your throat, I just haven't had anyone who cared enough to let me do so until now. :D
01:09mattmossRaynes: Not at all... Hey, I need more control than simply (sh "ls"), so I'm happy to help get conch more stable/usable/whatever.
01:09mattmossRaynes: Beats me trying to figure out all sorts of Java nonsense.
01:09mattmosslol
01:10Raynes<3
01:20mattmossWoot!
01:20mattmossRaynes: I think I've got what I need... awesomeness.
01:21mattmossRaynes: In any case, my brain is fried, and I need to chill for the night. Tomorrow, I can gist up some sample code for you to see.
01:22RaynesCooool
01:22Raynesmattmoss: Night.
01:24mattmossSeeya.
01:34tomojhmm (defn wrap-dispatch [app dispatch] (fn [req] ((dispatch app req) req)))
01:50amalloydoes anyone know if a decent parser-combinator library exists for clojure? i know about fnparse, but i think that's stuck in monolithic-contrib, and i've heard of parsley but don't know if it's any good
01:51noidiznDuff, re: my question regarding the += operator yesterday, I needed it for JS interop
01:52noidiI ended up writing a macro that expands (+= foo.bar baz) to (set! foo.bar (+ foo.bar baz)), which results in foo.bar = foo.bar + baz in the generated JS
02:04Raynesamalloy: I think parsley is kinda the only option. I have a sneaking suspicion that the library is probably one big version range though.
02:05RaynesSigh
02:07amalloynoidi: when i was building some transients in jvm-clojure, i wrote a macro change!, such that you could write (change! (.bar foo) + baz)
02:07amalloyyou might do the same rather than use a special-purpose +=
02:09ivenkysfolks - is there a preferred _style_ of declaring datastructures - i.e. shorthand #{} or (set {})
02:10ro_stthe shorthand is reader sugar for the longhand. presumably it's there for a reason :-)
02:10ro_sthaving said that, i do find myself using (list …) quite a lot
02:10emezeskeWell (list ...) is much prettier than '(~x ~y ~z)
02:11emezeskeBut I think #{x y z} is generally prettier than (set x y z)
02:11amalloyemezeske: (set x y z) is also broken, isn't it?
02:11amalloyyou mean hash-set
02:11emezeskeamalloy: Yeah that
02:11ivenkysro_st: emezeske : hmm just getting into clojure and converting a project from Java to Clojure at work - so its one of those best practices thing -
02:11ro_stivenkys: you'll quickly find that it doesn't matter much.
02:12Raynesivenkys: You usually have a reason for using one or the other.
02:12emezeskeivenkys: I am not an authority on the subject, but I say use the literals unless you have a reason not to (e.g. you're building up a set of unknown size, etc)
02:12ro_stclojure is so concise that most decisions are small and easy to change
02:13RaynesFor example, why would you do (some (hash-set \x \y) ..) instead of (some #{\x \y} ..)
02:13RaynesIf you had a vector instead of a literal, it'd make sense to do (some (set myvec) ..)
02:14ro_styeah. or (fn [& args] (apply hash-map args)) to get all the named args. if i'm correct, you can only gather them like this, and you can't use a literal {}
02:15ivenkysRaynes: in some cases you cant use a literal - but in other places you get both versions - the reader sugar and the literal - i am sort of not sure whats considered better , i prefer the literal simply because its more readable -
02:16ro_stthen that's the right thing to do
02:16ro_stgenerally, literal for declaring new data, fns for converting one collection type to another
02:17ivenkysro_st: which is what i have gone with at the moment - i am sure someone in the team might have a different idea - but lets see how it rolls
02:17ro_stthat's how things have settled for me
02:17ivenkysro_st: Raynes :emezeske : amalloy : gents thanks for the help
02:18ro_stagain - it's very easy to change this decision later. the thing to realise with clojure is that it's actually just getting out of your way and you can focus on solving the problems you're working on
02:20ivenkysro_st: thats hopefully the plan - very early stages yet - taken a small "DSLish" component of a large high volume, low latency transaction engine (think trading engine)
02:26brainproxyhmmm, I want to call `and` on a collection which is being generated programatically... but `and` is a mcro
02:26brainproxy*macro
02:26brainproxytyring to cook up a way to work around that, but maybe I'm missing something
02:27amalloy&(doc every?)
02:27lazybot⇒ ------------------------- clojure.core/every? ([pred coll]) Returns true if (pred x) is logical true for every x in coll, else false. nil
02:27ro_stahh it's a macro so that eval is lazy
02:28brainproxyamalloy: yeah, but every? isn't quite what I wanted, but maybe it will have to do
02:28amalloybrainproxy: every? is exactly what you wanted, given your initial question
02:28amalloy(every? identity coll) ~= (apply and coll)
02:29brainproxyyeah, just realized I could use identity with it to nice effect
02:29brainproxythanks
03:16maleghastMorning All...
03:16maleghastAnyone in here had any experience with SpyGlass?
03:17maleghastI may be "letting my n00b show", but I can't work out from the docs how to handle the memcached server(s) configured in the connection I define being down.
03:17maleghastAny ideas?
03:57olliveraanyone knows a clojure bluetooth api?
03:58maleghastSorry, no...
03:58maleghastThis might be of some help to you though -> https://github.com/samaaron/serial-port
04:00augustlollivera: I tend to look for Java libraries for that sort of thing
04:01augustla lot of clojure libraries like that are just wrappers on top of java anyway ;)
04:04olliveraaugustl, so I just need to create a wrapper to the java api ... isn't it?
04:04_ulisesollivera: if there's nothing else around, I'd say yes
04:04_ulisesollivera: make sure you release it too! \o/
04:05augustlyeah
04:05ollivera_ulises, yes, I will do it
04:06augustlI generally don't find small clojure wrappers to be very useful
04:07augustlsince calling Java from Clojure is generally very terse
04:08_ulises"terse"
04:08augustlcan I use that word there? :)
04:08_ulisesyou can, but not in the same sentence as the word Java
04:08_ulises;)
04:09augustlgood enough for me! https://www.refheap.com/paste/6618
04:09_ulisesaugustl: how about this http://clojure.org/jvm_hosted
04:13augustlor this, omnomnom https://www.refheap.com/paste/6534
04:13_ulisesthat one's not too bad
04:14augustlobviously, if the Java API is verbose then your java interop will be too ;)
04:14_ulisesindeed
04:14augustland given the swing example you linked to, I too would probably prefer a clojure wrapper of some sort
04:14_ulisesthat's why I prefer if somebody else writes a wrapper around it, even if it's a super-thin one
04:15augustlso we seem to have a unique case here on whether or not to wrap: "it depends"
04:15augustlno silver bullet :(
04:15_ulisesindeed not
04:15amalloythat's not necessarily true, though. you can actually remove a lot of the rubbish verbosity just by writing in a better language, especially with doto and -> when creating new objects
04:15_ulisesI personally prefer to always wrap
04:15_ulisesI used to use memfn a lot
04:17augustlamalloy: Clojure is the best Java I've seen :)
04:17amalloy(doto (Person.) (.setName "frank") (.setFriends (doto (FriendList.) (.add x) (.add y)))) is a good example
04:17amalloyyou don't have to repeat anything, or invent names for the intermediate objects just so you can repeat those names
04:19augustlbeen using Lucene's Java APIs with no probs at all
04:19augustland in another project I'm mixing amd matching the Java APIs Jetty and CometD, also works great
04:20amalloyit's even a better example of clojure's power to trim out mess if you give the object a really awful API for working with friends: (doto (Person.) (.setName "frank") (-> (.getFriends) (doto (.add x) (.add y))))
04:22augustlanother pretty nice example imo: https://www.refheap.com/paste/6619
04:22Sgeo_What's that do on line 38 for?
04:23augustlSgeo_: I like to be explicit about doing imperative calls with side effects
04:23augustlso it's not for technical reasons
04:23amalloyis Document a Collection? it'd be nice to use .addAll once instead of .add zillions of times, if you can
04:24_ulisesamalloy: I don't think Lucene Documents are Collections
04:24_ulisescould be wrong though
04:24amalloynope, apparently not
04:24augustlhttp://lucene.apache.org/core/4_0_0/core/org/apache/lucene/document/Document.html
04:25augustlit's Iterable
04:25augustldoes that mean it's a Collection?
04:25amalloyno
04:25augustlI see
04:27amalloyfwiw, i think it's a little nicer to do it something like (doseq [field (cons (StringField. ...) (for [[attr value] data] (field-for-data ...))) (.add document field))
04:27amalloyyou get to spend more cognitive time in pure functions that way
04:28augustlTIL something new about doseq at least :)
04:29amalloyeh?
04:29augustlTIL = internet speak for today I learned
04:29amalloyi know. i don't think i said anything interesting about doseq
04:30amalloyit's just...it takes a collection, and you can use cons to build that collection
04:30augustlah I misread it
04:30clgvamalloy: let's build you a shrine anyway ;) :D
04:31augustlso does `for` return a collection? I would probably have used map there
04:31clgvaugustl: yes for does return a lazy seq
04:31augustls/collection/seq
04:31augustlclgv: I see
04:31Sgeo_,(class (for []))
04:31clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (1) passed to: core$for>
04:31Sgeo_,(class (for [] (do)))
04:31clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: >
04:32Sgeo_,(class (for [_ []] (do)))
04:32clojurebotclojure.lang.LazySeq
04:32clgv,(source for)
04:32clojurebotSource not found
04:32clgvah right. the bots have none...
04:33Sgeo_The bots have no class?
04:33Sgeo_>.>
04:34amalloy$source for
04:34lazybotfor is http://is.gd/hqDKdS
04:34amalloyi warn you now, shield your eyes
05:05clgvamalloy: yeah, evil code generation with loops afair ;)
05:09augustlamalloy: haha, wow
05:26fckwBuongiorno. Does anyone know whether there exist any databases that are homoiconic?
05:27foodoofckw: interesting question. What would be the consequence of a homoiconic database? All database schema can be contents of other tables?
05:28fckw@foodoo: I have something in mind how this might look like. But before trying to write my own database, I wanted to hear whether such a thing exists already.
05:29fckwAnd yes, basically there would be no separation between the "database schmea" and the data.
05:29maleghastThere is some weird shit going on in my IRC client today...
05:29foodooon Freenode at least
05:30Raynesmaleghast: It's just netsplits. It happens to everybody.
05:30Raynes$google netsplit
05:30lazybot[Netsplit - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Netsplit
05:31maleghastRaynes: Thanks - that would indeed explain it :-)
05:31RaynesI aim to please.
05:34babilenmaleghast: freenode staff is sorting out routing issues (check your global notices)
05:35maleghastbabilen: global notices (my n00b is showing again)
05:36babilenmaleghast: notices sent to everyone on the network (10:00 [GLOBAL NOTICE] - In a few minutes there will be some network disruption whilst we sort out some internal routing issues. It shouldn't take too long, but could be a bit noisy. Thank you for your patience.) -- But this is rather off-topic in here, so lets drop it :)
05:37fckw@foodoo: Sorry, some idiot seems to be flooding the chat.
05:37RaynesEh
05:38RaynesIt is the middle of the night for most of the US and nobody cares about mild offtopic chatter in here if it isn't disrupting Clojure discussion.
05:38fckwSo, again: Does anyone know of the existence of a "homoiconic database"?
05:38RaynesSo you're okay.
05:38RaynesAlso, nobody is flooding the room if you're talking about here.
05:38RaynesIt was a netsplit.
05:39fckwAh, ok. I was thrown out anyway multiple times.
05:41fckwOh, and another question: Does anyone know whether there exists a Java/Clojure implementation of HashMap or HashTable using longs as keys?
05:42fckw(Well, maybe it does not make so much sense in Clojure.)
05:43maleghastfckw: Were you asking about homiconic database(s) before the Netsplit sent everything a bit funny?
05:43fckwYes.
05:44maleghastHave you looked at Datomic -> https://github.com/Datomic
05:45fckwNope, thanks. I'll have a look.
05:45maleghastI'm not certain that it's what you are looking for, but it stands a good chance of being some of what you are looking for.
05:45maleghast;-)
05:48fckwI am neither certain what I am looking for. :D
05:48fckwDo you happen to also know some answer to my other question: A HashMap with the possibility of using longs as values?
05:49maleghastfckw: I have to be honest I have no idea - bit of a beginner at the ole Clojure myself, and I've not had to do what you describe, so I've not investigated it...
05:49fckwmaleghast: Ok, no problem. It's honestly not so much a Clojure question but more a Java one.
05:58teromfckw: couldn't you just use HashMap<Long, Object> or something similar?
05:59_ulisesterom: not sure you can check equality on Longs, and hence you can't really retrieve (k,v) from such hashmap
05:59fckwUsing a Long as a key is internally changed to an int value, as far as I know.
06:00teromah, ok...
06:01rcg-workhi
06:02rcg-worki got a question with respect to "objects" in clojure...
06:02rcg-worki want to do this: http://pastebin.com/m0Pc3m3s
06:02rcg-workbut all the conds etc. look a little strange.. also dispatching an action based on a keyword looks awkward
06:02rcg-worki am sure there is a better (more idiomatic) solution
06:03rcg-workcould please point me into the right direction?
06:03augustlwhy not different methods altogether?
06:03augustlscheduler-stop, scheduler-stop-now, etc
06:04_ulisesrcg-work: you have cond with single cases, better use if, also what augustl and for the [k] version, you have two branches which do exactly the same, I'd combine them with (or ...)
06:04augustls/methods/functions
06:05augustlanother thing, won't (scheduler :stop) just stop the newly created scheduler?
06:05augustli.e. do nothing? I'm not familiar with the Executors stuff though
06:05rcg-workaugustl, yep (scheduler :stop) would do nothing, but this i would assume the programmer to handle
06:06augustlI tend to use methods with different dispatches based on arguments be methods that does the same thing
06:06rcg-workthe point is that i want to encapsulate the executor object while still providing convenient access to it with functions and at the same time want to keep my code concise
06:06augustllike (def my-func ([thing] (my-func thing {})) ([thing opts] ... actual impl...))
06:07ChironHi, I have a seq that contains maps . every map has the key :x . how to find the min :x ?
06:07augustlin that case, having an optional "opts" argument
06:07augustlrcg-work: your method seems to do completely different things though, I personally find that a bit weird
06:07augustlbah, I need to stop calling functions methods
06:07_ulisesChiron: (reduce min (map :x your-seq))
06:07_ulisesaugustl: good idea ;)
06:08Chiron_ulises: wicked :)
06:09_ulises,(reduce min (map :x '({:x 1} {:x 2} {:x -1 :y -10})))
06:09clojurebot-1
06:09_ulisesphew
06:09_ulisesit does work :)
06:09Anderkento ye of little faith
06:09rcg-workaugustl, well, my function creates a function.. that then, depending on how it is called does different things, yes
06:09Chiron_ulises: what if i want to the map that holds the min :x ?
06:10rcg-workmy idea was to encapsulate the executor via a clojure and then access it via the inner fn
06:10Chiron_ulises: i mean i want to get the map that holds the min :x
06:10rcg-workand dispatch in the inner fb based on number of args and keywords
06:10rcg-work*fn
06:10augustlrcg-work: you can still encapsulate it with multiple functions :)
06:10rcg-workcan i?
06:10foodoorcg-work: If you have only one condition, it may make sense to use (when) instead of (if) because the lack of an else-clause is then more obvious
06:11_ulisesChiron: what if you have two maps with the same min?
06:12Chiron_ulises: then one of them is ok
06:12rcg-worki found this http://pastebin.com/dM2pfvH5 by stuart halloway
06:12_ulisesChiron: if you don't care, you can reduce with your own fn along the lines of (fn [m1 m2] (if (< (m1 :x) (m2 :x)) m1 m2))
06:12rcg-workthere he uses a map to select the appropriate function
06:12rcg-workwould this be more idiomtic
06:12rcg-work?
06:13_ulisesChiron: keep in mind that that fn assumes :x is in the map, so you probably need to actually (get m1 :x Integer.MAX_VALUE) but that assumes you're dealing with integers, etc.
06:13_ulisesChiron: but you see where I'm coming from
06:13rcg-workfoodoo, i just used a cond with a single statement there in case i want to extend it later
06:13augustlrcg-work: http://pastebin.com/xmZtu0jr and so on
06:14augustlit does the same thing (except I changed the stop methods to take an executor), but it does it with multiple functions instead of manual dispatch based on arguments
06:14rcg-workaugustl, but this way i expose the object to my user
06:14augustlrcg-work: your original function probably doesn't do what you think it does, then ;)
06:14rcg-workaint that considered bad? as now the user can do arbitrary, possibly dangerous things, with the object?
06:14augustlit will create a new executor object every time you call it
06:14Chiron_ulises: will try, thanks
06:14_ulises,(reduce (fn [m1 m2] (if (< (m1 :x) (m2 :x)) m1 m2)) '({:x 1} {:x 2} {:x -1 :y -10}))
06:14clojurebot{:x -1, :y -10}
06:15_ulisesChiron: ^^^
06:15AnderkentChiron: alternatively, (first (sort-by :x [{:x 1} {:x 13} {:x -1}]))
06:15rcg-workaugustl, only when i call (scheduler) this gives me function which i would use then
06:15_ulises,(reduce (fn [m1 m2] (if (< (m1 :x) (m2 :x)) m1 m2)) '({:x 1} {:x 2} {:x -1 :y -10} {:y 5}))
06:15clojurebot#<NullPointerException java.lang.NullPointerException>
06:15_ulisesChiron: ^^^^
06:15augustlrcg-work: doh I misread it
06:15Anderkent,(first (sort-by :x [{:x 1} {:x 13} {:x -1}]))
06:15clojurebot{:x -1}
06:15augustlrcg-work: nvm :)
06:15_ulisesAnderkent: thanks :)
06:15rcg-worksorry bbl
06:16Anderkentit's a little less efficient so if your map array is huge you might want the reduce approach
06:16Chironcool ! thanks fellas
06:18augustlrcg-work: interesting problem, my clojure-fu is low but I'm trying to think of something
06:24augustlrcg-work: the only alternatives i can find return a map that contains the functions you can call, so it becomes ((:stop-all my-executor))
06:25augustlrcg-work: in general I wouldn't have worried that much about encapsulation. For portability and future proof-ness you could always make your own defrecord that you put the executor object in. It'll be accessible, but it allows you to change what it is composed of without affecting the users of your API
06:26augustlrcg-work: also, from http://clojure.org/datatypes, "Encapsulation of information is folly" ;)
07:08tgoossensDid factorial on 4clojure. how can i usefully compare the quality of both snippets? http://pastebin.com/vQZ3ZfBP
07:12rcg-workaugustl, right, i see.. thanks
07:13augustlrcg-work: keep in mind that I'm no expert though ;)
07:13Anderkenttgoossens: what do you want to compare? First one's obviously better just because it uses the proper recursion constructs
07:14tgoossensi was mindblown about the result that someone else produced. That i asked myself the question: "has this other more difficult code an advantage over my solution?"
07:14AnderkentNo, they just didn't know about recur I asume
07:15Anderkentthey're doing recursion themselves if I'm reading it correctly
07:16Raynestgoossens: The first one is better simply because it isn't completely hideous like the second one.
07:16ludstonAnyone in this room do Clojurescript?
07:17thorwildoes it matter if functions of 1 argument are wrapped in () or not, inside a (->) form? so far i thought i t doesn't, but wonder about examples i see
07:17ludston(#clojurescript is a bit ghetto)
07:17Anderkentthorwil: no, -> makes its args a list if they're not
07:17Anderkent,(source ->)
07:17clojurebotSource not found
07:17Anderkent,(doc ->)
07:17clojurebot"([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
07:20thorwilty
07:22hyPiRionYou can check it out by using macroexpand-1
07:23hyPiRion,(macroexpand-1 '(-> foo (bar baz) bbq))
07:23clojurebot(clojure.core/-> (clojure.core/-> foo (bar baz)) bbq)
07:24alexnixontgoossens: looks like the second one is using the y combinator, so not very readable but cool from a first-principles point of view
07:25tgoossenswhat do you mean "first-principles " ?
07:25Anderkenttgoossens: lambda calculus
07:25thorwilkinda using lego blocks, not lego assemblies
07:26Anderkentmore like making the lego blocks yourself instead of buying them
07:27tgoossensok
07:27AnderkentHonestly it looks like they just took the lisp example from http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator
07:28Anderkentand changed define->def lambda -> fn and some brackets ;P
07:28Anderkent(i ment scheme not lisp actually)
07:29tgoossensdo you believe it necessary to study lambda calculus in order to really understand functional programming
07:29tgoossens?
07:30Anderkentnot at all, but it's pretty interesting how much you can do with such a limited syntax
08:02ivenkysAny suggestions on documentation to _really_ understand HOF in Clojure ?
08:04stevenfxivenkys: http://goo.gl/YXsgO
08:04stevenfxI have not read it tough
08:05stevenfxjust searching about...
08:05babilenivenkys: I like the way in which they are introduced in Clojure Programming (http://www.clojurebook.com/) -- In particular the logging example is wonderful (as is the rest though)
08:06ivenkysstevenfx: i saw that one - i "sort of" understand HOF's but when it comes to actual development i tend to not use them even when they finally turn out to be the best way - i guess i want to try and understand them in a bit more depth
08:07ivenkysbabilen: heard good things about that book - its time to order it i guess
08:07Anderkentivenkys: sounds more like pattern matching issue than understanding - there's not that much to understand in HOF, but you need to match your problem to a suitable HOF
08:07ivenkysbabilen: stevenfx : thanks gents
08:08Anderkenti.e. you need to know and easily recall the functions available in clojure, which I guess mostly comes from practice
08:08babilenivenkys: I like it a lot. It certainly is my favourite together with Joy of Clojure among the current lot .. (well have read the old "Programming Clojure" and "Clojure in Action" as well, so can't really compare it to many)
08:09babilenivenkys: I am also looking forward to https://leanpub.com/fp-oo
08:10stevenfxbabilen: That looks interesting
08:14ivenkys~ping
08:14clojurebotPONG!
08:15ivenkysbabilen: that book looks interesting - thanks
08:16stevenfxHas anyone here read the book?
08:16maleghaststevenfx: Which book?
08:16stevenfxhttps://leanpub.com/fp-oo
08:19maleghaststevenfx: Thanks - looks interesting, I may well pick it up - I loved his book about everyday scripting with Ruby
08:19stevenfxmaleghast: babilen suggested it
08:20stevenfxmaleghast: Yeah I am also looking into maby getting it
08:20Mr_Bondstevenfx: awesome!
08:20maleghastThanks babilen
08:20babilenmaleghast: No problem -- I am currently debating if I want to buy it right now ....
08:52thorwilhow's (defn logout [r] /friend/logout (ring.util.response/redirect "/") wrong
08:52thorwilthat it triggers cemerick.friend$logout$fn__1347 cannot be cast to clojure.lang.IPersistentMap ?
08:52ToBeReplacedit returns the function, wrap another set of parens
08:52clgvthorwil: that's no valid clojure: /friend/logout you probably forgot ""
08:53Anderkentthorwil: you're also missing a closing paren
08:53thorwil(defn logout [r] (friend/logout (ring.util.response/redirect "/"))
08:53thorwilso much for retyping it to not paste linebreaks :)
08:54clgv;)
08:54clgvseems there is some anonymous function created in logout that accidently is casted to IPersistentMap
08:55clgvso probably some wrong parameter type.
08:55Anderkentit should be
08:55Anderkent(-> r
08:55Anderkentoh nvm
08:56thorwilmy first thought was that i should def logout, relying on friend/logout delivering a handler. but with that, i get a 404
08:56Anderkentfriend/logout takes a handler and gives you back a handler, you need to apply the result to the request
08:57Anderkenti.e. (defn logout [r] ((friend/logout (ring.util.response/redirect "/")) r)), i think.
09:00thorwilAnderkent: that's 404
09:00Anderkentare your routes defined correctly?
09:01Anderkent(is it 404 on trying to logout or on the redirect/)
09:01thorwilit's 404 still on /logout
09:02Anderkentand what's your route definition for /logout?
09:03thorwilAnderkent: https://www.refheap.com/paste/6620
09:04thorwilas if i just say '["logout"] h/logout' that is rather lacking in context
09:06Anderkentright, I don't know moustache at all, so can't help you there, sorry.
09:06thorwilthanks for looking! :)
09:11cgrandthorwil: need help w/ moustache?
09:13thorwilcgrand: well, the intersection of moustache and friend, i guess
09:14cgrandwithout friend, your routing works?
09:14thorwilcgrand: that h/login called in https://www.refheap.com/paste/6620
09:15thorwilthe handlers https://www.refheap.com/paste/6621
09:15thorwilcgrand: yes, everything prior to introducing friend was a non-issue
09:16thorwilnow logout fails with cemerick.friend$logout$fn__1347 cannot be cast to clojure.lang.IPersistentMap
09:17Anderkentthat's because you're returning a handler as if it was a response
09:18cgrandwhat is v/login?
09:19thorwilcgrand: delivers a hiccup generated login form. that part works
09:20cgrandv/login is a response map or a function returning a response map?
09:21thorwilcgrand: function returning a response map
09:21Anderkenthttps://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L81 as you can see friend/logout wants you to give it a handler, it then returns a function that you call with the request
09:22Anderkenttry something like
09:22Anderkent(defn- logout- [r] (redirect "/"))
09:22Anderkent(defn logout [r] ((friend/logout logout-) r))
09:22cgrandthrowil: so some parenthesis are missing around v/login: you are returning the function
09:26thorwilcgrand: my answer was not appropriate then. view.clj: https://www.refheap.com/paste/6622
09:26cgrandok
09:29thorwilcgrand, Anderkent: thank you, Anderkent's 2 definitions do the trick
09:33cgrandthorwil: or (def logout (app friend/logout (fn [r] (redirect "/"))))… or bubble the friend/logout application up to the routes def
09:33thorwillogout handling seems cleaner in https://github.com/marianoguerra/immutant-recipes/blob/master/friend-acl/immutant.clj
09:34Anderkentthorwil: yeah, that's what cgrand suggested. You can have logout just call (redirect "/"), and then do the (friend/logout h/logout) in your routes
09:34AnderkentI would have suggested that but was too lazy to modify both files ;P
09:35cgrandhttps://gist.github.com/4066032
09:35Anderkent(is that really [friend/logout logout] instead of (friend/logout logout)? Bizzare.)
09:36cgrandit is, but it's a moustache trick
09:36thorwilAnderkent: moustache's app macro is ... wicked :)
09:36cgrandà la -> but in reverse: you can apply several middle wares that way [mw1 (mw2 arg1 arg2) … handler]
09:37Anderkentmakes sense
09:37cgrandand in lieu of handler you can also have a route or method dispatch
09:38thorwili hope i can put all friend stuff in routing, then. so far my plan had been to have it solely in handlers
09:39Anderkentyou should be able to, it's middleware
09:59ro_stanyone done remember-me for a ring web app yet?
10:04ro_stRaynes: any idea how to get noir to write Secure cookies?
10:07ro_sti want to set both of these for my ring-session cookies: http://en.wikipedia.org/wiki/HTTP_cookie#Secure_and_HttpOnly. how?
10:10Anderkentcall put! with a map that has :secure and/or :http-only set
10:11ro_stthanks. where did you see that?
10:11Anderkentdoc for put! says 'to set custom attributes provide a map', doc for ring.middleware.cookies says which attributes are accepted
10:11Anderkent(noir.cookies just wraps ring.middleware.cookies)
10:12ro_stahh, the middleware
10:12ro_stthank you -bow-
10:13ro_stok,so, i don't write the session cookie, ring or noir does
10:13ro_stok i see ring's wrap-session has :cookie-attrs
10:15ro_stah of course. noir's server start has a key for it
10:47gauravagwhat are the built in macros in clojure?
10:49vijaykirangauravag: http://clojure.org/macros
10:51algernongit grep defmacro in clojure/src is also a reasonable estimate
10:53gauravagalgernon: thanks
11:07S11001001,(-> #'defn meta :macro)
11:07clojurebottrue
11:07S11001001gauravag: loop over ns-publics of clojure.core accordingly :)
11:08gauravag,(-> #'defn meta :macro)
11:08clojurebottrue
11:21gauravag(println "is anyone able to see the fun in this?")
11:29clgv&(println ",(println \"I do see the fun in this!\")")
11:29lazybot⇒ ,(println "I do see the fun in this!") nil
11:29clgv,(println "&(println \"I do see the fun in this!\")")
11:30clojurebot&(println "I do see the fun in this!")
11:30lazybot⇒ I do see the fun in this! nil
11:30tgoossenslol
11:30tgoossensthis is funny :p
11:30wingylol
11:31clgv,(println "lazybot, do you like that???")
11:31clojurebotlazybot, do you like that???
11:31lazybotclojurebot: Yes, 100% for sure.
11:31tgoossenswtf
11:32clojurebotWhat is seq
11:32tgoossenswtf did just happen :p
11:33sw1nnhi, any emacs+clojure-mode+auto-complete experts around?
11:33sw1nnI have autocomplete working in emacs+clojure-mode. but the documentation popup isn't working
11:33sw1nnin elisp mode it does work. any idea what the key setting is?
11:37sw1nni'm using nrepl if that makes a difference
11:46mudgeI need to replace a java switch statement with something in clojure, what in clojure should I use in place of a java swtich statement? a conp?
11:46mudgecondp?
11:46technomancypattern matching
11:47mudgetechnomancy: I should use pattern matching?
11:47technomancymaybe
11:47pjstadigcase
11:47mudgetechnomancy: like write a function that uses destructuring?
11:47pjstadigmudge: an example might help
11:47clgvmudge: probably `case`
11:49mudgepjstadig, clgv, technomancy: here's the java code I'm replacing with clojure: https://gist.github.com/b5a54b7ea9e14edba5fa
11:49clgvmudge: you want `case` then
11:50technomancywhatever you do, follow your heart
11:50mudgethe problem with case and condp is that they work on the first matching thing --- well I have two possible things that could match and I want the same result
11:50clgvtechnomancy: feeling romantic today? ;)
11:51mudgetwo cases expressions -> runs one result
11:51technomancyclgv: no just smart-alecky
11:51clgvmudge: case can have more than one value: (case x (2 4) :this 4 :that :default)
11:51mudgedon't know how to do that using clojure case or condp
11:51clgv,(case 4 (2 4) :this 5 :that :default)
11:51clojurebot:this
11:52clgv,(case 2 (2 4) :this 5 :that :default)
11:52clojurebot:this
11:53mudgeclgv: interesting, I see
11:53mudgeclgv: I thought everything within parentheses would cause a function call unless preceded by '
11:54mudgeunless a macro was used
11:54raekmudge: that's almost always the case
11:54raekby convention
11:54raekbut there are exceptions
11:54clgvmudge: no, `case` is a macro which handles lists as more than one value
11:54mudgeclgv: gotcha, thanks!
11:54mudgeraek: thanks
11:55clgvmudge: in case you ever want to match something sequential, you can use a vector in case.
11:55raekah, well macros and special forms are where those exceptions happen, so you seem to understand this already
11:55mudgeraek: is it the case that anything in parentheses is a function call unless it is a macro?
11:56mudgeraek: oh i see, yes in special forms too
11:56mudgeraek: so in macros and special forms then
11:56raekyeaj
11:56raek*yeah
11:57mudgeraek: I guess that's one way to immediately tell if you are working with a macro and not a function
11:57raekand everything inside a macro or a special form can potentially behave specially
11:57mudgeraek: yes, I wonder how much clojure programmers write their own macros for things
11:57raekwell, it can be hard to tell.
11:58raekgenerally you avoid macros if you can express the same thing with "the usual" syntax
11:59mudgereak: what if you can express the same thing with "the usual" syntax, but it is just shorter and nicer to use a macro?
11:59babilenthat is: use a function if possible
12:00raekmudge: then write a function as a base, and then provide the macro as well
12:00raekso that if you need the "underlying" function, you can use it
12:00mudgeraek: okay, cool
12:00raekone example is bound-fn and bound-fn* in clojure.core
12:01raekthe one with the asterisk is the function variant
12:01raek(bound-fn [x] some-expression) is equivalent to (bound-fn* (fn [x] some-expression))
12:02raekin the latter you can provide the function dynamically at runtime, but in the first you are restricted to a "literal"
12:03mudgeraek: cool
12:31devn,(:macro (meta #'defn))
12:31clojurebottrue
12:55actsasgeekFor some reason, lein cljsbuild auto started crashing with a "Too many arguments to def (core.clj:46)" exception. Has anyone seen this behavior before? It's not "inside" cljsbuild (it's not the colored stack trace). It was working just fine until I accidentally killed the JVM. http://pastebin.com/KvY0up7J
13:12dnolenacagle: did you try a lein cljsbuild clean?
13:12dnolenoops
13:12dnolenactsasgeek: ^
13:15Licenserhmm can anyone give me a hint what 'Exception in thread "main" java.lang.NullPointerException, compiling:(login.clj:1)' means?
13:15Licensersomething is ugly in login.clj but nullpoointer exception isn't really helping much :(
13:15actsasgeekdnolen: yes.
13:15AnderkentLicenser: can you post your login.clj somewhere?
13:16dnolenactsasgeek: and you're sure it's not some code change in your own code?
13:16dnolenactsasgeek: like a macro file?
13:17LicenserAnderkent https://gist.github.com/4067414 :) thanks
13:18actsasgeekdnolen: I have just one simple main.cljs file that I've been compiling…I tried emptying it of everything except the namespace and leon cljsbuild still crashes.
13:18actsasgeek(spell checker is determined that lein is leon)
13:19dnolenactsasgeek: did you try starting a new project to see if the issue is actually local to that project?
13:19actsasgeekdnolen: yeah, that's my next test. I went into a different project with clojurescript and lein cljsbuild works there.
13:21AnderkentLicenser: sorry, no clue :P
13:21LicenserAnderkent that was my reaction too ^^
13:21Anderkentare you using lein?
13:21Anderkentor mvn/
13:21Licenserlein of cause :)
13:22Anderkentyou can run DEBUG= lein compile i think
13:22Anderkentfor the full stack trace
13:23Licenserhttps://gist.github.com/4067453 is the stack
13:23AnderkentAFAIK null pointer exceptions in compiling happen when a namespace you import shadows some core functions and gen-class gets confused
13:23LicenserI don't really get smart form it so
13:23Anderkentyeah
13:23Anderkentthat list shadowing
13:23Licenserohhhhh
13:23Anderkentin .user
13:23Anderkentdo :refer-clojure :except list
13:23Licenserbut it's a waring not a i go and die a horrible unintelligable death
13:23Anderkent(dont remember the syntax but that will fix it)
13:24Anderkentit's a warning unless you're compiling and gen-class uses it
13:24LicenserAnderkent it's not clojurescript
13:24Anderkentprobably a bug
13:24Anderkentyes, and?
13:24Anderkentrefer-clojure is not clojure script either :)
13:24Licenserokay because you said refer-clojure thought that's for scriptish stuff
13:24Anderkent,(doc refer-clojure)
13:24clojurebot"([& filters]); Same as (refer 'clojure.core <filters>)"
13:25Anderkentwhat you want is (ns <w/e> (:refer-clojure :exclude [list]))
13:25Anderkentin your .user ns
13:25LicenserI just renamed list into list-users ;)
13:26Licensersneakyer solution
13:26Licenserwhat confuses the hell out of me is that the same thing was working yesterday, perhaps the null pointer exception was still to groggy from the weekend to show up for work
13:28LicenserAnderkent thanks mate that did the trick :) all the sadowy functions killed
13:53aaelonytinkering with clj-ssh.ssh and clj-ssh.cli attempting to tunnel to a server that has a mysql database I'd like to query via clojure.java.jdbc.
13:53aaelonyDoes anyone have an example from clojure that can set up the tunnel then issue one or more queries ?
13:55solussdis there a predicate that tests if something is a map entry?
13:56znDuffsolussd: whether the map has something as a key, you mean?
13:56solussdI'm walking a map of maps and need to know if the current form is a map entry
13:56solussdactually, nevermind, I might as well do this at the map level. ;)
13:56solussdthanks
13:57actsasgeekdnolen: it would seem that I somehow managed to get a configuration of clojure, jayq, crate, fetch, noir and cljsbuild all working and lost it. If I use cljsbuild 0.2.1 it was working but now I get that weird error. If I use cljsbuild 0.2.9, I get an error that it can't find macros for crate on the classpath.
13:57gfredericks,(ancestors (first {3 4}))
13:57clojurebotnil
13:57gfredericks,(ancestors (class (first {3 4})))
13:57clojurebot#{clojure.lang.IMapEntry java.lang.Runnable clojure.lang.Counted java.lang.Iterable clojure.lang.AFn ...}
13:58gfredericksmap entries are runnable?
13:58dnolenactsasgeek: yes my other suspicion was that you have some kind of problem in your dependencies.
13:58gfredericks,(filter #(re-find #"java" (str %)) (ancestors (class (first {3 4}))))
13:58clojurebot(java.lang.Runnable java.lang.Iterable java.util.List java.util.Map$Entry java.util.Collection ...)
13:59gfrederickssolussd: for your no-longer-a-problem, java.util.Map$Entry might be an answer
13:59solussdgfredericks: yeah, there's also clojure.lang.MapEntry, but I wanted something implementation agnostic
14:05andrewmcveighanyone know where cljs' "satisfies?" is declared?
14:07andrewmcveighnevermind, found it.
14:26robinkraftHey all, I'm looking for a way to string format a double to have a max of 7 decimal places, but without adding padding if it's actually shorter. So 3.4 -> 3.4, but 3.44444444444444 -> 3.4444444. Any suggestions?
14:27robinkraftOr rather, 3.4 -> "3.4", and 3.4444444444444 -> "3.4444444"
14:28gfredericks,(format "%.7f" 3.4)
14:28clojurebot"3.4000000"
14:28gfredericks,(->> (format "%.7f" 3.4) reverse (drop-while #{\0}) reverse (apply str))
14:28clojurebot"3.4"
14:29gfredericksrobinkraft: ^ that at worst :)
14:29robinkrafthaha nice!
14:32robinkraftis there a round function I'm not aware of that handles rounding to a specific number of digits? round in numeric-tower only rounds to nearest integer
14:33amalloy$javadoc Math
14:33lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Math.html
14:35metellusI'm surprised there isn't a format string that can do what robinkraft wanted
14:35gfredericks,(Math/nextUp 3.4)
14:35clojurebot3.4000000000000004
14:35aaelonyis this still valid? http://stackoverflow.com/questions/10751638/clojure-rounding-to-decimal-places
14:35gfredericksthere's some weird stuff there
14:36gfredericksmetellus: robinkraft: I don't know that there isn't. Wouldn't surprise me.
14:36metellusI've been looking at the Java Formatter docs and I can't find one
14:37amalloyi don't think there is, in java or c
14:38gfredericksoh crap mine borks on integers
14:38gfredericksrobinkraft: what should it do when given "3.00000"?
14:38robinkraftpython has a handy 'round' function: http://stackoverflow.com/a/10505705/699026
14:39robinkraftI care most about not adding digits where there weren't any before, and truncating anything after 7 digits
14:39robinkraftso 3.000000 could stay as it is
14:39robinkraftbut in an ideal world it'd go to 3.0 :)
14:41amalloy"not adding digits where there weren't any before"?
14:41robinkrafti.e. 3.4 -> "3.4" rather than "3.4000000"
14:43amalloyfloating point numbers (indeed, any numbers inside a computer) don't have [decimal] digits in any meaningful sense. 3.0 is the same as 3.000000, so if you're happy with the latter staying as is, it doesn't make sense to require that 3.400000 print as 3.4
14:43AKFLOWhey
14:44AKFLOWneed some advice
14:44AKFLOWnew to the clojure thing
14:44robinkraftfair enough … hmmm, well the 3.4 case is the driving force here, so then I guess it's not ok for 3.000000 to stay as is either
14:44AKFLOWis their like a noob section
14:45AKFLOWor this is it???
14:45lazybotAKFLOW: How could that be wrong?
14:45amalloy(inc lazybot)
14:45lazybot⇒ 8
14:45znDuffAKFLOW: We don't bite. :)
14:45znDuffAKFLOW: ...well, not in #clojure. Over in, say, #bash, the rule is tough love... but this isn't there. :)
14:46AKFLOWI am tryng to convert matlab files to clojure files
14:48AKFLOWis there a way you could do it with a script
14:48technomancyno
14:48AKFLOWor are there any good pharsing example out there using clojure???
14:48lazybotAKFLOW: Oh, absolutely.
14:50znDuffAKFLOW: Lots of tools and frameworks for parsing, yes.
14:50AKFLOWsweet
14:50technomancythough... maintained parsers, not so much
14:50AKFLOWok
14:50znDuffHmm. Indeed, http://www.clojuresphere.com/?query=parser has lots of things which haven't been updated in a while.
14:51AKFLOWSWEET !!!! let me go there and be right back thank you znDuff
14:51amalloyyeah, i was thinking that the other day, technomancy. someone has actually quietly updated fnparse for 1.4
14:52amalloyoh hey, and he works at factual? sweet, maybe i can actually go bop him on the head if there's something i want from fnparse
14:52technomancyamalloy: huh; unofficial fork?
14:52amalloyyeah. https://github.com/joshua-choi/fnparse/network
14:52technomancythat's cool
14:52technomancyis fnparse based on parser combinators too?
14:53amalloy"too"? from a brief read of parsley's docs, i'd say fnparse is the only one that is
14:53technomancyparsatron is
14:53amalloy$google clojure parsatron
14:53lazybot[youngnh/parsatron · GitHub] https://github.com/youngnh/parsatron
14:54technomancyhe gave a great talk at strangeloop last year
15:00mudgewhy doesn't this work: (condp some #(= kind %)
15:01mudgegetting this error: Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq
15:04gfredericksmudge: the form you pasted is incomplete
15:06mudgegfredericks: the full code snippet is here: https://gist.github.com/4068032
15:06amalloyso's the stacktrace :P
15:07amalloynot that this stacktrace is terribly important. the args to condp just don't make any sense here
15:07mudgeamalloy: the stacktraces in clojure/leiningen/nrepl are not very good, is there a way to get better stacktraces in clojure?
15:08mudgeamalloy: i think you are right
15:08amalloymudge: the stacktraces are imposing if you're not used to them, but they provide a wealth of important information. one would have to be very, very careful (ie, more careful than clj-stacktrace is) to change them for the better rather than the worse
15:09mudgeamalloy: makes sense, thanks
15:35mudgels
15:35lazybotetc home lib lost+found mnt root selinux srv swap sys tmp var
15:48brehautoh look at that, its #clojure tumbleweed season again
15:48danlarkinbrehaut: are you coming this time?
15:49brehautdanlarkin: sadly the combination of international travel and buying a house prevent it
15:49danlarkin:/
15:49danlarkinbummer
15:49brehautindeed
15:50brehauthopefully i'll finagle some clojure work in the next year and be able to justify it as a business expense
15:50Clemenshelp
15:50brehautyou'll need to be more specific
15:51danlarkinwhere do you live?
15:51Clemensyeah, i meant /help...
15:51brehautNew Zealand
15:55danlarkinso far!
15:56AKFLOWznDuff hey
15:57brehautdanlarkin: yup, probably not too many places that are farther
16:01AKFLOWare there any ruby2clj parsers???
16:01lazybotAKFLOW: Yes, 100% for sure.
16:02AKFLOWla
16:02brehautAKFLOW: what do you mean by that?
16:02brehaut(though the answer is probably no in anycase)
16:11boodleI'm having a chicken/egg problem on returning a Java.io.File as a value (works great) but also want to delete the file inside the calling function. Any way I can get a final call after a return value?
16:11technomancyboodle: doto
16:12boodletechnomancy: tyvm!
16:12technomancyno problem
16:13znDuffAKFLOW: if by "parser" you mean "converter"... well, you're not going to find many straight-across code translators for _any_ nontrivial language.
16:13callenboodle: generally speaking anytime you need to do a bunch of things to an object in sequence, especially when interfacing with Java, doto is what I see people doing
16:13callenznDuff: that's not true...unless by straight-across you mean, "looks like a human wrote it"
16:14technomancywith a little imagination you could consider mirahc's java output human-written
16:14technomancyalso depending on your opinion of the human race
16:15znDuffcallen: I did say "many", as opposed to "any".
16:15technomancycoffeescript, stalin, parenscript
16:15callencoffeescript's javascript output makes sense once you understand the scope-magic they're doing.
16:15znDuffNotably, all of those have a built-to-purpose source language
16:15technomancysorry, chicken
16:16znDuff...which makes a particularly big difference when translating between the different available library sets is part of the work.
16:16technomancyoh, chicken and stalin
16:16znDuff(which is certainly the case from Ruby to Java)
16:16callenchicken does a damn decent job too.
16:17mudgewhat's the best way to find out of a vector contains a certain value?
16:18Raynes&(some #{1} [2 3 4 1 4 5])
16:18lazybot⇒ 1
16:18Raynes(first (filter ..)) also works.
16:21mudgeRaynes: looks good, thanks
16:21callenI usually just use first filter because that's what I do in Python anyway.
16:22technomancycallen: ...?
16:22technomancythat idiom doesn't make sense without laziness
16:23callentechnomancy: I have a weird assortment of idioms in Python that are vaguely related to things I do in Haskell and Clojure
16:23callentechnomancy: it's best not to take the semantics literally.
16:23brehauttechnomancy: generaetors in python are lazy
16:23callenand yes, yield/generators are always there.
16:24callenbut more realistically it has a lot more to do with my extensive abuse of maybe monads.
16:24technomancyoh, gotcha
16:24callentechnomancy: the laziness isn't really key here, IMo.
16:24callenis there some element of the idiom I'm not understanding? I don't doubt that that could be the case.
16:26technomancycallen: it's just wasteful
16:27mattmosstechnomancy: Leiningen is your baby, yes? If so, does :scope "test" on a dependency do what it sounds like -- limit that dependency to "lein test"? Or do I need to not limit the scope like that if I (run-tests) from the repl?
16:27brehauttechnomancy: hows that different from any other python code ;)
16:27callentechnomancy: non-set composite type presence tests in Python usually are.
16:28amalloyhah. fine criticism, from a user of the language that generates piles and piles of garbage instead of just modifying stuff in place, brehaut
16:28mattmoss...if I *also* (run-tests) from the repl...
16:28technomancymattmoss: you probably want profiles
16:28technomancyI have no idea why Leiningen supports :scope TBH
16:28mattmossheh, ok
16:28technomancysomeone probably talked me into it, but I forget the motivation. it's only used in pom output
16:29mattmossok, gotcha
16:29mattmossthanks
16:29technomancysure
16:29brehautamalloy: lol. i also use python too. its not fast
16:31kilonunless you cheat with cython
16:33rcganyone here who can help with clojars.org?
16:33rcgi accidentally uploaded something under a wrong name
16:34brehautkilon: or my preference: F# ;)
16:34kilondamn lucky man, you have a preference, i still have not make up my mind :D
16:35kiloni think i need to frankestein some languages together
16:35brehautkilon: i still write python for my day job, but i prefer other languages
16:36kilonnothing wrong with that, i love lisp , smalltalk and clojure
16:36kilonmost of my coding is in python
16:37brehautive been quite excited about F#3 and fsharp.org moving toward making F# more independant of MS
16:38kilonhaskell look scary but fun too
16:38mattmossI dare you to write a web service in befunge.
16:38brehautahaha
16:41kiloncurrently trying to learn the abomination of the lisp world, elisp
16:42brehautbrave
16:42kilonand expand emacs to make it a bit more better python ide
16:43kilonclojure could help there too, to leverage some java libraries
16:43kilonsince it has good emacs integration
16:44kilonman so many choices
16:44kiloni will probably end up doing nothing as always :D
16:44brehautnothing is better than implementing a metaweblog backend :P
16:45kilon"meta" i hate that world, its always covered in mystery
16:45kilon*word
16:45brehautthis mystery is doubled by the amount of link rot involved
16:45brehautits always a bad sign when wordpress is an authoritative source
16:47brehautha
16:50brehautkilon: short version: implementing nothing is better than implementing a stupid thing
16:51callenWhen creating the context for various its of data in stencil templates, I find myself repeating a lot of redundant bits for the sake of kicking data backwards either to a direct template renderer or to a partial.
16:51callenhow do I keep from having to repeatedly kick back chunks of the request context to stencil templates in a ring web app?
16:59callenamalloy: hate to be 'that guy', but why not Kyoto Cabinet for jiraph?
17:00amalloyas opposed to tokyo cabinet? i dunno, decision made long before i arrived
17:00callenamalloy: kyoto is generally what most people were supposed to migrate to. I don't know how compatible the APIs are.
17:03AKFLOWsorry ppl, I am trying to convert ruby code to clojure code, are there any scripts available ???
17:03lazybotAKFLOW: How could that be wrong?
17:05ohpauleezAKFLOW: There are no automated scripts to convert ruby code to Clojure code that I'm aware of. The paradigms differ between Ruby and Clojure, so you're going to have to do a mental port as well more than likely
17:05technomancyAKFLOW: you have to use your little grey cells
17:06AdmiralBumbleBeeif there was a script to do that, then there'd be no reason to do that
17:06danlarkintechnomancy: +1
17:07AKFLOWok
17:07pjstadigi have a script
17:07AKFLOWok
17:07AKFLOWcan I get a link ????
17:07pjstadigit's written in haskell though
17:07danlarkinyeah paul
17:07danlarkinshare your script
17:08technomancy1. find a programmer that knows Ruby and Clojure. 2. Give him the code. 3. Pay him.
17:08technomancy4. Profit?
17:08danlarkinyou forgot ????
17:08technomancydanlarkin: yeah I'm not good at memes sorry
17:08AdmiralBumbleBeethe pay him must've been the ????
17:08scriptortry this script, AKFLOW, https://github.com/richhickey
17:08AKFLOWshure
17:08AKFLOWlet me give it a try
17:09callentechnomancy: there's work to be had where one can get paid to replace filthy Ruby with glorious Clojure? Sign me up.
17:10AKFLOWthank you
17:10AKFLOWreally scriptor
17:11AKFLOWblahhh
17:12pjstadigAKFLOW: if a script exists to convert Ruby to Clojure, it probably means that Clojure is so similar to Ruby that it is not worth learning
17:12pjstadiguse JRuby
17:12scriptorAKFLOW: on a serious note, what do you need it for?
17:19TimMcMy wife is using a script to convert Matlab to R code. :-P
17:19TimMcWell, it mostly works. She has to keep adding regexen.
17:20sunkencityryleh,(doc deftype)
17:20clojurebot"([name [& fields] & opts+specs]); Alpha - subject to change (deftype name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the curren...
17:22sunkencityrylehcan I create a subclass of PersistentList in clojure? I'd like to subclass to change some behaviour in a protocol i'm extending for a particular case and then send in the subclass. Would that be a good or bad idea?
17:23balinthow could I make this work: (get (dorun (for [x (range 7)] x)) 2)
17:24brehautTimMc: mostly works but adding regexp sounds like the worst kind of works to me :S
17:24brehautbalint: how about you describe your problem first?
17:24gfredericksbrehaut: stand back, I'm going to add some regexp
17:24balintit should return 2 since the sequence the for generates gets force-evaulated by dorun I'd think
17:24balintbrehaut: :)
17:24TimMcbrehaut: Sometimes that's all you need.
17:25gfredericksTimMc: wat??!! but two problems!
17:25TimMcinorite
17:25balintbrehaut: my problem is that a for loop generates a "maze" in a challenge in which I then use 'get-in' to find a certain element
17:25brehautso why do you need to force evaluation?
17:25balintthe element is there but since the maze is lazily generated the get-in returns nil and my code breaks
17:25TimMcbalint: get isn't going to work on a seq.
17:26gfredericksprobably nth instead of get?
17:26gfrederickss/instead/nthstead/
17:27TimMc&(get (vec (range 10)) 5)
17:27lazybot⇒ 5
17:27TimMc&(get (range 10) 5)
17:27lazybot⇒ nil
17:27balintTimMc: is this the distinction between seq and coll?
17:28TimMcSpecifically, get is for sublinear-time lookup, which seqs don't support.
17:28balintah, ok
17:28dnolenbalint: you probably want to represent the maze w/ a different data structure if you need quick access to elements in the maze.
17:28TimMc~seqs and colls
17:28clojurebotseqs and colls is http://www.brainonfire.net/files/seqs-and-colls/main.html
17:29balintdnolen: I don't need it to be fast but since originally it's represented as an array of strings, get-in seemed a good choice
17:29TimMcget-in is correct, but you need a different data structure for it to work.
17:30balintthat's the challenge: http://www.4clojure.com/problem/117#prob-title :)
17:30mycelloandi,(doc get)
17:30clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
17:30TimMcI don't know why ##(get (range 5) 2) doesn't throw an exception.
17:30lazybot⇒ nil
17:31balintso I should probably convert the original data structure to something more amenable to quick/simple lookups
17:32gfredericks&(get "foo" 3)
17:32lazybot⇒ nil
17:32gfredericks&(get :WAT 7)
17:32lazybot⇒ nil
17:33balint&(get "foo" 2)
17:33lazybot⇒ \o
17:33gfredericks&(get (Object.) 42)
17:33lazybot⇒ nil
17:33gfredericks&(get (Object.) :akey)
17:33lazybot⇒ nil
17:33gfrederickshuh;
17:33balintgfredericks: it works for strings
17:33mycelloandiwhy does get return nil for that -- wouldn't it be better to throw an exception?
17:33TimMc$def get
17:34gfredericksmaybe clojure only throws type exceptions if there's a specific interface it can require?
17:34gfredericksand if it's going to work for strings then that's obviously not the case
17:35TimMcIt *does* have the contract that if the index is out of bounds, nil is returned, but that's still not really an excuse.
17:35balint"Returns the value mapped to key, not-found or nil if key not present."
17:35dnolenget doesn't ever throw, it just tests a bunch of interfaces - see RT.java
17:36TimMchttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L634
17:36TimMcI guess that's useful if you don't know if *either* the collection or key is bad.
17:36gfredericks(defprotocol IGettable ...)
17:36amalloydnolen! i asked a question about core.match last night, but you were gone: anyone know if there's a good way in core.match to match a seq like "at least three elements, the second of which is :foo"? i've tried ([x :foo y & more] :seq), but as of 0.2.0-alpha10 that matches even with only two elements, binding y to nil and more to ()
17:37balintthank you guys, I'll sort this out
17:38dnolenamalloy: huh ... yeah just seems like a bug. perhaps I can convince people start helping me out with core.match during the conj :)
17:38dnolenamalloy: that should just work
17:40dnolenamalloy: that said, I'm pretty sure I'm going to retire seq matching
17:45amalloyoh no, retire seq matching? it's the only thing i use core.match for! how would i do something like that without seq matching?
17:47dnolenamalloy: vector matching would support the very same thing - albeit the algorithm may favor vectors perf wise.
17:47Clemens&*ns*
17:47lazybot⇒ #<Namespace sandbox7657>
17:48amalloydnolen: i'd have to do like (match (vec x) ...) rather than (match x), and then vector matching would work? that's fair enough, i suppose
17:48amalloysince i don't have to worry about infinite seqs for the moment
17:50dnolenamalloy: no change really, vector matching will probably now match on sequential, so no need to convert your data.
17:50amalloyoh good
17:51dnolenamalloy: the neat thing about seq matching was it was very optimized for seqs - so that's all that going out the door. getting rid of seq matching will eliminate a lot of surprises. people were running into a lot of weird things if they mixed vector matching /w seq matching because of interface overlap.
17:54callendnolen: it's good that you're willing to remove things that didn't work out.
17:54callendnolen: too many projects let the albatross just hang around their necks instead.
17:54JamesBordengood evening
17:54callenJamesBorden: good afternoon.
17:55JamesBordenI have a question about something I am seeing in ring.middleware.json
17:55JamesBordenat: https://github.com/ring-clojure/ring-json/blob/master/src/ring/middleware/json.clj
17:55ynnivI bet this already exists… I want to apply a series of keywords to a map, like ,(-> { :x { :y { :z 5 } } } :x :y :z) but where :x :y :z are a seq and not forms
17:55JamesBordenit is line 17
17:55ynnivwow, that looks rather angry in colloquy
17:55JamesBorden[handler & [{:keys [keywords?]}]]
17:55JamesBorden(defn wrap-json-body
17:55JamesBorden "Middleware that parses the :body of JSON requests into a Clojure data
17:55JamesBorden structure."
17:55JamesBorden [handler & [{:keys [keywords?]}]]
17:55JamesBorden (fn [request]
17:55JamesBordenwhat is keywords?
17:55TimMcJamesBorden: Please don't paste to the channel -- use a pastebin such as refheap.com or gist.github.com
17:56JamesBordenit seems to me like it is a test for a keyname keywords maybe?
17:57muhoo,(doc keyword) ;; JamesBorden
17:57clojurebot"([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically."
17:57brehautJamesBorden: if you click on the line numbers, github will update the #anchor in the url
17:57brehauteh https://github.com/ring-clojure/ring-json/blob/master/src/ring/middleware/json.clj#L14-21
17:57JamesBordenbrehaut: thanks
17:57dnolencallen: I have no problem getting of stuff that doesn't work :) As usual, I just wish I had seen it earlier.
17:57ynnivmuhoo: he's asking about a destructuring directive, not a function
17:58metellusynniv: ##(get-in { :x { :y { :z 5 } } } [:x :y :z]) is that what you want?
17:58lazybot⇒ 5
17:58callendnolen: hey, recognition and rectification puts you ahead of 99.9% of the crowd. Never sweat something like that.
17:58JamesBordenhttps://github.com/ring-clojure/ring-json/blob/master/src/ring/middleware/json.clj#L12 has json/parse-string
17:58ynnivmetellus: that is *exactly* what I want
17:58JamesBordenwhich I would like to give the extra parameter "true"
17:59metellusgreat
17:59ynniv(inc metellus)
17:59lazybot⇒ 1
18:00callen(inc metellus)
18:00lazybot⇒ 2
18:00callenI learned something too.
18:00ynnivI'm also going to use :x as an example in colloquy more often
18:41TylerGillieswhats the best way to auto download java deps in my leiningen project?
18:43rcgTylerGillies, are the java deps available via maven?
18:43TylerGilliesrcg: yes
18:43rcggreat, then you can simply specify these as dependencies in your project.clj
18:44rcgthis works, essentially, the same way you specify clojure dependencies
18:44RaynesBecause they're the same thing.
18:45TylerGilliesrcg: so just [name.space "version"] ?
18:45rcgRaynes, ;)
18:45rcgTylerGillies, yep
18:45RaynesNo.
18:45TylerGilliesrcg: brilliant, thanks
18:45TylerGillieser...
18:45TylerGilliesno?
18:45clojurebotno is tufflax: there was a question somewhere in there, the answer
18:45RaynesYou need the group id and artifact id.
18:45rcgRaynes, ?
18:45RaynesWhat are you trying to depend on? Give me an example.
18:45RaynesJust one example will do.
18:46rcg[com.espertech/esper "4.6.0"] <- i use this for esper
18:46TylerGilliesnothing yet, its a theoretical, i was thinking about adding one but wanted to figure out how to do it first
18:46TylerGillieshttps://github.com/fusesource/leveldbjni
18:46TylerGilliesthis is the one im thinking about
18:46RaynesMaven search will tell you what the group id and artifact id are. It might look like what rcg just showed.
18:46mattmossRaynes: BTW, here's the basic code I'm doing with conch. Stripped of all incriminating evidence. ;)
18:47TylerGilliesso group if the first part and artifact id is the second part?
18:47Raynes[org.fuseresource/fuseresource-pom "1.9"]
18:47RaynesYes.
18:47TylerGilliesah
18:47TylerGilliesthats what i meant
18:47RaynesEr.
18:47RaynesThat's the parent.
18:47mattmossHmm, url is good too: https://gist.github.com/4068423/
18:47TylerGilliesi thought that those terms were synonymous
18:47TylerGilliesmy bad
18:47Raynes[org.fuseresource.leveldbjni/leveldbjni-project "99-master-SNAPSHOT"] for example.
18:48Raynesmattmoss: I refuse to look at gists out of principle. Put it on refheap and we'll talk.
18:48TylerGilliesRaynes: thanks
18:48TylerGillies<dogma/>
18:48TylerGilliesheh
18:49mattmossoops, gotta run... back later
18:49RaynesI was kidding.
18:49RaynesGood stuff.
19:02TimMcTylerGillies: Figuring out that namespaces had nothing to do with Maven coordinates was definitely one of confusing points in my early learning of Clojure. (cc: clojure-doc folks)
19:08TylerGilliesRaynes: [INFO] Unable to find resource 'org.fuseresource.leveldbjni:leveldbjni-project:jar:99-master-SNAPSHOT' in repository clojars (http://clojars.org/repo/)
19:09TylerGillieslooks like its looking in clojars, and then failing
19:10Apage43lein is quite noisy, and will report -every place- that it looks even if a later repo succeeds
19:11TylerGilliesah
19:11TylerGilliesits still in the process
19:11TylerGilliesi thought it teminated
19:11TylerGilliesprolly still looking
19:11TylerGilliesApage43: thnx
19:11Apage43yeah
19:11technomancyApage43: not on master actually
19:12Apage43technomancy: nice. Will make a lot of folks a lot less confused a lot of the time.
19:12technomancyyeah, the default you get from aether is rubbish
19:16TylerGilliesis it normal for lein deps to hang for awhile? i got some exceptions because it couldn't find jar in clojars and then.... just hangs i think it might be working
19:22technomancyTylerGillies: it can happen on unstable connections
19:23TylerGilliestechnomancy: thnx
19:30brehauthttps://twitter.com/plt_hulk/status/268508480481157120
19:31TylerGillieslawl
19:43mattmossRaynes: https://www.refheap.com/paste/6650
19:47nickikWhen I use nRepl in Emacs, how can I use reuse the last expression I evaluated.
19:47nickikIt used to be just hitting enter on the expression (in swank)
19:48technomancynickik: *1 is typically used
19:49nickikok, then I will have to get used to that.
19:53nickiktechnomany, ist it often the problem that I have to change some little things and then reevalute things? That I cant handly with *1.
19:53technomancyoh, you mean like M-p?
20:02holohi
20:03holoi'm having a "Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string" when i remove an unneeded dependency from the namespace of a script executed with lein exec -p <script>
20:04holoi tried lein clean
20:04technomancydon't use lein exec
20:05technomancyit only exists because the run task used to be less powerful
20:05TimMcgfredericks: Looks like someone was reading the "get" discussion: http://dev.clojure.org/jira/browse/CLJ-1107
20:07nickiktechnomany, thats what I wanted thx.
20:08holotechnomancy, ok, i'm going to forget this debugging and run it with "run". thanks
20:12TimMc&(long \a)
20:12lazybotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number
20:12TimMc&(long (int \a))
20:12lazybot⇒ 97
20:12TimMchmmmm
20:33gfredericks&(doc int)
20:33lazybot⇒ ------------------------- clojure.core/int ([x]) Coerce to int nil
20:33gfredericks&(doc long)
20:33lazybot⇒ ------------------------- clojure.core/long ([x]) Coerce to long nil
20:34TimMcOh, looks like it is fixed in 1.5.0-beta1
20:36TimMchttp://dev.clojure.org/jira/browse/CLJ-977
21:19yedihas anyone done anything with clojurescript and appjs?
21:28TimMc~anyone
21:28clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
21:28TimMcllasram: Currently working on grokking your lein-otf v2 changes.
21:32yedii don't have a question, I was just curious if anyone had
23:39TylerGillieshow do i add a resource to leiningen project to add jars?
23:39TylerGilliesthe repo i want to download from is located at http://repo.fusesource.com/nexus/content/groups/public-snapshots
23:39TylerGilliescan i add a repo manually?
23:40Sgeo__You're.... not supposed to, but I think that that's annoying, here's what I did I don't know if lein jar will actually package it properly though
23:40Sgeo__https://github.com/Sgeo/clj-vp/blob/master/project.clj
23:40Sgeo__I put it on resource-paths
23:41TylerGilliesSgeo__: thanks
23:41Sgeo__yw, but... there are probably more elegant ways
23:41Sgeo__But I have no idea what they are
23:45technomancyTylerGillies: you can add it to :repositories in project.clj
23:45TylerGilliestechnomancy: thanks
23:45TylerGilliesi found a link but it was the wrong syntax
23:45amalloyhuh? adding repos manually is exactly what you're supposed to do
23:46TylerGillieshttps://github.com/technomancy/leiningen/blob/master/sample.project.clj helped
23:46Sgeo__I sort of thought TylerGillies was talking about adding a .jar
23:46TylerGilliesnope
23:47Sgeo__Ah, ok
23:47TylerGilliesi added it, but its not showing when in do lein deps... odd
23:48TylerGilliesah there it goes n/m
23:55TylerGillieshrm getting: Could not find artifact org.fuseresource.leveldbjni:leveldbjni-all:jar:99-master-SNAPSHOT in fuse community snapshot (http://repo.fusesource.com/nexus/content/groups/public-snapshots)
23:55TylerGilliesbut i see it on http://repo.fusesource.com/nexus/content/groups/public-snapshots/org/fusesource/leveldbjni/leveldbjni-all/99-master-SNAPSHOT/
23:56Sgeo__Is there a way to call some arbitrary code when it's time to do dependency resolution?
23:56Sgeo__Or... otherwise have the code be part of a build process?
23:56Sgeo__I'm wrapping a C API with the help of JNAerator...
23:57hiredmanthere is no reason to run jnaerator more than once
23:57Sgeo__If the C API changes...
23:57antares_Sgeo__: using Leiningen hooks
23:57TylerGilliesmust be because of the filenames..
23:57TylerGilliesim assuming its because of the datestamp appended to jar filename?
23:58Raynesantares_: I wish you were going to the conj?
23:58Raynesconj.
23:58RaynesQuestion marks suck.
23:59RaynesI want us to argue about the priorities of the Clojure community in person. Perhaps engage in fisticuffs over a slab of meat or something.