#clojure logs

2013-05-02

00:00pl6306Yup
00:00uvtcSegFaultAX: right. metellus pointed that out a bit earlier. I meant, "in Clojure". But, yes, you're right.
00:00uvtcSegFaultAX: thanks.
00:00pl6306Process and ProcessBuilder?
00:00SegFaultAXuvtc: How is that not "in clojure"
00:01n_bpl6306: There's also clojure.java.shell, not sure how much you need to do
00:02uvtcSegFaultAX: I was looking for something along the lines of `(index-of some-coll some-val)`. Though, just now I see that .indexOf is right there on the cheatsheet...
00:03pl6306Thanks I will give clojure.java.shell a try
00:05akhudekit's interesting that subs exists in clojure, despite .substring, but this is not the case for some other functions
00:09uvtcAnyhow, I'm glad to see (once again, in fact) that what I thought required a clunky solution actually had a built-in solution already that works nicely.
00:11uvtcmetellus: for the record, if you're backlogging: https://www.refheap.com/paste/14126
00:24gdevlazybot: whatis he talking about
00:24lazybothe is talkin bout my g-g-g-generation
02:32amalloyuvtc: anytime you work with indexes in clojure, your brain should be screaming "do we *really* need to use indexes?" remove-one-from is so much easier to write, and more efficient, without any indexes
02:35amalloyhe's gone, i guess, but for anyone following along at home, https://gist.github.com/amalloy/5500495
02:40noidiyou could replace the let with destructuring to make it even simpler: (when-let [[x & xs] coll] ...)
02:49amalloynoidi: you could, but that's a bad habit to get into
02:50amalloybecause that will force realization of the first two elements in coll, not just the first one
02:50amalloy(since destructuring & uses next, not rest)
02:55noidiaren't you realizing xs anyway in the body?
02:56noidiah no, not in the else block
02:56noidiamalloy, I hadn't thought about that, good to know, thanks
02:57amalloynoidi: i don't realize xs in either side of the if
02:57amalloyrest is lazy
02:57noidiah, right
02:58noidiand with chunking that extra evaluation could be quite expensive
02:58noidi*realization
02:58noidiin case x is the last element of a chunk
02:59amalloy*shrug* even without chunking
02:59amalloyyou don't want to eagerly realize one too many elements of the ackermann sequence
02:59noidihehe
03:00amalloyanyway, i wrote a lot of lazy-sequence functions with [x & xs], and it took me a long time to realize they were therefore all broken
03:00noidiwhy does it use next instead of rest?
03:00amalloyprobably legacy reasons, from back when there was no lazy rest
03:01amalloyso people wrote code like (let [[x & xs] coll] (if xs ...))
03:01Apage43it also will guarantee xs is nil if there is no more stuff left, if you're checking that
03:01amalloyApage43: right, which IMO is a bad guarantee to make, except that it has to stay in because of legacy
05:05clgvis there a clojure bug with respect to type inference for primtives regarding the `cond` macro?
05:16amalloythat's not possible, clgv. cond is just a macro expanding to nested ifs, and any inferencing is performed on the expanded form
05:17clgvamalloy: ok then this is pretty strange. I get an autoboxing warning from recur when using `cond` but not when I write those nested `if` statements manually
05:43no7hinghaving a small problem with protocols: define a protocol in ns A, require it in ns B, compiler tells me it can't resolve it
06:02antares_no7hing: how do you require it? You should just require a namespace. Are you trying to extend it in another ns?
06:03no7hingi required the ns the protocol was defined in; with (:use [the.ns :only [TheProtocol]]) it works
06:04no7hingthat i have to require the ns either way too, was kind of ..surprising
06:08djcoinHi folks, i'm not in clojure right now. But i had a question, it is really appealing to see such a language (flexbility but performance thx to the jvm, simplicity etc. compilation to javascript, etc.).
06:09djcoinBut isn't it too hard to code without any types ?
06:09djcoinGiven immutability/performance, I would be tempted by haskell too (yet laziness is a bit scary)
06:10djcoin+ Types and compilation makes code fast, I wonder if layers and layers of untyped clojure code can not alter performance
06:10djcoinANy hints ?
06:11ucbdjcoin: you can provide type hints to speed things up a tad; but it might just be that you're preemtively worrying for no good reason :)
06:11ucbdjcoin: in a word: speed is not /normally/ a problem, and when it is, I've not seen it be because of the lack of types (although reflection can be a bitch sometimes)
06:12ucb(lack of types is wrong; dynamic types more like it)
06:12djcoinyeah, that's what i meant
06:12djcoinWhat about "programming in the large", librairies and stuff. Wouldn't types help to structure things up ?
06:13djcoin(even if GC + immutability are already key points)
06:13ucbyes and no. If you have too many types then it gets a bit silly. If everything is a string, it also gets silly.
06:17djcoinucb: sure, but I'm doing mostly javascript/nodejs those times (before python, i did too a bit of C/Java) but i'm beginning to be tired by types errors. + Finding a lib (especially in javascript I guess) can be cumbersome. When I see stuff like hoogle for haskell (google for types), I see this as really helping building abstraction too
06:18antares_no7hing: you don't need refer to the protocol unless you want to extend it. Simply use functions defined in it as if they were regular functions in the ns.
06:19antares_no7hing: if you need to extend a protocol from another ns, see https://github.com/clojurewerkz/money/blob/master/src/clojure/clojurewerkz/money/hiccup.clj for a small example
06:22noididjcoin, there are efforts to add static typing to clojure https://github.com/clojure/core.typed
06:23djcoinnoidi: yeah I saw that, inspired by typed racket, it looks nice. Wonder how far you can go with it
06:27no7hing@antares_: that's what i was trying to do, after i had issues using a record that was implementing the protocol; i moved the record definition to the ns where it's actually used and ran into the require/use issues; will take a deeper look into this in a calm hour today
06:28arcatan
06:28naegHow can I modify existing functions using macros? e.g. add another argument to that function, modify a function call inside that function
06:29noididjcoin, by all means, check out haskell as well if it seems more appealing to you
06:29noidipersonally I found clojure much less daunting
06:29naegbasically, I want to do this: https://www.refheap.com/paste/14113
06:29noidiand I really like the REPL-centric workflow that Clojure provides
06:29no7hing@antares_: is there a preferred way on wether to :use or :import protocols?
06:29djcoinnoidi: I fear a bit haskell for its laziness (and space leaks)
06:30antares_no7hing: you simply need to require the namespace
06:30noididjcoin, Clojure's laziness can trip you up as well, although only sequences are lazy by default
06:30antares_no7hing: when extending, refer to a protocol as if it was a function, using the ns prefix you used in require + /ProtocolName
06:31antares_imports are necessary for records
06:31antares_because records are compiled to Java classes
06:31antares_:use should be avoided if you use Cloure 1.4+, see http://clojure-doc.org/articles/language/namespaces.html
06:32no7hing@antares_: when mixing that up, it looks like it's time for a break; thanks for helping
06:33no7hing@antares_: once you do it right, it just works
06:34djcoinnoidi: I guess you chose clojure over haskell, what are the tradesoff if I may ?
06:36antares_djcoin: running on the JVM/.NET/JavaScript is by far the biggest trade-off (both a pro and a con). Learning curve in haskell is very steep, even for basic things like working with I/O and JSON, you have to have some understanding of monads and advanced control structures.
06:36noidiwhat antares_ said :)
06:37djcoinantares_: but if you do understand how to code the haskell way (monads and stuff), i mean, putting aside the learning curve
06:38djcoinTo be fair, the JVM ecosystem (java, xml etc.) is not very appealing to me, but i see how a super optimized jvm and using java to code the low level stuff can be great
06:38djcoin+ well, the types :s
06:39antares_djcoin: with deep understanding of either, what matters the most is library availability, operations tooling (that haskell lacks) and if your problem can be better expressed in a DSL vs type system
06:40antares_djcoin: unless your program is hundreds of thousands of lines or requires numerical computations efficiency, I don't think the static vs dynamic typing debate is very relevant
06:40noidiI work at a (mostly) Java shop, and I can imagine getting to work with Clojure in a year or two (we already have a couple of Clojure projects, sadly I'm not in one of them)
06:40antares_it's great to have static type checking and type inference. It's not a deal breaker for me.
06:40noidion the other hand, there's a zero chance of the company moving to Haskell
06:41antares_noidi: in that case Scala is what you want
06:41antares_kinda the middle ground
06:41antares_and also a bag of compromises, but Java shops find it appealing most of the time
06:41noidiI don't :)
06:41djcoinantares_: Thanks for your answer, what do you mean by "operations tooling" ?
06:42antares_if you like Haskell, I think there's quite a bit you will like about Scala
06:42antares_djcoin: tools like visualvm, jstack, metrics libraries, JMX, JVM-specific profiling and monitoring
06:42antares_dtrace support
06:42noidiI'm really a Clojure guy at heart, and I've only looked at Haskell and Scala out of curiosity
06:43antares_haskell very much lacks all of this stuff
06:43noidiI do miss static typing from time to time, but for me that's not a big enough reason to give up all of Clojure's dynamic, malleable goodness
06:43djcoinSure
06:45djcoinantares_: isn't all those tools (the whole env) adding a lot to the learning curve ?
06:46antares_djcoin: you don't need them initially but it's scary to go into production without them
06:46djcoin(this is the same for all languages I guess - but does it integrate well with clojure ?)
06:46antares_and something like jstack or visualvm can be learned in an hour
06:46antares_visualvm and jstack work great with clojure
06:48noidiantares_, do you use Scala much? I think I remember seeing some Scala libraries by you, but I might be mistaken...
06:49antares_noidi: I used to, then switched to Clojure
06:49antares_Scala in 2007-2009 was a very different ecosystem. Binary compatibility and upgrades were total hell.
06:49djcoinThanks antares_ , did you try haskell haskell, would you recommend it ? I guess not if you say operational tools are missing
06:50antares_djcoin: I like haskell but would highly recommend taking the learning curve and ops tools availability into account
06:52djcoinantares_: talking about ops tool, I guess Erlang must be a great fit
06:53jjl`presumably the ops tools are so great that someone wrote erjang to get worse ops tools for the jvm...
06:53djcoin:)
06:54djcoinMAybe the "port" is not good itself
06:54antares_djcoin: Erlang has a good story there. But these tools are not nearly as well known.
06:55antares_jjl`: AFAIK erjang was developed as an experiment
06:56jjl`i think so. but i'm pretty sure the JVM's ops stuff was the reason for it
06:56noididjcoin, here's something to watch while you're procrastinating on the language choice :) http://www.ted.com/talks/barry_schwartz_on_the_paradox_of_choice.html
06:56jjl`i mean erlang is *FAST*. they didn't need to move it to the jvm for performance
06:56djcoinnoidi: yeah, i'm always weighting pros and cons
06:56djcointhanks :)
06:59djcoinjjl`: oh I did not understand, I thought they coded some "erlang like" ops tools, in fact no, they port the whole vm oO a bit crazy
07:01djcoinDo you need to deal with (is it better to have some (extensive) knowledge of) java and its environment, do go for Clojure ?
07:01djcoinin "real world clojure"
07:02noidiyes, you pretty much need to know Java
07:03jjl`well, some of it
07:03jjl`more about the stack as a whole than java the language
07:03antares_jjl`: no, erlang is not fast on computational workloads. Faster than Ruby and Python but that's nothing to be proud of :)
07:03jjl`antares_: i can compute in my head faster than ruby
07:04antares_jjl`: can't we all
07:04djcoinYeah, well i know a bit of java, i know what the jvm is, but I don't know how deep the "java" stack goes and if you need to reach for it regularly
07:04noidicore parts of Clojure use things like Readers, so it certainly helps if you can read enough Java to understand documentation explaining them
07:05antares_djcoin: it's a well known fact that some of the most famous Clojure community members don't know much Java but did pick up some JDK bits and concepts :)
07:05noidiif you can more or less understand what's going on when reading a random snippet of Java, you'll probably do fine
07:06djcoinok good :)
07:06antares_binary vs char streams is a great example
07:06jjl`most of it is the java libraries really. you'll use them a lot in clojure
07:06djcoinYeah, i'm a bit afraid of using clojure as a combiner of java lib
07:06djcoin(don't why I should though)
07:07djcoins/should/am
07:07jjl`clojure that uses java libs tends to be a bit ugly. java libraries are generally very much written for the imperative style
07:08lucianthere are wrappers for most things you'd care about, though
07:09lucianmy problem is the jvm itself, way too slow for development
07:09jjl`indeed. and a wrapper waiting to be written for the rest
07:09luciani'm also much too comfortable with python
07:09lucianjjl`: luckily they're trivial to write compared to binding to C from Python/Ruby
07:09jjl`yes, quite
07:10jjl`but i come from perl where there's never a need because someone else has done it already
07:10lucianthere are certainly advantages, but whenever i start to do something in clojure i get too annoyed at the jvm being slow
07:10lucianjjl`: it would be as much of an issue with perl for custom things, though
07:11djcoinhow slow ? you mean at startup ? because otherwise it should be fast no ?
07:11jjl`worse. have you ever written XS?!
07:12arcatanyeah, the startup time of JVM is pretty bad. you don't want to be restarting it just to reload code.
07:13jjl`have you tried using -Xint to make it run in interpreted mode?
07:14jjl`not something you'd want to do for production, but for dev...
07:15djcoinlucian: so how slow for dev ?
07:16luciandjcoin: at least on my machine, it takes seconds to boot up
07:16antares_in Clojure, you will eventually use a long-running REPL from emacs/vim/IDE
07:16antares_and discover drip
07:16lucianwhereas, say, python, is instant
07:16lucianantares_: even with drip, it still takes more than 1sec
07:17antares_note that Clojure code is compiled when it is loaded
07:17lucianeven lein's help command takes 3-5sec :(
07:17antares_it's not a JVM problem. But that's also why Clojure doesn't suffer from the binary compatibility hell nearly as much as most compiled languages.
07:17antares_lucian: lein help is the worst case, it has to load *all* the plugins first
07:18antares_to display help for them
07:18djcoinyeah lein help is pretty daunting
07:18djcoindauting *
07:18luciani'm pretty sure it's a jvm problem, i've had the same issue with plain java
07:18djcoinsry daunting*
07:18luciani think its class loading is broken
07:19naeghow to get the name of a function with the namespace? e.g. #'f gives #'namespace/f, but I just want "f"
07:19naegsplitting at / seems cumbersome to me
07:19luciandjcoin: so if you can put up with that, it's probably fine
07:20lucianfor me there aren't enough advantages over python to be motivated to put up with it :)
07:21djcoinlucian: parallel/concurrent programming, immutability, flexibility, functional style ?
07:21djcoinand perf
07:21djcoin:)
07:22Apage43naeg, the var will have :name in its metadata
07:22luciandjcoin: the first is less of an issue than one might think, second is meh, third is not the case, fourth i have enough of to be satisfied already
07:23lucianactually, i like immutability a bit more than 'meh'
07:23Apage43&(:name (meta #'map))
07:23lazybot⇒ map
07:23djcoinI say simple and true flexibility, without weird lamba and metaclass
07:24Apage43if you have a var for some reason and want the name
07:26luciandjcoin: expression lambda and metaclasses are fine for me. i prefer traits/typeclasses/protocols to classes/meta, but i the benefit is not large enough
08:51gdevlazybot: fortune
08:51lazybotthe impedance of mismatch is all your fault
08:52gdev=[
08:56xumingmingvlazybot: future
08:56xumingmingvlazybot: fortune
08:56lazybot,(println "PRIVMSG #hackerschool :herp")
08:56clojurebotPRIVMSG #hackerschool :herp\n
08:58gdevlazybot: whatis (+2_2)
08:58lazybot(+2_2) is 5 for extremely large values of 2
09:18augustlis it possible to implement a multimethod using a function that returns a new function? I.e. (defmulti foo :my-dispatch (call-function-that-returns-other-function))?
09:25pjstadigaugustl: defmethod macro expands to this https://gist.github.com/pjstadig/5502123
09:26pjstadigso you can always manually call .addMethod on your multimethod
09:26pjstadigthere's clojure.core/remove-method, but unfortunately not clojure.core/add-method, so you have to do it manually
09:29jcromartieso I rewrote my Clojure JSON API in Rails last night
09:30jcromartieI am already using at least two racist/mysogynist libraries
09:30jcromartiethank you, Clojure community, for not doing that
09:34naegjcromartie: racist/mysogynist libraries? o.O
09:35jcromartieFeedzirra
09:35mefestoi only use libraries that treat me with respect
09:36jcromartieI think I had more earlier but I dropped some dependencies
09:36naegwhat exactly I racist about feedzirra? can't really see it right now
09:37duck1123Think Godzilla
09:38hfaafbis godzilla racist?
09:39naegeither I still fail to see it, or we have a very different perception of "racist"
09:39duck1123combined with the R for L thing, it's a little insensitive, not quite racist
09:39mefestohfaafb: instead of feedzilla it's feedzirra which seems like the intention was to sound the way asians can sometimes mispronounce the letter L
09:40winkdepends how you define mispronounce
09:40mefestoi'm korean and find it kind of funny
09:40mefesto... well half korean.
09:40naegoh, understand it now. but can't tell whether this was/is the intention of the developer
09:42bengillieshow is it mysogynist then?
09:43jcromartiebengillies: it's not
09:43jcromartiebut there are others
09:47jcromartieI am exaggerating a bit. I dont think they named their gems to hate on other people.
09:48jcromartiebut it might be odd to explain the dependency on "feedzirra" to e.g. a gov't bureaucrat in charge of auditing an app or something like that, let alone gems like "clit", or "tit" or "daddys_girl"
09:49jcromartieor "trollop"
09:50jcromartieball_gag, hash_dealer :)
09:50mefestoi think feedzirra wouldn't be an issue but yea those others are a bit much
09:54Morgawrhey guys :) a few days ago I finished a game in ClojureScript for the Ludum Dare competition, I wanted to thanks everyone who helped me with my random questions in here about Clojure. http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=8711 Here's the game if you're interested, it's a silly game but it's also on github in case anyone wanted to take a look a the code (it's not good code but at least it works)
09:55MorgawrI hope I can take this to the next level and develop an easy-to-use clojurescript engine for adventure games on the web, who knows
09:55mefestoi noticed that hiccup.form/form-to will convert any method that is not :get or :post into a :post but with a _method param. does compojure take this param into consideration with routes? [ex. (PUT "/my/uri" [] ...)]
09:56weavejestermefesto: It does
09:57mefestoweavejester: great. i figured it would but just wanted to check. thanks
09:58jcromartieMorgawr: awesome
09:59Morgawr:)
09:59dnolenMorgawr: neat
10:00dnolenMorgawr: it's cool to see people do games with ClojureScript
10:01Morgawrdnolen: yeah, it was an interesting challenge. I had never developed anything "useful" with functional programming so I wanted to see how it would go
10:01Morgawrit's really powerful after all, some hiccups here and there because I had never developed on the web nor with javascript before but it was fun
10:02Morgawrespecially in 48 hours haha
10:10silasdavisMorgawr, how much acid did you drop...
10:11silasdavisI'm in the castle
10:13Morgawrsilasdavis: haha, way too much acid, just wait for the end
10:13Morgawrkeep in mind it was very rushed because of 48hours limit
10:13Morgawr(around 3/4 of the time was spent on the actual engine, the rest on content creation)
10:14silasdavisno I'm impressed that's a fair bit of content and code for 48 hours
10:14Morgawrthe wonders of very little sleep :)
10:16hfaafbAre there any examples of open source performant action games in clojurescript?
10:16Morgawruh.. I remember viewing a few when trying to look for example code
10:16Morgawrhttps://github.com/mrmekon/tempest-cljs this one for example
10:17Morgawrhttps://github.com/thomcc/ld23 there's also this one, which was made for Ludum Dare 23 one year ago
10:18Morgawrhttp://lispgames.org/index.php/Clojurescript and there's this wiki with a few other
10:19Morgawrwhich reminds me I need to add my game to that list
10:19yogthosMorgawr: I made one too a while back :) https://github.com/yogthos/Clojure-Tetris
10:19Morgawrnice! :)
10:21jcidahoanyone benchmarked elastisch against clj-elasticsearch?
10:21jcidahoseems 10x slower, I'm prob missing something
10:34gfredericksis there anything mutable about an ##(Object.)?
10:34lazybot⇒ #<Object java.lang.Object@1bede95>
10:45TimMcgfredericks: The mutex associated with it, I guess.
10:45TimMcYou might be able to carry 1 bit of state that way.
10:48trptcolinmight be able to alter method accessibility w/ reflection?
10:48trptcolin[kind of a stretch]
10:49TimMc&(let [o (Object.)] (locking o (.wait o 1000)))
10:49lazybot⇒ nil
10:50TimMcA good candidate for that would be Object#finalize()
10:51ivanremember to lock your Strings before mutating them
10:52ivanyou don't want another thread to see a mutated string without the mutated hashCode
10:53gfredericksI still want mutable nils
10:54trptcolini guess by definition, (Object.) is as immutable as anything can be, aside from primitives, in Java (and by extension Clojure)
10:54ivanhow about some metadata on your nils
10:54ivanI want to know how long it took to generate this nil
10:56gfredericks,(with-meta nil {1 2})
10:56clojurebot#<NullPointerException java.lang.NullPointerException>
11:00tcrayfordclojurebot: for reals?
11:00clojurebotIt's greek to me.
11:01tcrayfordoh, nil is just java null, makes sense that there's no meatdata
11:05trptcolinmeatdata. gross tcrayford
11:05tcrayford#notveganfriendly
11:31rasmustoI have a long-running loop with a Thread/sleep in it, and I get a stack overflow error if it runs for too long. I do a (swap! myatom (partial map somefunc)) on an atom within the loop and then check for some condition to break out of it.
11:32rasmustoI see lots of "LazySeq" and "map$fn" in my stack trace. Is using map (and laziness) a problem?
11:33gdevcan you paste the code on refheap?
11:33xeqiit could build up a bunch of thunks, but I would expect something other then a stack overflow
11:38rasmustogdev: I'll post what I can
11:45dnolenhow many people only use ClojureScript with simple optimizations in production in some way?
11:46dnolenor any optimization really that isn't advanced - I'd assume hardly anyone but curious
11:48cmajor7dnolen: I did, but just because it was quite hard to figure out the reason on why "advanced" did not work. we had too much code to figure it out easily, and the "not found $b.a c.." was not giving it away.
11:48akhudekI still do, but that's mostly because I can't manage to debug a problem.
11:48cmajor7the whole codebase was about a meg
11:49akhudekYes, I have the same issue as cmajor7
11:49cmajor7advanced made it 150Kb, but would not run
11:49trptcolinsame. we're doing that so far, but it's an internal app and i've only been looking at cljs for a couple weeks
11:49mefestoim using advanced opts for production
11:51dnolenfor the people that use simple optimization for some reason, I don't suppose you're super concerned about performance then?
11:51trptcolinyep, for now
11:53McqfrTheScottChousuke, vieläkö ajattelet musta?
11:53rasmustogdev: I had to butcher some of the code, but the gist of it is still there: https://www.refheap.com/paste/d9371bde35befc47d6efa8aea
11:53McqfrTheScottMusta, hollantilaisesta joka puhuu suomea äidinkielena
11:54rasmustoxeqi: I am calling out to clojure.java.shell.sh, I'm not sure if that's relevent at all
11:54dnolenI'm asking because I'm looking at switching keywords to a real type away from JS strings.
11:55dnolenunder advanced compilation we can optimize constant literals easily of course
11:55dnolenbut not under any other optimization mode - so that it means non-advanced compiled code will take a small perf hit for keyword occurences, they have to constructed wherever they occur.
11:56dnolenwell "small"
11:59xeqirasmusto: I would expect lazyness is biteing you there. For (some ...) to get the last element its going to have to step into each (partial map ..) which might contain another call of the same type due to lazyness. I could see this blowing the stack
11:59xeqialso, you could loop/recur to avoid the atom/while/swap! if desired
12:01rasmustoxeqi: okay. I can probably modify the collection I'm using for my loop condition to something less sequential, or make two buckets instead
12:02xeqirasmusto: you could add another doall to confirm before going to far
12:03rasmustoxeqi: doall in the swap?
12:04xeqisure
12:06alex_baranoskydo any of you have a good Emacs configuration that allows you to Meta-. into Java methods, so you can easily dive into clojure implementation details?
12:08cmajor7dnolen: I would love to use it, but it just did not work for me (compiled, but did not run). I wanted to do it more for a size reasons vs. performance, but in any case I agree with "keywords" as a real type vs. strings. Eventually people who run in "simple" would figure out the root cause of "why", and move to "advanced" anyway.
12:09rasmustoxeqi: Okay. I'll give that a shot and see if I can reproduce/fix this issue. Thanks for the suggestions :)
12:37gdevrasmusto:) sorry, I got called away from my desk right as you pasted the link
12:49ynnivis there a way to specify exclusions to plugin dependencies in lein?
12:51xeqiynniv: [lein-plugin "..." :exclusions [some-dep]]
12:52ynnivhmm. what about implicit dependencies?
12:52ynnivbasically: [swank-clojure \"1.4.3\"] -> [clj-stacktrace \"0.2.4\"] is overrulling [ring \"1.2.0-beta2\"] -> [ring/ring-devel \"1.2.0-beta2\"] -> [clj-stacktrace \"0.2.5\"]
12:53ynnivi tried adding swank clojure as an explicit dependency with an exclusion, but it isn't taking
12:53technomancywhat are implicit dependencies?
12:53xeqitechnomancy: dependencies added by a plugin by altering the project before e-i-p
12:54technomancyoh, yeah. =(
12:54technomancyin retrospect I regret ever doing that or encouraging that
12:55xeqi... I can't think of a way. Declaring a top level dep with the version of clj-stacktrace desired would work
12:55xeqi* should work to get that version
12:55ynnivoh, that's simple enough
12:55ddellacostaynniv, what is the plugin you are working with?
12:55ynniv[lein-swank "1.4.5"]
12:56ynnivas well as [lein-ring "0.8.5"] and [lein-pedantic "0.0.5"], but they don't seem to be involved
12:57gdevtechnomancy:) I'll create a feature request to have leiningen display a message when it is asked to do something that you regret adding
12:57ddellacostaIt's interesting 'cause it sounds similar to an issue I had with lein-ring
12:57ddellacostahttps://github.com/weavejester/lein-ring/pull/71
12:57technomancygdev: with a patch please
12:57ddellacosta…so I'm wondering if it's the same kind of issue.
12:57gdevtechnomancy:) mkay, first I need a list of everything you regret
12:57ynnivddellacosta: I had the same problem. I probably fixed it by specifying the library directly without realizing what I was doing
12:58ynnivtechnomancy: also, thanks for making the greatest project management system I have used
12:58dnolenhttp://jsperf.com/fn-caching
12:58dnoleninteresting results
12:58ieureMan it's kind of a drag that (deftype) constructors can't have varargs.
12:58ynnivdon't worry about regrets
12:58technomancyynniv: thanks =D
12:58xeqihmm, I need to remember to deprecate lein-pedantic once lein 2.2 is out
12:58dnolenwe do this kind of caching for reify already, but this could make local fns cheaper
12:59ToBeReplacedieure: the constructor can't, but your function to call the constructor can
12:59ynnivdnolen: wow, what's up with safari?
12:59ieureToBeReplaced, Yeah, but it's pretty crap that I have to make an adjunct function to construct the thing instead of just saying (deftype Blah [& xs])
12:59ieureNow I need (make-blah [& xs] (Blah. xs))
13:00ddellacostaynniv: probably this line is the culprit, I would guess: https://github.com/technomancy/swank-clojure/blob/master/lein-swank/src/leiningen/swank.clj#L62
13:01ToBeReplacedxeqi: i missed the start of the discussion -- deprecate because lein will start rejecting automatically?
13:01ddellacostaynniv: ah, and you already tried added an explicit dependency, and that didn't take, huh...doh.
13:02ddellacostaynniv: sorry, it's 2 AM for me here so I have to hit the hay, but good luck solving this one.
13:03xeqiToBeReplaced: deperecate because I put something similar into lein itself
13:03ynnivddellacosta: thanks for looking into it. Now that I know it's a problem I'll just hack around until it works.
13:04xeqiit won't reject them, just warn on `lein deps :tree`. Thought I think we had a brief discussion on a flag to warn all the time, can't remember now
13:08Okasudnolen: Is this caching are just boring memoization?
13:09dnolenOkasu: it avoids paying the cost of constructing the inner function on every call
13:11ynnivok, I just hit c-c c-z and everything worked… are we not using clojure-jack-in anymore?
13:12ynnivor perhaps more succinctly, how are people using clojure in emacs these days?
13:12dnolenOkasu: so we can cache all inner functions as functions on the namespace, and GClosure will optimize it.
13:13Okasudnolen: Nice.
13:13jstewGreetings. I want to make a small web application to sharpen my clojure skills. What do most people use as a framework? Compjure? Ring? Noir? I'm not lookingfor full stack, just something I can play with.
13:14ynnivI prefer straight compojure
13:14gdevjstew:) http://pedestal.io/
13:14ynnivIIRC noir is no longer maintained
13:14Okasujstew: https://github.com/Okasu/rss Compojure + Ember.js + Ember Data .
13:14jstewI looked at pedestal. I was sort of put off by the "sign and fax developer agreement" think.
13:14jstews/think/thing
13:15jstewOkasu: nice! Thanks.
13:15ynnivOkasu: what's your experience with ember? I've been trying to build useful apps since Sproutcore 0.7, but the system always seems to trip over itself.
13:15technomancyanother vote for straight compojure
13:15gdevyou don't need a CA to use pedestal do you?
13:16jstewgdev: Nope. I could be wrong, but my perception is that the CA will hinder adoption and development.
13:16ynnivcompojure, like sinatra, is probably never going away
13:17tcrayfordI'd vote for compojure over pedal stool as well
13:17Okasuynniv: It's nice and stable atm(not ember data), 1.0 is really near, we are currently using ember at work, and it's really great.
13:17rkneufeldjstew: Relevance guy here, you don't *have* to fax it, you could just digitally sign it.
13:17rasmustogdev: no problem, I think another 'doall' might resolve my problem
13:17rkneufeldjstew: and then email it.
13:17Okasus/at work/in production/
13:18stuartsierragdev: No, you do not need a CA to *use* Pedestal. It's open source (EPL).
13:18stuartsierraIf you want to contribute code *to* Pedestal, then you need to sign & email the CA.
13:19gdevthat's what I thought, I was just wondering why a CA would be a blocker for someone to use it, seemed odd
13:20ieureSo protocols don't generate classnames you can use for hinting?
13:20ynnivthe CA is too prominent on the website. it should probably be under the "open source" "tab", versus jumping out at people on a cursory glance over the page
13:20ynnivalso, the "tabs" are a poor design choice. they don't look like tabs, and they're difficult to use on mobile.
13:21rkneufeldynniv: really, it's almost at the bottom of the page?
13:21xeqiyou mean those are buttons you can click on?
13:22ynnivrkneufeld: yep, I can quickly swipe my fingers to get an overview of the page, and it stops with legalese in my face.
13:22ynnivxeqi: yep
13:22rkneufeldynniv: fair point. I'll echo that feedback to the people working on the website.
13:23ynnivrkneufeld: compare that to reading about languages. you scroll down, don't understand what the framework is about, glance at some grey icons, maybe realize they're clickable, then try to click them (which failed for me on mobile the first time around)
13:23ynnivthat would be excellent
13:24ynnivI like the graphic design, tho
13:28rkneufeldThanks
13:28gfredericksieure: they do -- they generate a jvm interface by the same name I think
13:29gfredericksieure: but you'd have to import it or use it fully qualified. Also I can't imagine that it would accurately describe all types that satisfy the protocol
13:29ieuregfredericks, Sure doesn't seem to work.
13:30ieure(defprotocol Component ...)
13:30ieure(.stop ^Component c)
13:30ieureException in thread "main" java.lang.IllegalArgumentException: Unable to resolve classname: Component
13:30ieureThis is all in the same ns.
13:32gfredericksieure: you may well still have to fully qualify it
13:32hiredmanieure:a protocol is not a class, you cannot use it for type hinting
13:32gfredericksI just tried it at the repl and it worked fully qualified. I don't think you'd want to try to make Component refer to both the protocol and the interface
13:33ieurehiredman, So basically I can't use protocols for performance-sensitive stuff?
13:33ieureOr it has to be the _type_?
13:33gfrederickshiredman: you can't?
13:33hiredmanieure: use the protocol functions
13:34ieurehiredman, Reference please.
13:34gfredericksoh right
13:34gfredericksbut you can use the interface, if that suffices
13:34hiredmanieure: when you create a protocol, you create functions
13:34tieTYT2hiredman: thanks for your help earlier
13:34ieureOkay, wow, protocols are some bullshit.
13:34tieTYT2hiredman: thanks to you, I got some clojure code into our pure java, javaee application
13:35technomancyieure: yesss... feel the hat flow through you
13:35tieTYT2I don't know what the opposite of pandoras box is, but you may have just opened it
13:35technomancyuh
13:35technomancyhate
13:35ieuretechnomancy, I liked the first one.
13:35technomancywhatever floats yer boat
13:36ieureSo what happens if I define two protocols with the same methods in the same ns?
13:36hiredmanieure: protocol functions get inline caches, so use them
13:36hiredmanieure: you can't
13:36hiredmanthey are collections of functions
13:36ieurelmfao
13:36hiredmanthey are not classes/interfaces/methods
13:36gfredericksieure: you can use typehints in the example you gave though
13:36hiredmangfredericks: but you shouldn't
13:36gfredericksbecause it doesn't work for 3rd-party types?
13:37linuxoshow do i get a negative rational number?
13:37hiredmangfredericks: because it is silly
13:37gfrederickslinuxos: ##-3/4
13:37gfredericks&-3/4
13:37lazybot⇒ -3/4
13:37linuxosdon't know why my repl crashes when i do that
13:37linuxosclojure 1.4
13:38gfredericksignore the ## and the &, just type -3/4
13:38hiredman(.stop ^Component x), if stop is a protocol function, be the same performance wise (after jitting) as (stop x)
13:38linuxosi get Exception Ambiguous match for "-3/4" by #<Object[] [Ljava.lang.Object;@5223588b>
13:38hiredmanshould be
13:38linuxos,3/4
13:38clojurebot3/4
13:39linuxos,-3/4
13:39clojurebot-3/4
13:39gfrederickslinuxos: what sort of repl is this?
13:39linuxoslein repl
13:39gfrederickshave you tried rebooting your modem?
13:39hiredmanbecause the clojure compiler can see that stop is a protocol function, it will emit a protocol callsite for (stop x) which includes an inline cache
13:40gfrederickslinuxos: does the stack trace point to anything interesting?
13:40ieureSo is there some way to support multiple protocols in a type?
13:40gfredericksieure: one type implementing multiple protocols? yes that's normal
13:40hiredmanieure: of course, you can name your functions differently, or put them in different namespaces
13:41hiredmanjust like regular functions
13:41hiredman"why can't I have two (def x y) in the same namespace?"
13:41ieurehiredman, Right, but this requires me to understand implementation details of (deftype).
13:42hiredmanno, it requires you to know how clojure functions work
13:42ieureWhich is the problem. It's not clear that it's happening or how it's implemented.
13:42gfredericksnot really; just the fact that the protocol functions are resolvable as vars inside the namespace would suggest you can't overload them
13:42gfrederickswhich I assume is the recommended usage, as hiredman says
13:42ieureThe fact that they ARE resolvable as vars inside the ns is not what's clear.
13:42hiredmanobviously, if a protocol is just a collection of functions in a namespace, you cannot have multiple functions in a namespace with hte same name
13:43hiredmanwhich is why, at the beginning I said "protocols are not classes/interfaces/etc"
13:43gfredericksieure: where are you learning about protocols from? clojure.org/protocols mentions this
13:43ieuredeftype docs: "Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the current namespace, the given fields, and, optionally, methods for protocols and/or interfaces."
13:43ieureIndicates that it makes a class. It works like a class.
13:44gfredericksdeftype is different from defprotocol
13:44ieureDoes not say "Generates functions in the ns corresponding to methods in the type."
13:44hiredmandeftypes don't
13:44gfredericksthe docs for defprotocol indicate in the examples that this is what happens
13:45hiredmandeftypes are not protocols
13:45ynnivoh, swank-clojure is deprecated in favor of nrepl.el? always something new...
13:45technomancyswank still works
13:45hiredmandeftypes can have protocols extended to them
13:46hiredmanif you extend the protocol Component (which has the function stop) to the type X, then you can call the function stop on X
13:46linuxosgfredericks: https://www.refheap.com/paste/14146
13:46technomancylinuxos: I think that's fixed in the latest leiningen
13:46linuxosok
13:46ieureYeah guys you're not convincing me that this stuff is any less shitty.
13:47ieureOnly that you don't understand that to try to use these is peeling a shit onion.
13:47hiredmanieure: you've only convinced me you don't know what you are doing
13:47hiredmanread the docs
13:48gfrederickswell. that was a fruitful interaction.
13:49gfredericksI wish I could understand that to try to use these is peeling a shit onion.
13:50gfredericksthen I could help people better.
13:51technomancyI got a good hat-related laugh out of it.
13:51technomancyin my book that's a win.
13:51gfrederickssuccess criteria: either helping people learn the language or getting a good hat-related laugh
13:51arrdemÂ/me starts reading scrollback, shocked to see a troll in #clojure
13:51hiredman"I wish you could understand that this tool sucks, because I don't know how to use it, and it made me feel bad"
13:52daemiani got "peeling a shit onion" out of it. +1
13:52llasramI would like to tactfully suggest that mocking people who are having a difficult time does not encourage others to join the community
13:52ynniv,(inc shitonion)
13:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: shitonion in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:52gfredericksI wonder if "shit" is an adjective-adjective like a brit might use, or a noun-adjective like anybody else
13:53technomancyllasram: in general I agree, but I know ieure and he's got very thick skin.
13:53llasramFair enough then
13:53gfredericksI don't think we mock people just for having a difficult time
13:54gfredericksthat doesn't make it constructive though
13:54TimMcarrdem: ieure was not being a troll.
13:54ynnivfwiw, I avoid the protocol stuff as well. the bits of clojure that get too involved with java have unexpected "functionalities"
13:55TimMcMocking someone for not understanding a language feature is never going to help that language community.
13:55arrdemdon't understand scrollback... need more coffee
13:55gfredericksit's difficult to handle people getting mad at you after you try to help them. a bit like parenting I guess :)
13:56TimMcLuckily, in this case you can just abandon the angry person.
13:56TimMcNo pesky legal ramifications!
13:56ynnivTimMc: just make sure you're abandoning the person and not the problem
13:56hiredmanI am mocking him for have a ridiculous attitude about it and not being self aware enough to realize it
13:56TimMcynniv: Very true.
13:58gfredericksprobably best to be gracious about self-awareness-lackages; I've definitely been in that position before, and have no way to prove I amn't currently
13:58ynnivhiredman: I think that I showed up here a while ago with a similar protocol related aggravation, but hopefully was more self-aware of my behavior
13:59technomancyman, protocols.
13:59gfredericksthat's technomancy's lesson
13:59hiredman*eyeroll*
13:59arrdemfeh. they exploded in my face the first time..
13:59ynnivI have disavowed all knowledge of polymorphism other than defmulti
13:59hiredmantechnomancy just hates anything that generates lein bug reports
13:59technomancygfredericks: life is simpler when you can just stop paying attention as soon as you hear certain words.
14:00technomancyhiredman: basically
14:00technomancycygwin, protocols, war files.
14:00technomancysublime text
14:00xeqiaot ?
14:00technomancythat too!
14:00gfrederickswhy stop at cygwin? windows
14:00hiredmanalex miller has a talk he gave where he metions protocols for spis, which is where they really shine
14:01llasramspis?
14:01hiredmansevice provider interface
14:01gfredericksspies?
14:01gfredericksnope
14:01llasramhehe
14:01ynnivxeqi: definitely aot. the extension of my knowledge of clojure's aot is :main ^:skip-aot
14:01technomancygfredericks: well, that hate predates leiningen
14:01hiredmanan api can be a lot of regular functions built on top of a protocol (an spi)
14:02gfrederickshiredman: in the dnolen style?
14:02hiredmanso you can use the api to deal with anything you extend the spi to
14:02hiredmangfredericks: sure
14:02gfredericksalso similar to the functions that take seqs
14:02hiredmangfredericks: you ca drop the the 'the' and just say 'dnolen style' because it starts with a d
14:02hiredmangfredericks: seq is a hand rolled protocol
14:02gfrederickshiredman: and now I will
14:03gfredericksyeah I used dnolen style for cljs arithmetic
14:03gfredericksit feels verbose. but I don't have any better suggestion
14:05hiredmanour storage stuff at work is structured that way, we have a protocol that describes what operations we need from an object store, and then a bunch of functions on top for retries, md5sum checking, etc
14:06hiredmanso to use the storage functions with a new object store, you wire up the protocol at the bottom
14:06gfredericksright
14:06ynnivcan I defer to a different route in compojure? kind of a server-side redirect
14:06gfredericksynniv: you could extract all the functionality to a function that both routes call
14:07gfrederickswhich is to say "no I don't think so"
14:07ynnivthere isn't enough code to bother with that, but I don't want them to fall out of sync
14:07gfrederickshow would you even specify what route? construct another path?
14:08ynnivyeah
14:08gfredericksyou could do that a bit manually, but that feels gross
14:08gfredericks(defroutes app (GET "foo" req (app {assoc req :uri "bar"})) (GET "bar" ...))
14:08gfrederickssomething like that
14:09gfredericksprobably lots of reasons not to
14:09xeqior make a mod-rewrite ype middleware
14:09arrdemgfredericks: will that work?
14:09gfredericksyeah that sounsd a lot cleaner
14:09gfredericksarrdem: probably not that exact code. Something similar I think should "work"
14:10arrdemgfredericks: I mean I get rewriting the request, I'm just not sure how compojure does routing.
14:10gfredericksapp is a ring handler, so you can just call it with a request
14:10arrdemyeah that'd do it
14:11gfredericksdoes ring say anything about handlers returning nil?
14:12amalloygfredericks: i don't know if it's explicit, but since nil doesn't contain any of the REQUIRED keys, they're not valid responses
14:17gfredericksI wonder what the adapters do...404 or 500?
14:17xeqiadapters?
14:17gfrederickse.g., the ring-jetty-adapter
14:17xeqiah, right
14:17gfredericksthe thing responsible for taking the clojure value returned and actually telling the client about it
14:18gfredericksor telling jetty about it I guess
14:24amalloygfredericks: 500, i'm pretty sure
14:24amalloyif you want a 404, you do it yourself
14:26tieTYT2is it inefficient to do this every time a method is called: RT.load("clojure/core"); //need to do this first to initalize the RT clojure.lang.Compiler.load(new InputStreamReader(resourceAsStream, "UTF8"));
14:26technomancytieTYT2: yes, reloading all of core is costly
14:27tieTYT2ok maybe I could put this part ina static block
14:27tylergilliescan "case" function take multiple values matches? like (case foo ("bar" or "baz") "quxx")
14:28tylergillieslooks like yes
14:28tylergilliesn/m
14:28[raven]Hi :)
14:30hiredmantieTYT2: https://github.com/sonian/Greenmail/blob/master/src/main/java/com/icegreen/greenmail/pop3/Pop3Server.java#L24-32
14:31tieTYT2hiredman: is that lock relevant?
14:31hiredmannope
14:31tieTYT2phew
14:31tieTYT2any reason these first lines aren't final?
14:31[raven]I've a question, i'm trying to achieve this: http://paste.fedoraproject.org/10082/ but since I'm a noob, i'm not able to figure out how to make it happen. Someone can help me with some actual code? (I wroted a function that split the = string)
14:31hiredmanif you reference the RT class, it should load clojure.core in a static init, so you don't need to
14:31hiredmantieTYT2: nope
14:31tieTYT2ok I'll try this
14:32kastermaI am learning core.logic, using midje to do some testing. I wrote a function last, and corresponding facts. The facts don't behave the way I expect.
14:32kastermahttps://gist.github.com/kasterma/5504254
14:32kastermaHow to check the output of a function?
14:33kastermafunctiono
14:33kastermaI meant.
14:33tieTYT2is that static block saying, (require 'greenmail.pop3) ?
14:33kasterma(lasto [1 2 3] 4) => u# fails.
14:33hiredmantieTYT2: yes
14:34tieTYT2ok thanks, sorry for all the questions
14:35hiredmankasterma: seems like a bad test, running logic goals out side of a run or run* is weird
14:35hiredman(and who knows what kind of weird stuff midje is doing)
14:35kastermaWeird indeed, but at least I expect that to be the output.
14:35kasterma (logic/run 3 [q] (lasto q 3)) => '((3) (_0 3) (_0 _1 3))
14:35kasterma (logic/run* [q] (lasto [1 2 3 4 5] q)) => '(5)
14:35kastermaThese are as expected.
14:36kastermaIs my expectation about the output incorrect?
14:36hiredmankasterma: sure, and those should be, but looking at the result of a goal outside of a run is looking an implementation detail
14:38kastermahiredman: that is an interesting idea; I didn't think of it as such.
14:38tylergilliesdafuq is up with this? https://gist.github.com/tjgillies/2652fe183ab19c2d9923
14:38tylergilliesheh
14:38kastermadoes seem to make sense though. Guess I'll refrain from testing like that. thx
14:39tylergilliesthrowing CompilerException java.lang.IllegalArgumentException: Duplicate case test constant: or, compiling:(NO_SOURCE_PATH:4:3)
14:40tylergilliesoh derp
14:40tylergilliesthe default clause is a single clause
14:40tylergilliesnot a clause called default
14:41tylergilliesdoh that didn't seem to work either
14:42justin_smithtylergillies: case does not want a function to apply, it wants the literal value to check
14:42justin_smithit is turning (or "develop" "staging") into "develop" before the statement runs
14:42justin_smithnot comparing to both
14:43akells`how does one get the length of a byte array? For example, I get a 'no matching field' found for (.length (.getBytes "abc"))
14:43akells`sorry, this is a borderline java question I guess
14:43llasram&(count (.getBytes "abc"))
14:43lazybot⇒ 3
14:43ToBeReplacedtylergillies: justin_smith is right, consider cond, or transforming your value before the case
14:43akells`thanks llasram
14:44tieTYT2god I really hate that -/_ bs that clojure makes you do
14:44xeqi&(alength (.getBytes "abc"))
14:44lazybot⇒ 3
14:44tieTYT2it would be simpler if they just forbade the - symbol
14:44tylergilliesdoh thanks
14:46akells`thanks xeqi
14:46justin_smithcase is nice because it can do constant time dispatch unlike other stuff. one simple option: (case cluster-name "develop" "testing" "staging" "testing" "production" "production" "production)
14:46akells`alength vs. count -- is there a reason to pref one over another?
14:46justin_smithI missed a " above
14:47TimMc,(class -)
14:47clojurebotclojure.core$_
14:48ToBeReplacedakells`: if it's a java array and you need speed, use alength... if it's a clojure collection, use count
14:48akells`much appreciated ToBeReplaced
14:48xeqiI believe alength gets translated into the jvm bytecode for array length, so should be faster
14:48amalloyjustin_smith, tylergillies, ToBeReplaced: that's not really an accurate description of what case does, or how to fix his problem
14:48akells`thanks xeqi
14:48dnolenkasterma: did you solve your problem?
14:49justin_smithoh, test-constants- I see that now
14:49justin_smith!
14:49amalloycase takes literals, so it doesn't evaluate them at all. it's certainly not turning it into "develop" at compile-time; rather, it treats a list of things as an "implicit" 'or
14:49justin_smithcool, amalloy, thanks!
14:49amalloyso it's saying that it will fall into clause 1 if the value is any of: 'or, "develop", "stagin"; and clause 2 if the value is any of: 'or, "production"
14:50kastermadnolen: well, solve is one word for it. :-) I learned that the results of goals are considered implementation dependent, and I should just test in the context of run.
14:50amalloythe fact that the symbol 'or falls into two clauses means it can't compile. if you just removed the or from both of those lists, everything would work fine
14:50tylergillies(inc amalloy)
14:50lazybot⇒ 52
14:50kastermaThis removes the problem, but I am still getting used to it.
14:50dnolenkasterma: this true, results of a goal is opaque anyhow, you'll just get a function
14:51kastermadnolen: => s# worked though, only the => u# didn't.
14:51kastermaI did see that in the repl different function no's were given.
14:51amalloyakells`: alength if the array is type-hinted
14:51amalloycount if you don't know its type, or you care more about readability than performance
14:52akells`amalloy: much appreciated, thank you
14:52kastermadnolen: anyway, thanks for checking up with me. I am really excited about learning core.logic. Just a year ago I switched from being a logician to being in IT. Now logic is back!
14:53dnolenkasterma: heh, cool.
14:53hiredmanalength is silly
14:53hiredmancount can take arrays and has a special case for them and doesn't do anything silly like turning them in to seqs first
14:53clojurebotseqs and colls is http://www.brainonfire.net/files/seqs-and-colls/main.html
14:53amalloyhiredman: count does reflection for arrays
14:53kastermadnolen: I am finding it strangely easier to proof the existence of weird stuff from AC, than to get into logic programming. Just started though.
14:54dnolenkasterma: AC?
14:55kastermadnolen: axiom of choice.
14:55[raven]no help? http://paste.fedoraproject.org/10082/
14:55dnolenkasterma: the learning curve around logic programming is pretty steep I think, but then it gets very flat.
14:56kastermadnolen: I am doing the prolog 99 problems now. Directly working on what I think it'll help with is a bit too steep.
14:57dnolenkasterma: cool! I haven't tried those myself - it may be that some of the more advanced example may require features of Prolog we don't have yet.
14:57Okasu~/quit
14:57clojurebotNo entiendo
14:57dnolenadvanced problems I mean
14:58ToBeReplacedamalloy: that's wacky with case; i had no idea ->
14:58kastermadnolen: if I have as much fun with learning as I expect, than I'll just keep going and help implement to get the features. :-)
14:58ToBeReplaced,(case '(0) (0) 1 0)
14:58clojurebot0
14:59dnolenkasterma: help always welcome
14:59ToBeReplacedthat scares me... because that's not at all obvious
14:59ToBeReplaced,(case '(0) [0] 1 0)
14:59clojurebot1
14:59tieTYT2why's there no disj for maps?
14:59kastermadnolen: one other thing I read recently that I am very interested in in probabilistic prolog ideas; think Church.
14:59kastermaare there implementations of that going?
15:00dnolenkasterma: we might do a Google Summer of Code on that
15:00amalloyyes, if you have never read the docstring for case, that is not obvious. but it includes a specific mention about not doing that
15:00dnolenkasterma: there is an existing Church-like project
15:00kastermadnolen: link?
15:00dnolenhttps://github.com/clojure/core.logic/wiki/CLP%28Prob%29
15:02kastermadnolen: thx, I'll take a careful look after I finish singletono and next2lasto.
15:03trptcolin[raven]: https://www.refheap.com/paste/14150
15:05[raven]trptcolin: Thanks a bunch!
15:07gfredericksToBeReplaced: that's pretty weird; what's the difference there?
15:07gfredericks,(case '(0) '(0) 1 0)
15:07clojurebot1
15:13ToBeReplacedgredericks: if the test constant is a list, it checks whether the expression is in the list, not equal to the test constant
15:14ToBeReplacedi didn't know that until a few minutes ago... amalloy points out that it's in the docstring... still took me by surprise
15:14amalloy,(case 'quote '(0) 1 0)
15:14clojurebot1
15:15tieTYT2,(type vals {})
15:15clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$type>
15:15tieTYT2,(type (vals {}))
15:15clojurebotnil
15:15tieTYT2doh
15:15tieTYT2why does that return a clojure.lang.APersistentMap$ValSeq ?
15:15tieTYT2I guess that's a type of sequence
15:16tieTYT2i'm taking the result of a (vals m) call and trying to put it in an ArrayList
15:17amalloytieTYT2: why would you put it into an ArrayList?
15:17tieTYT2but that's not working as expected. It's giving me a persistent list with APersistentMap$ValSeq in it, with the values in there that I want
15:18tieTYT2I want to put the values into an arraylist
15:18tieTYT2I'm calling it from java
15:19tieTYT2and the java code wants to put it in an arraylist
15:19tieTYT2i'm not sure if I answered your question or not
15:19amalloytieTYT2: if the java code really wants an arraylist it's pretty bad java code
15:20amalloyit should be happy to accept a Collection, or at least a List, which clojure sequences implement
15:20tieTYT2well the thing is this is going to be passed to JPA
15:20tieTYT2and I'm concerned JPA will freak out if it's a clojure List
15:21antares_Titanium beta1 is released: http://blog.clojurewerkz.org/blog/2013/05/02/titanium-1-dot-0-0-beta1-is-released/
15:21amalloywell that's silly. unless it actually has a problem, or the javadoc explicitly says it must have an ArrayList, don't be concerned until you've tried the obvious, easy thing and it doesn't work
15:22tieTYT2ok fair enough
15:23amalloyglancing through the JPA javadoc, it seems to work with interfaces as generic as possible, so good on them
15:23tieTYT2but, vals is returning a List that returns a PersistentVector when I call "get" on it
15:23tieTYT2so there must be some flaw in my clj code
15:31tieTYT2oh the group-by result has a list wrapped around it for some reason
15:31tieTYT2must be a problem with my input
15:40tieTYT2oh i get it now. Group by returns a map where the values are wrapped in a vector. I forgot that vector part
15:42justin_smithcode I literally just now wrote: (defn itemize-by [k m] (into {} (map (fn [[k [v]]] [k v]) (group-by k m))))
15:42justin_smith
15:42justin_smithyes I use k twice, which is bad
15:46tieTYT2how can I make this code more idiomatic? https://www.refheap.com/paste/cc1d92f1176a5eaf454cadcc6
15:49rbxbx``tieTYT2: I believe (vals (apply dissoc (keyed-map db) (keys (keyed-map changes) could be replaced by using select-keys (http://clojuredocs.org/clojure_core/clojure.core/select-keys)
15:49tieTYT2how's this? https://www.refheap.com/paste/dce5a89c541657841a9645b82
15:49rbxbx``(I think that's what you're doing, yes?)
15:50tieTYT2yes I think so
15:50tieTYT2ok thanks
15:50rbxbx``np
15:52tieTYT2actually I think select-keys is the opposite of what I want
15:52tieTYT2i want to remove the keys
15:53tieTYT2not keep them
15:53tieTYT2oh but i think ic an do it this way
15:57justin_smith#(.getConsentKey %) == (memfn getConsentKey)
15:58justin_smiththat is one way to make it more idiomatic, tieTYT2
15:58llasramExcept that `memfn` is basically deprecated
15:58justin_smithit is?
15:58justin_smithwhy is that?
15:58ppppauli want to do something like (update-in {:a "1"} [:a] Long/parseLong)
15:58ppppauland suggestions?
15:58ppppaulany*?
15:59tieTYT2justin_smith: what I did or what rbxbx`` is suggesting?
15:59gfredericksppppaul: #(Long/parseLong %)
16:00ppppaulthanks :)
16:00gfredericksnot really possible to call a static method succinctlier than that
16:00llasramjustin_smith: *shrug* All I know is that parts of the Internet believe rhickey so-considers it
16:00ppppauli guess i could wrap it
16:01ppppaulllasram, what?
16:01llasramppppaul: Re: memfn pseudo-deprecation
16:01justin_smithtieTYT2: well it applies to both, I personally think (memfn getConsentKey) is better than #(.getConsentKey %) but they are identical in what they do
16:01gfredericksmemfn reduces the number of classes generated by compilation, no?
16:01gfredericks,(class (memfn foobar))
16:02clojurebotsandbox$eval36$fn__38
16:02gfredericks,(map class [(memfn foo) (memfn bar)])
16:02clojurebot(sandbox$eval75$fn__77 sandbox$eval75$fn__80)
16:02llasramgfredericks: memfn is a macro, so no
16:02gfrederickshmm
16:02gfredericksah good point
16:02gfredericksit's partial that does that
16:02gfredericks,(map class [(partial + 2) (partial + 4)])
16:02clojurebot(clojure.core$partial$fn__4214 clojure.core$partial$fn__4214)
16:02gfredericksphew
16:02gfredericksI'm right about _something_ at least
16:02llasramHeh :-)
16:03llasramI try not to let that go to my head when it happens to me
16:03gfredericksask me anything about clojure and I'll find something different that I'm right about
16:04amalloygfredericks: do you guarantee that it's a different something every time?
16:04amalloyif so, i have uncountably-many questions for you whenever you've got the time
16:04justin_smithoh - one reason #(.foo %) beats (memfn foo) is that you can type hint the former
16:04gfredericksamalloy: sure, just send me a list of them
16:05amalloygfredericks: (keep to-ascii-string (range))
16:05gfredericksI question your use of "uncountable"
16:05amalloyyeah, i know. that's countable, sadly
16:06gfredericksyou can't waffle on the very thing I was counting on to prevent you from fulfilling my demands
16:06amalloyi couldn't quickly think of a way to generate an uncountably-infinite list in clojure
16:06technomancythere's no reason memfn couldn't take an optional type hint though
16:06technomancykind asilly
16:06gfredericks"uncountably infinite list" is oxymoronic
16:06amalloyis it?
16:06gfredericks"countable" == "listable"
16:07justin_smithtechnomancy: I agree, I like memfn better than anonymous function literals, just reporting what I find when looking for an explanation for the deprecation
16:08tieTYT2justin_smith: http://blog.jayfields.com/2011/08/clojure-memfn.html
16:08tieTYT2according to that, "...it is almost always preferable to do this directly now..."
16:08technomancyis there a good reason why references to static methods can't be auto-memfnd?
16:08technomancyerr--not memfn but some static equivalent of memfn
16:09technomancyseems like it could be easy to determine at compile time
16:09gfrederickssuch that you could (map Long/parseLong ["1" "2"])?
16:09technomancywhy not?
16:09gfredericksI've wondered that too
16:09gfrederickssame for instance methods, no?
16:09technomancymaybe arity ambiguity?
16:10technomancygfredericks: depends on whether a leading dot is legal anywhere elsee
16:10ystaelgfredericks: i don't suppose you'd accept "map with well-ordered domain" as a proxy for "list"? :)
16:10technomancyI guess you could have :require [my.stupid.long :as Long]
16:10amalloygfredericks: (for [n (range), set (power-set (range n))] (to-ascii set))? that should have cardinality larger than the integers, thus uncountable, right?
16:10technomancycapitalization isn't a reliable indicator in this case
16:11ystaelamalloy: nope, that's a countable union of finite sets, still countable
16:12gfredericksany list of finite objects is countable
16:12gfredericksso if you've giving me a list of finite strings then it doesn't matter how you generated them
16:14amalloyi've changed my mind and now hate set theory forever
16:14gfredericksread about ordinals instead of cardinals
16:14gfredericksthey're much trippier
16:15technomancyso the "ambiguity" is actually resolvable (duh) because the compiler knows the ns map
16:15gfrederickswell; based on the amounts of either topic that are in my head
16:15technomancyhow silly of me
16:15gfredericksystael: your map with a well-ordered domain would have to accept infinite arguments I guess?
16:17ystaelgfredericks: well, your well-ordered domain could be [0..1] given any well-ordering from Zermelo's theorem :)
16:17gfredericksbut if you're in clojure you can't represent arbitrary irrational numbers
16:18gfredericksunless you want to argue that some mapping from infinite lazy sequences of something to irrational numbers suffices
16:18ystaelthe map still would not be representable in clojure, that's true
16:19gfredericksyou brought up well-ordering as a weaker form of a "list"?
16:19ystaeli was being silly :)
16:20gfredericksI cannot take set-theory but seriously
16:20technomancyset theorists, on the other hand
16:20ystaeli figured, if you want to give an uncountable "list" of questions, maybe you could at least index them by the first uncountable ordinal or something
16:21djwonkdo functions used in `reduce` have conventional param names? (e.g. [acc item] or something?)
16:21gfredericksystael: it's a "generalized list" :)
16:22technomancydjwonk: I usually use `acc' unless I can come up with a better name (nodes, counts, etc)
16:22djwonktechnomancy: thanks
16:22technomancyelem, item, or x for the second
16:22djwonktechnomancy and hello from clojure/west
16:22technomancyhi hi
16:23gfrederickswhat? clojure/west is happening again?
16:23gfredericksthis must be a dream
16:23gfrederickscrap crap crap I must be missing my talk
16:23djwonkit probably will, but not today
16:24gfredericksI bet there's a class I failed to show up to all semester too while we're at it
16:24djwonkthe swearjure talk was brilliantly executed, it set a new bar for seriously joking talks
16:24gfrederickshaha, thanks
16:25djwonkoh, I said that without realizing it was you!
16:26djwonkmaybe my subconscious knew?
16:27ystaelevery time i hear the phrase "brilliantly executed" my mind's eye sees a very, very shiny axe
16:30clojurenewbhi, is there a way to handle an assertion error nicely, presenting a friendly message to the user without littering my function with exception handling ?
16:30djwonkystael: as opposed to duly executed, like a legal document or rusty guillotine?
16:31djwonkI guess it makes a difference: duly executed vs. dully executed
16:32stuartsierraclojurenewb: Exception-handling is usually messy.
16:33djwonkI'm thinking about a parsing problem. I've got a list of things and I'm building up a array (with nesting). I'm thinking about building it up with 'reduce' but it might not be the right way... since I need to keep track of the "next position" where an insert will happen
16:33clojurenewbstuartsierra: totally agree
16:33clojurenewbit just makes my functions cluttered
16:34technomancyclojurenewb: there was a lib recently announced called "dire" that attempts to separate that kind of stuff out. haven't tried it, but it might address what you're asking.
16:36mthvedtdjwonk: if you're using a parser lib, there is probably some way to rewrite parser rules to make it simpler
16:36clojurenewbtechnomancy: yes, I had a look at that, was hoping to avoid more dependencies etc, see if there was anything doable in core clojure
16:36djwonkmthvedt: I'm not currently using a parser lib, maybe I should consider doing so
16:36gfredericksclojure's built-in error handling is pretty raw
16:37gfrederickswhich is probably partly because libraries can make it arbitrarily nice via macros &etc
16:37technomancyI wouldn't worry about avoiding dependences, but avoiding new constructs that aren't built-in or particularly well-understood/well-documented is wise
16:37mthvedtdjwonk: i'd like to plug my project, https://github.com/eightnotrump/clearley, to try to make "parsers that do things" easy to write
16:37gfredericks technomancy worries about dependencies so that you don't have to
16:37technomancygfredericks: &etc is redundant
16:37technomancyetc or &c
16:38gfredericksjust because it's redundant doesn't mean I don't want to say it
16:38technomancyI see
16:39gfredericksredundancy is desirably in all sorts of situations, especially communication
16:39gfredericksI'll go as far as I have to in order to keep from backtracking on anything I say
16:39technomancy"pin number"
16:40trinary"atm machine", "NIC card"
16:40reesesnic has been retronamed controller
16:40reesessince they're not usually on cards anymore
16:41trinaryfair enough :)
16:41callengfredericks: & is et which is "and"
16:41callengfredericks: et cetera => & cetera => &c
16:41reeses&c. is a great way to create an affected style
16:41lazybotjava.lang.ClassNotFoundException: c.
16:42winknever seen &c
16:42winkbut I've also never seen "and yet" as in http://andyet.com/
16:42technomancyit's even better if you have fancy-pants typesetting on your ampersands
16:42winkyou and your silly mothertongue!
16:42djwonkmthvedt: cool. do you think it would be a good fit for: https://gist.github.com/bluemont/5505213
16:43reesestechnomancy: the two do seem to go hand-in-hand, don't they?
16:43technomancyreeses: one would hope
16:43reesesthe sort of person who uses ffi ligatures
16:44reesesor the worst, the ct and st ligatures
16:44TimMcoffice
16:44TimMcdoesn't look too good in my terminal
16:44djwonkligatures are a pain
16:44technomancydjwonk: that's how it shows you care
16:45technomancyif it were easy everyone would do it
16:46djwonkoh? I mean converting ligatures from PDFs into searchable text is something I need to deal with
16:46djwonkprobably not too bad if I just did it and quit complaining about it
16:46reesesthey're fine if implemented correctly, so the text layer has the non-ligature version for searching/indexing
16:46mthvedtdjwonk: taking a look… that grammar's partially context-sensitive, i think
16:46reesesdjwonk: you're dealing with the output of lazy typesetters, then
16:47mthvedtis any x.y intended to be a subheading of x?
16:47djwonkreeses: I think there are decent ligature conversion tools in Unicode
16:48djwonkmthvedt: the actual text of the heading does not matter. I should have mentioned I have a `heading-level` function that returns the nesting level
16:48reesesyeah, you can play with the text layer to replace them
16:49mthvedtdjwonk: is heading level a fn of the number of ='s
16:49djwonkmthvedt: just updated the gist, "==" is level 1, "===" is level 3, etc.
16:49djwonkurg... "===
16:49djwonk is level 2
16:50djwonkFWIW, I'm parsing MediaWiki headings
16:51djwonkmthvedt: I think if I pass along the current heading level in the reducer, I can parse manually pretty easily, not that I think about it
16:51djwonknot->how
16:51mthvedtdjwonk: that sounds best
16:52mthvedtit's a context-sensitive grammar, so no parser can do it automatically, the best is to split the chunks into tokens and do the thing you said
16:53mthvedtat least, no parser i know of for clojure
16:53djwonkmthvedt: thanks for taking a look
16:53djwonkI'll share back when I've got it
16:54mthvedtdjwonk: np
17:04TimMcdjwonk: NFKC doesn't do what you need?
17:06TimMc(Norm/normalize "\ufb03" NF/NFKD) ;;= "ffi"
17:06djwonkTimMc: haven't tried http://docs.oracle.com/javase/7/docs/api/java/text/Normalizer.Form.html#NFKC yet -- hopefully it will!
17:06djwonkthanks
17:07TimMcNFKD might actually be what you want, I dunno.
17:08djwonkit sounds better than ignoring it and hoping they will fix themselves
17:12djwonkmthvedt: side note: converting the output structure to all arrays (no hashes) makes it easier to incrementally build
17:14tieTYT2i like how pre/post throw errors even if -ea isn't set
17:14akells`does anyone have experience with java.nio.file.Files readAllBytes method? I'm about to tear my entire project apart under the assumption that it isn't reading all of a files bytes, but I wanted to ask around before I do. google doesn't seem to be helping me here. here's the code I'm using to create the byte array: http://pastebin.com/X9MhtxsC
17:15djwonkakells`: any chance you are closing the file too soon?
17:15akells`djwonk: I'm wondering if that might be the case, because all of my files are several kb short
17:15djwonkI've done that by mis-using `with-open`
17:16akells`djwonk: but the pastebin code is the only part that is actually dealing with the filesystem
17:16akells`I just don't see how I could be closing it too early, based on the nio.file.Files docs
17:17djwonkthat was my only guess, it might not be the actual problem
17:17akells`djwonk: I appreciate the input
17:18djwonkakells`: can you share the code where you consume the bytes?
17:18akells`djwonk: as in, where I'm writing them out?
17:19djwonksure
17:19gfrederickscallen: now I know
17:22akells`djwonk: sorry it took a minute. http://pastebin.com/s9s2gw0f
17:22akells`the top function is just the snippet I'd pasted before
17:23akells`I'm able to properly get the length of the byte array -- at the point that its doing the concatenation, it knows the proper size of the image file
17:23djwonkakells`: black & white clojure code is hard to read (nudge)... where's the syntax highlighting... :)
17:23akells`oh sorry
17:23akells`http://pastebin.com/1e1FxBZR
17:25djwonkthanks :) I'm no expert, maybe someone else can help. I was just trying to figure out where the files were being opened and closed. it looks implicit -- if so, I'm not sure how you could be messing that up (not saying you are)
17:25akells`yeah. something must be going wrong at the concat part, I think. because I have a function that gets the length, and it uses the same .readAllBytes method to get the length
17:26akells`so that makes me think that if .readAllBytes is properly returning the length, it is probably also getting all the bytes properly. which would indicate that maybe the problem is somewhere else -- like the concat function or the actual outputting
17:27mebaran151easiest way to do an sha1sum?
17:27djwonkakells`: any chance you are reading the file twice and messing up the file pointer?
17:29gdevlazybot:) whatis he talking about?
17:29akells`djwonk: hm I'll look into that
17:38mchampinemebaran151: Perhaps https://github.com/franks42/clj.security.message-digest but are you sure you just want SHA1? What's it for?
17:40mchampineDon't use SHA1 for password hashing. There are better alternatives.
17:41aaelonystarted playing around with Analemma which is really nice for drawing svg graphs served by ring. xy-plot (https://github.com/liebke/analemma/blob/master/src/analemma/charts.clj) works really well, but trying to figure out how to connect points into lines and also how to add an x label and a y label....
18:00mebaran151mchampine: not exactly for password hashing: I wanted an easy way for a partner app to demonstrate it generated a certain bit of JSON
18:09SegFaultAXmebaran151: bcrypt for passwords. Seriously.
18:12arrdemmebaran151: bcrypt yo you know you want to
18:26mchampinemebaran151: I put a snip w/ a simple SHA1 here: http://pastebin.com/3PfQfM7Q
18:27trptcolinmebaran151: if that bit of JSON is for the partner app to prove it knows a secret, you probably want a MAC [assuming security actually matters for your use case]. SHA1 is vulnerable to length extensions (https://blog.whitehatsec.com/hash-length-extension-attacks/#.UYLl_Ss4VV8)
18:29_gdevgdev: y u no remember to log out
18:30mchampineAs long as you're just making sure 2 chunks of text match SHA1 is fine. If it's for anything you want to be secure, don't use it. trptcolin is right, use MAC (e.g. HMAC) to prove you know a secret - via challenge/response.
18:47arohnerare there any libraries (or emacs modes) for properly indenting a chunk of clojure source?
18:47arohnerwith newlines
18:47hiredmanclojure.pprint has a code mode
18:48hiredmanwhich is not perfect by any means, but is better than nothing
18:48nDuffemacs isn't that far off with clojure-mode IME
18:49hiredmanactually, I should say it is pretty good, when I used it last the most annoying thing was docstrings
18:49hiredmanit would print a doc string like a string literal so "\n" instead of newlines, etc
18:50arohnerI tried clojure.pprint, but it royally screwed some fns, like (foo \n bar \n baz \n 1 \n 2), etc
18:50technomancyyeah, I've had mixed luck with pprint
18:51hiredmanarohner: using the code-dispatch?
18:51arohnerhiredman: yes
18:51hiredmanhave you adjusted *print-right-margin* ?
18:52hiredmanthere is https://github.com/brandonbloom/fipp
18:52arohnerhiredman: ah, no. I'll play with that. thanks
18:52hiredmanit doesn't have a code mode
18:57callen"The latest stable version of Clojure Core is 1.3.0." <-- remind me why we tolerate clojuredocs?
18:59technomancybecause the alternative is incessant whining?
18:59callentechnomancy: wasn't there an effort to make a similar site a year'ish ago?
19:00technomancydunno
19:00callenit was around the time I was pondering something similar, and I was told not to bother because they had something in the works.
19:00callenbut nothing's changed, so I'm reconsidering.
19:00technomancythere's a new backend
19:00callenwut
19:00callentechnomancy: to clojuredocs.org?
19:00technomancyayup
19:00technomancyit's just blocked on someone volunteering to port the rails codes
19:01callenstill looks to be rails to me.
19:01callenif the current app is Rails, what was the old app?
19:01technomancyevery time it comes up someone is like "oh I guess I should help out with that" and no one ever does
19:01callenmy solution wasn't really to fix clojure-docs, it was to just make a clojure-backed wiki that was populated with documentation.
19:01technomancythe current frontend is from the old version
19:02technomancythe current backend is a compojure REST API thingy
19:02callenisn't the documentation populated by a script? Why isn't that just re-run for 1.4 and 1.5?
19:02callenI feel like I'm missing something here.
19:02technomancyI don't think there's a script
19:02technomancyit was probably hand-imported
19:03technomancymysql was involved
19:04arrdemtechnomancy: incessant whining is easier than porting a rails app
19:04arrdemfor now
19:05callenso is the issue that the rails app needs to be ported to a clojure app/
19:06callenI'm a little puzzled as to why the delineation of frontend rails app // backend compojure app exists.
19:06technomancyjust a clojure HTML UI really
19:06callenI'm bumbling around on his github, looking for that backend.
19:06technomancycallen: IIRC the backend was added to make the repl clojuredocs-client more feasible
19:07arrdemI mean if it's just an issue of porting the frontend style to a compojure template we have tools to automate a good chunk of that
19:07arrdemI and three other ppl have written html -> compojure templating engines
19:07callentechnomancy: do you know who owns/runs the backend?
19:07callenI can't find it on zkim's gh
19:07technomancyI know dakrone is involved
19:07callenarrdem: no.
19:07technomancyantares probably too given how much he goes off on docs
19:08amalloytechnomancy: i don't think so. i think antares just started clojure-doc.org or whatever, to compete instead of fixing
19:08technomancyamalloy: there's no competition really
19:09technomancyone is completely static long-form prose, one is per-var reference and comments
19:09amalloysure, the value they provide is totally different. but they're fighting over domain name mindshare :P
19:09callenthey're both nice to have.
19:10callenI just wish the API docs were 1.5
19:10technomancyamalloy: long-term plan is to make the prose one a subdomain
19:10technomancyI think there were hiccups around domain registration transfer or something
19:11technomancyI just use docstrings
19:11technomancyand ask on IRC when something is confusing
19:11technomancyHTML docstrings are way overrated
19:13Apage43If I'm really feeling crazy I'll use markdown docstrings
19:15arrdemApage43: long live lein-marg!
19:16Apage43yes :)
19:17stian_Want to do a "quantified self" app in Clojure - both to store data from my time tracker (start, end, category), but also be able to insert arbitrary time-based "facts" (time, ran 2km) (day, sleep quality: 4) etc... What would be a good storage layer? I was thinking about a key-value store, but needs to be embedded (this will not be a web app). And need good ability to query on range of time/date.
19:18arrdemstian_: first off github that 'cause that's something I've been thinking about for a while
19:18callenstian_: don't implement your own logical storage layer yourself
19:18callenstian_: use a real database and store time in UTC
19:19arrdemstian_: callen beat me to it.
19:19technomancystian_: there's a decent embedded BDB for Java IIRC
19:19stian_callen: Yeah, but if embedded, it's basically Sqlite3?
19:19technomancydon't use sqlite
19:19technomancyon the JVM
19:19callenstian_: define embedded for me.
19:19technomancythe jdbc bindings are no good
19:19stian_callen: I'd like to be able to wrap an uberjar in a DMG, and have someone run it. Witout having to start a Redis server or something
19:19callenstian_: because I've known srs-face embedded engineers and people who just mean, "doesn't use a daemon"
19:19arrdemstian_: ibdknox's simpledb would probably cut it for a start,
19:20arrdemstian_: then transition to a mongo instance
19:20callencringe.
19:20arrdemcallen: better plan?
19:20brehautdoesnt derby come with java these days
19:20callenstian_: the most well-tested solution to this "zero-daemon database" is sqlite3, despite the whining about it.
19:20stian_arrdem: Mongo instance for a "native" GUI app?
19:21technomancysqlite3 is fantastic
19:21callenstian_: bdb is the other well tested solution, but you'll be hacking up your own indices and projections.
19:21technomancyif you are not on the JVM
19:21callentechnomancy: what's the problem with sqlite3 on the JVM?
19:21callenarrdem: is this a desktop application?
19:21technomancycallen: the jdbc bindings are a mess as soon as you need concurrency
19:21stian_H2?
19:21arrdemcallen: evidently
19:21hiredmanderby or h2 are both respectable choices
19:21callentechnomancy: singleton db handler. :P
19:21stian_callen: Yes.
19:22technomancyuse derby or h2 if you need SQL, BDB if you need just k/v
19:22hiredmanI have a 3 gig h2 db here I've been using for crunching log stats
19:22callenstian_: is this a toy or scratch-my-itch thing?
19:22callenhiredman makes a good point about derby and h2, assuming JVM is a given.
19:22stian_callen: Both :) Just playing around for now, but of course I'll put it on GH and if other people like it, maybe it could become sth more. Not talking about a lot of data though - performance is not a big issue.
19:23callenstian_: I'd say sqlite3 with a singleton database handler, h2, or derby.
19:23stian_callen: Thanks
19:23callenI'm not sure to what extent you're going to need concurrency here.
19:23stian_FleetDB?
19:24callenstian_: no.
19:28stian_OK, I think I'll try with H2.
19:56pendlepantsanyone have a recommendation for a cassandra library?
20:11djwonkI want to apply a function n times. This is what I'm using. Is there a more idiomatic way? (nth (iterate peek my-vector) 2)
20:11djwonkI'm grabbing the 'last' part of a nested vector
20:11djwonkin the above case, (peek (peek my-vector))
20:11amalloydjwonk: no
20:12amalloyyou could (-> (iterate peek my-vector) (nth 2)) if you want; i don't like nth's argument order, personally
20:12djwonkamalloy: thanks! the parsing code I'm working on is pretty fun
20:35tieTYT2what if I'm using the threading operator to pass through dissoc and map? The former wants the seq as the first, the second wants it as the last
20:35tieTYT2should I just not use threading in this case?
20:37mthvedttietyt2: https://github.com/rplevy/swiss-arrows
20:37tieTYT2jesus that's intimidating
20:37tieTYT2there's not an easier way?
20:38tieTYT2I was hoping I could do this with the ->> operator: #(dissoc % nil)
20:38mthvedttietyt2: i think that's allowed
20:38mthvedtalso
20:38RaynestieTYT2: You should just not use threading in that case.
20:39RaynesPlease don't try to hack around things just to use the threading operators.
20:39RaynesThey're made for specific situations.
20:39tieTYT2I did this: (->> (dissoc consents nil) vals (map count) (filter #(not= 1 %)) empty?)
20:40tieTYT2that's not too hacky is it?
20:40RaynesNo.
20:40tieTYT2ok good
20:40tieTYT2i don't understand why my anonymous fn didn't work though
20:40tieTYT2it said it couldn't convert something into an ISeq
20:40mthvedti think you have to do
20:40mthvedt(#(blah blah))
20:41tieTYT2oh yeah
20:41tieTYT2it looks better the way I wrote it so I'll leave it like that
20:46mthvedtif you have a long threading chain, it's often easier just to stick a (#()) in there
20:46mthvedti don't think it's more obscure than lots of irritating superfluous parens
20:48tieTYT2seems practical, thanks
20:48tieTYT2i lucked out that I didn't need to do that
20:48mthvedtyeah, your solution is fine, i was just trying to be passive-aggressive towards raynes
20:49mthvedt:P
20:49tieTYT2hah
20:49xeqiyou wont win that battle
20:49amalloyhaha
20:49mthvedtpassive aggression isn't choosing battles… it's a lifestyle
20:50tieTYT2thanks, ttyl
20:51RaynesI've been called the king of passive aggressiveness before.
20:51RaynesBe careful.
20:53xeqior direct aggressiveness https://twitter.com/IORayne/status/247648094362157057
21:01dobry-denthere is just no end to raynes' rage. i encountered this gh issue last week https://github.com/kingtim/nrepl.el/issues/83#issuecomment-8794778
21:02RaynesThat was my very thoroughly filtered thoughts.
21:04mthvedtraynes? more like
21:04mthvedtraygenes
21:04mthvedt(one syllable)
21:08djwonkis `conj` efficient for vectors? If so, how would I know from the docs?
21:09gfredericks,(doc conj)
21:09clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
21:09gfredericksit's _very_ mildly implied from the last sentence
21:11djwonkthanks gfredericks
21:11gfredericksthe idea is that conj adds things in a way that's appropriate for the datatype
21:12djwonkit is mentioned on the cheatsheet at http://clojure.org/cheatsheet, but not at this summary of vector functions: http://clojure.org/data_structures#Data Structures-Vectors (IPersistentVector)-Related functions
21:12djwonkso there is a slight disconnect in the docs as to the question of "is conj encouraged" for vectors
21:12gfredericksit definitely is
21:13gfredericksassoc works too but you have to know the index so that's dumb
21:13djwonkthanks
21:13akhudekconj is amortized log32n or something for vectors, so very fast
21:39gfredericks,(let [v (vec (range 10000))] (time (dotimes [_ 10000] (conj v :foo))))
21:39clojurebot"Elapsed time: 5.003558 msecs"\n
21:39gfredericks,(let [l (apply list (range 10000))] (time (dotimes [_ 10000] (conj l :foo))))
21:39clojurebot"Elapsed time: 1.476985 msecs"\n
21:40xeqiyou know the bots sandbox and manipulate forms so their timing will be way off
21:40gfredericks,(let [s (set (range 10000))] (time (dotimes [_ 10000] (conj s :foo))))
21:40clojurebot"Elapsed time: 12.914148 msecs"\n
21:40gfredericksthis is the most scientific way to do it
21:40xeqiah, then carry on
21:40gfredericks:)
21:40gfredericksthat's a good point I hadn't thought of that
21:41xeqialso, don't trust clojure benchmarks that don't use criterium
21:41xeqihttps://github.com/hugoduncan/criterium
22:03SegFaultAXGithub down again?
22:03TimMcNope.
22:03TimMcHow the crud am I allegedly calling RT.readString here? Stack trace: https://gist.github.com/timmc/5506742 code: https://github.com/timmc/kpawebgen/blob/collapse-tagcat/clj/src/kpawebgen/spit.clj#L46
22:03SegFaultAXWeird, it isn't loading for me.
22:04hiredmanI've been having weird issues connecting various hosts via the internet all day
22:04SegFaultAXhiredman: How else might you connect to them? ;)
22:05hiredmanwell hosts my lan are fine :P
22:05hiredmanon
22:05SegFaultAX:D
22:05holohi
22:05SegFaultAXI can literally connect to any other site.
22:06hiredmanthe first thing I noticed was google search where taking a long time
22:07hiredmanand what I see now is I have a list of 6-7 hosts and run 5 pings against them, every time another one of the hosts has all 5 pings timeout
22:07hiredmanTimMc: preconditions and macros can both screw with line numbers
22:08TimMcIt has to be a macro, right? The stack trace indicates a direct call from my code.
22:08amalloyTimMc: no, see the <clinit>?
22:09TimMcUgh, yes. Class init?
22:09amalloythat's spit$ensure-db$fn being *compiled*, not being called
22:09amalloyi've seen this a couple times in 1.5.x, and i don't really understand enough about classloading to know why clinit is happening at runtime
22:09hiredmanthat is the compiled code being loaded
22:10amalloyi've gotta run; i hope you guys leave an interesting explanation in the scrollback for me
22:10TimMcI think I'll sleep on it. :-/
22:10TimMc(Maybe you'll figure it out before me!)
22:10hiredmanclinit is what java static inits are compiled to
22:11hiredmanso the code is already compiled, so this is happening as the compiled classfile is loaded and the static init is called
22:11hiredmanwhich makes sense, because that is where any compiler emited calls to re-hydrate a pr'ed data structure would happen
22:11hiredmanwhich it would do using read-string
22:12lfranchidumb clojure question... what's the most "clojure-ish" way to, given a seq of ints, generate a new seq with the nth element changed?
22:13hiredmandon't use a seq
22:13SegFaultAXWeird, I can connect to github repos just fine but not github.com
22:13lfranchiit can be a vector, as well
22:13hiredmanuse a data structure with indexed access and indexed updates (vectors or maps)
22:14hiredmanvectors are associative of indices to elements
22:15lfranchiyeah, so if I want to get a new vector with a changed item at index n, what's the best way of doing that with a vector?
22:15hiredmancan you think of another associative data structure?
22:15lfranchiah, I can use assoc w/ a vector. interesting
22:16lfranchithanks for the tips :)
22:19holoread-str disappeared from cljs-uuid.core since last version of cljs-uuid. I used to use it from the clojure side to read raw uuid like "7dc53df5-703e-49b3-8670-b1c468f47f1f". is there a more standard way of doing this now? I can just plug the deleted implementation in my project though
22:41technomancyholo: you can read #uuid"7dc53df5-703e-49b3-8670-b1c468f47f1f" with the reader these days
22:43TimMchiredman: That all sounds very well and good, but I've been running with -Dclojure.read.eval=unknown for a while and this is the first time I've seen this. I don't see any fancy syntax here either.
22:45holotechnomancy, I don't have a #uuid"7dc53df5-703e-49b3-8670-b1c468f47f1f", but instead a "7dc53df5-703e-49b3-8670-b1c468f47f1f"
22:47hiredmanTimMc: *shrug* have you upgraded any libraries recently? have you run `lein clean` recently?
22:47TimMcNo, yes.
22:48TimMcI also tried to pare down the code to find the piece at fault, but I overshot. There's a lot of I/O here to work around. :-/
22:48technomancyholo: oh, you don't control the format; gotcha
22:49hiredmanTimMc: if you had not run `lein clean` in while and had stale class files sitting around, running `lein clean` could have triggered the change
22:50TimMcMmm, I see. Nothing's AOT'd, though.
22:50hiredmanyou could find the classfile it is blowing up on (assuming you aot) and run javap on it to take a look at the bytecode to find the printed form that is being read
22:57brehautyeah
22:57brehautoops
22:59TimMcWhen I do (compile 'kpawebgen.spit) and then javap the relevant class file, I get https://gist.github.com/timmc/5506900
23:02TimMc...why does that have the namespace's docstring embedded in it?
23:04TimMcMaybe that's just an inlined constant...?
23:04hiredmanI wonder if slingshot is doing it for some reason
23:07hiredmanhah
23:08hiredmanit is from logging
23:08hiredmantaoensso.timbre
23:08Recursive,(doc ->)
23:08clojurebot"([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."
23:09TimMchiredman: ! How can you tell?
23:10TimMcThat was definitely it -- I upgraded timbre from 1.5.2 to 1.6.0. What the hell was it up to?
23:11hiredmansomewhere it using the output of a pedicate in a macro, but the predicate doesn't return booleans
23:11hiredmanin the true case it returns a namespace object or something like it
23:12hiredmanhttps://github.com/ptaoussanis/timbre/blob/master/src/taoensso/timbre.clj#L304 is the predicate
23:12hiredmandunno what macro it is
23:13hiredmanit is fixed in the current master of timbre
23:13hiredmanhttps://github.com/ptaoussanis/timbre/commit/0dc4951db73eca38951a29dd8c751e60d799b4e4
23:13holotechnomancy, ,(java.util.UUID/fromString "7dc53df5-703e-49b3-8670-b1c468f47f1f")
23:13Recursive,(java.util.UUID/fromString "7dc53df5-703e-49b3-8670-b1c468f47f1f")
23:13clojurebot#uuid "7dc53df5-703e-49b3-8670-b1c468f47f1f"
23:15TimMchiredman: Man, how did you track that down?
23:15TimMcAnd thank you.
23:15holothank you Recursive
23:15hiredmanit was the closest recognizable string to the readString call in the javap output
23:16TimMcAh, I see -- https://gist.github.com/timmc/5506900#file-gistfile1-java-L699 "78:ldc#81; //String taoensso.timbre"
23:17holo(inc Recursive)
23:17lazybot⇒ 1
23:17hiredmanyep
23:17holo(inc technomancy)
23:17lazybot⇒ 52
23:17TimMcOr I guess line 692, ns-filter-cache.
23:24djwonkto append one vector to another, I'm using `into`. Should I look at other options?
23:24djwonk,(doc into)
23:24clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
23:25technomancyinto is great
23:26yacinany idea what this error is? CompilerException java.lang.ClassFormatError: Invalid method Code length 236383 in class file pdns/lab$eval36980, compiling:(NO_SOURCE_PATH:1)
23:26yacinit may be a cascalog issue, but searching google didn't yield any good cascalog leads
23:26yacinthought i'd ask here too
23:30danielglauserdjwonk: Looking at the code for into if the first collection is an IEditableCollection (I'm assuming most Clojure data structures are) then it has a fair amount of optimizations if that is your concern.
23:33djwonkdanielglauser: not extremely worried about performance... just was rooting around looking for 'merge' or 'append' and didn't find those, so when I found 'into' I figured that was the way to go
23:33djwonktechnomancy: thanks
23:34holoyacin, I found this doing a little search on google. hope it helps: https://groups.google.com/forum/?fromgroups=#!topic/clojure/7mdnjn1vyYc
23:34danielglauserdjwonk: Cool
23:42yacinholo: hmm, this definitely seems somewhat related. thanks
23:43yacini'm dealing with large sets, but i'm def'ing them so they should have vars
23:43yacinwhich someone suggested would fix it
23:46yacinand i'm already reading the sets from a separate file. hmm
23:51axle_512hey guys, I'm writing a high performance scheduler in clojure (partly as a learning experience)
23:52axle_512I have the code here: https://github.com/stephenjohnston/clj-sked
23:52axle_512it uses promises to deliver the results of scheduled items, can handle hundreds of thousands of simultaneous jobs
23:52axle_512would appreciate any positive critique
23:54akhudekhow does it compare to Quartzite?
23:54Raynesamalloy and I did some cool scheduling stuff recently that you might like axle_512. First, we devised a library that he wrote called chronicle https://github.com/flatland/chronicle (very new and currently undocumented, but I'll fix that soon) that can be used to generate an infinite seq of Joda DateTime objects based on a simple cron-like spec. It doesn't have a scheduling piece included, but...
23:55RaynesI wrote this naive little scheduler based on it: https://github.com/flatland/turntable/blob/master/src/flatland/turntable/timer.clj
23:55axle_512raynes: Sounds really interesting, I'll definitely take a look. I don't have cron support, but it was something I was thinking of adding.
23:55RaynesI want to tear that out into a library and making it better (i.e. use executers instead of timers, probably)
23:56Raynesaxle_512: I really like the idea of chronicle because it's so much more general than a scheduling specific library and can be used as the lower-level of such a scheduling library.
23:56axle_512akhudek: I believe quartzite is a wrapper around quartz. Quartz will have a lot more features, my little scheduler is only 100 lines of code.
23:56akhudekyes, but that's 100 lines of clojure :-)
23:57axle_512raynes: reading the source for flatland now
23:58Raynesaxle_512: You pass 'schedule' a function to execute at the specific times and a chronicle spec (which is basically a Clojureized version of a cron spec) like {:minute [0 15 35 45]} to run every 15 minutes, for example.
23:58RaynesIt could be made much more robust, but it's really easy to implement these kinds of things in terms of chronicle.
23:59RaynesI did timer.clj in like 10 minutes.
23:59holoyacin, glad it could help
23:59RaynesAnyways, enough tooting our horn. I just haven't told anyone about chronicle and it's kind of like finding religion, you want to tell everyone about it and make them do it too.