#clojure log - Apr 23 2013

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:47 talios: shiny

3:47 NeedMoreDesu: how do you do nested loops?

3:47 ucb: ,(doc for)

3:47 clojurebot: "([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 ...], ...

3:47 ucb: NeedMoreDesu: you could try with for

3:48 NeedMoreDesu: If I wish to loop for (< i n) ?

3:49 ofc I can make lazy list of increases lol

3:49 ucb: NeedMoreDesu: you can map over (range n)

3:49 NeedMoreDesu: Is it lazy?

3:49 jaen: fzz

3:50 ucb: both map and range are

3:50 NeedMoreDesu: oh, nice.

3:50 jaen: ;;--

5:23 linux_: Buy Korean stuff, all is well

5:32 silasdavis: how should I go about debuggin a ring-based application

5:33 I'd like to be able to break on a line and inspect variable values

5:33 clgv: silasdavis: first there is a middleware that prints you the encountered exceptions in a readable way

5:33 silasdavis: or at least see a trace of arguments

5:33 clgv, I think I'm seeing that (I get a stacktrace in the browser)

5:34 something like:

5:34 APersistentVector.java:265 clojure.lang.APersistentVector.invoke

5:34 friend.clj:196 cemerick.friend/authenticate*

5:34 friend.clj:208 cemerick.friend/authenticate[fn]

5:42 zackzackzack: How should I go about typing hinting methods that don't take any arguments?

5:44 mpenet: it seems like you want to type the instance

5:56 piranha: it seems there is no easy way to check if string contains a substring, right?

5:57 ejackson: piranha: use a regexp

5:58 ucb: piranha: alternatively use .substring

5:58 ejackson: ,(re-find #"substring" "string with substring")

5:58 clojurebot: "substring"

5:59 piranha: ejackson: I also thought about (if-not (neg? (.indexOf str substr)))

5:59 ucb: lovely

5:59 ejackson: although ucb is right, .substring should be faster

5:59 piranha: but still, no simple clojure.string/contains?, eh

6:00 well, substring is like a slice, I need .indexOf

6:01 Ember-: ,(.indexOf "my merry string" "merry")

6:01 clojurebot: 3

6:01 Ember-: what's wrong with that?

6:01 clojure does not try to invent the wheel again where java suffices

6:02 piranha: well, I have to check for -1, instead of true/false, which makes a lot more parens :)

6:02 Ember-: so you need index number except if there is no such substring in which case it should return false?

6:03 ucb: ,(.substring "foo" "foobar")

6:03 Ember-: or do you just need true/false if there is such a string?

6:03 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>

6:03 ucb: orly

6:03 ,(.subString "foo" "foobar")

6:03 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: subString for class java.lang.String>

6:03 ucb: bleh

6:06 piranha: (defn str-contains? [s1 s2] (.contains (.toLowerCase s1) (.toLowerCase s2)))

6:06 ,((fn str-contains? [s1 s2] (.contains (.toLowerCase s1) (.toLowerCase s2))) "foobarbaz" "foo")

6:06 clojurebot: true

6:43 piranha: Ember-: yes a true/false, yes

6:44 ucb: piranha: see above

6:44 piranha: ucb: yep, I could have a simple helper

6:44 sure, thanks

6:44 ucb: np :)

6:44 piranha: I haven't realized java has .contains on a string

6:45 was looking at some funny (and outdated) documentation :\

6:56 jjl`: 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?

7:01 tcrayford: jjl`: I'd assume on github

7:04 jjl`: ta

7:07 heh, someone else already reported it

7:55 clgv: what 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?

8:12 piranha: alandipert: octagon: are any of you guys here by any chance? :)

9:40 TimMc: &(hash-map "\u00e9" "c" "\u0065\u0301" "d")

9:40 lazybot: ⇒ {"é" "c", "é" "d"}

9:41 TimMc: What Unicode normalization form should I use before hashing a password?

9:42 I'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."

9:44 I should really take that to StackOverflow.

9:45 pjstadig`: NFC

9:46 TimMc: I'm concerned that the NFC form might change if a future Unicode spec adds a composite form.

9:47 s/form/character/

9:49 pjstadig`: so you use the stable version of NFC

9:50 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

9:51 http://unicode.org/reports/tr15/#Versioning

9:51 TimMc: Ah, the stability thing is new to me.

9:52 I'm pretty sure any of the normalization forms have collisions. That's what normalization is, yeah?

9:53 ,(.importClass *ns* 'Norm java.text.Normalizer)

9:53 clojurebot: java.text.Normalizer

9:53 pjstadig`: i suppose that's true, someone could enter two separate characters that would get composed under NFC

9:53 TimMc: ,(.importClass *ns* 'NF java.text.Normalizer$Form)

9:53 clojurebot: java.text.Normalizer$Form

9:53 pjstadig`: not sure if java.text.Normalizer supports stable normalization or not

9:54 TimMc: Yeah, I don't see a way to do that.

9:55 But the D or KD forms should be stable, right?

9:57 pjstadig`: 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

9:57 with respect to Unicode 3.1.0

9:58 TimMc: Do you see any harm in D or KD?

9:59 The "must not" scares me, but there's no need for round-tripping or preservation of semantics.

10:00 I'm OK with "office" -> "office"

10:01 pjstadig`: i think the non-round-tripping and non-preservation of semantics is why the recommend not using with arbitrary text

10:01 if you know that, then maybe you'll be ok

10:12 xorola: Hey guys, i got a question. In what ways clojure macros differ from C macros and Other lisp macros ? a resource would be great .

10:13 tcrayford: principally, clojure macros operate on data structures, C macros operate on strings

10:13 http://clojure.org/macros

10:14 they are very similar to common lisp macros (though there's only one namespace, which makes things a bit different)

10:17 stuartsierra: To 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:18 tcrayford: stuartsierra: oops. Thanks

10:18 stuartsierra: tcrayford: No problem. Just saw an opportunity for confusion there.

10:21 xorola: tcrayfod: 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:22 stuartsierra: Macros are most-often used for language extensions. For example, many parts of Clojure itself are implemented as macros.

10:23 tcrayford: see clojure.core/defn for an example (though a noticeably hairy one)

10:24 in 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:25 stuartsierra: Macros are rarely used in application-level programming, but they are a very powerful tool for extending the language.

10:27 TimMc: xorola: Macros are never the only way to solve a problem.

10:30 xorola: TimMc: fair enough, :)

10:33 TimMc: pjstadig`: 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:33 pjstadig`: TimMc: right, but annex #15 is stable

10:39 TimMc: pjstadig`: 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:41 murtaza52: I 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:42 gtrak: murtaza52: I recommend multimethods

10:43 I wrote a similar little interpreter the other day: https://github.com/gtrak/webbedfeet/blob/master/src/com/garytrakhman/webbedfeet.clj

10:44 stack-based

10:44 pjstadig`: 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:44 Unicode N will continue to normalize according to annex #15, which means against the 3.1.0 Unicode database

10:45 TimMc: Hmm. So no new compositions are allowed, then?

10:45 pjstadig`: not according to annex #15, if i'm reading it right

10:46 cmajor7: can't get flatland https://github.com/flatland/clojure-protobuf extensions to work: https://www.refheap.com/paste/13884 anything I am missing? thx

10:46 pjstadig`: 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:47 TimMc: "However, the Unicode Consortium strongly discourages new compositions, even in such restricted cases."

10:47 I guess that works.

10:48 pjstadig`: 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:50 TimMc: My concern is where the client sends newer characters than the server's Unicode support understands.

10:50 Just reject it, maybe? :-/

10:51 For that matter, I suppose byte sequences invalid for UTF-8 (or whatever) mus tbe rejected.

10:54 pjstadig`: i think any newer characters would just pass through the normalization process

10:54 TimMc: I'd be willing to say "the server always has a recent Unicode".

10:55 pjstadig`: there's a closed set of characters that the normalization process detects and (de)composes, anything else just passes through

10:56 TimMc: Perhaps then an NF(K)C form is preferable.

10:57 Let'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:58 (The client here is at Unicode > 6.1 or whatever the current version is.)

10:58 pjstadig`: normalization is defined against the unicode 3.1.0 database

10:58 it is frozen forever

10:59 you will never get different results for a newer version of Unicode

10:59 TimMc: Oh! "A normalized string is guaranteed to be stable; that is, once normalized, a string is normalized according to all future versions of Unicode."

10:59 pjstadig`: (after 4.1)

10:59 TimMc: That's a pretty strong guarantee.

11:00 Actually, "For all versions, even prior to Unicode 4.1, the following policy is followed:"

11:00 ^

11:00 "strongly discourages new compositions" is a weaker statement.

11:04 Ugh, that "*and* contains only characters allocated in that version" still bothers me. :-/

11:05 "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:08 ToBeReplaced: if 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:08 joegallo: create a promise and have the other thread deliver on the promise

11:08 for instance

11:09 ToBeReplaced: joegallo: what type gets delivered?

11:09 joegallo: whatever you put into it...

11:14 ToBeReplaced: joegallo: 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:15 joegallo: i would promise to return a lazy-seq, and then i'd return a lazy-seq

11:15 or are you trying to get into a producer and consumer?

11:19 ToBeReplaced: consumer 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:28 TimMc: pjstadig`: 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:33 pjstadig`: TimMc: with recommendation #1 what you are saying is you want NPSS http://unicode.org/reports/tr15/#Stabilized_Strings

11:33 which is fine, i just wanted to point out that annex #15 handles that case (if you hadn't seen)

11:38 TimMc: Thanks, yes.

11:42 mynomoto: I'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:43 aphyr: mynomoto https://github.com/clojure/core.match + a macro?

11:45 clgv: I 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:46 tcrayford: mynomoto: I did something like this a while back (it almost definitely won't run anymore): https://github.com/tcrayford/umbrella

11:46 the source there might be useful, it's not too long

11:47 ucb: clgv: is your implementation of future available anywhere?

11:47 (I just happen to have a need for such thing :) )

11:48 clgv: ucb: 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:49 ucb: clgv: *nod*

11:51 mynomoto: aphyr: Thanks.

11:52 tcrayford: I will look at the source, looks like what I'm looking for.

11:52 tcrayford: myonmoto: iirc it's kinda fucked in it's current state. But you can probably get some ideas from there

11:52 (as in, even if the code ran, it'll be broken)

11:58 noncom: hi! 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:58 mynomoto: tcrayford: I'll try to run but the transmogrification appear to be what I want.

12:04 andrew__: 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:09 nz: ~.

12:09 clojurebot: Cool story bro.

12:09 nz: ls

12:09 lazybot: bin boot sbin srv swap

12:10 noncom: a 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:10 do i have to create a correct pom for that with dependencies section?

12:12 S11001001: noncom: what are these "other jars"?

12:15 noncom: S11001001: 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:15 there 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:17 S11001001: noncom: 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:20 nz: noncom: 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:20 joegallo: from 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:20 that's the long term correct answer

12:21 nz: I don't if lein and clojars support project hierarchies

12:21 check123`: hey, are there any books written specifically for beginning programmers based upon clojure?

12:22 david_pidcock: Just 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:22 Couldn't find anything on the web yet.. :D

12:24 clgv: ucb: ok I found the error

12:24 ucb: clgv: oh?

12:27 noncom: nice! 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:28 clgv: usb: https://gist.github.com/guv/5445115

12:28 ucb: ^^

12:31 ucb: clgv: nice. What was the issue?

12:31 danielglauser: david_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:31 clgv: ucb: the position of the type hint ^Callable led to the selection of the wrong submit method

12:32 danielglauser: david_pidcock: there are *tons* of ways to solve the web flow problem in Clojure

12:32 ucb: clgv: I see.

12:32 danielglauser: david_pidcock: And yes, I can see where that is a challenge for folks getting started

12:32 gtrak: david_pidcock: checked out pedestal yet?

12:33 david_pidcock: danielglauser: 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:33 gtrak: what's more flowy than event-sourcing?

12:33 david_pidcock: gtrak: 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:34 danielglauser: gtrak: david_pidcock: The pedestal "base everything off of events" isn't a bad way to go.

12:34 david_pidcock: danielglauser: gtrak

12:35 danielglauser: david_pidcock: One approach with Ring/Compojure would be to store the intermediary state in a DB

12:35 david_pidcock: that has the added advantage of letting you serve requests via clustered Clojure servers

12:36 david_pidcock: removes the session replication problem

12:37 david_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:38 david_pidcock: gtrak: 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:38 gtrak: danielglauser

12:39 danielglauser: david_pidcock: you could always keep the intermediary state in a distributed cache, something like Redis, <insert data store of the week here>

12:39 gtrak: so 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:40 danielglauser: gtrak: inc

12:40 gtrak: I would be hesitant of any 'do something to everything' strategy

12:40 david_pidcock: danielglauser: 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:40 gtrak : you have an excellent point

12:41 (wherever that map might be held)

12:41 danielglauser: david_pidcock: in memory session state is an optimization, one I'm not convinced is any faster than an in memory store or cache

12:42 david_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:43 david_pidcock: danielglauser: 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:44 danielglauser: david_pidcock: You're welcome. Best of luck!

12:45 n_b: Could 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:45 gtrak: JCIP, then CTMCP

12:46 n_b: gtrak: the second one is by Van Roy?

12:46 gtrak: yea

12:46 SegFaultAX: n_b: Isn't the Java Concurrency book considered the de facto standard?

12:47 gtrak: JCIP 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:47 n_b: SegFaultAX: 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:47 amalloy: i've heard nothing but good things about JCIP

12:48 i wonder if the office has a copy of it, actually. maybe i should read it

12:48 SegFaultAX: n_b: Definitely go with JCIP.

12:48 gtrak: In terms of design? What do you mean?

12:49 gtrak: SegFaultAX: 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:50 it was more like... 'don't do these things... these are the guarantees provided by the java memory model, etc..'

12:50 SegFaultAX: gtrak: I don't really think it's supposed to be the former, is it?

12:50 gtrak: no, I guess not :-)

12:50 SegFaultAX: gtrak: I've never had that impression about it.

12:51 amalloy: right, you want more of a "concurrency in general" for that, not specifically java concurrency

12:51 gtrak: it 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:51 amalloy: since the building blocks are mostly shared across languages

12:51 gtrak: CTMCP is more philosophical

12:51 n_b: Follow-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:52 SegFaultAX: n_b: Doubt it, since all of Clojure's concurrency primitives either wrap Java primitives, or literally ARE Java primitives.

12:52 dnolen: gtrak: hmm, I think Clojure's design reflects a fairly close reading of JCIP

12:53 SegFaultAX: Also, IIRC Hickey is a fan of JCIP and HFJ

12:53 gtrak: I 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:54 SegFaultAX: gtrak: I think you didn't have reasonable expectations for what JCIP would teach you.

12:55 gtrak: yea, I'm not saying don't read it, just that it doesn't address some things that I thought it might

12:55 that other might think it would, too

12:55 other people*

12:55 n_b: SegFaultAX: 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:56 SegFaultAX: n_b: You'll learn about thread pools and executors for sure. Agents aren't that much more once you have the basics.

12:57 Has anyone here looked at RxJava by Netflix? I watched a talk about it last night on InfoQ.

12:59 dnolen: gtrak: makes sense

12:59 noncom: S11001001: 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:59 n_b: SegFaultAX: 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:00 ucb: clgv: forgot to ask: are you releasing your future+?

13:01 gtrak: SegFaultAX: what's HFJ?

13:01 SegFaultAX: n_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:01 clgv: ucb: you can use the code from the gist. it's too small for a lib just yet

13:01 SegFaultAX: gtrak: Head First Java.

13:01 gtrak: One of the more popular intro to Java type books, I think.

13:01 ucb: clgv: cool, thanks :)

13:02 SegFaultAX: clgv: Have a link handy?

13:03 clgv: SegFaultAX: for the future+?

13:03 SegFaultAX: Yup

13:03 gtrak: I really like 'Effective Java'

13:03 had a few epiphanies from that one

13:04 SegFaultAX: gtrak: Also an excellent book.

13:04 ucb: SegFaultAX: https://gist.github.com/guv/5445115

13:05 clgv: SegFaultAX: that's the one ^^

13:05 SegFaultAX: `fogus: Do you know yet if JoC 2 will be available in a Kindle format?

13:05 ucb: Thanks!

13:06 `fogus: SegFaultAX: Probably through Manning yes.

13:07 SegFaultAX: `fogus: Awesome! Looking forward to it. How much of an update is it over version 1?

13:15 `fogus: SegFaultAX: 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:16 pl6306: Does edn support datetime? If so how do I represent one?

13:20 llasram: pl6306: #inst

13:22 &#inst "2013-04-23T13:21:00.000"

13:22 lazybot: ⇒ #inst "2013-04-23T13:21:00.000-00:00"

13:22 technomancy: pl6306: be aware that #inst will result in a java.util.Date unless you fix it though

13:22 see clj-time

13:22 tcrayford: does clj-time have tools for #inst now? I was fighting this the other day (ended up just serializing to json instead)

13:23 (in all honesty I didn't look all that hard)

13:23 pl6306: thanks!

13:23 technomancy: haven't used it myself, but pretty sure it's easy to hook up the parts

13:29 silasdavis: how can I join multiple ring routes together

13:29 SegFaultAX: Why 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:29 technomancy: SegFaultAX: concurrent IO is hard =)

13:29 silasdavis: say I have defroutes routes1 ..., defroutes routes2... I want to combine [routes1 routes2] into a single handler

13:30 technomancy: silasdavis: you can call routes2 from routes1

13:30 it's just a function

13:30 amalloy: technomancy: yes, but he just wants (routes r1 r2)

13:31 technomancy: that too

13:31 lots of ways to do it =)

13:31 req is a map, routes1 and routes2 are functions; you do the math

13:31 amalloy: silasdavis: 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:32 technomancy: was trying to think of a point-free way to do it

13:32 SegFaultAX: Compojure uses `some` but yea.

13:32 amalloy: SegFaultAX: note i said "equivalent to"

13:32 technomancy: oh yeah; some

13:32 duh

13:32 silasdavis: which `routes` function in `(routes r1 r2)`?

13:33 amalloy: it's in the same place as defroute, unsurprisingly

13:33 defroutes is nothing but a macro that expands to (def ... (routes ...))

13:34 technomancy: (comp first (partial remove nil?) (partial map (partial (flip deliver) req))), i think? if we're willing to pretend we have flip

13:35 technomancy: hah; nice

13:39 deg: I'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:39 Tried lein clean, and renaming the file, but the error persists.

13:42 silasdavis: amalloy, hm so will I need (apply routes r1 r2)?

13:42 since I don't know the number of GETS, POSTS etc in the macro

13:42 or no because that macro has already expanded

13:42 amalloy: there are no macros involved. r1 and r2 are both functions of one argument

13:42 antares_: 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:43 silasdavis: In general if you have (macro1 (macro2 ...) ...) will macro2 have expanded by the time it acts as an argument to macro1

13:43 ?

13:43 I suppose that's up to macro1

13:44 gtrak: silasdavis: macros expand recursively... if you don't have one with side-effects, why do you care when it happens?

13:44 silasdavis: it might be clear I haven't looked into macros in any depth yet...

13:45 SegFaultAX: silasdavis: 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:46 silasdavis: SegFaultAX, I was thinking that they could be 'unexpanded macros' or something like that

13:46 gtrak: silasdavis: it happens top-first, ##(macroexpand-1 '(fn [] (let [blah 1])))

13:46 lazybot: ⇒ (fn* ([] (let [blah 1])))

13:46 gtrak: let is also a macro

13:47 SegFaultAX: silasdavis: Macros are expanded at compile time. By the time (routes r1 r2) runs, all of that would have been expanded.

13:47 silasdavis: got it

13:56 n_b: Is there some Reader-like construct for sequences, i.e. traversable once, dropping items once accessed?

13:57 amalloy: n_b: how is that different from a sequence itself?

13:57 i mean, what you've described is an iterator, but that's just a seq with gratuitous mutation

14:06 n_b: amalloy: 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:07 amalloy: *shrug* sequences implement Iterable, so you can make an iterator if you want

14:07 n_b: Ah, I see. Thank you.

14:08 jtoy: is 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:09 S11001001: noncom: 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:09 n_b: amalloy: annnd your comment made me realise a way this can work with just a plain seq without changing anything. Much cleaner :)

14:11 S11001001: jtoy: aside, (fn [x] (pop x)) ≡ pop

14:16 jtoy: S11001001: I want to pass the arg into my filter

14:16 i think I can do this, im having a mental blopc kthough

14:17 S11001001: jtoy: irrelevant

14:18 jtoy: S11001001: how do I call (classify-scalar forest x) if the arg I pass is 'classify-scalar forest) ?

14:19 (classify-scalar forest) I mean and the x needs to be passed as a nn argument?

14:19 S11001001: jtoy: 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:20 jtoy: ok, i see what you mean, does that help with my problem?

14:20 i see that that simplifies my code

14:20 S11001001: jtoy: insofar as you should see that `classify-scalar' might be found in the list of arguments to your function, yes

14:22 jtoy: functions are ordinary values, and functions you make with defn are just as functiony as ones you make with `fn'

14:22 rasmusto: is 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:22 S11001001: jtoy: including the functions in the standard library

14:23 jtoy: im still not exactly sure

14:23 amalloy: rasmusto: so it's a map with only one k/v pair in it?

14:24 rasmusto: amalloy: it could have other k/vs

14:24 amalloy: but you want to take one k/v pair out and do this to it?

14:24 rasmusto: amalloy: I'm thinking I might just do a zipmap whenever I find a vector as a key

14:25 amalloy: I'd like to dissoc [:a :b :c] from the map, and merge (zipmap [:a :b :c] [1 2 3]) with that map

14:26 amalloy: I think I have a solution bubbling up to the surface, I'll paste it in a sec

14:27 jtoy: S11001001: 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:29 SegFaultAX: ,((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:29 clojurebot: {:a 1, :b 2, :c 3}

14:30 SegFaultAX: rasmusto: ^

14:30 ToBeReplaced: heh, i'd have (apply zipmap (first (select-keys {[:a :b :c] [1 2 3]} [[:a :b :c]])))

14:31 oh there's a merge misread, nvm me

14:31 S11001001: jtoy: arg-to-call is an arg you have yes?

14:32 rasmusto: SegFaultAX: that's beautiful. Thanks

14:32 SegFaultAX: rasmusto: Honestly I'm more curious why you have such a requirement.

14:33 rasmusto: SegFaultAX: parsing stdout strings from some crappy tool

14:33 SegFaultAX: rasmusto: Ugh, that sucks. Hopefully that's what you're looking for.

14:33 jtoy: S11001001: 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:33 and get ArityException Wrong number of args (1) passed to: core$classify-scalar clojure.lang.AFn.throwArity (AFn.java:437)

14:34 rasmusto: SegFaultAX: most definitely. I have it figured out now :)

14:34 llasram: jtoy: Are you trying to get to something like `(comp (partial = 1) (partial classify-scalar forest))`

14:34 ?

14:35 jtoy: passing this in works: (fn[x] (classify-scalar @american_forest x)) is this the way I should pass my argument?

14:36 llasram: I havent used partial, im studying it now

14:36 hmm, thats cool

14:37 SegFaultAX: jtoy: ##((partial + 1) 1)

14:37 lazybot: ⇒ 2

14:38 jtoy: cool, so I'll just pass partial then, seems easier then calling with a funcfn

14:40 amalloy: jtoy: your client keeps sending 0x7F (ascii DELETE) characters instead of actually backspacing over stuff before you send it

14:41 jtoy: amalloy: yeah, something seems broken, thx

14:42 Raynes: This is sad. I can't remember how to configure refheap.vim.

14:42 The reason that is so sad is because I wrote it.

14:42 jtoy: haha

14:43 Raynes: Ah, there we go.

14:47 arrdem: am I reading this right? because algo.monads works using lazy sequences you can't use ^:dynamic vars "correctly" in monadic code.

14:48 technomancy: arrdem: you can't use dynamic vars anywhere laziness is used; correct

14:48 arrdem: bah ok thanks technomancy

14:48 technomancy: not strictly true, but trying to use them together is very error-prone

14:51 if you can guarantee the laziness is consumed inside the scope of the binding it can work. but there are serious composability issues.

14:56 arrdem: yeah that's what I'm running into right now..

14:57 gfredericks: usually "don't use dynamic binding" is the preferred solution

14:57 technomancy: probably even more error-prone if the laziness is hidden behind monadic magic

14:57 (the irony of a guy who goes by "technomancy" complaining about magic is not lost on me)

14:57 pl6306: Can I add meta data to an entry of map? Or is only possible add it to a map.

14:57 arrdem: pl6306: if the entry extends IObj yes you can

14:58 gfredericks: ,(-> {1 2} first (with-meta {::a ::b}) (list) (->> (into {})) first meta)

14:58 arrdem: ok. guess I'm stuck with my global state atom then.

14:58 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.MapEntry cannot be cast to clojure.lang.IObj>

14:58 amalloy: arrdem: wait, to the entry or the value?

14:59 arrdem: well gfredericks just torpedoed the entry.

14:59 I was talking about the value

14:59 (meta (:foo {:foo (with-meta :bar {:foo 3})}))

14:59 amalloy: gfredericks: that's lame. i would have expected c.l.MapEntry to be an IObj

14:59 deg: Re 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:59 arrdem: ,(meta (:foo {:foo (with-meta :bar {:foo 3})}))

14:59 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.IObj>

14:59 gfredericks: amalloy: I thought it was a terribly fascinating question

14:59 arrdem: oh frick

14:59 technomancy: amalloy: if only we had inheritance amirite

14:59 deg: Did I violate a known rule, or should I report this as a bug?

15:00 gfredericks: since 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:00 amalloy: technomancy: hm?

15:00 arrdem: ,(meta (:foo {:foo (with-meta [:bar] {:foo 3})}))

15:00 clojurebot: {:foo 3}

15:00 arrdem: ok yes so you can have metadata on vals in a map

15:00 technomancy: amalloy: just amusing that it looks like that problem is due to avoiding implementation inheritance

15:01 gfredericks: interfaces can inheret though, no? IPersistentVector could extend IObj?

15:01 amalloy: technomancy: really? clojure.lang doesn't make any effort at all to avoid implementation inheritance afaict

15:01 technomancy: amalloy: it's possible I don't actually know Java or anything about Java

15:01 amalloy: i 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:02 llasram: I thought keywords couldn't have metadata because they are explicitly singletons. You can't have different copies with different metadata

15:02 amalloy: llasram: indeed

15:02 technomancy: it would be like putting metadata on numbers

15:02 danneu: Question: 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:02 llasram: Oh, I didn't scroll back far enough

15:02 technomancy: ^:even 2

15:03 llasram: Heh

15:03 * arrdem legitimately tried to put meta on numbers a few days back

15:03 technomancy: ^:prime 7

15:03 Glenjamin: can anyone recommend a validation library? i've done a quick survey but it's not obvious which one is actually used by people

15:03 technomancy: the Clojure Way is to write your own validation library

15:04 everyone's doing it

15:04 arrdem: technomancy: no that's the Lisp Curse

15:04 Glenjamin: heh, certainly seems that way

15:04 callen: Glenjamin: validation for what? Web?

15:04 * arrdem goes back to putting window dressing on his global state atom

15:04 Glenjamin: in my case, yes - but maps in general should be fine

15:05 callen: Glenjamin: Okay, just use one of the existing libraries.

15:06 Glenjamin: mm, just trying to pick one that isn't abandonware

15:07 xeqi: Glenjamin: I've used weavejester's valip

15:07 Glenjamin: the one from weavejester looks good, but hasn't been touched for 2 years!

15:07 callen: maybe it's perfect!

15:07 >_>

15:07 technomancy: for something that simple it's possible

15:08 TimMc: Glenjamin: clj-schema works well, although mind the lack of semver and changelogs.

15:09 danneu: prob spend more time looking for a lib than the moment it takes to roll your own every-pred

15:10 Glenjamin: meh, i hate rolling my own when existing options exist

15:11 most of the stuff i've used for this project so far i've contributed back a fix/improvement for - everyone wins

15:11 danneu: Glenjamin: https://github.com/weavejester/valip/tree/master/src/valip

15:11 SegFaultAX: Glenjamin: Look at the source for valip

15:11 Glenjamin: It's like 10 lines of code.

15:12 technomancy: heh

15:12 Glenjamin: with tests, and other contributors

15:12 if we all keep re-inventing the same simple wheels, we'd never build a decent car

15:12 SegFaultAX: There are a few obvious things you could do to improve it, but it doesn't do very much as it is.

15:12 gtrak_: what's even the measure of a good validation library?

15:12 xeqi: ... does it validate

15:13 SegFaultAX: Also a shitload of pre-built validators.

15:13 technomancy: xeqi: I'm imaginging a "does it blend" style video series

15:13 gtrak_: the subset of all functions that take an arg and return a boolean?

15:13 danneu: libraries are useful when they save you time.

15:13 SegFaultAX: gtrak_: I'm thinking more like ActiveModel::Validations

15:14 gtrak_: I guess that's not a shit load per se, but it covers a large number of the common cases.

15:14 danneu: yeah, the value added clearly comes from the predicates, not the actual implementation

15:15 xeqi: technomancy: Yes, it validates!

15:15 SegFaultAX: One 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:16 Glenjamin: i appear to have stumbled onto a hot button topic

15:16 SegFaultAX: Also, making composable validators is really handy. I often have a core set of validations that are shared across a number of different things.

15:17 jcromartie: I feel like using sets along with watches and validators is better than using hash maps to model collections

15:17 amalloy: a 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:17 jcromartie: amalloy: xargs

15:17 Raynes: lol

15:17 amalloy just got told to xargs. That's a twist.

15:17 amalloy: jcromartie: wat. that is not even related

15:18 jcromartie: amalloy: no? how does xargs not do that?

15:18 SegFaultAX: amalloy: #bash can help.

15:18 Glenjamin: -P maxprocs Parallel mode: run at most maxprocs invocations of utility at once.

15:18 ^^ from man xargs

15:18 arrdem: wat

15:18 amalloy: interesting. i didn't know about that option. i guess it assumes each argument could be a separate call to proc

15:18 arrdem: well that's new...

15:19 Raynes: Wherein Glenjamin changes our lives.

15:19 SegFaultAX: (inc jcromartie)

15:19 lazybot: ⇒ 4

15:19 jcromartie: xargs -P 8 -n 1 ...

15:19 Glenjamin: credit to jcromartie :)

15:19 jcromartie: yay

15:19 SegFaultAX: (inc Glenjamin)

15:19 lazybot: ⇒ 2

15:20 xeqi: Glenjamin: have any interest in commit rights for peridot?

15:21 Glenjamin: xeqi: can do, nothing planned to add at the moment

15:21 i'm building up some functions to use kerodon with speclj at the mo

15:21 xeqi: awesome, https://github.com/xeqi/kerodon/issues/8

15:23 Glenjamin: i've got a (should-have) function which behaves similarly to (has)

15:24 xeqi: added, nothing planned here either, but nice to have others that can do something if I get busy/miss a pr

15:25 Glenjamin: cheers

15:53 callen: Glenjamin: (should-have) is a very quaint way of saying (has).

15:54 Glenjamin: callen: in the context of speclj, all of it's test assertion methods start with (should)

15:55 callen: Glenjamin: sounds like communism.

16:07 arrdem: is 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:08 Raynes: callen: I really like speclj's name. Except for the stupid fricken clj crap.

16:08 I hope nobody ever creates a new project with a cutesy clj or jure name in front of me.

16:08 For their safety cannot be guaranteed.

16:09 trptcolin: Raynes: juraynesic_parclj

16:09 n_b: Tell us how you really feel ;)

16:09 trptcolin: granted, it's a stretch

16:09 Raynes: n_b: How I really feel is illegal in all governed countries.

16:10 Glenjamin: could be worse, in ruby-land libraries tend to be named after common dictionary words which make them hard to google for

16:11 Raynes: There is a python lib called 'requests'.


16:11 Glenjamin: heh, true

16:11 Chousuke: haskell libraries are even more fun

16:11 if you google for them, you get wikipedia pages full of maths

16:12 Raynes: I am guilty of using Haskell's name in vain in my libraries.

16:12 $google haskheap

16:12 lazybot: [Raynes (Anthony Grimes) · GitHub] https://github.com/Raynes?tab=repositories

16:12 * Raynes hides his head in shame.

16:12 amalloy: what's wrong with 'requests'?

16:12 Raynes: amalloy: We were complaining about libraries that are common dictionary words.

16:12 amalloy: like...laser, tentacles...?

16:13 Raynes: I wasn't complaining, you'll kindly notice.

16:13 amalloy: you uh...shouted FU so loudly they heard you in arkansas

16:13 jjttjj: yeah i kinda like that googleibility is an aknowledged thing in clojure

16:13 Glenjamin: i could make a form handling lib, and call it "forms"

16:13 Chousuke: I don't really mind using common words for names, but then you should prefix it with clj or py or something

16:13 Raynes: amalloy: I was playing along with Glenjamin.

16:13 Chousuke: Get off my IRC.

16:13 Chousuke: nothing wrong with a library called py-requests

16:13 Glenjamin: "clojure forms" is bound to be a fruitful search term

16:13 Raynes: clj-* names are equally as anger inducing.

16:14 We need very strict laws governing library naming.

16:14 Chousuke: well, clj is not so good as a prefix

16:14 Glenjamin: you could pronounce it "kludge"

16:14 bbloom: i prefix all of my library names with me.raynes.bbloom.

16:14 Chousuke: since you can't even pronounce it

16:14 callen: Raynes: the requests library is really nice though.

16:14 Raynes: bbloom: <3

16:14 callen: Raynes: I love everything that guy does.

16:14 Raynes: callen: Yes it is. Ken is amazing.

16:14 stuartsierra: Group IDs are the way to go.

16:14 callen: Raynes: REITZ IS MAH HOMEBOY

16:14 jjttjj: after working with R for a bit i'd take the cheesy/generic names over things even more slightly harder to find on google

16:15 SegFaultAX: stuartsierra: Have you looked at RxJava?

16:15 stuartsierra: SegFaultAX: not yte

16:15 *yet

16:15 Raynes: stuartsierra: 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:15 SegFaultAX: stuartsierra: There is a pretty good talk about it on InfoQ from the lead at Netflix.

16:15 bruceadams: and Ken Reitz is coming to talk at Pittsburgh Python's meetup tomorrow. anyone in Pittsburgh should come!

16:16 stuartsierra: Raynes: I don't lead lynch mobs. I just complain. ;)

16:16 SegFaultAX: stuartsierra: Observables are similar in a lot of ways to PromisesA it seems. Possible a substitute for a cljque-type lib.

16:16 Raynes: stuartsierra: Sure. That blue hair was merely a disguise.

16:17 bbloom: i'm with technomancy: short, reasonably unique by best effort google/github search, no ceremony

16:18 SegFaultAX: bbloom: Then you'll appreciate the new "unicorn" lib that's hot on HN right now.

16:18 Completely unrelated to all the other unicorn projects, but still uses the name and images associated with them.

16:18 bbloom: that's total fail at best effort search

16:18 callen: zero effort

16:18 also, how can you possibly not know about unicorn (rack) and gunicorn (wsgi)?

16:19 and still be working on an HTTP related thingi?

16:19 mpenet: stuartsierra: did you see dajac/react, it's another impl of promises/futures & co

16:19 SegFaultAX: Worse, it's indistinguishable from the unicorn web server.

16:19 Even the fricken logo is the same as the one GH uses.

16:19 bbloom: once past the best effort search, there is like a several week probation period where people can ask you to change the name

16:19 past that, conflicts are not my problem

16:19 mpenet: stuartsierra: apparently it's used at paper.li

16:19 SegFaultAX: callen: They actually specifically address the name conflict on their site.

16:19 Something ot the effect of "we named it before it was written, and never changed it"

16:20 callen: ...

16:20 SegFaultAX: the author of using the excuse that his little sibling or something named it.

16:20 is*

16:20 Glenjamin: i don't see a unicorn on HN...

16:20 stuartsierra: mpenet: no, haven't run into that

16:20 Glenjamin: aha, page 2

16:21 SegFaultAX: callen: Even so, they could have added something to it. unicornhttp or something, I don't know. And to use the angry unicorn. Wtf.

16:22 callen: SegFaultAX: they named the Ruby version "unicorn-rest" and the python one "unicorn" <--- lol

16:22 SegFaultAX: 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:23 mpenet: stuartsierra: have a look, he took another interesting approach, uses atoms under the hood, and seems to have a rich api around its futures

16:23 SegFaultAX: For those interested in RxJava: http://www.infoq.com/presentations/netflix-functional-rx

16:23 stuartsierra: mpenet: I haven't had any time to focus on promise for months.

16:24 callen: SegFaultAX: that looks a LOT like Twitter's Finagle

16:24 SegFaultAX: same idea and use-case, implemented differently.

16:24 SegFaultAX: callen: RxJava?

16:24 callen: SegFaultAX: da comrade

16:25 technomancy: gun-i-corn

16:25 is how I say it

16:25 SegFaultAX: callen: I haven't looked at Finagle, I'll take a look. RxJava in particular is a port of Rx.Net.

16:25 callen: technomancy: I say gew-nee-corn

16:25 SegFaultAX: technomancy: I say "goon-i-corn"

16:26 callen: SegFaultAX: well the idea behind Finagle was to have a generic framework for composable SOA with deliverables wrapped in promises in Scala

16:26 laliluna: lein midge causes: Caused by: java.lang.NullPointerException

16:26 at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:332)

16:26 at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:987)

16:26 at clojure.lang.Namespace.find(Namespace.java:188)

16:26 SegFaultAX: callen: From what I've read so far, RxJava is just a normal observer + an onComplete and onException callback.

16:26 callen: laliluna: midje?

16:27 SegFaultAX: callen: Otherwise they're identical to what you normally think of with Observers. And their interface is nearly identical to iterables.

16:27 laliluna: once cheshire.core is used

16:28 SegFaultAX: laliluna: Can you refheap the offending code and exception? It's hard to read in IRC.

16:29 jasonjckn: Does each var have it's own timeline in Rx?

16:29 how do you get a consistent view

16:29 in parallel environment

16:30 laliluna: https://www.refheap.com/paste/13903

16:30 callen: laliluna: first bit of advice, don't use midje.

16:31 SegFaultAX: callen: Aww, why? I like midje.

16:31 callen: SegFaultAX: I like things that work even more.

16:31 technomancy: because callen said so, obvs

16:31 (actually I agree in this case)

16:31 Raynes: callen: Works for me in laser.

16:31 *shrug*

16:32 I switched it to midje before everyone decided that it is the worst thing ever.

16:32 SegFaultAX: callen, technomancy: clojure.test users?

16:32 TimMc: Minus the bizarre stack traces, it works fine.

16:32 SegFaultAX: TimMc: Clojure isn't known for awesome stack traces as it is. But generally yea.

16:32 technomancy: SegFaultAX: 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:33 SegFaultAX: technomancy: Actually the only thing that drew me into midje was auto test in the repl. Is there something like that for clojure.test?

16:34 technomancy: if 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:34 SegFaultAX: sure; clojure-test-mode

16:34 trivial to wire into an after-save-hook in emacs

16:34 SegFaultAX: that's actually another gripe of mine though

16:34 jasonjckn: SegFaultAX: https://github.com/stuartsierra/lazytest

16:34 SegFaultAX: technomancy: Oh is that an emacs thing? I'm a vim user.

16:34 technomancy: why would the auto-runner be coupled to the test framework

16:34 that's just wrong

16:35 write 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:36 (personally I haven't done it because I just use the elisp equivalent)

16:37 n_b: SegFaultAX: You should be able to just have a BufWrite aucmd for test files

16:37 SegFaultAX: Sure, or use guard to watch the files.

16:37 How does one reload the entire project without having to restart the repl? I'm not too familiar with the nrepl internals.

16:38 And by not too familiar, I mean at all.

16:38 Glenjamin: there's lots that are based on running an executable, but i think doing it within the jvm would be tricky to generalise?

16:38 technomancy: SegFaultAX: require with :reload-all

16:38 Glenjamin: or not

16:38 technomancy: Glenjamin: I don't think so. with :eval-in :nrepl you could easily do it without starting up a new JVM

16:38 Glenjamin: speclj's auto-runner is pretty nice, manages to figure out the dependency chain and only re-run affected tests

16:38 SegFaultAX: technomancy: That won't reload the project.clj file will it?

16:39 laliluna: By the way, any idea why it is failing once I require chesier?

16:39 technomancy: SegFaultAX: no, changes to project.clj require a fresh repl

16:39 SegFaultAX: but that's already a given in the repl-based workflow

16:39 so nothing really changes there

16:39 SegFaultAX: technomancy: Just curious.

16:40 laliluna: This is the way, I refer to cheesier: (ns foo.bar (:require [cheshire.core :refer :all]))

16:40 SegFaultAX: Heh cheesier.

16:41 llasram: Took me a minute to parse that :-)

16:41 laliluna: The irc client has type incorrection

16:42 TimMc: That's for sure.

16:46 Foxboron: So, every time i try eval a record in emacs-live, everything freeze.

16:46 s/record/protocol

16:56 nz: so what is actually wrong with midje (other than it is not standard like clojure.test)?

16:56 trptcolin: technomancy: unless i'm misunderstanding, that's what speclj does: https://github.com/slagyr/fresh

16:57 technomancy: trptcolin: ten points to griffindor!

16:57 nice

16:58 I think it could be done as a leiningen task too, but I haven't considered the trade-offs between the two approaches

16:58 TimMc: ,(isa? 5 5)

16:58 clojurebot: true

16:58 trptcolin: it's pretty handy; we use it for the clojure koans as well

16:59 Raynes: nz: Well, admittedly it is a giant macrofest hack. But I'm fine with that for the most part.

16:59 trptcolin: [without actually using speclj]

16:59 TimMc: Has anyone seen Clojure's ad-hoc hierarchy system in use out in the wild? I'm curious what people use it for.

16:59 technomancy: trptcolin: will have to remember that for the next time someone says that's why they don't use clojure.test =)

17:00 TimMc: the only one I know of that does that is friend

17:00 amalloy: TimMc: we use it a little at geni

17:01 the 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:01 technomancy: how long does it take before the "geni in a bottle" jokes get old?

17:03 TimMc: amalloy: Interesting. That uses a custom hierarchy, not the global one, right?

17:03 amalloy: nah, i think we just pollute the global hierarchy with keywords like :geni.api/bird or something

17:06 TimMc: ,(isa? = 1 1)

17:06 clojurebot: true

17:06 TimMc: ,(isa? = 1 2)

17:06 clojurebot: #<NullPointerException java.lang.NullPointerException>

17:06 TimMc: bah :-P

17:07 I should have just left it at that.

17:07 technomancy: at least it didn't say true

17:08 SegFaultAX: Oh man, we just got a ping pong table in my office.

17:08 Goodbye productivity.

17:08 Foxboron: Trying again, having problems evaluating protocols in emacs-live, everything just freeze. Anyone able to point me int the right directions?

17:08 technomancy: Foxboron: 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:09 gtrak: SegFaultAX: happier devs means better code?

17:09 SegFaultAX: gtrak: That's the idea, I guess.

17:09 Foxboron: technomancy: 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:09 gtrak: I loved it when we had one, it made my life like 15% better

17:09 Apage43: Could be worse, we have a kegerator >.>

17:10 technomancy: Foxboron: you'd have to disable packages one by one till it quits breaking

17:10 but IIRC emacs-live doesn't even use proper packages, so I don't even know how you'd do that

17:10 SegFaultAX: Apage43: Yelp had awesome kegerators.

17:11 Foxboron: technomancy: maybe i should just backup everything and do it the normal way :/ Annoying tho.

17:12 stuartsierra: jasonjckn, 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:12 technomancy: Foxboron: 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:12 SegFaultAX: stuartsierra: So what are you doing now?

17:12 technomancy: (note that this is not an emacs-live vs starter-kit thing; the starter kit has all the same problems)

17:13 Raynes: technomancy: Emacs live is super weird.

17:13 stuartsierra: SegFaultAX: Simulant.

17:13 technomancy: Raynes: well that too

17:13 SegFaultAX: stuartsierra: How does that work?

17:13 technomancy: I mean the "not using package.el" thing is specific to emacs-live and a really annoying problem

17:13 Foxboron: technomancy: i'll follow it closly. Thanks.

17:13 andrew__: 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:14 stuartsierra: SegFaultAX: It's a totally different approach to testing. Not for everyone, but I like it.

17:14 Foxboron: Raynes: 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:14 stuartsierra: https://github.com/datomic/simulant

17:14 SegFaultAX: stuartsierra: Are simulations different from unit tests?

17:14 Raynes: I don't like solutions that are bizarre when you stop being a beginner.

17:14 I like things that just help you get going.

17:14 stuartsierra: SegFaultAX: very

17:15 hiredman: andrew__: serversocketchannel is an nio thing, which is java's async io framework, which is not what you want

17:15 technomancy: Raynes: that's why I want to switch gears to just documentation

17:15 stuartsierra: Simulation testing is a heavyweight approach to testing a whole system from the outside.

17:15 Raynes: technomancy: You're a good person.

17:15 Foxboron: I 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:15 technomancy: note that I haven't done it yet

17:15 hiredman: andrew__: serversocket has an accept method which blocks until a client connects, then returns a new socket you can get input and outpustreams from

17:15 stuartsierra: Foxboron: Yes, dev.clojure.org is still actively maintained.

17:16 Raynes: technomancy: You're a good person for wanting to do it.

17:16 andrew__: hiredman: I should've mentioned that, I'm trying not to use serversocket

17:16 hiredman: andrew__: clojure's *in* is for binding to streams

17:16 Foxboron: stuartsierra: you think anyone would mind if i add a few lines about my Clojure packages for ST2?

17:16 hiredman: clojure's reader reads from streams

17:16 stuartsierra: Foxboron: please do. There are "Getting Started" pages for each major editor / IDE.

17:16 SegFaultAX: stuartsierra: What do you like about it more than other more traditional styles of testing?

17:16 Foxboron: stuartsierra: i know, why i am asking ;)

17:17 hiredman: there are channel->stream adapters but you are biting off way more than you can chew

17:17 andrew__: hiredman: hmm, so it sounds like I'm trying to fit a square peg into a round hole

17:17 stuartsierra: SegFaultAX: Don't really have time to go into the details. Stuart Halloway has done some presentations on it.

17:17 SegFaultAX: stuartsierra: Ok I'll take a look. Thanks!

17:17 stuartsierra: np

17:21 Foxboron: stuartsierra: damn confusing site <.<

17:21 technomancy: Foxboron: clojure-doc.org has a lot better coverage of editor support

17:22 stuartsierra: Foxboron: dev.clojure.org suffers from serving multiple purposes: developer notes and user documentation.

17:22 Also, Confluence. :(

17:22 Foxboron: stuartsierra: trying to see if i can edit the "Gettign started with Sublime Text"....nope..

17:23 technomancy: "a lot better", ST isnt even mentioned as i can see :P

17:23 stuartsierra: Foxboron: I believe the editing rights are given automatically to signers of the Clojure Contributor Agreement.

17:24 technomancy: Foxboron: a lot better for most topics; a lot easier to improve anyway

17:24 Foxboron: technomancy: i'll take a look at it tomorrow. Wanted to make a quick edit at dev.clojure.org...

17:24 wasnt that quick

17:25 TimMc: stuartsierra: My apologies for denigrating clojure/data.json yesterday. I was either working off of old information or thinking of a different lib entirely. :-'

17:25 * :-/

17:26 andrew__: hiredman: by serversocket, did you mean the java ServerSocket class, or the server-socket library that used to be part of clojure.contrib?

17:26 stuartsierra: TimMc: Thanks you.

17:26 Foxboron: stuartsierra: i'll look into it. If anyone else can add them i got them on my github acc. Might be faster that way.

17:27 stuartsierra: TimMc: If I had a nickel for every ounce of grief I've gotten over that little JSON library, I could retire.

17:27 TimMc: That's like a metrix ton of grief.

17:28 *metric, I shouldn't be allowed near keyboards today (or yesterday, apparently)

17:30 stuartsierra: Oh, I'm curious; you have a private *escape-unicode* var -- is that intended to be public at some point?

17:30 (I was checking for correct behavior around U+2028 and U+2029.)

17:31 stuartsierra: TimMc: No, control is all through key/value options on the public API functions.

17:33 TimMc: Oy, that's what I get for not reading docstrings.

17:33 stuartsierra: :)

17:35 TimMc: stuartsierra: 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:36 stuartsierra: TimMc: yes

17:36 TimMc: And I know your policy on that.

17:37 stuartsierra: Well, the Clojure contrib policies trump mine in this case.

17:38 TimMc: Yes, but IIRC, you also explicitly reserve the right to rewrite patches to your liking. :-)

17:38 stuartsierra: Indeed. :)

17:40 andrew__: 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:44 mynomoto: How do I call (meta) on a namespace?

17:46 stuartsierra: ,(meta (the-ns 'clojure.core))

17:47 clojurebot: {:doc "Fundamental library of the Clojure language"}

17:47 Glenjamin: bah, why is there no with-err-str :(

17:47 mynomoto: stuartsierra: Thanks!

17:50 goza: hi, 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:51 lzm: hfaafb: you will be missed

17:51 arrdem: goza: so clojure.contrib.* is dead.

17:51 goza: https://github.com/clojure/math.combinatorics

17:52 goza: arrdem: yea, it's supposed to be under math.combinatorics now, but I can't find it

17:53 arrdem: ClassNotFound for both clojure.math.combinatorics and math.combinatorics

17:53 Glenjamin: is it possible to with-redefs a java function?

17:59 goza: ah, 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:05 joegallo: Glenjamin: no. write a function that calls the function. always use that. that can be with-redef'd.

18:05 s/that calls the function/that calls the method/

18:05 Glenjamin: yeah, just wrapped it - cheers

18:05 i hate testing randomness =/

18:06 UUID/randomUUID

18:06 joegallo: yeah

18:06 (defn random-uuid [] ...) ; awww yeahhhh

18:06 Glenjamin: mm

18:08 arrdem: goza: yep, check out technomancy's tool "lein" for dealing with all that.

18:15 llasram: I've just started telling people that the Clojure command-line tool is spelled "lein," for historical reasons

18:16 technomancy: llasram: close; it's actually for hysterical reasons

18:16 llasram: heh

18:16 technomancy: not to be confused with hysterical raisins

18:18 callen: llasram: you don't tell them it's named after the story?

18:25 Glenjamin: I've decided to write a tcl interpreter in clojure...

18:26 so i can name it tclj!

18:26 nightfly__: ticklojure

18:29 arrdem: Raynes: ^^

18:30 Raynes: arrdem: He's in DC, man. That's about as far away as you can get from me while still being in mainland USA.

18:31 arrdem: hum... so why does clojure.set not have a universal set..

18:31 bbloom: arrdem: the set of all objects including itself?

18:32 arrdem: bbloom: that's the one...

18:32 technomancy: (constantly true) <- that one?

18:32 arrdem: close enough.

18:32 hiredman: clojure.set is largely written in terms of seqs on sets

18:33 clojure.set is only suitable for dealing with set datastructures, not math sets

18:35 arrdem: ok. 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:35 looks like I'll just hack it tho.

18:53 pppaul: .set is nice

18:54 functions don't eat

18:54 they consume

19:17 aaelony: does anyone know the best place to ask incanter questions?

19:18 * gfredericks does a (defmacro if-try ...)

19:20 hiredman: try-let! let-try!

19:20 technomancy: there is no try. only do.

19:20 hiredman: ,(try not do)

19:20 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)>

19:20 hiredman: bah

19:21 technomancy: huh?

19:21 shouldn't that be "couldn't take the value of a macro"?

19:21 hiredman: do isn't a macro

19:21 gfredericks: hiredman: it doesn't surprise me that you've probably written this before :)

19:21 hiredman: no, I try-let and let-try are just things I bring up at work from time to time

19:22 given how often tryand let are combined

19:22 like my with-with macro, which I think I actually implemented at one point

19:22 gfredericks: this is for having result-handling code alongside error-handling code

19:22 technomancy: ruby's def has an implicit begin (their version of try)

19:22 gfredericks: where the result-handling code's exceptions are _not_ caught

19:23 technomancy: sometimes I feel like that would make me more likely to bother catching exceptions

19:23 if I didn't have to introduce another level of nesting to do it

19:23 hiredman: you would do (with-with [binding [...] with-connection connect] ...) and with-with would build (binding [...] (with-connection ..))

19:23 technomancy: you only need an explicit begin/rescue if you want to limit the scope of your handling to part of the function body

19:24 gfredericks: hiredman: one of the swiss arrows flattens out that pattern as well

19:42 pick: anymore familiar with monger?

19:43 *anyone

19:44 failing 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:45 amalloy: your program is AOT-compiled against clojure 1.5, but running on an older version, pick

19:45 gfredericks: hiredman: (if-try (compute) res (f1 res) Exception e (f2 e))

19:57 pick: amalloy: many thanks! sorting deps tree, blarg

20:00 Raynes: pick: lein clean

21:50 tieTYT: why 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:50 (str "Deleting: " (.getAbsolutePath f)))

21:55 holo: tieTYT, maybe you need to have same arity both in defmulti and defmethod

21:55 tieTYT: hrm

21:56 i thought I did have that

21:56 oh right

21:56 holo: in defmethod I see 2 inputs

21:56 tieTYT: ok so how do you deconstruct a list?

21:57 holo: [_ f] if you mean this, I guess it's alright. what I mean is inputs of defmulti is 1, and defmethod is 2

21:59 maybe you mean: (defmulti action-as-string (fn [[_ _] action] (nth action 0)))

22:00 tieTYT: you're right about my issue

22:00 but now I'm asking, how do you destructure a list?

22:03 holo: tieTYT. dunno. i usually just destructure vectors

22:03 tieTYT: yeah that's what I had to do

22:04 xeqi: &(let [[x y & more] (list 1 2 3 4 5 6)] {:x x :y y :more more})

22:04 lazybot: ⇒ {:x 1, :y 2, :more (3 4 5 6)}

22:04 tieTYT: ah so you just treat it like a vector

22:05 I feel like destructuring is pretty hard in the "making simple easy" sense

22:05 maybe it's because the jay fielding article only demonstrates it in let bindings which adds another layer of complexity

22:08 holo: tieTYT, what's the difference if you do it in let or input params?

22:09 tieTYT: in a let, you need an even number of arguments

22:10 so when you're trying to learn the destructuring syntax, the let syntax obscures the signal by adding noise

22:12 holo: tieTYT, 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:14 xeqi: well, you could write it ##((fn [[x y & more]] {:x x :y y :more more}) (list 1 2 3 4 5 6))

22:14 lazybot: ⇒ {:x 1, :y 2, :more (3 4 5 6)}

22:14 tieTYT: holo: just create a function and call it instead

22:37 murtaza52: I 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:43 amalloy: try (map list xs (rest xs)) and see if you can get anything interesting from that

22:49 murtaza52: amalloy : ah thats clever, really clever !

22:50 capcrunch: anyone uses clj-native ?

22:53 amalloy: ~anyone

22:53 clojurebot: anyone is anybody

22:54 amalloy: clojurebot: forget anyone |is| anybody

22:54 clojurebot: I forgot that anyone is anybody

22:54 amalloy: ~anyone

22:54 clojurebot: Just 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:55 capcrunch: so nobody uses clj-native ?

22:57 amalloy: evidently nobody who uses it is so excited about it that they answer questions like "does anyone use it" within four minutes, at least

23:05 capcrunch: amalloy ...

23:07 Raynes: I sure bet the guy who wrote it uses it.

23:07 Probably worth your chances emailing him or opening an issue on the github issue tracker or something.

23:10 capcrunch: Raynes , thanks ok , did you coded noir framework ?

23:13 xeqi: &(clojure.walk/postwalk #(if (vector? %) (remove nil? %) %) {:x [nil 1 2 3]})

23:13 lazybot: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry

23:14 xeqi: simplified example, but spot what I'm doing wrong?

23:14 *anyone spot

23:15 technomancy: using clojure.walk, which has been repeatedly disowned by its author? =)

23:16 xeqi: heh

23:16 I suppose that could be it

23:17 was hoping for an easy way to transform a map with values of vectors of maps with vectors of maps ... :/

23:17 technomancy: IIRC clojure.walk was only included in clojure because clojure.test uses it

23:17 xeqi: lame

23:18 akhudek: I should really get around to releasing the zipper based visitor library I have.

23:18 xeqi: *insert rage comic here*

23:26 amalloy: xeqi: what about an orgy of into/for?

23:27 technomancy: postwalk implies to me that you don't know all that much about the structure of the input

23:28 xeqi: amalloy: I'm headed down a multimethod path that looks that direction

23:29 amalloy: heh. postwalk docstring addendum: "only intended for transformations that would be impossible in a statically-typed language"

Logging service provided by n01se.net