#clojure log - Mar 07 2013

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

0:15 devn: Raynes: you got it babe.

0:25 yogthos: howdy

1:18 michaelr5251: I love Thursdays :)

1:20 jeremyheiler: Why is that?

1:21 michaelr5251: Because it's the last work day of the week (here in Israel)

1:21 jeremyheiler: ahihi, that would make Thursday's better.

1:21 Ah**

1:28 kencausey: michaelr5251: Do you start again on Sunday or Monday?

1:29 michaelr5251: Sunday

1:29 kencausey: OK, nice to learn new things about distant societies. Thanks!

1:30 michaelr5251: haha

4:08 ciphergoth: It seems weird that if I want a task to happen in a separate thread, I can just give it to an agent, but if the agent wants to try again in one second, I'm going to have to start worrying about Java thread pools. Am I looking at this wrongly?

4:09 mpenet: agents are about shared acces to some state, if doesn't really make sense to use it just to run a task in a separate thread, futures could be better for that

4:11 ciphergoth: agents are appealing because I can send a message to an agent saying "here, add this to the list of things you ask about when you poll"

4:11 mpenet: but anyway, they are backed by a cachedthreadpool so in theory you shouldn't have to worry about that

4:12 ciphergoth: OK

4:12 mpenet: and if you (really) need to take control of the underlying pool you can do it with send-via, if you are running 1.5

4:14 ciphergoth: I don't think I do need or want to take control of the underlying pool - that's what I was hoping to avoid!

4:14 You say "Supports :at-fixed-rate :with-fixed-delay :once, matching the corresponding Java methods." - I can't find what corresponds to :once, though I can guess what it means

4:14 it sounds like I can just use your library, and schedule the next poll with (schedule :once :with-fixed-delay 1000 #(send ...))

4:16 mpenet: this matches http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html

4:16 and you cannot combine :once :with-fixed-delay

4:17 ciphergoth: "once" doesn't appear on that page

4:17 OK

4:18 does "once" take a time to wait before executing?

4:19 mpenet: yes, you can pass :initial-delay, there's an example in the readme

4:19 ciphergoth: ah!

4:20 am looking at the source now, I see it

4:20 thank you!

4:20 mpenet: np

4:24 technomancy: since clojurescript-mode is deprecated, would it make sense to add cljs extension to auto-mode-alist on clojure-mode?

4:41 Foxboron: Basic question. I got a vec, i want a function to be used on all the items in the vec. I have tried for and map, but still dosnt work.

4:45 mpenet: ,(map inc [1 2 3])

4:45 clojurebot: (2 3 4)

4:45 mpenet: ,(mapv inc [1 2 3])

4:45 clojurebot: [2 3 4]

4:46 mpenet: Foxboron: maybe you are being tricked by lazyness

4:48 Foxboron: hmm

4:49 mpenet: well basically, i got this IRC bot i want to join several chans. So i got a vec of chans.

4:49 It dosnt even seem to execute the function itself.

4:49 mpenet: you are using map for side effect in other words

4:50 either you wrap it with doall, or better use doseq

4:50 Foxboron: ahh doseq.

4:50 awsome, thanks :)

4:52 mpenet: awsome, it works :D

4:58 mpfundstein: whats the newest clojure.contrib version?

4:59 vijaykiran: mpfundstein: there's no clojure.contrib anymore - http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

5:00 mpfundstein: ah ok

5:01 so command-line-arguments is now included in clojure?

5:01 mpenet: it's in tools.cli now

5:26 corecode: hi

5:26 i'm working through the 4clojure excercises

5:26 and i wonder how to implement an efficient fib sequence

5:27 that whole recursive call thing is compact but also has a terrible complexity

5:28 ideally i'd like to use lazy-cons, but i don't know exactly how to

5:31 leku: corecode: good questiosn I think, maybne just bad timing

5:31 it is 4:32 AM here in the US of A

5:32 corecode: no european cljers?

5:32 noidi: corecode, do you want the answer or just a hint? :)

5:32 corecode: so my hunch is that i have to carry along the 2 last fib numbers

5:33 so that i can grow the sequence

5:33 noidi: yes

5:33 corecode: aha

5:33 see i watched an outdated talk

5:33 where rest still returned nil, and lazy-cons existed

5:33 noidi: and the sequence is infinite, so it has to be lazy. hence, wrap it in (lazy-seq ...)

5:33 and prepend to it using cons

5:52 corecode: hm

5:52 (take 4 (fn fib [] (cons 1 (cons 1 (lazy-seq (map + (fib) (rest (fib))))))))

5:52 this doesn't work

5:53 Foxboron: corecode: loop & recur?

5:54 corecode: i'll try that

5:55 noidi: no, recur is strict

5:55 corecode: noidi: you mean loop is?

5:55 noidi: you can use recur without loop :)

5:55 corecode: yes

5:55 i saw the definition of filter

5:56 noidi: corecode, write a (defn fibs [a b] (lazy-seq ...)) that returns a lazy sequence of all the fibonacci numbers starting with a and b

5:57 hmm, it's hard to give hints without giving the full solution :)

6:00 note that in order to be lazy, you must only prepend one concrete result to a lazy sequence that contains the rest of the items

6:00 corecode: right

6:00 i get an obscure error message

6:00 noidi: welcome to clojure :P

6:00 corecode: IllegalArgumentException Don't know how to create ISeq from: java.lang.Long clojure.lang.RT.seqFrom (RT.java:505)

6:01 noidi: I'd guess you're trying to cons to a number

6:01 ,(cons 1 2)

6:01 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

6:02 corecode: aha!

6:02 forgot my actual call

6:02 very nice

6:03 (take 10 ((fn fib ([] (cons 1 (fib 0 1))) ([a b] (cons (+ a b) (lazy-seq (fib b (+ a b))))))))

6:03 yey

6:04 noidi: great :)

6:05 Foxboron: i always struggle with Fib :c. IRC Bot sockets etc? No problem. Pritning 1 1 2 3 5 etc....nope

6:06 noidi: here's what I came up with initially

6:06 (defn fibs ([] (fibs 0 1)) ([a b] (lazy-seq (cons a (fibs b (+ a b))))))

6:07 Ember-: sniff... beautiful

6:07 corecode: aha

6:07 Ember-: :)

6:07 corecode: yes

6:07 better

6:18 huh? why is

6:19 ,(reduce #'and '(false false))

6:19 clojurebot: true

6:19 corecode: oO

6:23 edoloughlin: Anyone using clojure.data.xml? Should this be possible?

6:23 reply.eval-modes.nrepl=> (use 'clojure.data.xml)

6:23 nil

6:23 user=> (emit-str (element :something {} false))

6:23 IllegalArgumentException No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: java.lang.Boolean clojure.core/-cache-protocol-fn (core_deftype.clj:541)

6:44 noidi: corecode, with #' you're getting hold of the function that implements the macro. the fact that macros are implemented as functions is an implementation detail which you shouldn't rely on

6:45 corecode: that's no good

6:45 that means i need to know what is a macro and what is a function

6:46 noidi: the macro functions take two arguments before the "real" macro arguments, so the result you're getting is the macroexpansion for `and` called without arguments

6:46 ,(macroexpand-1 '(and))

6:46 clojurebot: true

6:46 noidi: yes, you need to know the difference, but Clojure helps you there

6:46 ,and

6:46 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0:0)>

6:47 noidi: you've gone around that check by using #' to get hold of the var holding the macro function

6:47 but you'd get that error if you tried to call (reduce and ...)

6:48 the proper way to write that reduce would be (reduce #(and %1 %2) ...)

6:58 tsdh: How do you natives say to (map f coll)? f is mapped through the elements of coll?

7:00 ciphergoth: (zipmap (vals map) (keys map))

7:03 noidi: tsdh, I'm not a native English speaker, but I think "f is mapped over ..." is a valid way to put it

7:04 google seems to agree :) https://www.google.fi/search?q=functional+programming+"is+mapped+over"

7:04 tsdh: noidi: Ok, thanks.

7:06 noidi: Ah, it seems one says "f is mapped over coll", or "coll is mapped through f".

7:12 AWizzArd: Is there a better way to consume a PushbackReader stream of Clojure objects? (take-while identity (repeatedly #(read pbr false false)))

8:01 ciphergoth: I'm pretty sure this line is being executed, but trigger-poll isn't being called: (knit/schedule :once :initial-delay 2 trigger-poll)

8:01 am I missing some kind of setup that makes this work?

8:13 tomoj: should there be (defmacro as->> [name & forms+expr]) ?

8:14 ciphergoth: Is there a better way to do (apply dissoc map keylist)

8:21 Kowboy: cemerick, does CCW have support for ctrl+click navigation to function definitions?

8:21 cemerick: Kowboy: yup

8:21 cmd + click on OS X FWIW

8:21 Kowboy: can you think of a reason it wouldn't be working?

8:22 cemerick: Kowboy: do you have a REPL open for the project in question, with your code loaded therein?

8:22 Kowboy: at the moment, no

8:22 cemerick: Do so, and you'll have code completion, go-to-definition, etc

8:23 Kowboy: interesting

8:23 so, the project I am working on loads some namespaces at runtime

8:24 based on configuration

8:24 so I don't get go-to-def functionality on those

8:24 unless I load them in the repl

8:25 mrb_bk: good morning #clojure

8:26 cemerick: Kowboy: right; introspection only ever works if you have a running environment

8:32 Kowboy: is there documentation on the supported features of CCW's paredit mode?

8:33 dan_b: argh classpath. or jni search path, if that's a thing

8:37 clgv: does someone know how to modify the theme of rainbow-delimiters in emacs?

9:21 devn: clgv: (omg (this (looks (like (a (clown car))))))

9:22 clgv: devn: lol. wrong order of the sentence with respect to execution order ;)

9:22 devn: I hardly see the color distinction with the default fonts...

9:27 Icarot: Guys, I am a terrible programmer.

9:28 Kowboy: can we blame it on Perl?

9:29 Icarot: And for some reason, I cannot for the life of me even formalize in psuedocode how to track the frequency of hours, given some data.

9:29 e.g., (1, 12, 30, 13, 14) -> Array[2]

9:30 I feel like I'm trying to implement a kth largest element selection algorithm.

9:30 except, somewhere along the line, I forgot that I'm an idiot.

9:37 ciphergoth: is there something like ring.mock.request for multipart params?

9:42 grc: macro and meta data problem: I wish to use a macro to define a function with meta-data which is passed as an argument to the macro.

9:42 (defmacro foo [a] `defn ^#{:bar ~a} baz [] 42)

9:43 But this is rejected with (defmacro foo [a] `defn ^#{:bar ~a} baz [] 42)

9:43 or rather java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map

9:43 Any suggestions on how to get tehre?

10:07 llasram: grc: Well, you have several problems there

10:08 grc: somehow I'm not surprised! Up for education though

10:08 llasram: ^

10:08 llasram: First: ##(quote '(`defn baz [] 42))

10:08 lazybot: ⇒ (quote ((quote clojure.core/defn) baz [] 42))

10:09 llasram: The body of your macro consists of the single syntax-quoted form `defn followed by a bunch of un-quoted things

10:09 First: ##(`defn baz [] 42)

10:09 lazybot: java.lang.RuntimeException: Unable to resolve symbol: baz in this context

10:10 llasram: Er, didn't mean to re-say "First", but you get the picture

10:10 Second, the ^{} reader metadata notation is just that -- *reader* metadata. It puts metadata on the forms being read

10:10 &(meta (^:example 'x))

10:10 lazybot: clojure.lang.ArityException: Wrong number of args (0) passed to: Symbol

10:11 llasram: &(meta ^:example 'x)

10:11 lazybot: ⇒ nil

10:11 llasram: &(macroexpand `(meta (^:example 'x)))

10:11 lazybot: ⇒ (clojure.core/meta ((quote clojure.core/x)))

10:11 llasram: &(macroexpand `(meta ^:example 'x))

10:11 lazybot: ⇒ (clojure.core/meta (quote clojure.core/x))

10:12 llasram: I keep trying to use paredit in the ERC buffer... apparently need more coffee :-)

10:12 grc: First one was a poor truncation of my actual problem: I'm passing in baz to the macro and teh body reads (defn ~baz ....)

10:13 llasram: Ok

10:14 clgv: grc: if you want help with a macro always show the intended macro call syntax and the expansion you want to create...

10:14 llasram: So skipping along -- because the reader metadata syntax is in fact reader syntax, it applies immediately to forms as they are read

10:14 grc: OK I think I've grokked the reader aspect. For now. So how do I apply meta data to the function I'm defining in the body of teh macro? Is taht through use of (meta ...)

10:14 sorry cross-typing

10:15 llasram: np

10:15 clgv: grc: use `with-meta` on the symbol

10:15 llasram: You need to porgrammatically generate the metadata with ^^ clgv with-meta, or vary-meta

10:17 &(let [a 'foo, b `~(vary-meta a assoc :example true)] [b (meta b)])

10:17 lazybot: ⇒ [foo {:example true}]

10:17 grc: llasram, clgv: whenever I play with macros I seem to get lost in a twisty maze of indirection. I'll go and hack some code, but first and more importantly, think this through properly. Thanks fo ryour help

10:18 llasram: good luck!

10:19 * grc crosses fingers

10:20 solussd: what's a good way to enforce a protocol's contract when implemented? e.g. if I define a protocol with a function that must return a string, how can I enforce that someone implementing the protocol uses a function that returns a string?

10:21 in other words, how can I put pre/post conditions on the protocol function declarations?

10:21 llasram: solussd: Does it work to just put the pre/post condition metadata on the protocol function declaration? I know it works with other standard var metadata like :private

10:21 solussd: it does not. :(

10:22 it is ignored

10:22 llasram: solussd: Aww. Well, I guess create a private protocol and expose public wrapper functions with the conditions?

10:25 solussd: you mean: the protocol could declare a private fucntion, e.g. -protofunc that calls a public function, protofunc which the user of the protocol implements?

10:25 that was suggested before, I just forgot the details. thanks

10:34 Anderkent: Anyone know why midje might fail to intercept a call to a public function? i.e. (fact <testcode> (provided (a/func anything) => ...result)) , and a/func is called from the testcode.

10:34 It uses the real implementation in and complains that the prerequisite function is never called

10:39 clgv: Anderkent: you will have to post more context.

10:39 Anderkent: figured it out - apparently provided only applies to the latest arrow, not the entire fact

10:39 i.e. (fact (foobar 1) => 1 (foobar 2) => 2 (provided (foobar [x] 2))) can succeed

10:40 rather unintuitive, but well

10:40 danneu: in an OOP language, if you create an array of Tweet objects (with Tweet#text and Tweet#username), is the surrogate for that in clojure a list of {:username _, :text _} hashmaps?

10:42 clgv: danneu: yes

10:42 dan_b: that would certainly be one way to model it

10:42 depends what questions you want to ask about that data, i guess

10:43 clgv: danneu: it is the most general way. in special cases you would need defrecords or deftypes if you really need those

10:47 danneu: clgv: thanks. just read about those on the clojure website. i like it

10:49 S11001001: danneu: careful; defrecord/deftype are great ways to overdesign

10:49 clgv: danneu: just start with the maps^^

10:51 danneu: cool. i've been rewriting Ruby to Clojure and have been using hashmaps.

10:52 kittylyst: Am still getting my sea-legs back after an absence. I wrote this to exclude any user with a freeware address (freemail domain held in list) from a list of users:

10:52 (mapcat (fn [domain] (filter #(re-matches (re-pattern (str ".*" domain ".*")) (:email %)) users)) freemail)

10:52 It's obviously inefficient, not that it matters for the list sizes

10:52 Suggestions for a more idiomatic / cleaner solution?

10:53 danneu: My biggest learning obstacle is how to organize my Clojure code that was once organized into succinct Ruby classes.

10:54 kittylyst: Whoops, actually that code returns all the freemail users. C&P wrong code - but basic question stands

10:56 Foxboron: danneu: i was told this. 1 file for one purpose, and namespaces should give you the general idea.

10:56 borkdude: would anyone know why (ref:someid) doesn't work in some clojure code block in org-mode when exported to html?

10:57 it does when I put it on its own commented line: ;;(ref:someid)

11:07 danneu: Wow, LightTable is amazing

11:08 Ember-: not ready, but promising, yes

11:09 danneu: Better than my Vim workflow for Clojure

11:09 At least*

11:09 Anderkent: you don't have a very good vim workflow for clojure then, I guess? :P

11:10 danneu: Anderkent: right. it's hard to arrive at a workflow when im still new to clojure though

11:10 Foxboron: I am using Emacs....but really not THAT happy. Anyoen tried Emacs and VIM with Clojure?

11:11 danneu: and?

11:11 kittylyst: danneu: I am using Emacs on a Mac & am very happy

11:11 Anderkent: fair enough. I find vim-foreplay and a backgrounded repl work nice (though because of YouCompleteMe if I don't have a repl open opening a file takes a while as it times out while connecting - need to get that fixed)

11:11 danneu: I didn't mean to suggest that anyone was unhappy with their setup! I just meant to express some love for LightTable

11:12 pimeys: I found it pretty horrible at this point

11:12 but 15 years of history with vim and now using emacs, I kind of find every other editor pretty horrible

11:13 danneu: pimeys: yeah i guess it's just the simple point of clojure (and jvm build step) being new enough to me to where using a ide at the beginning is more convenient than the convience of editing code with vim

11:13 pimeys: what's the difference between an ide and emacs/vim :)

11:13 less menus?

11:13 no, emacs has menus

11:13 ok, setting them up requires some patience

11:14 arrdem: plugin systems that don't suck?

11:14 danneu: hey now, vim with vundle is nice!

11:14 pimeys: very

11:14 mpfundstein: Foxboron: i do all coding in vim

11:14 pimeys: and emacs with elpa

11:14 mpfundstein: Foxboron: fastest environment for editing code

11:15 Foxboron: mpfundstein: well, i was more after someone who have used both heavily and can elaborate on what they think

11:15 pimeys: vim command mode must be the best way to edit anything

11:15 Foxboron: mpfundstein: "fastest enviorment" is a relativ term for the person

11:15 danneu: by ide i guess i mean software that tends to handle build steps for you and integrate with them. like showing you eval'd output next to the code.

11:15 clgv: danneu: you can try counterclockwise as well ;)

11:15 Anderkent: clgv: not until slurp and barf are in :P

11:15 pimeys: danneu: so, emacs is an ide :)

11:15 clgv: Anderkent: your choice ;)

11:16 emacs is an operating system :P

11:16 Foxboron: hahaha

11:16 with a bad text editor

11:16 pimeys: and a potato

11:16 Foxboron: with evil mode, it's pretty good

11:16 and all those evil plugins

11:16 Anderkent: I use vim, actually :P having to toggle paredit to fix every single mistake in counterclockwise is just too much pain for me

11:16 nDuff: danneu: Personally, LightTable is great for exploration, but I find myself using emacs+nrepl for interactive evaluation when doing real work.

11:16 Foxboron: pimeys: i know, i use evil mode. Just gotta learn the vim keybinds better

11:16 nDuff: Anderkent: that's only the case because CCW's paredit is underpowered.

11:17 pimeys: I cannot use emacs without it

11:17 but everything else in emacs is better than in vim

11:17 nDuff: Anderkent: ...full emacs paredit you don't _need_ to disable to fix mistakes.

11:17 pimeys: vim has a better editor

11:17 clgv: Anderkent: "toggle paredit to fix ..." care to explain what you mean exactly?

11:17 danneu: nDuff: cool, that's what i was trying to say

11:17 arkx: Again this discussion… :)

11:17 Anderkent: nDuff: yes, that's why I said I need slurp/barf

11:17 nDuff: Anderkent: *nod*.

11:18 Anderkent: clgv: say I want to do ((function arg1 arg2) arg3) but type ((function arg1) arg2 arg3)

11:18 to fix it in counterclockwise I have to disable paredit and move the paren by hand

11:18 in vim i just go to the paren and press ,>

11:19 clgv: Anderkent: laurent mentioned that the underlying lib for paredit got more functionality lately. so the missing parts will be there soon^^

11:21 Anderkent: yeah, I have the issue starred :) Once it's in I might switch to ccw just for the debugging support

11:26 corecode: what's counterclockwise?

11:26 nDuff: corecode: Clojure plug-in for a Java IDE; I don't offhand recall which one.

11:26 corecode: ah

11:27 nDuff: Anderkent: With respect to debugging support, I'm hoping to see ritz merged into emacs-live soon.

11:27 corecode: nm then

11:29 clgv: eclipse ;)

11:36 gfredericks: derefing a private atom: @@#'foo.bar/baz

11:36 pjstadig: gfredericks: you should be ashamed

11:37 nDuff: That's... actually a lot less ugly than how I'm getting into clojure.data.xml's privates.

11:37 Anderkent: also a lot nicer than how I'm changing the set of currently loaded namespace in clojure.core ...

11:37 pjstadig: of course i should talk https://github.com/pjstadig/nio/blob/master/src/nio/core.clj#L48

11:38 Anderkent: https://github.com/lshift/cloverage/blob/master/cloverage/src/cloverage/coverage.clj#L103

11:38 are we bringing out the dirt? :P

11:39 (I know I should be doing it via #' probably, but at the time it was an improvement over (in-ns 'clojure.core) (apply ...) (in-ns orig-ns) :D

11:39 * nDuff was directly calling clojure.lang.RT/var

11:39 nDuff: ...had forgotten about #', which is considerably the saner approach.

11:40 (convincing relevant folks to expose the function, of course, being ideal, _but_).

11:40 Anderkent: but indeed

11:52 gfredericks: in this case I am the relevant folk.

11:52 I tend to privatize things even when their publicity makes testing easier

11:52 corecode: is there a way to revert (use)?

11:52 clgv: let's really free those functions in these open source projects by declaring them public ;)

11:53 there was a call for that for java open source projects ;)

11:53 nDuff: gfredericks: ...the relevant folk for clojure.data.xml, you mean?

11:53 clgv: corecode: only for the mapping part

11:54 nDuff: gfredericks: ...because if so, yes, I'd welcome an opportunity to lobby for making pull-seq public

11:54 clgv: corecode: ns-unmap

11:54 * nDuff _does_ understand why it's private -- can't guarantee the flags it's constructed with otherwise -- but sometimes the public interfaces just don't work

11:55 nDuff: (as is the case when trying to handle results from javax.xml.xquery)

11:55 corecode: clgv: what does that mean, for the mapping part?

11:55 clgv: (use 'clojure.string) overwrote my 'reverse

11:55 :/

11:55 clgv: corecode: without classloader artistic you can not undo that the namespace was loaded

11:55 corecode: (in the repl)

11:56 clgv: corecode: the lesson here is to use (require '[clojure.string :as str]) and using e.g. (str/join ...)

11:56 corecode: :)

11:57 yea, i'm still struggling with use, require, import

11:59 llasram: corecode: You can ignore `use` for new >=1.4 code

11:59 corecode: okay

12:00 llasram: (:use [some.namespace :only [foo]]) <-> (:require [some.namespace :refer [foo]])

12:01 papachan: weird

12:01 i have a Exception in thread "main" java.lang.ExceptionInInitializerError

12:01 clgv: llasram: `use` is not deprecated in the docs though. is the intention to get rid of `use`?

12:01 papachan: when i launch today clojure

12:02 llasram: clgv: My understanding is that it's kind of "unofficially deprecated". Not sure why not officially, since `require` now can do everything `use` does

12:03 papachan: nothing say. it working fine now

12:04 gfredericks: nDuff: not clojure.data.xml, just my own code

12:05 don't futures run in a fixed-size thread pool? How does that interact with IO-bound futures?

12:06 technomancy: IIRC they use the send-off pool

12:06 gfredericks: I create 300 futures with a Thread/sleep in them, and apparently they all are running in parallel

12:06 llasram: gfredericks: Yeah, futures use the Agent/soloExecutor pool, which unbounded

12:07 gfredericks: ah ha

12:07 so if I want a bounded number of jobs running at one time, I need a different mechanism

12:07 llasram: send-via!

12:07 Well, or just a queue

12:13 jcidaho`: Hi - anyone got any elisp using nrepl for loading a default ns when nrepl loads in a project - I know this question has been asked a few times. I've got some for if the user has the project.clj open, but if any file in the directory tree for that project is open it's proving very tricky

12:14 technomancy: jcidaho`: I think there's an open pull request for that in nrepl.el that hasn't been applied yet

12:15 jcidaho`: Does it work :-) I'll try it

12:15 borkdude: what's the difference between require with no options such as :as and load?

12:16 gfredericks: borkdude: require will only load once

12:17 borkdude: I wondered why this file contains load statements: https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint.clj

12:17 technomancy: load lets you do terrible things with namespaces

12:18 llasram: Well, I wouldn't say "terrible." It lets you divide a single namespace into multiple files.

12:18 Anderkent: borkdude: because load doesnt enforce the other file to have its own namespace

12:21 technomancy: load is only suitable for development tools to use; you shouldn't use it in actual code

12:21 Anderkent: I guess the drawback is it's hard for a person to find the source for a function by hand

12:21 (a tool obviously can just load the ns and look at the metadata of the function to locate it)

12:21 tgoossens: how can i load a jar file for use in repl?

12:21 llasram: technomancy: Why so?

12:21 Anderkent: tgoossens: after starting the repl or before?

12:22 tgoossens: preferably after ?

12:22 llasram: It seems like otherwise people go through weird contortions to define vars in implementation namespace then expose them in API namespaces

12:22 technomancy: llasram: because you are not a unique snowflake; you can follow the rules for namespaces like everyone else =)

12:22 Anderkent: tgoossens: you can use clojure.core/add-classpath , though it seems it was deprecated

12:22 not sure what the suggested alternative is

12:23 jballanc: ,(when-let [foo (:bar {:bar nil})] (println "This makes sense"))

12:23 clojurebot: nil

12:23 llasram: tgoossens, Anderkent: you can use pomegranate to add arbitrary deps via aether dependency resolution

12:23 jballanc: ,(when-let [{:keys foo} {:bar nil}] (println "This seems like a bug"))

12:23 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>

12:23 jballanc: whoops...meant this

12:23 ,(when-let [{:keys [foo]} {:bar nil}] (println "This seems like a bug"))

12:23 clojurebot: This seems like a bug\n

12:23 jballanc: ^^^ any reason why ":keys" destructuring does that?

12:24 llasram: technomancy: I honestly haven't had a big need for it in my code, but having some mechanism for implementation/interface separation seems sensible, and `load` seems to be the closest the stdlib gets

12:24 Anderkent: technomancy: uh any actual examples of how it's bad? I.e. what intuition about namespaces does it break for you?

12:25 technomancy: Anderkent: for starters, it leads to files that don't have ns forms in them

12:25 llasram: jballanc: when-let just checks to ensure that the expression is non-nil, and `{:bar nil}` is definitely non-nil. It can't check that each of your destructured things is non-nil without essentially re-implementing destructuring

12:25 Anderkent: sure, but these files are not exposed, so consumers of the lib don't care?

12:26 technomancy: Anderkent: regularity makes for fewer surprises in tooling

12:26 using load is like using resolve; it's a sign that you're getting clever and whatever you're doing will confuse automated tools

12:27 llasram: it doesn't really help with implementation/interface separation since all the implementation stuff still lives in the same namespace

12:27 so someone browsing via ns-map will still see it

12:28 llasram: technomancy: I was just thinking that... Good point

12:28 jballanc: llasram: ok, yeah...that makes sense

12:28 Anderkent: isn't that ns-map's fault for showing private members by default?

12:30 I mean it seems to me that since any tool can find the file a particular symbol was defined in no matter if it's required or loaded this isn't really that bad

12:30 technomancy: Anderkent: depends on what you want. you can use ns-publics for that case. but my point is that public/private is how you address hiding; putting it in separate files doesn't help.

12:30 hiredman: and hiding is dumb

12:31 don't do it

12:31 technomancy: if I were reading through code and wondering what namespaces it required, I would be really annoyed if I couldn't just go to the top of the file to find it

12:31 hiredman: I say this as someone staring at the stuff I need in the guts of javamail, and I have to use reflection to get it

12:35 corecode: clojure makes my head pop

12:37 solussd: erm.. when did clojure.core/protocol? become private?

12:38 ..and why?

12:49 pjstadig: hiredman: "and hiding is dumb" you say that now, but when they are banging down your door...you'll hide

12:55 technomancy: heh

13:01 tgoossens: with paredit ((xx)) -> (xx) . I'm unable to do it so far :p

13:01 technomancy: tgoossens: M-s

13:01 tgoossens: let my try that :)

13:02 ed_g: tgoossens, another way is kill the (xx) and yank it somewhere else, then you can erase the emtpy ()'s

13:02 tgoossens: pfft :p

13:03 solussd: how can I tell if something is a protocol now that I don't have the "protocol?" function?

13:03 borkdude: tgoossens I defined this in a script which I load for every repl I spin up: https://www.refheap.com/paste/12229

13:03 tgoossens so I can load in dependencies afterwards, if I need them

13:04 tgoossens: mmyes

13:04 thanks

13:04 llasram: solussd: When do you need to test if something is a protocol? In ClojureScript protocols aren't even reified -- there's nothing to call a `protocol?` function on

13:10 tgoossens: interesting

13:11 (using leiningen resource paths) i import classes from a jar into my mainspace

13:11 for some classes I finds a class , for others classdefnotdound

13:29 fbernier: how could I pass what's inside a vector as arguments to recur ?

13:31 since apply recur seems invalid

13:31 llasram: fbernier: Manual unpacking, I'm afraid. Or alter your interface so you're `recur`ing on a vector

13:32 technomancy: recur is weird since it's not technically a new function invocation

13:32 it doesn't even re-apply destructuring, which is really surprising to most people

13:36 fbernier: I see

13:36 thanks

13:37 I was trying to remove the loop from my 4clojure solution since I realized you can recur on functions

13:37 but I think It's better to leave it there in this case

13:44 jweiss: is there a way to compose this with comp and/or partial - (fn [x & args] (apply hash-set x args))

13:46 Anderkent: technomancy: how do you mean it doesnt apply destructuring?

13:46 ,((fn [[head & rest]] (prn head) (when rest (recur rest))) [1 2 3 4])

13:46 clojurebot: 1\n2\n3\n4\n

13:46 Anderkent: that seems to destructure it fine?

13:46 borkdude: jweiss ((partial hash-set 1) 2 3) ?

13:49 technomancy: Anderkent: sorry, I meant rest args

13:49 ,((fn [head & rest] (prn head) (when rest (recur rest))) 1 2 3 4)

13:49 clojurebot: #<CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 2 args, got: 1, compiling:(NO_SOURCE_PATH:0:0)>

13:49 Anderkent: right, ok

13:50 technomancy: ,((fn f [head & rest] (prn head) (when rest (f rest))) 1 2 3 4) ; whereas re-invoking f works fine

13:50 clojurebot: 1\n(2 3 4)\n

13:51 technomancy: eh; I guess you'd need to apply there. anyway, it's unexpected

13:52 hiredman: yeah, varargs in fns don't really mesh with destructuring, even though the syntax is the same

13:54 gfredericks: if I don't shutdown a thread pool, but I lose refs to it and it runs out of jobs, will it be GC'd? or is shutdown important?

13:55 pjstadig: gfredericks: YOU'RE BONED!

13:55 gfredericks: O_O

13:55 pjstadig: just kidding, i don't really know

13:55 i'm not a clojure programmer, i just play one on tv

13:55 technomancy: you can't shut down your computer anymore

13:55 gfredericks: oh pjstadig. always yelling at people that they're boned.

13:55 technomancy: those threads will just run to the heat death of the universe, sorry

13:55 hiredman: http://stackoverflow.com/questions/7728102/why-doesnt-this-thread-pool-get-garbage-collected

13:56 gfredericks: hiredman: thanks! Now I am no longer boned.

14:09 ghadishayban: I wish there was a most remote REPL award, because only today, I'd win it

14:09 tgoossens: if (ns :import [pgx.blablah ClassName]) gives NO compile error. But (ClassName. xxxx) throws a classdefnotfound. Then what might be wrong?

14:10 ghadishayban: I'm sitting in north Lebanon (http://goo.gl/maps/mClpg) sipping packets off a wireless mesh network connecting the hilltops

14:10 at a breezy 15KB/s

14:11 wish I could nREPL everyone in

14:16 tgoossens: i think i know what you mean, but that ns form should give you a compile error. can you paste specifics into refheap?

14:16 tgoossens: sure

14:16 interesting. (new to emacs) how do i copy from emacs to another app? :p

14:17 ghadishayban: highlight and then Meta-W should do it (i'm new too)

14:17 technomancy: tgoossens: depends on the OS

14:18 tgoossens: hmm (linux)

14:18 technomancy: the correct answer is that if you do everything in Emacs, you don't ever have to

14:18 tgoossens: tsssk :p

14:18 llasram: heh

14:18 chronno: ha

14:19 tgoossens: M-W does the trick

14:19 ghadishayban: sudo technomancy

14:19 tgoossens: https://www.refheap.com/paste/12234

14:19 ghadishayban: errgh su

14:19 tgoossens: ghadishayban: https://www.refheap.com/paste/12234

14:19 llasram: tgoossens: If you enable cua-mode, you can just use ctrl-{x,c,v}

14:20 tgoossens: llasrm: interesting

14:20 technomancy: cua-mode has composability issues

14:20 llasram: I don't do it myself, but it might be an easier path to having the same bindings in emacs as in your other apps

14:20 technomancy: I thought they'd ironed most of those out?

14:21 chronno: as technomancy said, if you were trying to copy something to paste it in refheap, you don't have to leave emacs: https://github.com/Raynes/refheap.el/blob/master/refheap.el

14:21 ghadishayban: tgoossens: your threading form is the culprit,

14:21 technomancy: llasram: there are workarounds, but it's not the kind of problem you can just solve

14:21 tgoossens: interesting

14:21 how come?

14:21 ghadishayban: make sure you do (-> (Constructor.) ... blah)

14:21 tgoossens: aha

14:21 of course

14:21 stupid me

14:22 yeah it works now :)

14:23 ghadishayban: the threading form needs something tangible to "carry" through the form

14:24 tgoossens: you are completely right. many thanks

14:24 jweiss: borkdude: ##((partial hash-set) nil 2 3)

14:24 lazybot: clojure.lang.ArityException: Wrong number of args (1) passed to: core$partial

14:25 jweiss: borkdude: i'm trying to create the function before x and args are known

14:25 borkdude: ,((partial hash-set 1) 2 3)

14:25 clojurebot: #{1 2 3}

14:25 jweiss: so you are including x in the partial

14:26 borkdude: ,(fn [x & args] (apply hash-set x args)) ;; why no good?

14:26 clojurebot: #<sandbox$eval69$fn__70 sandbox$eval69$fn__70@f7d693>

14:26 asteve: ain't no party like a clojure party because a clojure party causes you to determine how many parenthesis!

14:26 jweiss: borkdude: it's fine, just asking if there was another way

14:26 the general problem is i want to update a value to add to a hash-set, but the value might start off as nil

14:27 rabbit_airstrike: so I inherited this big clojure project, and just stumbled across a 75 line defn with 17 optional args

14:27 borkdude: jweiss there are dozens of other ways, but this is the most obvious one. but hash-set already accepts the same arguments

14:27 jweiss: so i wanted a function that always returns a hash-set. conj will assume nil is a list

14:27 rabbit_airstrike: I feel ill just looking at it

14:27 borkdude: jweiss this sounds like into?

14:28 jweiss or remove the nils?

14:28 jweiss: ,(apply into #{} nil #{2 3})

14:28 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core$into>

14:28 borkdude: ,(hash-set nil 1 2 3)

14:28 clojurebot: #{nil 1 2 3}

14:28 jweiss: ,(into #{} nil #{2 3})

14:28 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$into>

14:28 borkdude: ,(doc into)

14:28 clojurebot: "([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."

14:29 borkdude: ,(into #{} nil)

14:29 clojurebot: #{}

14:29 jweiss: ,((comp conj (partial into #{}) nil 1)

14:29 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

14:29 technomancy: I wonder why compojure's site handler doesn't use wrap-file-info

14:29 jweiss: ,((comp conj (partial into #{})) nil 1)

14:29 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$into>

14:29 jweiss: bah

14:33 borkdude: jweiss:

14:33 ,(reduce #(if (nil? %2) %1 (conj %1 %2)) #{} [nil 1 2 3]) ?

14:33 clojurebot: #{1 2 3}

14:34 jweiss: I really just want conj, except i want the final value to be a hash-set even if the inital list is nil

14:34 but yeah that's pretty much what you wrote :)

14:35 gfredericks: (fnil conj #{})

14:35 borkdude: ,(apply hash-set (remove nil? [nil 1 2 3]))

14:35 clojurebot: #{1 2 3}

14:36 jweiss: gfredericks: +10 internets :)

14:36 borkdude: gfredericks jweiss ah :)

14:36 fnil

14:37 jweiss: ,((fnil conj (hash-set)) nil 1)

14:37 clojurebot: #{1}

14:37 jweiss: w00t

14:38 * jweiss adds fnil to repertoire

14:38 noidi: wow, fnil looks really useful

14:38 borkdude: this week's function: fnil

14:38 owengalenjones: anyone have an idea why the second fact form would fail? Only difference is using the hash lookups: http://d.pr/i/Patj

14:39 * Raynes tosses jweiss a https://github.com/flatland/useful/blob/develop/src/flatland/useful/fn.clj#L20 and a https://github.com/flatland/useful/blob/develop/src/flatland/useful/fn.clj#L30

14:39 noidi: owengalenjones, how does it fail?

14:40 owengalenjones: noidi: http://d.pr/i/IzsC

14:40 jweiss: thanks Raynes - i really should just add useful to my project.clj so i can browse around when i need something

14:40 noidi: a bit OT, but I'd replace the lookups with concrete values

14:41 owengalenjones: so just not use hashes?

14:41 noidi: (call ..url.. :login "valid-user" "valid-key")

14:41 hiredman: I would stop using midje

14:41 owengalenjones: ?

14:42 hiredman: my guess is it is doing something ridiculous

14:42 noidi: owengalenjones, btw. in your first example you call (login ..url.. ...), in the other you're doing (login "http" ...)

14:45 owengalenjones: noidi: from prior tests, still happens without :( oh well thanks for your time

14:45 nDuff: Emacs clojure-mode question -- how can one pull up the next token, when potentially separated by larger amounts of whitespace, to start only a space away from the current token?

14:45 technomancy: nDuff: M-SPC

14:46 nDuff: technomancy: shoot; I'll have to adjust my window manager's keybindings to get it to give that up.

14:46 technomancy: nDuff: esc spc?

14:46 nDuff: Ahh; that works.

14:48 noidi: owengalenjones, FWIW, I'd rewrite the test like this https://www.refheap.com/paste/12235

14:48 nDuff: Is there a cheaper way to cancel a transaction than throwing an exception?

14:48 noidi: the only args whose value is important is the :login arg to call

14:48 -s

15:14 actsasgeek: I have an application that refreshes data from a database. Because the data fetch is initiated by a work request and these all arrive at the same time every day and at once, I have to keep from doing multiple data fetches. What seemed to work is a future wrapped in a delay wrapped in an atom. In local testing this was fine, but now I'm seeing multiple hits on the database. Is there a known solution for this use case? I'm not sure what the problem is

15:14 unless (-> cache deref deref deref) isn't getting the right locks. Any suggestions?

15:22 nDuff: actsasgeek: That seems like serious overkill.

15:22 * nDuff could see a delay wrapped in an atom, or a future wrapped in an atom, or simply a future or delay attached to a var that gets rebound when need be...

15:23 nDuff: ...but anyhow, that's beside the point of the behavior at hand.

15:23 amalloy: nDuff: i actually use a data structure that looks like (atom {:key (delay (future ...))}). it's more useful than you think

15:24 Bronsa: but then you have to @@(:key @map) :(

15:24 actsasgeek: it may well be. The data has to be re-fetched every day so that suggests an atom. The data fetch is initiated by the first thread that gets there so that suggests a future and I don't want it to execute until it is demanded so that suggests a delay.

15:24 amalloy: if you want to store a fugure in an atom, the only way to *get* it there is with a swap!, and since that can retry, you can't actually create the future inside of the swap!

15:25 so, wrap it in a delay, let the first guy "win", and then deref it when you're done swapping

15:25 nDuff: amalloy: ...ahh; that makes sense.

15:27 pjstadig: actsasgeek: if you want something to not happen until you demand it you use a delay, but i'm not understanding where the future comes in

15:29 actsasgeek: sorry. this is basically what I have which may make more sense than me describing it: http://pastebin.com/qJy7MqxC

15:30 nDuff: actsasgeek: would you mind putting that somewhere without the animated flash-based advertising?

15:30 actsasgeek: no problem.

15:30 nDuff: (we're partial to refheap, here, being as it's written in Clojure)

15:31 actsasgeek: here you go: https://www.refheap.com/paste/12239

15:32 Raynes: nDuff: o/

15:32 My buddy, my pal.

15:32 actsasgeek: oddly enough this works…you only see "reading the actual database" once and you always get the same value until you update -database.

15:32 amalloy: actsasgeek: this test code doesn't look threadsafe at all. what if all 10 threads you start block for a second or so before the scheduler gets around to them? then the reset-calc and update-database functions get called before any calls to the original cache happen

15:32 actsasgeek: …but not in real life.

15:33 amalloy: or if one of them runs, you hit the database, you reset, and then the rest run? they hit the database a second time

15:33 nDuff: actsasgeek: If you want the test to be a more realistic one, make the read-database call block for a while.

15:34 (and, err, I'm not sure what the future is giving you here that you don't already get from the delay).

15:35 actsasgeek: do delays block other threads?

15:35 amalloy: "block other threads" doesn't make sense as a question

15:35 nDuff: Ahh, gotcha.

15:36 ...delay doesn't document its semantics there.

15:37 actsasgeek: as I understand it. a dereferenced future causes the calculation to be performed in another thread, prevents other threads from doing the same (blocks them), and returns the value of the calculation to everyone.

15:37 so no subsequent thread causes the function in the future to be executed.

15:38 a delay only prevents any enclosed value from being evaluated but the evaluation, when dereferenced, is on the dereferencing thread. (could be wrong here).

15:39 pjstadig: delay also caches the result and returns the cached result on future derefs

15:39 nDuff: I'm not sure those nest the way you want them to, though. If dereffing the delay twice at the same time creates two different futures (before the first one has finished and been cached), you've got your race.

15:39 actsasgeek: yes, that's what I'm afraid of.

15:39 amalloy: nDuff: it doesn't, though. dereferencing a delay blocks just as much as dereferencing a future

15:40 nDuff: amalloy: Ahh. If _that's_ the case, there's no need for the future at all.

15:40 amalloy: it's what they're *for*: the &body of a delay will never be executed more than once

15:40 * nDuff doesn't see that promise explicit in http://clojuredocs.org/clojure_core/clojure.core/delay

15:41 amalloy: "invoke the body only the first time it is forced"

15:41 but really, a lot of clojure's promises aren't painted in bright-red letters

15:41 actsasgeek: except the future executes in a separate thread…maybe there's no reason for the delay? just the future?

15:42 ideally there are multiple threads requesting work and multiple threads getting data together…but I need only one actual request for each data element.

15:42 nDuff: actsasgeek: ...well, the future starts immediately on creation.

15:42 actsasgeek: it's up to you whether you want to precache the value or wait for someone to want to retrieve it.

15:42 actsasgeek: nDuff: which is why I wrapped it in a delay :(

15:43 but apparently those don't compose well.

15:43 nDuff: Err.

15:43 sritchie: cemerick: what was that ring handler you had that forced https?

15:43 didnt' bookmark that library

15:43 nDuff: I don't think "delays don't compose well" is established takeaway here.

15:43 Bronsa: o

15:43 cemerick: sritchie: it's a separate middleware in Friend

15:43 sritchie: requires-scheme*

15:43 sritchie: okay, but that's where I can find it

15:44 yeah, cool

15:44 pjstadig: actsasgeek: why is it important that it happen in a separate thread? the first thread to deref a delay will execute it, is that bad?

15:45 if you want it to happen on a separate thread, then you want a delay wrapped future, but if it can happen on the first deref'ing thread, then a delay should suffice

15:45 nDuff: actsasgeek: ...what I'm getting from amalloy's clarification is that you really don't need the future here, and only need the delay.

15:45 actsasgeek: pjstadig: to do the work there are multiple large (several Gb) Hive queries…I don't want to do them serially.

15:45 pjstadig: they would happen serially on the future's thread?

15:45 actsasgeek: each request is a separate one of these caches.

15:46 nDuff: I *thought* I tried that first…but I could be concurrency punchdrunk.

15:46 sabraham: hey, multithreading question for the room: i'm getting a weird issue with an agent hanging: in the dispatch action to the agent, there's a call to pmap of a function-- when i use pmap the agent hangs, when i map instead, the dispatch action completes

15:46 anyone have any insight as to why that may be happening?

15:47 ravster: hey all

15:47 actsasgeek: nDuff: oh, I probably didn't because again, there are several of these caches being managed, each with a 20 minute Hive query. I'd rather do them in parallel.

15:48 corecode: is there a FAQ on "none of my friends understand my exitement with clojure"?

15:49 actsasgeek: the box I'm running on has 76Gb of memory and 24 cores.

15:49 nDuff: actsasgeek: ...but you're acting to prevent them from running in parallel by doing the triple-deref, which blocks until there's a result to continue.

15:50 actsasgeek: If you wanted to kick them off by dereffing all the delays but not the futures in an initial stage, _that_ I'd understand.

15:50 llasram: sabraham: I can't think of a reason off the top of my head. Can you reproduce with a minimal example?

15:53 sabraham: llasram, i'll try and concoct something and report back

15:53 actsasgeek: nDuff: yeah, I think you're right…my mental image of how the data request threads and work request threads interacted wasn't quite correct.

15:54 sabraham: one possiblity is that pmap uses the same threadpool as the agent's, so maybe pmap is requesting the agent thread?

15:54 amalloy: sabraham: futures use an unbounded thread pool

15:54 sabraham: one thing i think i have ruled out is that the agent is in a failed state, as a i have an error handler set on it, and it never reports

15:55 actsasgeek: amalloy: I now understand your confusion…those stray functions before the (dotimes…) were not called in the REPL that way…it's just where I pasted them.

15:56 jtoy: can maps hold millions of key/value pairs ?

15:56 actsasgeek: nDuff: how can I make that read-database function block in Clojure?

15:57 amalloy: jtoy: try it and see

15:58 sabraham: amalloy: ah, i see. i wonder why i was mistaken. out of ideas then

15:58 actsasgeek: jtoy: yes. I have one that has 25Gb of data: long => [long]

15:59 jtoy: actsasgeek: gret to hear, im going to use a clojure hash-map inside of hadoop

15:59 actsasgeek: maybe not quite that much…25 million records, though.

15:59 I'm holding the results of a Hive query in one.

16:00 actually, I'm holding the results of 5 Hive queries in 5 of them.

16:00 jtoy: actsasgeek: mine should only be 1-2 million

16:05 actsasgeek: nDuff: LOL…just make it sleep. Darn but I've been at this too long today.

16:12 puchacz: hi, I come from Common Lisp. I would like to read something about streams, iterators and generators

16:12 to steal some ideas

16:13 hiredman: clojure has none of those things

16:13 technomancy: yeah, not having any of those is a pretty good idea worth stealing

16:14 the main thing CL could learn from Clojure is that sometimes you have to remove things to improve the language

16:14 puchacz: really? streams can be non-destructive, purely functinal

16:14 technomancy: but the CL mantra is that you can always improve the language by adding new things; macros will save us, etc.

16:15 actsasgeek: nDuff, amalloy thanks for you help.

16:15 puchacz: right, did I start religious war? I did not intend to

16:15 Raynes: No.

16:15 You provoked the two hardest to please people in the channel is all.

16:15 Carry on.

16:15 pjstadig: haha

16:15 amalloy: technomancy has been promoted to "religious war"? this is excellent

16:16 pppaul: puchacz there is a library that adds channels to clojure… i think it may be similar to streams

16:16 ToBeReplaced: is there a lazy-shuffle implementation lying around?

16:16 duck1123: Lamina is probably what you want

16:16 puchacz: so seriously, what would you recommend to read on clojure way dealing with restartable, and long data sources?

16:16 brehaut: puchacz: Oleg has got your back http://okmij.org/ftp/Streams.html http://okmij.org/ftp/continuations/

16:16 Raynes: amalloy: %!

16:16 amalloy: Someone just asked for lazy shuffle. Your time has come.

16:16 trptcolin: brehaut: beat me to it. that is something to read, indeed

16:16 amalloy: omgomgomg

16:17 brehaut: trptcolin: i recognise most of the words as words anyway

16:17 puchacz: ok, thanks, will check Oleg. just heard about him on CL channel

16:17 brehaut: puchacz: thats because Oleg has a brain the size of a small planet and has covered all this stuff

16:17 amalloy: except my current implementation is a bit stupid. take-shuffled requires a numeric arg, instead of just giving you all of them and letting you use take

16:18 i must have a real lazy-shuffle around somewhere

16:18 technomancy: I dunno; a lot of people come asking how to learn from clojure's approach to concurrency, when usually the answer is just that referential transparency makes it a non-issue.

16:19 puchacz: coolio, starting to read. thanks

16:19 technomancy: "When he heard this, he left very sad, because he was a man of great wealth."

16:19 amalloy: try https://www.refheap.com/paste/c8275b404d8ec64446008ede5

16:19 gfredericks: yep, religious war

16:19 brehaut: technomancy: you are biblical motherfucker

16:20 amalloy: (ToBeReplaced)

16:20 ToBeReplaced: amalloy: thanks looking

16:20 technomancy: brehaut: sell all your mutable data structures and give to the poor, and you will have concurrency.

16:21 brehaut: (inc technomancy)

16:21 lazybot: ⇒ 47

16:21 hiredman: ~#68

16:21 clojurebot: 68. If we believe in data structures, we must believe in independent (hence simultaneous) processing. For why else would we collect items within a structure? Why do we tolerate languages that give us the one without the other? -- Alan J. Perlis

16:22 technomancy: brehaut: it's easier for a camel to go through the eye of a needle than for an imperative program to run concurrently without bugs.

16:22 ok, I'm done

16:22 llasram: Truly, it is easier for an experienced programmer to pass through the pages of the Camel book than to enter the kingdom of the concurrent

16:22 technomancy: nice!

16:23 gfredericks: any #clojure conversation that continues for long enough eventually degenerates to bible recitation

16:24 technomancy: I tried to make it work as an OCaml joke, but it wasn't happening

16:26 hiredman: ~#46

16:26 clojurebot: 46. Like punning, programming is a play on words. -- Alan J. Perlis

16:30 arohner: are there any decent JVM libraries for process management? I'm looking to run `ps` and `kill` from clojure

16:30 brehaut: arohner: conch.sh

16:31 arohner: ok, let me rephrase that :-)

16:31 is there a decent library that will tell me "is there a process whose name matches regex", without having to parse the output of `ps -ef`?

16:31 pjstadig: probably not

16:32 the JVM isn't very unixy

16:32 arohner: k. I was hoping to avoid platform-specific output of ps

16:37 jtoy: is defonce lazy?

16:39 meaning inside the defonce if i read a file and add create a hash will that happen upon the functino definition or when i call it?

16:41 technomancy: only seqs are lazy

16:41 if you want to delay evaluation of non-seqs, you can use an explicit delay

16:42 devn: Have a feeling you cats will be interested in this kind of thing, or not: http://notonlyoo.org/

16:43 trptcolin: i read that as "not on YOLO" the first time

16:44 technomancy: oh no a manifesto

16:44 * technomancy runs

16:44 jimkcar: Let's go write some Java! #YOLO

16:44 Sgeo: "That is, while there is value in the items on the right (except for nulls), we value the items on the left more"

16:44 I like the hate on nulls

16:45 trptcolin: manifesto (n): Karl Marx's favorite core.logic function

16:45 technomancy: "✓ manifests over manifestos"

16:45 Sgeo: Um. Is the entire manifesto seriously "We like these over those other things?"

16:45 technomancy: Sgeo: that's all the Agile manifesto is too

16:46 brehaut: (inc trptcolin)

16:46 lazybot: ⇒ 1

16:46 jimkcar: Blog page has swag for sale

16:46 brehaut: seriously? 1?

16:46 gfredericks: trptcolin: do you value reading over earning #clojure karma?

16:47 technomancy: brehaut: trptcolin doesn't connect to freenode often enough to bask in his well-earned repl glory

16:47 brehaut: technomancy: apparently so. i <3 reply

16:47 * trptcolin tries to think of a joke including the word "opinionfest"

16:47 technomancy: which is too bad because it's a good source of vitamin D

16:48 * gfredericks likes saying "TERPtuhColin"

16:48 trptcolin: it's a very exciting pronunciation

16:48 brehaut: TRPTCERLERN

16:49 ivan: arohner: maybe pgrep works on more platforms

16:49 Raynes: brehaut: ERMAHGERD

16:54 arohner: ivan: good idea, thanks

16:55 firefux: What's recommend today to connect to postgres from Clojure?

16:56 pppaul: datomic

16:57 Raynes: pppaul: Leave this channel and never return,

16:57 gfredericks: {:simple clojure.java.jdbc, :easy Korma}

16:57 brehaut: firefux: java.jdbc

17:00 abp: gfredericks: Korma can be simple too, but there are many simple things.

17:00 At least simpler than writing sql.

17:00 gfredericks: sql is pretty simple.

17:00 pppaul: :D

17:00 abp: But verbose

17:00 brehaut: abp: ?? writing sql is really straight forward. its the reuse and composability of the written sql that is pants

17:00 abp: java can be pretty simple too :P

17:01 technomancy: SQL without syntax highlighting is a drag

17:01 abp: brehaut: Right, and I always compose my queries.

17:02 brehaut: technomancy: and writing SQL via an abstraction that isnt a clean match semantic match is also a drag :/

17:03 * brehaut curses everything

17:03 gfredericks: come on guys just use hibernate

17:03 technomancy: brehaut: https://mobile.twitter.com/collinvandyck/status/305031087896281088?p=v

17:03 gfredericks: the answer has been right in front of us the whole time

17:03 we just had our heads stuck too far up our parentheses to see it

17:03 brehaut: technomancy: lols

17:04 gfredericks: the empty list literal is now an emoticon i cannot unsee :/

17:05 gfredericks: oh man I wasn't even thinking of that

17:10 brehaut: this is a longshot, but anyone got any idea how you specify optional fields in a map using core.typed? (where the key may not be present, rather than a nilable value)

17:13 hiredman: you need paradox absorbing buffers for your robot's head

17:16 brehaut: .toString comes from of Object in java, rather than some interface right?

17:17 metellus: Object has a default .toString but it's usually overridden

17:17 brehaut: right, but in terms of types if something is toStringable, its and Object rather than IStringable

17:17 metellus: yes

17:18 brehaut: thanks

17:20 canweriotnow1: what's the best way to handle native dependencies with leiningen, when packaging a library?

17:21 i.e., if a Java dependency has platform-specific *.so binaries?

17:35 akhudek: I added domina to the toggle class performance test included with dommy: {:domina 18.9, :jquery 11.412, :dommy 4.73}

17:40 konr: would it be a bad idea to port Backbone.js to ClojureScript?

17:43 akhudek: ok, just updated it by adding a proper toggle-class to domina that uses google closure's toggle function

17:43 {:domina 4.465, :jquery 11.326, :dommy 4.621}

17:46 tomoj: konr: yeah

17:46 :P

17:47 konr: tomoj: why?

17:50 tomoj: you either wind up with something ugly or something that isn't backbone

17:51 it may well be a good idea, if only as an exercise

17:52 tjgillies: whats the best way to show exceptions in compojure?

17:54 nDuff: ...hrm; clojure-mode is highlighting lines with errors/warnings on C-c C-k compile, but I'm unclear on how to see what those warnings actually _are_.

17:54 danneu: konr: dunno how it's a 'bad idea'. you're just replicating work and need to backport changes that happen on backbone master

17:55 sounds intellectually/educationally fun tho

17:55 squidz: i am trying to call a function for every node of an xml document where the function differs if the node is an end node or not. Whats the easiest way to do this in clojure?

17:55 hiredman: "end node"

17:56 squidz: hiredman: ?

17:57 right now I am maping said function over (xml-seq ..), but I am not sure if there is a function out there that returns true/false based on if an xml node is an end node or not

17:58 technomancy: canweriotnow1: unfortunately the process for creating those jars isn't documented currently; you have to read the source

17:58 or copy an existing native jar

17:59 squidz: also, is there something out there that gives the depth of the xml node in xml-seq?

17:59 canweriotnow1: technomancy: is it still the native/target_os/target_arch schema?

18:00 technomancy: canweriotnow1: basically yeah

18:00 every time someone asks, I tell them once they figure it out they should submit a pull request with documentation

18:00 canweriotnow1: also: I guess that means it's necessary to package native deps as a separate jar and add it to project.clj, I can't bundle them with my project?

18:01 hah, if I figure out a good way to do it, I'll definitely submit one!

18:01 danneu: squidz: im new to clojure but your requirements sound really simple http://www.gettingclojure.com/cookbook:xml-html

18:01 technomancy: canweriotnow1: yeah, that's usually how it's done. just a bunch of .so/.dll/whatever-mac-uses in a certain path structure in the jar

18:02 tomoj: clojurescript.test! woot

18:02 canweriotnow1: okay, thx... I wish maven handled this better :(

18:03 squidz: danneu: yeah that is pretty much what I have so far, but doesnt tell me how to figure out how deep I am in the xml

18:04 it looks like what I want is clojure.zip, but i cant seem to get it to work

18:05 ed_g: squidz: does end? not work for you?

18:06 squidz: ed_g: no, it is giving me a : string cannot be cast to IFn exception. Maybe it is because I am using xml-seq?

18:09 ed_g: squidz: I would guess so. by end node you mean node with no children? in a zipper it means the last node when traversing the zipper.

18:09 squidz: ed_g: okay I see I have to use xml-zip instead of xml-seq to be able to use end? but I am getting null pointer exceptions now

18:10 jtoy: how would split a string and have the first element in a variable and the remaining items in anothern variable?

18:11 canweriotnow1: technomancy: Thanks! It's ugly, but it worked!

18:12 (all this just to write a clj wrapper for Pam auth)

18:12 akhudek: jtoy: this is a very confusing question. If you split a string and get back a seq of results, the first element is (first results) and the rest would be (next results).

18:12 jtoy: my code for it is bad now: (let first_part (first (clojure.string/split line )) last_part (range 1 -1 (clojure.string/split line )) )

18:12 akhudek: I mean like that

18:13 ed_g: squidz: it sounds like your definition of end node is similar to what you might also call a leaf node, that is a node with no children? do I have that right?

18:13 squidz: yes that is what I mean

18:13 akhudek: jtoy: split it once, and use first and next on the result

18:14 technomancy: canweriotnow1: ugly sounds about right

18:14 akhudek: jtoy: you can also use destructuring if you really want to be clever

18:14 ed_g: in which case you can iterate using xml-seq and look for nodes without :content

18:15 technomancy: at least you don't have to recompile it on every install like you do with rubygems though

18:15 akhudek: jtoy: (let [[f & r] (clojure.string/split line)] …)

18:16 canweriotnow1: ha, true!

18:17 jtoy: akhudek: hmm, that might be too advanced for me ,not sure what that does

18:17 danneu: akhudek: does clojure have a func that's like Enumerable#partition in Ruby/Scala? [1, 2, 3].partition { _ > 1 } #=> [[1], [2 3]]

18:17 akhudek: jtoy: all you need is first and next

18:17 ed_g: for instance (filter (fn [e] (empty? (:content e))) (xml-seq your-xml))

18:18 akhudek: jtoy: (let [result (clojure.string/split line) f (first result) r (next result)] … )

18:20 scottj: danneu: partition-by and group-by

18:21 squidz: ed_g: im trying it out. ill let you know if it works

18:22 nDuff: Hrm.

18:25 saolsen: Does anybody know off hand the state of clojurescript sourcemaps? I've been googling around and found a few different discussions on it but I can't tell.

18:26 ed_g: squidz: I wrote a version of map and filter for zippers which you might find useful just for experimenting, not sure where the paste page is for this channel but I can put them there

18:27 squidz: okay just send me the paste link

18:30 ed_g: http://pastebin.com/1QeuTpuf keep in mind that modifying a zipper this way is challenging.

18:31 tjgillies: im working with cheshire and monger

18:31 im requiring monger.json like in the docs

18:31 but cheshire/encode can't serialize the doc

19:09 amalloy: ed_g: huh? why have map-zipper and filter-zipper, instead of just mapping and filtering over a zip-seq?

19:12 ed_g: amalloy: because I didn't see zip-seq in my quick reference docs :-)

19:12 actually I still don't -- what library is it in?

19:12 amalloy: ed_g: i don't know that it exists, but writing it yourself is preferable to writing map-zipper and filter-zipper

19:13 ed_g: amalloy: keep in mind these are basically the first functions I wrote in clojure

19:13 korny_: Hi - anyone here familiar with Liberator? We're trying to define a basic resource with a basic JSON representation, but it seems we have to explicitly call (json-str data) to get a json response

19:14 e.g. (defresource foo :handle-ok ["a" "b" "c"] :available-media-types ["application/json"]) gives an error

19:15 whereas :handle-ok (json-str ["a" "b" "c"]) works, but it seems strange to have to explicitly call this.

19:21 sshack: Is there a clojure library for parsing csv files that handles headers? I swear there was at one point, but can't remember the name now.,

19:24 scottj: saolsen: idk but I think status is not working but being worked on here and there when dnolen gets the time and motivation. see source-map branch on clojurescript repo maybe

19:29 jtoy: how do I turn a vector of items into a vetor of vectors? this doesnt work: (defn ts [i] [(map #([%]) i)]) ; (ts [1 2 3 4])

19:30 technomancy: jtoy: (vec (map ...))

19:30 err

19:31 (vec (for [i is] [i]))

19:31 jtoy: ok

19:31 not sure what the difference is between map and for, seem almost the same

19:31 technomancy: map is a function that takes a function as an argument; for is a macro

19:31 hiredman: for can filter and concat

19:32 jtoy: ok, imtesting itthanks

19:33 technomancy: it can concat?

19:34 hiredman: ,(for [a [[1 2] [3 4]] b a] b)

19:34 clojurebot: (1 2 3 4)

19:34 hiredman: concat

19:34 technomancy: oh, because of how it nests. yeah, never thought of it that way but it makes sense

19:35 hiredman: I just had an idea

19:35 reducers/for

19:35 that expands in to calls to the reducer fns

19:36 technomancy: you might say

19:36 that I'm for it

19:36 ( •_•)

19:36 ( -_-)~⌐■-■

19:36 (⌐■_■)>

19:37 hiredman: ~clap

19:37 clojurebot: Gabh mo leithscéal?

19:38 hiredman: ~applaud

19:38 clojurebot: excusez-moi

19:38 technomancy: I need to make an emacs defun for that because I was worried someone would respond in between lines

19:40 amalloy: hiredman: because having the entire implementation of the 'for macro copy/pasted into 'doseq wasn't bad enough

19:41 hiredman: amalloy: well, you can't do it as a c&p

19:43 man, I never remember :while

19:43 and I always try and use :where instead of :when

19:44 technomancy: :where would make more sense

19:45 hiredman: :where would be sql like

19:48 amalloy: hiredman: the tricky bit is remembering what :while does

19:49 (for [x '[a b c] y [1 2 3 4] :while (< y 3)] [x y]) returns '([a 1] [a 2] [b 1] [b 2] [c 1] [c 2]), whereas it's easy to forget and expect it to just be '([a 1] [a 2])

19:49 hiredman: yeah, screw :while

19:55 https://gist.github.com/5113363 fitting in the :when's would be tricky

19:56 sshack: So, clojure csv libraries?

20:14 Okay, question. How do I map a function with dirty > 1 ? Trying to do (map (nth 3) myseq)

20:14 In mathematica I'd do Map[nth[&,3], mylist]

20:14 & standing in for the mapped list.

20:14 lazybot: java.lang.RuntimeException: Unable to resolve symbol: standing in this context

20:15 root`: you want every third value from `myseq`

20:15 ?

20:16 sshack: root`: Well, each whatever value.

20:16 I've got a seq of seq's (rows from a csv file)

20:16 So I want to handle all the values of each type one at a time.

20:16 Do I make sense?

20:17 root`: sshack: yea, one sec

20:18 qbg: &(map #(nth % 2) [[1 2 3] [4 5 6] [7 8 9]])

20:18 lazybot: ⇒ (3 6 9)

20:20 sshack: qbg: Perfect! Thanks.

20:20 qbg: &(apply map vector [[1 2 3] [4 5 6] [7 8 9]])

20:20 lazybot: ⇒ ([1 4 7] [2 5 8] [3 6 9])

20:20 qbg: That might be useful for you too

20:22 sshack: qbg: That is actually

20:24 qbg: Is the JVM smart enough to not clobber memory resources doing that?

20:24 I'm thinking about 400meg csv files here.

20:25 qbg: How many columns do you have?

20:25 sshack: 200 or less

20:25 few hundred thousand rows.

20:26 qbg: map is lazy, so the above might be sufficient

20:27 eh, got that backwards.

20:27 sshack: Cool. I'm trying to cut down the number of columns. Should be ~50-70 soonish.

20:27 qbg: apply map vector would yield some big vectors in that case

20:27 sshack: I have this in my toolbox: (def transpose

20:27 (partial apply map list))

20:28 qbg: that is the same as above :)

20:29 If you have a seq of seqs, you'll be walking the outer seek when processing each column

20:29 So almost certaintly you'll end up with the entire file in memory

20:30 sshack: Good point. I think the best approach is get the data into a DB first. Then deal with it there.

20:31 So now I have to remember the name of that CSV file that deals with headers.

20:31 qbg: db would work. You could also read the entire file multiple times

20:33 sshack: I've sort of been burnt dealing with CSV files (mathematica, python, etc). So I think I'll parse things into a normalized DB and then go from there.

20:44 ambrosebs: It might be useful, say if you had a seq of possibly nil Closeables, and you (map close! cseq)

20:44 (doall ...) :)

20:46 sorry wrong chat

20:50 alandipert: is there a slurp-binary or similar in someone's awesome lib somewhere?

20:50 i have an input stream and know the length, would like to get a byte array w/ the stuff in it

20:51 qbg: There is a static method for that in apache commons io's IOUtils at least

20:57 Frozenlock: Is there a way to make everything in the repl pretty-printed?

20:59 alandipert: Frozenlock: it depends on how you're repl-ing; with lein repl i know you can do :repl-options [:print clojure.pprint/pprint] in your project.clj

21:00 i've never tried to do it any other way though, maybe nrepl and swank can be configured similarly

21:00 Frozenlock: Thanks, that's exactly what I was looking for!

21:06 xeqi: alandipert: in clojars we use something like: (let [bs (java.io.ByteArrayOutputStream.)] (io/copy in bs) (.toByteArray bs))

21:06 for a slurp-binary

21:07 alandipert: xeqi: oh, that's nice, len not required even. thanks!

21:12 Frozenlock: alandipert: I must have done something wrong... I see now difference :(

21:12 *no

21:23 Oh well.. (define-key map (kbd "C-c C-p") 'nrepl-pprint-eval-last-expression) .... should have read the nrepl.el sooner.

21:23 brehaut: do i have to officially ask for my jira privs to be bumped on the dev list, is someone just able to do it for me?

21:47 amalloy: if anyone important were in here, they could do it for you, brehaut

21:47 brehaut: amalloy: andy fingerhut did it on the list, but cheers

23:23 RazWelles: does clojureclr have any sort of introspection, like dir() for python?

23:23 also, how do you register event handlers?

23:33 noprompt: RazWelles: I'm not sure about the CLR version, but theres the doc function. You could try that

23:33 ,(doc map)

23:33 clojurebot: "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."

23:33 RazWelles: noprompt, I found something that kinda works... but now I'm at a loss for how to register an event handler :\

23:53 n_b: If I have a vec, is the more idiomatic way to access the last item in faster than linear time than doing (some-vec (dec (count some-vec)))?

23:55 I suppose (nth (dec (count some-vec)) some-vec)?

23:55 alandipert: n_b: peek may be what you want

23:55 RazWelles: ArgumentTypeException expected EventHandler`1, got EventHandler .CallSite.Target (:0)

23:55 Any idea what this means?

23:56 n_b: alandipert: That'd do it. Cheers!

23:56 jeremyheiler: n_b Maybe (first (rseq [1 2 3]))?

23:57 ahihi, didn't see your reply there, alandipert

23:57 Ah*

Logging service provided by n01se.net