#clojure logs

2013-04-23

00:47taliosshiny
03:47NeedMoreDesuhow do you do nested loops?
03:47ucb,(doc for)
03:47clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], ...
03:47ucbNeedMoreDesu: you could try with for
03:48NeedMoreDesuIf I wish to loop for (< i n) ?
03:49NeedMoreDesuofc I can make lazy list of increases lol
03:49ucbNeedMoreDesu: you can map over (range n)
03:49NeedMoreDesuIs it lazy?
03:49jaenfzz
03:50ucbboth map and range are
03:50NeedMoreDesuoh, nice.
03:50jaen;;--
05:23linux_Buy Korean stuff, all is well
05:32silasdavishow should I go about debuggin a ring-based application
05:33silasdavisI'd like to be able to break on a line and inspect variable values
05:33clgvsilasdavis: first there is a middleware that prints you the encountered exceptions in a readable way
05:33silasdavisor at least see a trace of arguments
05:33silasdavisclgv, I think I'm seeing that (I get a stacktrace in the browser)
05:34silasdavissomething like:
05:34silasdavisAPersistentVector.java:265 clojure.lang.APersistentVector.invoke
05:34silasdavisfriend.clj:196 cemerick.friend/authenticate*
05:34silasdavisfriend.clj:208 cemerick.friend/authenticate[fn]
05:42zackzackzackHow should I go about typing hinting methods that don't take any arguments?
05:44mpenetit seems like you want to type the instance
05:56piranhait seems there is no easy way to check if string contains a substring, right?
05:57ejacksonpiranha: use a regexp
05:58ucbpiranha: alternatively use .substring
05:58ejackson,(re-find #"substring" "string with substring")
05:58clojurebot"substring"
05:59piranhaejackson: I also thought about (if-not (neg? (.indexOf str substr)))
05:59ucblovely
05:59ejacksonalthough ucb is right, .substring should be faster
05:59piranhabut still, no simple clojure.string/contains?, eh
06:00piranhawell, substring is like a slice, I need .indexOf
06:01Ember-,(.indexOf "my merry string" "merry")
06:01clojurebot3
06:01Ember-what's wrong with that?
06:01Ember-clojure does not try to invent the wheel again where java suffices
06:02piranhawell, I have to check for -1, instead of true/false, which makes a lot more parens :)
06:02Ember-so you need index number except if there is no such substring in which case it should return false?
06:03ucb,(.substring "foo" "foobar")
06:03Ember-or do you just need true/false if there is such a string?
06:03clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>
06:03ucborly
06:03ucb,(.subString "foo" "foobar")
06:03clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: subString for class java.lang.String>
06:03ucbbleh
06:06ucbpiranha: (defn str-contains? [s1 s2] (.contains (.toLowerCase s1) (.toLowerCase s2)))
06:06ucb,((fn str-contains? [s1 s2] (.contains (.toLowerCase s1) (.toLowerCase s2))) "foobarbaz" "foo")
06:06clojurebottrue
06:43piranhaEmber-: yes a true/false, yes
06:44ucbpiranha: see above
06:44piranhaucb: yep, I could have a simple helper
06:44piranhasure, thanks
06:44ucbnp :)
06:44piranhaI haven't realized java has .contains on a string
06:45piranhawas looking at some funny (and outdated) documentation :\
06:56jjl`ugh, i've just spent an hour figuring out why my code doesn't work and it's a hiccup bug. where can i report it?
07:01tcrayfordjjl`: I'd assume on github
07:04jjl`ta
07:07jjl`heh, someone else already reported it
07:55clgvwhat am I doing wrong when I use `applet` from "quil" and additional window with title "Quil 1" opens in addition to the one I added the applet to?
08:12piranhaalandipert: octagon: are any of you guys here by any chance? :)
09:40TimMc&(hash-map "\u00e9" "c" "\u0065\u0301" "d")
09:40lazybot⇒ {"é" "c", "é" "d"}
09:41TimMcWhat Unicode normalization form should I use before hashing a password?
09:42TimMcI'm inclined towards NFKD, although http://unicode.org/reports/tr15/#Norm_Forms says "Normalization Forms KC and KD must not be blindly applied to arbitrary text."
09:44TimMcI should really take that to StackOverflow.
09:45pjstadig`NFC
09:46TimMcI'm concerned that the NFC form might change if a future Unicode spec adds a composite form.
09:47TimMcs/form/character/
09:49pjstadig`so you use the stable version of NFC
09:50pjstadig`NFKD means that people could enter two different passwords and have them hash the same because they would decompose into the same sequence of code points
09:51pjstadig`http://unicode.org/reports/tr15/#Versioning
09:51TimMcAh, the stability thing is new to me.
09:52TimMcI'm pretty sure any of the normalization forms have collisions. That's what normalization is, yeah?
09:53TimMc,(.importClass *ns* 'Norm java.text.Normalizer)
09:53clojurebotjava.text.Normalizer
09:53pjstadig`i suppose that's true, someone could enter two separate characters that would get composed under NFC
09:53TimMc,(.importClass *ns* 'NF java.text.Normalizer$Form)
09:53clojurebotjava.text.Normalizer$Form
09:53pjstadig`not sure if java.text.Normalizer supports stable normalization or not
09:54TimMcYeah, I don't see a way to do that.
09:55TimMcBut the D or KD forms should be stable, right?
09:57pjstadig`actually i think annex #15 defines normalization in terms of the 3.1.0 unicode database, which means the JVM implementation of annex #15 should be stable
09:57pjstadig`with respect to Unicode 3.1.0
09:58TimMcDo you see any harm in D or KD?
09:59TimMcThe "must not" scares me, but there's no need for round-tripping or preservation of semantics.
10:00TimMcI'm OK with "office" -> "office"
10:01pjstadig`i think the non-round-tripping and non-preservation of semantics is why the recommend not using with arbitrary text
10:01pjstadig`if you know that, then maybe you'll be ok
10:12xorolaHey guys, i got a question. In what ways clojure macros differ from C macros and Other lisp macros ? a resource would be great .
10:13tcrayfordprincipally, clojure macros operate on data structures, C macros operate on strings
10:13tcrayfordhttp://clojure.org/macros
10:14tcrayfordthey are very similar to common lisp macros (though there's only one namespace, which makes things a bit different)
10:17stuartsierraTo clarify tcrayford's comment, Common Lisp has separate symbol tables (namespaces) for functions and normal variables, called a "Lisp-2." Clojure does not, called a "Lisp-1." Clojure also has a language feature called "namespaces" which are something completely different.
10:18tcrayfordstuartsierra: oops. Thanks
10:18stuartsierratcrayford: No problem. Just saw an opportunity for confusion there.
10:21xorolatcrayfod: i have been through that link? it is still vague to me where should i use macros? I want to see a compelling use case where macros only solves the problem or macros is the way to go? any source code link?
10:22stuartsierraMacros are most-often used for language extensions. For example, many parts of Clojure itself are implemented as macros.
10:23tcrayfordsee clojure.core/defn for an example (though a noticeably hairy one)
10:24tcrayfordin fact, searching this file: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj for defmacro will give you a host of examples
10:25stuartsierraMacros are rarely used in application-level programming, but they are a very powerful tool for extending the language.
10:27TimMcxorola: Macros are never the only way to solve a problem.
10:30xorolaTimMc: fair enough, :)
10:33TimMcpjstadig`: Drat. I just read the part of the spec about stabilized strings. Even the D and KD forms need stabilization in the face of new characters.
10:33pjstadig`TimMc: right, but annex #15 is stable
10:39TimMcpjstadig`: You're talking about "3. Versioning and Stability", right? That only seems to cover assigned characters. I'm trying to understand how a Unicode N-aware system would handle normalization of characters introduced in Unicode N+1.
10:41murtaza52I have a structure - [+ 1 2 3 [- 4 3] 5 6 [- 9 8]]. In which if the form is a vector, then the first element is a fn and rest its args. How do I write a fn to eval it ?
10:42gtrakmurtaza52: I recommend multimethods
10:43gtrakI wrote a similar little interpreter the other day: https://github.com/gtrak/webbedfeet/blob/master/src/com/garytrakhman/webbedfeet.clj
10:44gtrakstack-based
10:44pjstadig`TimMc: the way i read annex #15 it defines The Normalization Process™ and if someone claims to support that annex they normalize against the Unicode 3.1.0 database
10:44pjstadig`Unicode N will continue to normalize according to annex #15, which means against the 3.1.0 Unicode database
10:45TimMcHmm. So no new compositions are allowed, then?
10:45pjstadig`not according to annex #15, if i'm reading it right
10:46cmajor7can't get flatland https://github.com/flatland/clojure-protobuf extensions to work: https://www.refheap.com/paste/13884 anything I am missing? thx
10:46pjstadig`TimMc: maybe annex #nn will define normalization process 2.0 against a new version of the unicode database, but for now if anyone claims to support unicode normalization, they support it against the 3.1.0 database
10:47TimMc"However, the Unicode Consortium strongly discourages new compositions, even in such restricted cases."
10:47TimMcI guess that works.
10:48pjstadig`right, they're saying that if they add a new composition character, it will be a composition of two new characters to a new composition character, which means it could not upset previously normalized text
10:50TimMcMy concern is where the client sends newer characters than the server's Unicode support understands.
10:50TimMcJust reject it, maybe? :-/
10:51TimMcFor that matter, I suppose byte sequences invalid for UTF-8 (or whatever) mus tbe rejected.
10:54pjstadig`i think any newer characters would just pass through the normalization process
10:54TimMcI'd be willing to say "the server always has a recent Unicode".
10:55pjstadig`there's a closed set of characters that the normalization process detects and (de)composes, anything else just passes through
10:56TimMcPerhaps then an NF(K)C form is preferable.
10:57TimMcLet's say the year is 2015. The server is at Unicode 6.1, and the client registers with a Klingon password. It is full of unassigned characters, and passes through normalization unchanged. Later that yearm the server is updated, and starts performing normalization on that password. The hash no longer matches.
10:58TimMc(The client here is at Unicode > 6.1 or whatever the current version is.)
10:58pjstadig`normalization is defined against the unicode 3.1.0 database
10:58pjstadig`it is frozen forever
10:59pjstadig`you will never get different results for a newer version of Unicode
10:59TimMcOh! "A normalized string is guaranteed to be stable; that is, once normalized, a string is normalized according to all future versions of Unicode."
10:59pjstadig`(after 4.1)
10:59TimMcThat's a pretty strong guarantee.
11:00TimMcActually, "For all versions, even prior to Unicode 4.1, the following policy is followed:"
11:00TimMc^
11:00TimMc"strongly discourages new compositions" is a weaker statement.
11:04TimMcUgh, that "*and* contains only characters allocated in that version" still bothers me. :-/
11:05TimMc"If an implementation normalizes a string that contains characters that are not assigned in the version of Unicode that it supports, that string might not be in normalized form according to a future version of Unicode."
11:08ToBeReplacedif i have a callback function being called asynchronously in a thread, how can I use that callback to create a lazy-seq in main?
11:08joegallocreate a promise and have the other thread deliver on the promise
11:08joegallofor instance
11:09ToBeReplacedjoegallo: what type gets delivered?
11:09joegallowhatever you put into it...
11:14ToBeReplacedjoegallo: so would you create a seq of promises in an atom, have the thread deliver them in order, then have main deref them as it goes?
11:15joegalloi would promise to return a lazy-seq, and then i'd return a lazy-seq
11:15joegalloor are you trying to get into a producer and consumer?
11:19ToBeReplacedconsumer producer; i have a service subscription that hits a callback in a separate thread; i want to view that subscription as a lazy-seq instead so that a doseq can run forever
11:28TimMcpjstadig`: Thanks. I've collected what I learned into a SO post: http://stackoverflow.com/questions/16173328/what-unicode-normalization-and-other-processing-is-appropriate-for-passwords-w/
11:33pjstadig`TimMc: with recommendation #1 what you are saying is you want NPSS http://unicode.org/reports/tr15/#Stabilized_Strings
11:33pjstadig`which is fine, i just wanted to point out that annex #15 handles that case (if you hadn't seen)
11:38TimMcThanks, yes.
11:42mynomotoI'm trying to detect repetition in code. I would like to make the expressions generic so (string? abc) is converted to something like (string? x). Any ideas of how to do that?
11:43aphyr mynomoto https://github.com/clojure/core.match + a macro?
11:45clgvI cloned Clojure's `future` implementation to be able to exchange the threadpoolexecutor which is bound in a dynamic variable. when using clojure.core/binding-conveyor-fn in the `future-call` implementation I always get nil as result. when I remove `clojure.core/binding-conveyor-fn` then it works as expected. why?
11:46tcrayfordmynomoto: I did something like this a while back (it almost definitely won't run anymore): https://github.com/tcrayford/umbrella
11:46tcrayfordthe source there might be useful, it's not too long
11:47ucbclgv: is your implementation of future available anywhere?
11:47ucb(I just happen to have a need for such thing :) )
11:48clgvucb: I can make it available. but first it needs to work. it would be a shame to loose future's sematic with respect to thread-local-bindings...
11:49ucbclgv: *nod*
11:51mynomotoaphyr: Thanks.
11:52mynomototcrayford: I will look at the source, looks like what I'm looking for.
11:52tcrayfordmyonmoto: iirc it's kinda fucked in it's current state. But you can probably get some ideas from there
11:52tcrayford(as in, even if the code ran, it'll be broken)
11:58noncomhi! I have a jar which depends on other jars in the same folder. how do i instruct leiningen to push it to clojars correctly, specifying which is the mainjar and which are dependencies?
11:58mynomototcrayford: I'll try to run but the transmogrification appear to be what I want.
12:04andrew__does anyone have experience using server-socket (https://github.com/technomancy/server-socket/blob/master/src/server/socket.clj) to eventually write binary files? It defaults to using an OutputStreamWriter but I'm wondering if I can change it to using something different that might make serving up binary files a little bit easier (sorry, I'm really new to all of this so I'm probably not explaining too well)
12:09nz~.
12:09clojurebotCool story bro.
12:09nzls
12:09lazybotbin boot sbin srv swap
12:10noncoma question about clojars: I have a jar which depends on other jars in the same folder. how do i instruct leiningen to push it to clojars correctly, specifying which is the mainjar and which are dependencies?
12:10noncomdo i have to create a correct pom for that with dependencies section?
12:12S11001001noncom: what are these "other jars"?
12:15noncomS11001001: i'm trying to push the Minim sound library (https://github.com/ddf/Minim). Those extra jars are it's dependencies. The library is written in java and has no pom descriptors...
12:15noncomthere is a 3-year old push on clojars, in (https://clojars.org/org.clojars.automata/ddf.minim/versions/2.1.0) but that version is outdated
12:17S11001001noncom: I don't think maven supports an arbitrary set of jar artifacts for a particular artifactid. As with the link you just posted, each one needs to be pushed, so you have a dependency graph known to maven & its clients. Good news is you can just grab the poms there already and update them for your push.
12:20nznoncom: or you could have a hierarchy of pom.xmls and parent pom.xmls, then you can push jars from whole hierarchy to maven repo.
12:20joegallofrom https://github.com/technomancy/leiningen/wiki/Repeatability, you should open a bug with the project to ask them to get their work into the maven central repo
12:20joegallothat's the long term correct answer
12:21nzI don't if lein and clojars support project hierarchies
12:21check123`hey, are there any books written specifically for beginning programmers based upon clojure?
12:22david_pidcockJust out of interest -- I"m working on a little Grails thing using their web flow plugin. At the same time I'm learning Clojure and getting feet wet with Luminus -- does the concept of a Web Flow even make sense in a Functional language? If so, have there been any efforts to create one in Clojure?
12:22david_pidcockCouldn't find anything on the web yet.. :D
12:24clgvucb: ok I found the error
12:24ucbclgv: oh?
12:27noncomnice! thank you for the answers. I have open the bug on the project and I will try to push the jars to my Clojar group for the meanwhile
12:28clgvusb: https://gist.github.com/guv/5445115
12:28clgvucb: ^^
12:31ucbclgv: nice. What was the issue?
12:31danielglauserdavid_pidcock: I haven't done a ton of webdev in Clojure but I don't think folks have found a web flow style necessary
12:31clgvucb: the position of the type hint ^Callable led to the selection of the wrong submit method
12:32danielglauserdavid_pidcock: there are *tons* of ways to solve the web flow problem in Clojure
12:32ucbclgv: I see.
12:32danielglauserdavid_pidcock: And yes, I can see where that is a challenge for folks getting started
12:32gtrakdavid_pidcock: checked out pedestal yet?
12:33david_pidcockdanielglauser: Yes - this was my gut instinct .. that the fundamental concepts of functional programming don't "project" on to web flow in the same conceptual way. I was wondering what the "functional" way of thinking about web flows and state might be…
12:33gtrakwhat's more flowy than event-sourcing?
12:33david_pidcockgtrak: I have not looked deeply into Pedastal. I found Luminus to be easier to get my brain around at this stage of my clojure-foo
12:34danielglausergtrak: david_pidcock: The pedestal "base everything off of events" isn't a bad way to go.
12:34david_pidcockdanielglauser: gtrak
12:35danielglauserdavid_pidcock: One approach with Ring/Compojure would be to store the intermediary state in a DB
12:35danielglauserdavid_pidcock: that has the added advantage of letting you serve requests via clustered Clojure servers
12:36danielglauserdavid_pidcock: removes the session replication problem
12:37danielglauserdavid_pidcock: I used to do a lot of work with Grails and this pattern is what I recommended that we do in Grails as well
12:38david_pidcockgtrak: danielglauser: I will look into Pedastel more closely. The scalability of storing state in db has it's limits too, as I've discovered in some of the massive scale projects I've worked on in java+mysql in the past. Spring Web Flow claims to get around them by serializing the flow state with each request.. (which has other issues)
12:38david_pidcockgtrak: danielglauser
12:39danielglauserdavid_pidcock: you could always keep the intermediary state in a distributed cache, something like Redis, <insert data store of the week here>
12:39gtrakso far in my dev life, I've always preferred solutions that let me pick and choose the tradeoffs myself, instead of a one-size fits all thing.
12:40danielglausergtrak: inc
12:40gtrakI would be hesitant of any 'do something to everything' strategy
12:40david_pidcockdanielglauser: gtrak: (lol this silly auto-complete I'm using for the names just sends a blank line for multiples ) Anyways --- I imagine that passing a map to and fro is actually very functional-friendly, come to think of it.
12:40david_pidcock gtrak : you have an excellent point
12:41david_pidcock(wherever that map might be held)
12:41danielglauserdavid_pidcock: in memory session state is an optimization, one I'm not convinced is any faster than an in memory store or cache
12:42danielglauserdavid_pidcock: what you have in an architecture problem and not a Clojure problem, just know that Clojure supports just about any architecture that you could come up with
12:43david_pidcockdanielglauser: Well - I wouldn't call it a problem yet :D Just a question .. and one with many answers it seems. Thank you (and gtrak) for your insights.
12:44danielglauserdavid_pidcock: You're welcome. Best of luck!
12:45n_bCould someone suggest a good book on Java concurrency? I had a project this weekend where I felt having a better handling of the primitives underlying the Clojure system would've been a boon
12:45gtrakJCIP, then CTMCP
12:46n_bgtrak: the second one is by Van Roy?
12:46gtrakyea
12:46SegFaultAXn_b: Isn't the Java Concurrency book considered the de facto standard?
12:47gtrakJCIP was a bit unfulfilling in terms of design for me, I feel CTMCP will fill the gap. It was more about gotchas and primitive constructs.
12:47n_bSegFaultAX: I think so (it was recommended to nooglers last I checked), but I wasn't sure if anything had changed recently with Java7/8
12:47amalloyi've heard nothing but good things about JCIP
12:48amalloyi wonder if the office has a copy of it, actually. maybe i should read it
12:48SegFaultAXn_b: Definitely go with JCIP.
12:48SegFaultAXgtrak: In terms of design? What do you mean?
12:49gtrakSegFaultAX: I mean, I came into it with a mindset of 'I want to learn the design tradeoffs and how to build good concurrent systems from scratch', and it didn't really address stuff like that.
12:50gtrakit was more like... 'don't do these things... these are the guarantees provided by the java memory model, etc..'
12:50SegFaultAXgtrak: I don't really think it's supposed to be the former, is it?
12:50gtrakno, I guess not :-)
12:50SegFaultAXgtrak: I've never had that impression about it.
12:51amalloyright, you want more of a "concurrency in general" for that, not specifically java concurrency
12:51gtrakit never claimed to be I suppose, but that's what I was looking for and I couldn't tell at first glance that it wasn't it
12:51amalloysince the building blocks are mostly shared across languages
12:51gtrakCTMCP is more philosophical
12:51n_bFollow-up question: Is there anything Clojure-specific I should read? My problems were largely centred on properly balancing consumers and producers, actually handling failures of a part of the pipeline. Learning more about concurrency in general should be fine, I imagine, but input is, as always, welcome
12:52SegFaultAXn_b: Doubt it, since all of Clojure's concurrency primitives either wrap Java primitives, or literally ARE Java primitives.
12:52dnolengtrak: hmm, I think Clojure's design reflects a fairly close reading of JCIP
12:53SegFaultAXAlso, IIRC Hickey is a fan of JCIP and HFJ
12:53gtrakI could explain it another way, I already signed on to the principles of clojure and I didn't feel I learned a lot of new stuff from JCIP because of time spent studying clojure itself.
12:54SegFaultAXgtrak: I think you didn't have reasonable expectations for what JCIP would teach you.
12:55gtrakyea, I'm not saying don't read it, just that it doesn't address some things that I thought it might
12:55gtrakthat other might think it would, too
12:55gtrakother people*
12:55n_bSegFaultAX: When I ended up diving into futures that aspect was very welcome. It was very "Oh, hey, I know this!". Agents and the way they pool took a bit more digging. But JCIP to start, thanks again!
12:56SegFaultAXn_b: You'll learn about thread pools and executors for sure. Agents aren't that much more once you have the basics.
12:57SegFaultAXHas anyone here looked at RxJava by Netflix? I watched a talk about it last night on InfoQ.
12:59dnolengtrak: makes sense
12:59noncomS11001001: so ok, i have downloaded the 'automata' clojars group poms, and it has the poms with dependencies set correct.. how do i use them now to push it to my group with factual jars replaced?
12:59n_bSegFaultAX: Executors were very interesting to read about, it's been a great experience finding out just how little I know about both the Java stdlib and the JVM itself. Concurrency is fun stuff (until it's not)
13:00ucbclgv: forgot to ask: are you releasing your future+?
13:01gtrakSegFaultAX: what's HFJ?
13:01SegFaultAXn_b: I agree. I think one of the most eye opening experiences I had was when I was first trying to wrap my mind around Erlang's concurrency model. Really interesting stuff.
13:01clgvucb: you can use the code from the gist. it's too small for a lib just yet
13:01SegFaultAXgtrak: Head First Java.
13:01SegFaultAXgtrak: One of the more popular intro to Java type books, I think.
13:01ucbclgv: cool, thanks :)
13:02SegFaultAXclgv: Have a link handy?
13:03clgvSegFaultAX: for the future+?
13:03SegFaultAXYup
13:03gtrakI really like 'Effective Java'
13:03gtrakhad a few epiphanies from that one
13:04SegFaultAXgtrak: Also an excellent book.
13:04ucbSegFaultAX: https://gist.github.com/guv/5445115
13:05clgvSegFaultAX: that's the one ^^
13:05SegFaultAX`fogus: Do you know yet if JoC 2 will be available in a Kindle format?
13:05SegFaultAXucb: Thanks!
13:06`fogusSegFaultAX: Probably through Manning yes.
13:07SegFaultAX`fogus: Awesome! Looking forward to it. How much of an update is it over version 1?
13:15`fogusSegFaultAX: Most of the early chapters will be the same with some clarifications and new examples here and there. The latter chapters will be either new or quite different.
13:16pl6306Does edn support datetime? If so how do I represent one?
13:20llasrampl6306: #inst
13:22llasram&#inst "2013-04-23T13:21:00.000"
13:22lazybot⇒ #inst "2013-04-23T13:21:00.000-00:00"
13:22technomancypl6306: be aware that #inst will result in a java.util.Date unless you fix it though
13:22technomancysee clj-time
13:22tcrayforddoes clj-time have tools for #inst now? I was fighting this the other day (ended up just serializing to json instead)
13:23tcrayford(in all honesty I didn't look all that hard)
13:23pl6306thanks!
13:23technomancyhaven't used it myself, but pretty sure it's easy to hook up the parts
13:29silasdavishow can I join multiple ring routes together
13:29SegFaultAXWhy does leiningen sometimes have double messages while fetching a dep? RetrievingRetrieving ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jarring/ring-jetty-adapter/1.2.0-beta2/ring-jetty-adapter-1.2.0-beta2.jar fromfrom clojarsclojars
13:29technomancySegFaultAX: concurrent IO is hard =)
13:29silasdavissay I have defroutes routes1 ..., defroutes routes2... I want to combine [routes1 routes2] into a single handler
13:30technomancysilasdavis: you can call routes2 from routes1
13:30technomancyit's just a function
13:30amalloytechnomancy: yes, but he just wants (routes r1 r2)
13:31technomancythat too
13:31technomancylots of ways to do it =)
13:31technomancyreq is a map, routes1 and routes2 are functions; you do the math
13:31amalloysilasdavis: for educational purposes: (routes r1 r2) is equivalent to (fn [req] (or (r1 req) (r2 req))), and that's how defroutes works as well
13:32technomancywas trying to think of a point-free way to do it
13:32SegFaultAXCompojure uses `some` but yea.
13:32amalloySegFaultAX: note i said "equivalent to"
13:32technomancyoh yeah; some
13:32technomancyduh
13:32silasdaviswhich `routes` function in `(routes r1 r2)`?
13:33amalloyit's in the same place as defroute, unsurprisingly
13:33amalloydefroutes is nothing but a macro that expands to (def ... (routes ...))
13:34amalloytechnomancy: (comp first (partial remove nil?) (partial map (partial (flip deliver) req))), i think? if we're willing to pretend we have flip
13:35technomancyhah; nice
13:39degI'm trying to deploy a small cljs project, built with lein-cljsbuild, so I did 'lein uberjar' and get an error on my one .cljs file: "aborting ... duplicate entry"
13:39degTried lein clean, and renaming the file, but the error persists.
13:42silasdavisamalloy, hm so will I need (apply routes r1 r2)?
13:42silasdavissince I don't know the number of GETS, POSTS etc in the macro
13:42silasdavisor no because that macro has already expanded
13:42amalloythere are no macros involved. r1 and r2 are both functions of one argument
13:42antares_ClojureWerkz now has its own irc channel: http://blog.clojurewerkz.org/blog/2013/04/23/irc-channel-for-clojurewerkz-project/ — feel free to join :)
13:43silasdavisIn general if you have (macro1 (macro2 ...) ...) will macro2 have expanded by the time it acts as an argument to macro1
13:43silasdavis?
13:43silasdavisI suppose that's up to macro1
13:44gtraksilasdavis: macros expand recursively... if you don't have one with side-effects, why do you care when it happens?
13:44silasdavisit might be clear I haven't looked into macros in any depth yet...
13:45SegFaultAXsilasdavis: What you're asking for has nothing to do with macros. r1 and r2 are simply functions. You can use the routes function from compojure to effective compose those routes.
13:46silasdavisSegFaultAX, I was thinking that they could be 'unexpanded macros' or something like that
13:46gtraksilasdavis: it happens top-first, ##(macroexpand-1 '(fn [] (let [blah 1])))
13:46lazybot⇒ (fn* ([] (let [blah 1])))
13:46gtraklet is also a macro
13:47SegFaultAXsilasdavis: Macros are expanded at compile time. By the time (routes r1 r2) runs, all of that would have been expanded.
13:47silasdavisgot it
13:56n_bIs there some Reader-like construct for sequences, i.e. traversable once, dropping items once accessed?
13:57amalloyn_b: how is that different from a sequence itself?
13:57amalloyi mean, what you've described is an iterator, but that's just a seq with gratuitous mutation
14:06n_bamalloy: It's a sequence, the problem is the way I've written this and at the moment having an iterator is much easier than fixing it. Not ideal, obviously
14:07amalloy*shrug* sequences implement Iterable, so you can make an iterator if you want
14:07n_bAh, I see. Thank you.
14:08jtoyis there a way i can make a method that instead of calling this: (let [result (filter (fn[x] (= 1 (classify-scalar forest x))) (map (fn[x] (pop x)) examples) )] ....) can take an argument and call that in the the context of the map, so: (let [result (filter (fn[x] (= 1 (arg_to_call))) (map (fn[x] (pop x)) examples) )] ....)
14:09S11001001noncom: update the poms to have the proper groupid (yours) and version #s, and then...do something to deploy. I know the mvn deploy plugin can deploy a pom & jar pair in a single command, but there may be something easier to use.
14:09n_bamalloy: annnd your comment made me realise a way this can work with just a plain seq without changing anything. Much cleaner :)
14:11S11001001jtoy: aside, (fn [x] (pop x)) ≡ pop
14:16jtoyS11001001: I want to pass the arg into my filter
14:16jtoyi think I can do this, im having a mental blopc kthough
14:17S11001001jtoy: irrelevant
14:18jtoyS11001001: how do I call (classify-scalar forest x) if the arg I pass is 'classify-scalar forest) ?
14:19jtoy(classify-scalar forest) I mean and the x needs to be passed as a nn argument?
14:19S11001001jtoy: I've just been ignoring that part, in favor of pointing out that you can write (map (fn[x] (pop x)) examples) as (map pop examples)
14:20jtoyok, i see what you mean, does that help with my problem?
14:20jtoyi see that that simplifies my code
14:20S11001001jtoy: insofar as you should see that `classify-scalar' might be found in the list of arguments to your function, yes
14:22S11001001jtoy: functions are ordinary values, and functions you make with defn are just as functiony as ones you make with `fn'
14:22rasmustois there an idiomatic way to unroll {[:a :b :c] [1 2 3]} to {:a 1 :b 2 :c 3}? I know the [:a :b :c] key in advance.
14:22S11001001jtoy: including the functions in the standard library
14:23jtoyim still not exactly sure
14:23amalloyrasmusto: so it's a map with only one k/v pair in it?
14:24rasmustoamalloy: it could have other k/vs
14:24amalloybut you want to take one k/v pair out and do this to it?
14:24rasmustoamalloy: I'm thinking I might just do a zipmap whenever I find a vector as a key
14:25rasmustoamalloy: I'd like to dissoc [:a :b :c] from the map, and merge (zipmap [:a :b :c] [1 2 3]) with that map
14:26rasmustoamalloy: I think I have a solution bubbling up to the surface, I'll paste it in a sec
14:27jtoyS11001001: I think its something like this: (let [result (filter (= 1 arg_to_call ) (map pop examples) )] ....) but then Im not sure how filter passes the arg to arg_to_call
14:29SegFaultAX,((fn expand-key [m k] (let [v (m k)] (into (dissoc m k) (map vector k v)))) {[:a :b :c] [1 2 3]} [:a :b :c])
14:29clojurebot{:a 1, :b 2, :c 3}
14:30SegFaultAXrasmusto: ^
14:30ToBeReplacedheh, i'd have (apply zipmap (first (select-keys {[:a :b :c] [1 2 3]} [[:a :b :c]])))
14:31ToBeReplacedoh there's a merge misread, nvm me
14:31S11001001jtoy: arg-to-call is an arg you have yes?
14:32rasmustoSegFaultAX: that's beautiful. Thanks
14:32SegFaultAXrasmusto: Honestly I'm more curious why you have such a requirement.
14:33rasmustoSegFaultAX: parsing stdout strings from some crappy tool
14:33SegFaultAXrasmusto: Ugh, that sucks. Hopefully that's what you're looking for.
14:33jtoyS11001001: yes, the problem why I am not sure is because arg-to-call is (somemethod first-arg x_from_map), so I pass in(somemethod first-arg)
14:33jtoyand get ArityException Wrong number of args (1) passed to: core$classify-scalar clojure.lang.AFn.throwArity (AFn.java:437)
14:34rasmustoSegFaultAX: most definitely. I have it figured out now :)
14:34llasramjtoy: Are you trying to get to something like `(comp (partial = 1) (partial classify-scalar forest))`
14:34llasram?
14:35jtoypassing this in works: (fn[x] (classify-scalar @american_forest x)) is this the way I should pass my argument?
14:36jtoyllasram: I havent used partial, im studying it now
14:36jtoyhmm, thats cool
14:37SegFaultAXjtoy: ##((partial + 1) 1)
14:37lazybot⇒ 2
14:38jtoycool, so I'll just pass partial then, seems easier then calling with a funcfn
14:40amalloyjtoy: your client keeps sending 0x7F (ascii DELETE) characters instead of actually backspacing over stuff before you send it
14:41jtoyamalloy: yeah, something seems broken, thx
14:42RaynesThis is sad. I can't remember how to configure refheap.vim.
14:42RaynesThe reason that is so sad is because I wrote it.
14:42jtoyhaha
14:43RaynesAh, there we go.
14:47arrdemam I reading this right? because algo.monads works using lazy sequences you can't use ^:dynamic vars "correctly" in monadic code.
14:48technomancyarrdem: you can't use dynamic vars anywhere laziness is used; correct
14:48arrdembah ok thanks technomancy
14:48technomancynot strictly true, but trying to use them together is very error-prone
14:51technomancyif you can guarantee the laziness is consumed inside the scope of the binding it can work. but there are serious composability issues.
14:56arrdemyeah that's what I'm running into right now..
14:57gfredericksusually "don't use dynamic binding" is the preferred solution
14:57technomancyprobably even more error-prone if the laziness is hidden behind monadic magic
14:57technomancy(the irony of a guy who goes by "technomancy" complaining about magic is not lost on me)
14:57pl6306Can I add meta data to an entry of map? Or is only possible add it to a map.
14:57arrdempl6306: if the entry extends IObj yes you can
14:58gfredericks,(-> {1 2} first (with-meta {::a ::b}) (list) (->> (into {})) first meta)
14:58arrdemok. guess I'm stuck with my global state atom then.
14:58clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.MapEntry cannot be cast to clojure.lang.IObj>
14:58amalloyarrdem: wait, to the entry or the value?
14:59arrdemwell gfredericks just torpedoed the entry.
14:59arrdemI was talking about the value
14:59arrdem(meta (:foo {:foo (with-meta :bar {:foo 3})}))
14:59amalloygfredericks: that's lame. i would have expected c.l.MapEntry to be an IObj
14:59degRe my question above (duplicate entry in uberjar of lein-cljs project) it looks like the problem is having multiple :builds, with a dash in one of the :output-to js files.
14:59arrdem,(meta (:foo {:foo (with-meta :bar {:foo 3})}))
14:59clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.IObj>
14:59gfredericksamalloy: I thought it was a terribly fascinating question
14:59arrdemoh frick
14:59technomancyamalloy: if only we had inheritance amirite
14:59degDid I violate a known rule, or should I report this as a bug?
15:00gfrederickssince it's a vector, it oughta be an IObj. But since it's a map entry which isn't really first class, it'd be stupid to put metadata on it
15:00amalloytechnomancy: hm?
15:00arrdem,(meta (:foo {:foo (with-meta [:bar] {:foo 3})}))
15:00clojurebot{:foo 3}
15:00arrdemok yes so you can have metadata on vals in a map
15:00technomancyamalloy: just amusing that it looks like that problem is due to avoiding implementation inheritance
15:01gfredericksinterfaces can inheret though, no? IPersistentVector could extend IObj?
15:01amalloytechnomancy: really? clojure.lang doesn't make any effort at all to avoid implementation inheritance afaict
15:01technomancyamalloy: it's possible I don't actually know Java or anything about Java
15:01amalloyi think it's because c.l.MapEntry tries to be an optimized, special-purpose two-element vector and thus can't inherit any of the more general vector stuff
15:02llasramI thought keywords couldn't have metadata because they are explicitly singletons. You can't have different copies with different metadata
15:02amalloyllasram: indeed
15:02technomancyit would be like putting metadata on numbers
15:02danneuQuestion: I want to start 8 threads each with its own computation. Once any thread returns the answer, I want to clear out all the thread work and issue out 8 new computations. I've been reading about Java's Executors and Clojure's Agents, but could someone point me in the right direction?
15:02llasramOh, I didn't scroll back far enough
15:02technomancy^:even 2
15:03llasramHeh
15:03technomancy^:prime 7
15:03Glenjamincan anyone recommend a validation library? i've done a quick survey but it's not obvious which one is actually used by people
15:03technomancythe Clojure Way is to write your own validation library
15:04technomancyeveryone's doing it
15:04arrdemtechnomancy: no that's the Lisp Curse
15:04Glenjaminheh, certainly seems that way
15:04callenGlenjamin: validation for what? Web?
15:04Glenjaminin my case, yes - but maps in general should be fine
15:05callenGlenjamin: Okay, just use one of the existing libraries.
15:06Glenjaminmm, just trying to pick one that isn't abandonware
15:07xeqiGlenjamin: I've used weavejester's valip
15:07Glenjaminthe one from weavejester looks good, but hasn't been touched for 2 years!
15:07callenmaybe it's perfect!
15:07callen >_>
15:07technomancyfor something that simple it's possible
15:08TimMcGlenjamin: clj-schema works well, although mind the lack of semver and changelogs.
15:09danneuprob spend more time looking for a lib than the moment it takes to roll your own every-pred
15:10Glenjaminmeh, i hate rolling my own when existing options exist
15:11Glenjaminmost of the stuff i've used for this project so far i've contributed back a fix/improvement for - everyone wins
15:11danneuGlenjamin: https://github.com/weavejester/valip/tree/master/src/valip
15:11SegFaultAXGlenjamin: Look at the source for valip
15:11SegFaultAXGlenjamin: It's like 10 lines of code.
15:12technomancyheh
15:12Glenjaminwith tests, and other contributors
15:12Glenjaminif we all keep re-inventing the same simple wheels, we'd never build a decent car
15:12SegFaultAXThere are a few obvious things you could do to improve it, but it doesn't do very much as it is.
15:12gtrak_what's even the measure of a good validation library?
15:12xeqi... does it validate
15:13SegFaultAXAlso a shitload of pre-built validators.
15:13technomancyxeqi: I'm imaginging a "does it blend" style video series
15:13gtrak_the subset of all functions that take an arg and return a boolean?
15:13danneulibraries are useful when they save you time.
15:13SegFaultAXgtrak_: I'm thinking more like ActiveModel::Validations
15:14SegFaultAXgtrak_: I guess that's not a shit load per se, but it covers a large number of the common cases.
15:14danneuyeah, the value added clearly comes from the predicates, not the actual implementation
15:15xeqitechnomancy: Yes, it validates!
15:15SegFaultAXOne annoyance I have with valip is having to specificy the messages manually. That could be trivially moved into metadata with the option to override.
15:16Glenjamini appear to have stumbled onto a hot button topic
15:16SegFaultAXAlso, making composable validators is really handy. I often have a core set of validations that are shared across a number of different things.
15:17jcromartieI feel like using sets along with watches and validators is better than using hash maps to model collections
15:17amalloya bit off-topic here: is there a handy equivalent to pmap in bash? i'd like to perform N independent tasks in parallel, and be notified when they're all finished. i don't want to bring the system to its knees by forking them all at once, though, so it would be nice if it ran on something like the pmap threadpool
15:17jcromartieamalloy: xargs
15:17Rayneslol
15:17Raynesamalloy just got told to xargs. That's a twist.
15:17amalloyjcromartie: wat. that is not even related
15:18jcromartieamalloy: no? how does xargs not do that?
15:18SegFaultAXamalloy: #bash can help.
15:18Glenjamin -P maxprocs Parallel mode: run at most maxprocs invocations of utility at once.
15:18Glenjamin^^ from man xargs
15:18arrdemwat
15:18amalloyinteresting. i didn't know about that option. i guess it assumes each argument could be a separate call to proc
15:18arrdemwell that's new...
15:19RaynesWherein Glenjamin changes our lives.
15:19SegFaultAX(inc jcromartie)
15:19lazybot⇒ 4
15:19jcromartiexargs -P 8 -n 1 ...
15:19Glenjamincredit to jcromartie :)
15:19jcromartieyay
15:19SegFaultAX(inc Glenjamin)
15:19lazybot⇒ 2
15:20xeqiGlenjamin: have any interest in commit rights for peridot?
15:21Glenjaminxeqi: can do, nothing planned to add at the moment
15:21Glenjamini'm building up some functions to use kerodon with speclj at the mo
15:21xeqiawesome, https://github.com/xeqi/kerodon/issues/8
15:23Glenjamini've got a (should-have) function which behaves similarly to (has)
15:24xeqiadded, nothing planned here either, but nice to have others that can do something if I get busy/miss a pr
15:25Glenjamincheers
15:53callenGlenjamin: (should-have) is a very quaint way of saying (has).
15:54Glenjamincallen: in the context of speclj, all of it's test assertion methods start with (should)
15:55callenGlenjamin: sounds like communism.
16:07arrdemis there some trick I'm missing to make protocols use a default implementation over records? I'm being forced into replicationg the same code about 12 times 'cause I'm getting "no implementation" errors over my types if I don't.
16:08Raynescallen: I really like speclj's name. Except for the stupid fricken clj crap.
16:08RaynesI hope nobody ever creates a new project with a cutesy clj or jure name in front of me.
16:08RaynesFor their safety cannot be guaranteed.
16:09trptcolinRaynes: juraynesic_parclj
16:09n_bTell us how you really feel ;)
16:09trptcolingranted, it's a stretch
16:09Raynesn_b: How I really feel is illegal in all governed countries.
16:10Glenjamincould be worse, in ruby-land libraries tend to be named after common dictionary words which make them hard to google for
16:11RaynesThere is a python lib called 'requests'.
16:11RaynesFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUUU
16:11Glenjaminheh, true
16:11Chousukehaskell libraries are even more fun
16:11Chousukeif you google for them, you get wikipedia pages full of maths
16:12RaynesI am guilty of using Haskell's name in vain in my libraries.
16:12Raynes$google haskheap
16:12lazybot[Raynes (Anthony Grimes) · GitHub] https://github.com/Raynes?tab=repositories
16:12amalloywhat's wrong with 'requests'?
16:12Raynesamalloy: We were complaining about libraries that are common dictionary words.
16:12amalloylike...laser, tentacles...?
16:13RaynesI wasn't complaining, you'll kindly notice.
16:13amalloyyou uh...shouted FU so loudly they heard you in arkansas
16:13jjttjjyeah i kinda like that googleibility is an aknowledged thing in clojure
16:13Glenjamini could make a form handling lib, and call it "forms"
16:13ChousukeI don't really mind using common words for names, but then you should prefix it with clj or py or something
16:13Raynesamalloy: I was playing along with Glenjamin.
16:13RaynesChousuke: Get off my IRC.
16:13Chousukenothing wrong with a library called py-requests
16:13Glenjamin"clojure forms" is bound to be a fruitful search term
16:13Raynesclj-* names are equally as anger inducing.
16:14RaynesWe need very strict laws governing library naming.
16:14Chousukewell, clj is not so good as a prefix
16:14Glenjaminyou could pronounce it "kludge"
16:14bbloomi prefix all of my library names with me.raynes.bbloom.
16:14Chousukesince you can't even pronounce it
16:14callenRaynes: the requests library is really nice though.
16:14Raynesbbloom: <3
16:14callenRaynes: I love everything that guy does.
16:14Raynescallen: Yes it is. Ken is amazing.
16:14stuartsierraGroup IDs are the way to go.
16:14callenRaynes: REITZ IS MAH HOMEBOY
16:14jjttjjafter working with R for a bit i'd take the cheesy/generic names over things even more slightly harder to find on google
16:15SegFaultAXstuartsierra: Have you looked at RxJava?
16:15stuartsierraSegFaultAX: not yte
16:15stuartsierra*yet
16:15Raynesstuartsierra: You'll note that I've started naming reverse domaining all my libraries so as to not be lynched to death by an angry mob at my next conference appearance.
16:15SegFaultAXstuartsierra: There is a pretty good talk about it on InfoQ from the lead at Netflix.
16:15bruceadamsand Ken Reitz is coming to talk at Pittsburgh Python's meetup tomorrow. anyone in Pittsburgh should come!
16:16stuartsierraRaynes: I don't lead lynch mobs. I just complain. ;)
16:16SegFaultAXstuartsierra: Observables are similar in a lot of ways to PromisesA it seems. Possible a substitute for a cljque-type lib.
16:16Raynesstuartsierra: Sure. That blue hair was merely a disguise.
16:17bbloomi'm with technomancy: short, reasonably unique by best effort google/github search, no ceremony
16:18SegFaultAXbbloom: Then you'll appreciate the new "unicorn" lib that's hot on HN right now.
16:18SegFaultAXCompletely unrelated to all the other unicorn projects, but still uses the name and images associated with them.
16:18bbloomthat's total fail at best effort search
16:18callenzero effort
16:18callenalso, how can you possibly not know about unicorn (rack) and gunicorn (wsgi)?
16:19callenand still be working on an HTTP related thingi?
16:19mpenetstuartsierra: did you see dajac/react, it's another impl of promises/futures & co
16:19SegFaultAXWorse, it's indistinguishable from the unicorn web server.
16:19SegFaultAXEven the fricken logo is the same as the one GH uses.
16:19bbloomonce past the best effort search, there is like a several week probation period where people can ask you to change the name
16:19bbloompast that, conflicts are not my problem
16:19mpenetstuartsierra: apparently it's used at paper.li
16:19SegFaultAXcallen: They actually specifically address the name conflict on their site.
16:19SegFaultAXSomething ot the effect of "we named it before it was written, and never changed it"
16:20callen...
16:20callenSegFaultAX: the author of using the excuse that his little sibling or something named it.
16:20callenis*
16:20Glenjamini don't see a unicorn on HN...
16:20stuartsierrampenet: no, haven't run into that
16:20Glenjaminaha, page 2
16:21SegFaultAXcallen: Even so, they could have added something to it. unicornhttp or something, I don't know. And to use the angry unicorn. Wtf.
16:22callenSegFaultAX: they named the Ruby version "unicorn-rest" and the python one "unicorn" <--- lol
16:22callenSegFaultAX: not only do Python users love their gunicorn, but the Unicorn is the unofficial mascot of Django, so they're likely to get cranky.
16:23mpenetstuartsierra: have a look, he took another interesting approach, uses atoms under the hood, and seems to have a rich api around its futures
16:23SegFaultAXFor those interested in RxJava: http://www.infoq.com/presentations/netflix-functional-rx
16:23stuartsierrampenet: I haven't had any time to focus on promise for months.
16:24callenSegFaultAX: that looks a LOT like Twitter's Finagle
16:24callenSegFaultAX: same idea and use-case, implemented differently.
16:24SegFaultAXcallen: RxJava?
16:24callenSegFaultAX: da comrade
16:25technomancygun-i-corn
16:25technomancyis how I say it
16:25SegFaultAXcallen: I haven't looked at Finagle, I'll take a look. RxJava in particular is a port of Rx.Net.
16:25callentechnomancy: I say gew-nee-corn
16:25SegFaultAXtechnomancy: I say "goon-i-corn"
16:26callenSegFaultAX: well the idea behind Finagle was to have a generic framework for composable SOA with deliverables wrapped in promises in Scala
16:26lalilunalein midge causes: Caused by: java.lang.NullPointerException
16:26laliluna at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:332)
16:26laliluna at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:987)
16:26laliluna at clojure.lang.Namespace.find(Namespace.java:188)
16:26SegFaultAXcallen: From what I've read so far, RxJava is just a normal observer + an onComplete and onException callback.
16:26callenlaliluna: midje?
16:27SegFaultAXcallen: Otherwise they're identical to what you normally think of with Observers. And their interface is nearly identical to iterables.
16:27lalilunaonce cheshire.core is used
16:28SegFaultAXlaliluna: Can you refheap the offending code and exception? It's hard to read in IRC.
16:29jasonjcknDoes each var have it's own timeline in Rx?
16:29jasonjcknhow do you get a consistent view
16:29jasonjcknin parallel environment
16:30lalilunahttps://www.refheap.com/paste/13903
16:30callenlaliluna: first bit of advice, don't use midje.
16:31SegFaultAXcallen: Aww, why? I like midje.
16:31callenSegFaultAX: I like things that work even more.
16:31technomancybecause callen said so, obvs
16:31technomancy(actually I agree in this case)
16:31Raynescallen: Works for me in laser.
16:31Raynes*shrug*
16:32RaynesI switched it to midje before everyone decided that it is the worst thing ever.
16:32SegFaultAXcallen, technomancy: clojure.test users?
16:32TimMcMinus the bizarre stack traces, it works fine.
16:32SegFaultAXTimMc: Clojure isn't known for awesome stack traces as it is. But generally yea.
16:32technomancySegFaultAX: yeah; I find midje invents too many new concepts that don't offer provide enough value to justify not using similar built-in constructs
16:33SegFaultAXtechnomancy: Actually the only thing that drew me into midje was auto test in the repl. Is there something like that for clojure.test?
16:34technomancyif you have a small team on an internal project and everyone's on board that's one thing, but if you want contributors to your OSS project to bother with the tests, there's a very strong case to be made for the lingua franca.
16:34technomancySegFaultAX: sure; clojure-test-mode
16:34technomancytrivial to wire into an after-save-hook in emacs
16:34technomancySegFaultAX: that's actually another gripe of mine though
16:34jasonjcknSegFaultAX: https://github.com/stuartsierra/lazytest
16:34SegFaultAXtechnomancy: Oh is that an emacs thing? I'm a vim user.
16:34technomancywhy would the auto-runner be coupled to the test framework
16:34technomancythat's just wrong
16:35technomancywrite a watcher/auto-runner that operates on an arbitrary task; it's so obviously the right way to do it, but no one has actually done it =(
16:36technomancy(personally I haven't done it because I just use the elisp equivalent)
16:37n_bSegFaultAX: You should be able to just have a BufWrite aucmd for test files
16:37SegFaultAXSure, or use guard to watch the files.
16:37SegFaultAXHow does one reload the entire project without having to restart the repl? I'm not too familiar with the nrepl internals.
16:38SegFaultAXAnd by not too familiar, I mean at all.
16:38Glenjaminthere's lots that are based on running an executable, but i think doing it within the jvm would be tricky to generalise?
16:38technomancySegFaultAX: require with :reload-all
16:38Glenjaminor not
16:38technomancyGlenjamin: I don't think so. with :eval-in :nrepl you could easily do it without starting up a new JVM
16:38Glenjaminspeclj's auto-runner is pretty nice, manages to figure out the dependency chain and only re-run affected tests
16:38SegFaultAXtechnomancy: That won't reload the project.clj file will it?
16:39lalilunaBy the way, any idea why it is failing once I require chesier?
16:39technomancySegFaultAX: no, changes to project.clj require a fresh repl
16:39technomancySegFaultAX: but that's already a given in the repl-based workflow
16:39technomancyso nothing really changes there
16:39SegFaultAXtechnomancy: Just curious.
16:40lalilunaThis is the way, I refer to cheesier: (ns foo.bar (:require [cheshire.core :refer :all]))
16:40SegFaultAXHeh cheesier.
16:41llasramTook me a minute to parse that :-)
16:41lalilunaThe irc client has type incorrection
16:42TimMcThat's for sure.
16:46FoxboronSo, every time i try eval a record in emacs-live, everything freeze.
16:46Foxborons/record/protocol
16:56nzso what is actually wrong with midje (other than it is not standard like clojure.test)?
16:56trptcolintechnomancy: unless i'm misunderstanding, that's what speclj does: https://github.com/slagyr/fresh
16:57technomancytrptcolin: ten points to griffindor!
16:57technomancynice
16:58technomancyI think it could be done as a leiningen task too, but I haven't considered the trade-offs between the two approaches
16:58TimMc,(isa? 5 5)
16:58clojurebottrue
16:58trptcolinit's pretty handy; we use it for the clojure koans as well
16:59Raynesnz: Well, admittedly it is a giant macrofest hack. But I'm fine with that for the most part.
16:59trptcolin[without actually using speclj]
16:59TimMcHas anyone seen Clojure's ad-hoc hierarchy system in use out in the wild? I'm curious what people use it for.
16:59technomancytrptcolin: will have to remember that for the next time someone says that's why they don't use clojure.test =)
17:00technomancyTimMc: the only one I know of that does that is friend
17:00amalloyTimMc: we use it a little at geni
17:01amalloythe web API exposes a bunch of endpoints like /bird/status, /horse/status, ..., and our dispatcher uses an isa? hierarchy that says those are all just special cases of /animal/status
17:01technomancyhow long does it take before the "geni in a bottle" jokes get old?
17:03TimMcamalloy: Interesting. That uses a custom hierarchy, not the global one, right?
17:03amalloynah, i think we just pollute the global hierarchy with keywords like :geni.api/bird or something
17:06TimMc,(isa? = 1 1)
17:06clojurebottrue
17:06TimMc,(isa? = 1 2)
17:06clojurebot#<NullPointerException java.lang.NullPointerException>
17:06TimMcbah :-P
17:07TimMcI should have just left it at that.
17:07technomancyat least it didn't say true
17:08SegFaultAXOh man, we just got a ping pong table in my office.
17:08SegFaultAXGoodbye productivity.
17:08FoxboronTrying again, having problems evaluating protocols in emacs-live, everything just freeze. Anyone able to point me int the right directions?
17:08technomancyFoxboron: the problem with emacs-live is it pulls in a bajillion different packages, so it's hard to tell which one is actually at fault
17:09gtrakSegFaultAX: happier devs means better code?
17:09SegFaultAXgtrak: That's the idea, I guess.
17:09Foxborontechnomancy: i wasnt that succsessfull trying to setup Emacs on my own :/ Just feeling that this problem should have hit someone before, and not only me.
17:09gtrakI loved it when we had one, it made my life like 15% better
17:09Apage43Could be worse, we have a kegerator >.>
17:10technomancyFoxboron: you'd have to disable packages one by one till it quits breaking
17:10technomancybut IIRC emacs-live doesn't even use proper packages, so I don't even know how you'd do that
17:10SegFaultAXApage43: Yelp had awesome kegerators.
17:11Foxborontechnomancy: maybe i should just backup everything and do it the normal way :/ Annoying tho.
17:12stuartsierrajasonjckn, SegFaultAX: I gave up on auto-test-on-file-save after Lazytest. I think it's almost impossible for non-trivial apps. But that lead to tools.namespace and more work on reloading-from-the-REPL.
17:12technomancyFoxboron: I plan on writing a high-level guide covering various packages in the ecosystem and how they work together, but for now all I have is https://github.com/technomancy/better-defaults
17:12SegFaultAXstuartsierra: So what are you doing now?
17:12technomancy(note that this is not an emacs-live vs starter-kit thing; the starter kit has all the same problems)
17:13Raynestechnomancy: Emacs live is super weird.
17:13stuartsierraSegFaultAX: Simulant.
17:13technomancyRaynes: well that too
17:13SegFaultAXstuartsierra: How does that work?
17:13technomancyI mean the "not using package.el" thing is specific to emacs-live and a really annoying problem
17:13Foxborontechnomancy: i'll follow it closly. Thanks.
17:13andrew__Does anyone have experience using Java's ServerSocketChannel? I'm trying to make a simple server, but I can't seem to figure out how to set *in* to the proper thing to read any requests
17:14stuartsierraSegFaultAX: It's a totally different approach to testing. Not for everyone, but I like it.
17:14FoxboronRaynes: it is not that wierd...until you start messing with the whole package system. But out-of-the-box, it is OK for any beginner.
17:14stuartsierrahttps://github.com/datomic/simulant
17:14SegFaultAXstuartsierra: Are simulations different from unit tests?
17:14RaynesI don't like solutions that are bizarre when you stop being a beginner.
17:14RaynesI like things that just help you get going.
17:14stuartsierraSegFaultAX: very
17:15hiredmanandrew__: serversocketchannel is an nio thing, which is java's async io framework, which is not what you want
17:15technomancyRaynes: that's why I want to switch gears to just documentation
17:15stuartsierraSimulation testing is a heavyweight approach to testing a whole system from the outside.
17:15Raynestechnomancy: You're a good person.
17:15FoxboronI was just thinking btw. Are the dev.clojure.org site still in use? I wanted to add a few lines for the Sublime Text part as i got two packages for Clojure
17:15technomancynote that I haven't done it yet
17:15hiredmanandrew__: serversocket has an accept method which blocks until a client connects, then returns a new socket you can get input and outpustreams from
17:15stuartsierraFoxboron: Yes, dev.clojure.org is still actively maintained.
17:16Raynestechnomancy: You're a good person for wanting to do it.
17:16andrew__hiredman: I should've mentioned that, I'm trying not to use serversocket
17:16hiredmanandrew__: clojure's *in* is for binding to streams
17:16Foxboronstuartsierra: you think anyone would mind if i add a few lines about my Clojure packages for ST2?
17:16hiredmanclojure's reader reads from streams
17:16stuartsierraFoxboron: please do. There are "Getting Started" pages for each major editor / IDE.
17:16SegFaultAXstuartsierra: What do you like about it more than other more traditional styles of testing?
17:16Foxboronstuartsierra: i know, why i am asking ;)
17:17hiredmanthere are channel->stream adapters but you are biting off way more than you can chew
17:17andrew__hiredman: hmm, so it sounds like I'm trying to fit a square peg into a round hole
17:17stuartsierraSegFaultAX: Don't really have time to go into the details. Stuart Halloway has done some presentations on it.
17:17SegFaultAXstuartsierra: Ok I'll take a look. Thanks!
17:17stuartsierranp
17:21Foxboronstuartsierra: damn confusing site <.<
17:21technomancyFoxboron: clojure-doc.org has a lot better coverage of editor support
17:22stuartsierraFoxboron: dev.clojure.org suffers from serving multiple purposes: developer notes and user documentation.
17:22stuartsierraAlso, Confluence. :(
17:22Foxboronstuartsierra: trying to see if i can edit the "Gettign started with Sublime Text"....nope..
17:23Foxborontechnomancy: "a lot better", ST isnt even mentioned as i can see :P
17:23stuartsierraFoxboron: I believe the editing rights are given automatically to signers of the Clojure Contributor Agreement.
17:24technomancyFoxboron: a lot better for most topics; a lot easier to improve anyway
17:24Foxborontechnomancy: i'll take a look at it tomorrow. Wanted to make a quick edit at dev.clojure.org...
17:24Foxboronwasnt that quick
17:25TimMcstuartsierra: My apologies for denigrating clojure/data.json yesterday. I was either working off of old information or thinking of a different lib entirely. :-'
17:25TimMc* :-/
17:26andrew__hiredman: by serversocket, did you mean the java ServerSocket class, or the server-socket library that used to be part of clojure.contrib?
17:26stuartsierraTimMc: Thanks you.
17:26Foxboronstuartsierra: i'll look into it. If anyone else can add them i got them on my github acc. Might be faster that way.
17:27stuartsierraTimMc: If I had a nickel for every ounce of grief I've gotten over that little JSON library, I could retire.
17:27TimMcThat's like a metrix ton of grief.
17:28TimMc*metric, I shouldn't be allowed near keyboards today (or yesterday, apparently)
17:30TimMcstuartsierra: Oh, I'm curious; you have a private *escape-unicode* var -- is that intended to be public at some point?
17:30TimMc(I was checking for correct behavior around U+2028 and U+2029.)
17:31stuartsierraTimMc: No, control is all through key/value options on the public API functions.
17:33TimMcOy, that's what I get for not reading docstrings.
17:33stuartsierra:)
17:35TimMcstuartsierra: Would you consider a patch to always escape U+2028 and U+2029? It eliminates a certain class of bugs: http://timelessrepo.com/json-isnt-a-javascript-subset
17:36stuartsierraTimMc: yes
17:36TimMcAnd I know your policy on that.
17:37stuartsierraWell, the Clojure contrib policies trump mine in this case.
17:38TimMcYes, but IIRC, you also explicitly reserve the right to rewrite patches to your liking. :-)
17:38stuartsierraIndeed. :)
17:40andrew__hiredman: thanks for your input, I've played around with it a bit more and think you've set me down a much better path. Very much appreciated!
17:44mynomotoHow do I call (meta) on a namespace?
17:46stuartsierra,(meta (the-ns 'clojure.core))
17:47clojurebot{:doc "Fundamental library of the Clojure language"}
17:47Glenjaminbah, why is there no with-err-str :(
17:47mynomotostuartsierra: Thanks!
17:50gozahi, I'm trying to usecombinatorics on clojure 1.4, but I can't find the library as clojure.math.combinatorics or clojure.contrib.combinatorics. Anyone know where it went?
17:51lzmhfaafb: you will be missed
17:51arrdemgoza: so clojure.contrib.* is dead.
17:51arrdemgoza: https://github.com/clojure/math.combinatorics
17:52gozaarrdem: yea, it's supposed to be under math.combinatorics now, but I can't find it
17:53gozaarrdem: ClassNotFound for both clojure.math.combinatorics and math.combinatorics
17:53Glenjaminis it possible to with-redefs a java function?
17:59gozaah, I'm a total newb I guess. the libraries aren't like standard libraries. you have to download them because they're not built into clojure,
18:05joegalloGlenjamin: no. write a function that calls the function. always use that. that can be with-redef'd.
18:05joegallos/that calls the function/that calls the method/
18:05Glenjaminyeah, just wrapped it - cheers
18:05Glenjamini hate testing randomness =/
18:06GlenjaminUUID/randomUUID
18:06joegalloyeah
18:06joegallo(defn random-uuid [] ...) ; awww yeahhhh
18:06Glenjaminmm
18:08arrdemgoza: yep, check out technomancy's tool "lein" for dealing with all that.
18:15llasramI've just started telling people that the Clojure command-line tool is spelled "lein," for historical reasons
18:16technomancyllasram: close; it's actually for hysterical reasons
18:16llasramheh
18:16technomancynot to be confused with hysterical raisins
18:18callenllasram: you don't tell them it's named after the story?
18:25GlenjaminI've decided to write a tcl interpreter in clojure...
18:26Glenjaminso i can name it tclj!
18:26nightfly__ticklojure
18:29arrdemRaynes: ^^
18:30Raynesarrdem: He's in DC, man. That's about as far away as you can get from me while still being in mainland USA.
18:31arrdemhum... so why does clojure.set not have a universal set..
18:31bbloomarrdem: the set of all objects including itself?
18:32arrdembbloom: that's the one...
18:32technomancy(constantly true) <- that one?
18:32arrdemclose enough.
18:32hiredmanclojure.set is largely written in terms of seqs on sets
18:33hiredmanclojure.set is only suitable for dealing with set datastructures, not math sets
18:35arrdemok. I'm using a set of sequences of types as my function argument representation and was hoping for a non-hacky way to represent a function which will eat anything.
18:35arrdemlooks like I'll just hack it tho.
18:53pppaul.set is nice
18:54pppaulfunctions don't eat
18:54pppaulthey consume
19:17aaelonydoes anyone know the best place to ask incanter questions?
19:20hiredmantry-let! let-try!
19:20technomancythere is no try. only do.
19:20hiredman,(try not do)
19:20clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)>
19:20hiredmanbah
19:21technomancyhuh?
19:21technomancyshouldn't that be "couldn't take the value of a macro"?
19:21hiredmando isn't a macro
19:21gfrederickshiredman: it doesn't surprise me that you've probably written this before :)
19:21hiredmanno, I try-let and let-try are just things I bring up at work from time to time
19:22hiredmangiven how often tryand let are combined
19:22hiredmanlike my with-with macro, which I think I actually implemented at one point
19:22gfredericksthis is for having result-handling code alongside error-handling code
19:22technomancyruby's def has an implicit begin (their version of try)
19:22gfrederickswhere the result-handling code's exceptions are _not_ caught
19:23technomancysometimes I feel like that would make me more likely to bother catching exceptions
19:23technomancyif I didn't have to introduce another level of nesting to do it
19:23hiredmanyou would do (with-with [binding [...] with-connection connect] ...) and with-with would build (binding [...] (with-connection ..))
19:23technomancyyou only need an explicit begin/rescue if you want to limit the scope of your handling to part of the function body
19:24gfrederickshiredman: one of the swiss arrows flattens out that pattern as well
19:42pickanymore familiar with monger?
19:43pick*anyone
19:44pickfailing over here… clueless on this error when I try to connect with a db instance: NoSuchMethodError clojure.lang.RT.mapUniqueKeys([Ljava/lang/Object;)Lclojure/lang/IPersistentMap; monger.conversion/loading--4910--auto-- (conversion.clj:24)
19:45amalloyyour program is AOT-compiled against clojure 1.5, but running on an older version, pick
19:45gfrederickshiredman: (if-try (compute) res (f1 res) Exception e (f2 e))
19:57pickamalloy: many thanks! sorting deps tree, blarg
20:00Raynespick: lein clean
21:50tieTYTwhy am I getting this error: Exception in thread "AWT-EventQueue-0" clojure.lang.ArityException: Wrong number of args (1) passed to: core$eval10074$fn This is the code: (defmulti action-as-string (fn [action] (nth action 0))) (defmethod action-as-string :delete [[_ f] action]
21:50tieTYT (str "Deleting: " (.getAbsolutePath f)))
21:55holotieTYT, maybe you need to have same arity both in defmulti and defmethod
21:55tieTYThrm
21:56tieTYTi thought I did have that
21:56tieTYToh right
21:56holoin defmethod I see 2 inputs
21:56tieTYTok so how do you deconstruct a list?
21:57holo[_ f] if you mean this, I guess it's alright. what I mean is inputs of defmulti is 1, and defmethod is 2
21:59holomaybe you mean: (defmulti action-as-string (fn [[_ _] action] (nth action 0)))
22:00tieTYTyou're right about my issue
22:00tieTYTbut now I'm asking, how do you destructure a list?
22:03holotieTYT. dunno. i usually just destructure vectors
22:03tieTYTyeah that's what I had to do
22:04xeqi&(let [[x y & more] (list 1 2 3 4 5 6)] {:x x :y y :more more})
22:04lazybot⇒ {:x 1, :y 2, :more (3 4 5 6)}
22:04tieTYTah so you just treat it like a vector
22:05tieTYTI feel like destructuring is pretty hard in the "making simple easy" sense
22:05tieTYTmaybe it's because the jay fielding article only demonstrates it in let bindings which adds another layer of complexity
22:08holotieTYT, what's the difference if you do it in let or input params?
22:09tieTYTin a let, you need an even number of arguments
22:10tieTYTso when you're trying to learn the destructuring syntax, the let syntax obscures the signal by adding noise
22:12holotieTYT, I think let is more explicit for learning this, cause you need something to destructure right? (list 1 2 3 4 5 6) is what you need, as shown in the example above
22:14xeqiwell, you could write it ##((fn [[x y & more]] {:x x :y y :more more}) (list 1 2 3 4 5 6))
22:14lazybot⇒ {:x 1, :y 2, :more (3 4 5 6)}
22:14tieTYTholo: just create a function and call it instead
22:37murtaza52I have a seq '(2 3 1 4). I want to iterate through it, and whereever the previous element is smaller then the next element replace it with another seq '(- 4 1). So f('(2 3 1 4)) => (2 3 (- 4 1)). How do I write it?
22:43amalloytry (map list xs (rest xs)) and see if you can get anything interesting from that
22:49murtaza52amalloy : ah thats clever, really clever !
22:50capcrunchanyone uses clj-native ?
22:53amalloy~anyone
22:53clojurebotanyone is anybody
22:54amalloyclojurebot: forget anyone |is| anybody
22:54clojurebotI forgot that anyone is anybody
22:54amalloy~anyone
22:54clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
22:55capcrunchso nobody uses clj-native ?
22:57amalloyevidently nobody who uses it is so excited about it that they answer questions like "does anyone use it" within four minutes, at least
23:05capcrunchamalloy ...
23:07RaynesI sure bet the guy who wrote it uses it.
23:07RaynesProbably worth your chances emailing him or opening an issue on the github issue tracker or something.
23:10capcrunchRaynes , thanks ok , did you coded noir framework ?
23:13xeqi&(clojure.walk/postwalk #(if (vector? %) (remove nil? %) %) {:x [nil 1 2 3]})
23:13lazybotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry
23:14xeqisimplified example, but spot what I'm doing wrong?
23:14xeqi*anyone spot
23:15technomancyusing clojure.walk, which has been repeatedly disowned by its author? =)
23:16xeqiheh
23:16xeqiI suppose that could be it
23:17xeqiwas hoping for an easy way to transform a map with values of vectors of maps with vectors of maps ... :/
23:17technomancyIIRC clojure.walk was only included in clojure because clojure.test uses it
23:17xeqilame
23:18akhudekI should really get around to releasing the zipper based visitor library I have.
23:18xeqi*insert rage comic here*
23:26amalloyxeqi: what about an orgy of into/for?
23:27technomancypostwalk implies to me that you don't know all that much about the structure of the input
23:28xeqiamalloy: I'm headed down a multimethod path that looks that direction
23:29amalloyheh. postwalk docstring addendum: "only intended for transformations that would be impossible in a statically-typed language"