#clojure log - Feb 01 2013

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

0:06 rl: I'm working on how to make a HTML form from a database model. The idea is to define the database model via macros, allowing the user to lables and description which can be be used for the html form. Would it be considered bad to do use a macro to automatically define functions for saving/loading/and persisting these models?

0:06 sorry, mean saving, loading, and then displaying

0:07 thinking a head, I know in Java with JDO you can use annotations to have a function be called for each specific model type before or after saving and loading

0:08 using macros I can define functions to do this without having to do run-time to see if a pre or post save/load function should be called for each model

0:09 TimMc: I'm not entirely clear on what you're asking, but I haven't heard anything yet that precludes using functions instead of macros.

0:14 rl: TimMc: the idea is do something like

0:14 (define-model book ({:name author :description 'Author of book'} {:name published-data :description 'Published Date'}))

0:14 then a function such as (save-book book) can be defined, where it does all the necessary checking and sanitation if required

0:15 technomancy: rl: that would involve looking up what function to call at runtime based on user input; not a very good idea

0:17 rl: technomancy: how so? i thought by using macros i can avoid this lookup issue

0:17 technomancy: rl: macros happen at compile time

0:17 you don't have user input at compile time

0:18 rl: yes, their is no need for user input at compile time here

0:18 save-book would be a defined function by the macro which can be used at run time

0:18 technomancy: you don't need a macro for that

0:21 TimMc: rl: define-model would produce (defn save-book ...) and (defn load-book ...)?

0:21 rl: TimMc: yes, and (display-book) would be a html string such as a form

0:21 and (process-book) would parse the input data for a form

0:22 TimMc: Why not (save-model :book ...) and (load-model :book ...) etc.?

0:23 Then (def models {:book [{:name ... :description ...} ...]})

0:29 rl: tinmc: thinking a head, mabey their comes a time I need to add a field. instead of having to check each field needs to have a default field added, using amcros i can create a function to mark this part of the run process, reducing the overhead of loading entities

0:29 nonuby: ive got 2 arrays ['a','b','c'] and [1,2,3], I want to merge into a map { 'a': 1, 'b': 2, 'c': 3}, which clojure core function should I be looking at?

0:30 technomancy: nonuby: zipmap

0:30 nonuby: perfect!

0:31 rl: tinmc: erm, mean to say i can create a function to fill in the blanks for missing attributes if necessary.

0:31 if i did this during run time, i would have to keep checking every attribute of every model if their is a default value to be loaded, which would be costly

0:32 technomancy: I think you would be surprised about what is actually costly

0:32 I/O overhead will always dominate.

0:32 rl: but if your modifying 1,000 entities, why even have the overhead you know?

0:33 technomancy: because maintainability is more important than a few extra microseconds?

0:38 rl: technomancy: is it really that unmaintainable in your opinion? if so, why? im new to clojure and trying to understand best pracitices

0:39 technomancy: macros are much more unpredictable than functions

0:40 if I see someone using macros, I start looking for the reason behind it, and I assume there's something tricky going on

0:40 if I see a function call, it's easy to tell at a glance what it does

0:42 macros allow you to invent entirely new syntactic constructs, which is overkill for something like saving a DB record from a form.

0:46 rl: hm, well i guess I will run some tests. if i find it unacceptable I will go with my original idea.

0:46 thanks for your input.

0:47 gf3: I used a macro once. Once.

0:47 Never again.

0:47 Macros. Not even once.

0:48 * dnolen rolls eyes

0:48 rl: lol

0:49 i really think being able to shift some computation to compile-time rather then run-time is a big +

0:50 sure the jit has run-time optimizations in place , but if it's a function with a switch statement that handles 50models +

0:51 i'm not sure how well it can optimize

0:55 erm, sorry you wouldn't use switch statements here lol. i mean if every model is different, and every model can have a different pre,post,or default-value function to be evaluated, i don't think the jit would handle this well

0:56 dnolen: rl: fn invocation in Clojure is pretty cheap, you would be surprised.

0:56 SegFaultAX: I've never understood the irrational fear of macros.

0:56 Especially in the Clojure world.

0:57 Raynes: It isn't irrational and it isn't fear of macros.

0:57 It's fear of macros for stupid crap they aren't supposed to be used for.

0:57 dnolen: SegFaultAX: some early libraries overused macros is all

0:57 SegFaultAX: Sure, I understand that.

0:57 Raynes: Functions are wildly more flexible than macros.

0:57 dnolen: SegFaultAX: you have to remember Clojure attracted a lot people who hadn't used Lisp seriously before

0:57 Raynes: If you can use them there isn't much point in using macros.

0:57 SegFaultAX: But gf3's comments aren't the first I've heard like that.

0:57 Raynes: That was a stupid joke. People make those a lot.

0:58 gf3: PSA: macros are cancer.

0:58 Raynes: And when they do, they usually know they're making stupid jokes.

0:58 amalloy: the clojure community also attracts stupid jokes

0:58 gf3: code generation considered harmful?

0:58 Raynes: Macros have a purpose. The "First Rule Of Macro Club" shit is just to prevent them for being used for purposes they aren't really meant for.

0:58 gf3: amalloy: I was just being silly, in response to technomancy


0:59 amalloy: i know. you can see that i was too: considered harmful is just as silly as cancer

1:10 nonuby: given two arrays [1,2,3] and [4,5,6] if I wanted to produce an array of maps [{:in 1 :out 4} {:in 2 :out 5 } {:in 3 :out 6}] what function should i look at

1:12 TimMc: map

1:12 &(map (fn [a b] {:in a :out b}) [1 2 3] [4 5 6])

1:12 lazybot: ⇒ ({:in 1, :out 4} {:in 2, :out 5} {:in 3, :out 6})

1:14 TimMc: nonuby: ^

1:14 nonuby: thanks Tim

1:14 clojurebot: thanks for your suggestion, but as usual it is irrelevant

1:14 TimMc: clojurebot: You're terrible.

1:14 clojurebot: Huh?

1:14 TimMc: clojurebot: forget thanks for your suggestion, but as usual it |is| irrelevant

1:14 clojurebot: I forgot that thanks for your suggestion, but as usual it is irrelevant

1:17 amalloy: ~zip

1:17 clojurebot: zip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c))

1:28 desertmonad: It's probably just ignorance, but macros don't blow my mind quite like middleware and monads

1:30 SegFaultAX: desertmonad: What's so hard about monads? They're just like burritos.

1:30 desertmonad: Luckily I haven't partaken of the burrito monad :)

1:31 SegFaultAX: to be honest, burritos blow my mind a little too.

1:33 * nightfly remembers https://github.com/substack/node-burrito

1:33 Chousuke: monads aren't that weird at all in the end

1:33 brainproxy: monads are nice

1:34 Chousuke: if you want weird, you should look into type-level programming in Haskell

1:34 brainproxy: monad transformers are also nice

1:34 but can give you a headache

1:34 Chousuke: depends

1:34 TardisT certainly did to me

1:35 brainproxy: one level deep transformer isn't too bad

1:35 but you start going deeper and the mental overhead starts to grew exponentially

1:36 Chousuke: someone wrote a monad which allows forward-flowing state in addition to reverse-flowing state and used it to implement an algorithm where you can express the calculation as if you were accessing values from the future

1:36 brainproxy: that's the Tardis thing, right?

1:37 Chousuke: yeah

1:37 brainproxy: I remember seeing a link to it, but never really dug into it

1:37 desertmonad: piece of cake

1:37 er, I mean burrito

1:37 brainproxy: I have yet to read a good explanation of comonads

1:38 Chousuke: sometimes I feel Monads get a bit too much publicity as far as cool stuff in haskell goes.

1:38 brainproxy: but would be open to any suggestions

1:38 Chousuke: oh, hm, yeah

1:39 technomancy: my favourite thing about clojure is that you can often look at a referentially transparent function and understand exactly what it does in its entirety

1:40 it makes it so a greater portion of the code is self-evident without a lot of context

1:40 brainproxy: i dunno

1:40 technomancy: and macros are more context you have to carry around

1:40 brainproxy: i've seen some pretty crazy functions

1:41 Jim Duey's "comprehend" function in protocol-monads makes my head hurt every time I try to walk through it

1:41 it's like a purely functional implementation of do-monad macro

1:41 Chousuke: comonads are the dual of monads. whereas in a monad you put values in a context and perform operations within that context, a comonad is the opposite. you have a thing with a context, and there is an operation to take your value out of it.

1:42 technomancy: brainproxy: most people writing monads in clojure don't have "self-evident" high on their list of values

1:42 brainproxy: I made myself trace a couple of computations through his "comprehend" and then just decided that I would accept that it does the same thing as "do-monad" and leave it at that

1:42 Chousuke: a zipper, for example is a comonad

1:43 brainproxy: technomancy: https://github.com/jduey/protocol-monads/blob/master/src/clj/monads/core.clj#L25

1:45 anytime reduce is used to spit out a function, for me that's still like, "whoah..."

1:47 Chousuke: that looks like it's just a series of binds

1:48 for some reason written in pointless style. :P

1:48 brainproxy: Chousuke: yeah, it does the same job as "do" in protocol-monads, "do-monad" in algo.monads

1:48 but no macros involved

1:49 which is pretty nice for when you want to build other things on top of it

1:49 Chousuke: brainproxy: https://gist.github.com/312281 I wrote a protocol-monad thingy myself once too. my lift-function is awesome.

1:50 brainproxy: Chousuke: interesting

1:51 Chousuke: so, could you use a comonad in combination w/ a monad transformer?

1:52 the reason I ask is that sometimes when you build up a trasnformer combo thing, the "junction" between inner and outer monad is experienced to be quite "rigid"

1:53 in other words, you'd like to be able to reach in and do something with the value as it goes through the plumbing, but you just can't

1:53 Chousuke: I'm not really sure. I haven't seen many examples of comonads to begin with and never a comonad transformer (if such a thing makes sense)

1:54 brainproxy: what i have in mind is when you use the writer monad in combination with say maybe transformer and state transformer

1:54 the typical helper methods for working with the writer's "log" just don't seem to work right

1:56 would be nice to have some piece of plumbing to stick in there somehow which lets you take extract the writer monad out of the monad sandwich, mess with it, and then let it fall back in to place

1:57 Chousuke: that would require the transformer stack itself to be a comonad

1:57 which I don't think it is. since it's a monad :P

1:57 brainproxy: yeah, maybe so... need to learn some more haskell so I can actually read some papers on this stuff

1:58 Chousuke: I'm sure with the right combination of lifts and what have you, everything will work just fine

1:58 or use lenses.

1:58 lenses are magic

1:58 brainproxy: or maybe arrows

1:59 i dunno, I barely know anything about arrows, comonads and lenses, but I didn't know jack about monads until last Nov

1:59 so maybe w/ a little more time I can dig into that stuff

2:03 Chousuke: lenses are kind of scary

2:04 brainproxy: at one point I was poking at a javascript lenses library

2:04 was written by one of the guys who worked on the Flapjax reactive library for JS

2:04 Chousuke: a while ago someone asked how to get the pair of sums from a list of pairs, and then someone came up with "over both sum" (IIRC)

2:04 brainproxy: but I got diverted and never really got deep into the lenses stuff

2:04 ro_st: what are lenses?

2:05 SegFaultAX: I saw a really good talk at the SF haskell user group about lenses. Very interesting stuff.

2:05 ro_st: -butts in-

2:05 brainproxy: lenses are a way to express bidirectional computations

2:05 Chousuke: ro_st: "accessors" to data structures. on steroids and other crazy

2:06 johnnyluu: hello!

2:06 ro_st: interesting!

2:06 i'm really looking forward to the frp talk at CW

2:07 brainproxy: ro_st: a guy name Nathan Foster did his thesis on bidirectional computation, lenses stuff

2:07 http://www.lulu.com/shop/john-nathan-foster/bidirectional-programming-languages/ebook/product-17382419.html

2:07 free ebook edition of the thesis ^

2:08 ro_st: who's doing the frp talk?

2:08 ro_st: Alan Dipert

2:08 http://clojurewest.org/sessions#dipert

2:08 brainproxy: will look forward to seeing the recording

2:08 ro_st: he's also doing an unsession

2:09 brainproxy: oh hey, it's Flapjax based :D

2:09 Flapjax was like a revelation for me

2:09 piranha: :)

2:09 same thing

2:09 brainproxy: I spent months on the library, trying to understand it

2:09 piranha: what blows my mind is that it was out in 2006 or something

2:09 brainproxy: yep

2:09 piranha: and all those years I just discarded it

2:10 and now it's like I'm cured from blindness :))

2:10 brainproxy: the real kicker is figuing out how the scheduler works

2:10 ro_st: we have a mid-sized cljs app in production now (~5000 loc) and i'm pretty sure we can cut 10-20% off of that with FRP

2:10 brainproxy: once you realize how the topological sort thing works

2:10 piranha: the only thing which bothers me is that I can't find good examples of structuring FRP code

2:10 ro_st: since we already use event-sourcing for our client->server data

2:10 brainproxy: then it all starts to fall into place

2:10 piranha: all the examples are for small applications

2:10 ro_st: i'm sure it'll be a good fit

2:11 brainproxy: I found that Flapjax seemed limited

2:11 piranha: I'm mostly sure as well, but I'm trying to figure out myself and it's not going fast enough :)

2:11 brainproxy: I wanted it to do more

2:11 tried twice to rewrite it

2:11 was a bit naive about what that would really entail

2:11 but I learned a lot

2:13 johnnyluu: anyone knows where bbloom is?

2:13 piranha: brainproxy: what about lenses library btw, I can't find it :(

2:13 brainproxy: piranha: that's by a guy with last name Greene

2:13 hold on, i'll dig it up

2:13 piranha: thanks

2:13 brainproxy: it's pretty primitive I think

2:14 but even still, it seemed even more daunting than Flapjax

2:14 or at least at the time it did, to me

2:14 piranha: heh :)

2:15 johnnyluu: grr .. sometimes i just wanna talk to you guys for real .. but i know you can't be honest

2:15 brainproxy: piranha: unfortunately, it's not collected into some nice github repo that I could ever find

2:15 but here you go

2:15 http://www.cis.upenn.edu/~mgree/ugrad/lenses/docs/overview-summary-lens.js.html

2:15 dig in and have fun

2:16 try not to go blind

2:16 or have an anurism

2:16 piranha: ;D

2:16 okay, I'll try :))

2:18 brainproxy: piranha: i think the hot thing now is called "edit lenses"

2:18 which are probably what most of us engineering types want anyway

2:19 piranha: hm, ok, I'll try to dig in this direction :)

2:19 brainproxy: the kinds of lenses that Foster et al. deal with aren't differential

2:19 you send the whole data structure around

2:19 piranha: I probably should finish with my idea of structuring of application anyway before jumping on another topic again %)

2:19 oh

2:19 brainproxy: but edit lenses are differential

2:20 johnnyluu: i know what you are doing and will do when i release it .. all i want is to finish my work and release it quickly since it looks so cool. but perhaps your version will be lot cooler and i really hope so :) hope it can be like before when i can ask questions and have answers .. it's not fun having to hide all the time

2:22 piranha: johnnyluu: :)

2:22 johnnyluu: it won't be money based since i don't have the manpower .. so just ads .. but it looks cool anyway :)

3:14 maxalwings: What is your best CSS generator library for clojure?

3:53 jeffmess: As a complete noob to clojure. What is the recommended way to install clojure on OSX? Homebrew, dl installer from website, macports?

3:57 bdash: jeffmess: I'd do what is described at http://charlie.griefer.com/blog/2011/08/03/clojure-in-3-minutes/. basically, you don't install clojure, you install leiningen and let it manage clojure

3:58 jeffmess: bdash: thanks!

3:58 arcatan: and you can install leiningen with Homebrew, too

3:59 * arcatan saves the link for reference

4:02 jeffmess: sweet, I already feel 2% smarter.

4:04 xumingmingv: a question about develop clojure using emacs

4:04 I want to auto-start nrepl repl when I open a clj file

4:05 but I dont want the nrepl-jack-in be started again when I open another clj file (Beause the nrepl is already started)

4:05 apparently, the following code does not work: (add-hook 'clojure-mode-hook 'nrepl-jack-in)


4:05 How to make it work?

4:07 * ucb waves @ augustl

6:07 michaelr525: can i install lein 2 without upgrading all my existing projects?

6:32 scottj: michaelr525: you can have lein2 and lein1 installed at the same time.

6:32 no7hing: @michaelr525 it should be fine if you name lein 2 f.e. lein2

6:32 haha

6:33 well, now you know for sure

6:41 michaelr525: scottj: hehe thanks, just tried doing exactly that and it worked.. amazing how simple it is :)

6:41 clojurebot: Ack. Ack.

6:49 hyPiRion: Easy. Easy is the word.

6:51 michaelr525: hyPiRion: easy and simple

6:58 hmm

7:05 hyPiRion: michaelr525: True that, it's simple as well.

7:11 ljos: Hi. I am working a bit with Korma and I was wondering if anyone know if it is possible to do this query without resorting to `raw`: `SELECT date(created) FROM table;`

7:16 michaelr525: ljos: sqlfn, look up an example here: http://sqlkorma.com/docs

7:20 ljos: michaelr525: Thanks. That works. It becomes (select table (fields (sqlfn date :created)), though this returns a very ugly map back. Fixed that with (select table (fields [(sqlfn date :created) :date])).

7:21 I am very impressed by the expressiveness of korma.

7:21 michaelr525: ljos: good, because i think i'm gonna use this slqfn too for the problem i'm actually working on right now (never used it before) :)

7:22 i like korma too

7:22 it works well for me

7:24 ljos: michaelr525: the only thing I don't like right now is that I have to do (modifier "distinct") to do a SELECT DISTINCT. I feel that could have been handled without the string (e.g. just (modifier distinct) as they do with sqlfn.)

7:29 johnnyluu: ppppaul: i hope you didn't just smile to make it look like that we are working together

7:35 i have no partners, no incubators, nothing else but me on my project

7:40 michaelr525: REPL server launch timed out.

7:40 why?

7:40 clojurebot: why not?

7:40 michaelr525: clojurebot: 'cause it's supposed to work, egghead

7:40 clojurebot: Gabh mo leithscéal?

7:42 michaelr525: clojurebot: magairlí asal

7:42 clojurebot: No entiendo

8:35 `fogus: Hi all. Is Korma the go-to library for SQL

8:35 ?

8:35 The last time I needed SQL ClojureQL was king.

8:38 michaelr525: `fogus: i think so..

8:41 `fogus: Thanks. That's the one for me then. :-)

8:51 jeffmess_: pretty new to clojure. Are there any projects that are great to read so I can get an idea how best to structure an application?

9:43 AtKaaZ: is there something like splicing without unquoting? something like `~@

9:44 oh wait, does this work? '~@

9:44 nope

9:46 I basically need the effect of ~@restt but I'm not within a `(...)

9:48 ok i worked around this by using ` and a let because I needed to paste a raw symbol in the returned list (ie. thrown?)

9:51 Anderkent: AtKaaZ: you want `(is (~'thrown? ~@rest)) - the quote-unquote produces un-namespaced symbol

9:52 AtKaaZ: oh that's nice, thank you very much Anderkent

10:04 how do you compare if two lists have the same contents?

10:05 ok (= ...) is working, but I was instead evaluating the lists first

10:07 daviddpark: Recent upgrade to leiningen 2.0.0 now lein test results in ClassNotFoundException for clojure.java.shell.... What is the advised workaround?

10:09 Anderkent: daviddpark: what version of clojure is your project using?

10:09 daviddpark: 1.4.0

10:10 Anderkent: hm, works for me on 1.4.0. Were you upgrading from lein1 or lein2-preview?

10:11 daviddpark: lein2-preview.... upgraded to lein2 using "lein upgrade" however, I then upgraded from Lion to Mountain Lion, and did a brew upgrade, which _also_ upgraded leiningen to lein2. Not sure whether brew screwed me over.

10:12 Anderkent: mhm, could have :P Fire up a repl and see 1. what version of clojure is advertised and 2. if (require 'clojure.java.shell) succeeds

10:16 AtKaaZ: what am I missing here with lists equality? https://gist.github.com/4691902

10:17 daviddpark: Anderkent: 1. reports 1.4.0 and 2. requires just fine. I must be doing something stupid. thanks for your help, and I'll go back to the drawing board.

10:18 Anderkent: daviddpark: yeah, unfortunately clojure compile errors are not very helpful

10:19 AtKaaZ: where does the 'a' come from?

10:19 xumingmingv: a question about private function

10:20 AtKaaZ: Anderkent: it's probably enough? to just look at the actual: part? but a is (def a java.lang.RuntimeException)

10:20 xumingmingv: we know that private function has a meta: ^:private true

10:20 if I manually remove this :private meta

10:20 will it be callable in another namespace?

10:20 I tried, still cannt, dont know why

10:21 Anderkent: xumingmingv: dynamically or in the source? It definitely should be if you do it in the source. If you do it dynamically I couldn't tell (but you can call the function without doing that by accessing its var: (#'private.namespace/function args)

10:21 xumingmingv: in the repl

10:22 I know I can access it with the full-qualified name

10:23 but I want to access it directly in the repl(ease debuging)

10:23 Anderkent: how are you removing the metadata?

10:23 dyreshark: semantics question: if i have a decently large lambda i'm passing to reduce (on the order of 4-7 lines), is it better practice to declare/name it in a let, or just place it inline?

10:23 Anderkent: (you could just (def my-fn #'private.function) then do (my-fn args)

10:24 xumingmingv: (alter-meta! v (fn [curr-meta] (dissoc curr-meta :private))

10:24 I checked, the :private meta is indeed gone

10:26 Anderkent: I am writing a little tool to ease debugging, I just want to make developement as easy as it can be.

10:26 so if remove :private meta works, that would be the best option

10:27 Anderkent: it works for me

10:27 AtKaaZ: if the function is in a different namespace? Anderkent

10:28 Anderkent: https://www.refheap.com/paste/9162

10:28 AtKaaZ: I can't see what's going wrong with your code - one thing is that ' is tricky; if you call it from a different namespace the symbols might not match

10:30 AtKaaZ: also, try with (isthrown? java.lang.RuntimeException ...) instead of (isthrown? a)

10:30 AtKaaZ: Anderkent, about his function, what happens if you don't specifically namespace the function (ie. import it? or refer to it prior to unmeta)

10:32 jimduey: brainproxy: I'm working on a comonads post right now. Might get it done tomorrow, but probably not.

10:32 AtKaaZ: still false, Anderkent, also updated gist

10:33 Anderkent: AtKaaZ: that's too much pain for me to check, since I can't :require namespaces that are dynamically generated in the repl

10:33 and making the sources is effort :P

10:33 seems to work when I try it with just (refer) though..

10:33 https://www.refheap.com/paste/9163

10:34 AtKaaZ: can you show isthrown? as well?

10:34 AtKaaZ: sure, sec

10:35 done

10:36 pepijndevos: There was a pattern in core.logic to do construct lists, better than a chain of conso, right?

10:37 Maybe... (== l (llist a b c tail))?

10:37 xumingmingv: ok, I know what the issue is

10:38 I first use the namespace(where my private function is)

10:38 then I removed the function's private meta

10:38 AtKaaZ: do :reload ?

10:38 xumingmingv: then try to call the function

10:38 AtKaaZ: oh nvm that would overwrite it again:)

10:38 xumingmingv: the function is of course not there....

10:39 AtKaaZ: yeah, I use the namespace again

10:39 the function is available

10:39 thanks you guys

10:39 AtKaaZ: ok, not sure I got it then

10:40 xumingmingv: I guess when 'use' a namespace, only the public functions are made available

10:40 AtKaaZ: using the namespace again refreshes something in current namespace? like referrers or something? which auto-ignored private ones?

10:40 xumingmingv: even if we removed the :private meta

10:40 AtKaaZ: ok that makes sense

10:40 thx

10:40 xumingmingv: the previous private function is still not available

10:41 need to use the namespace again(to import the new public function)

10:41 AtKaaZ: so you were not namespace qualifying the function to be called?

10:41 the private one

10:41 Anderkent: xumingmingv: yes, :use only refers public symbols

10:41 xumingmingv: AtKaaZ: yeah

10:41 not full-qualified name

10:42 AtKaaZ: ok cool this makes total sense

10:44 so by re-using again, it updates the current ns refs to outside functions (in this case also adds one more referer in current namespace to the now public func) so like curns/former-priv-func refers to somens/former-priv-func while previously wasn't defined in curns

10:45 xumingmingv: yeah

10:48 BTW, what's most convinient way to access refheap? is there a plugin?

10:53 cemerick: pjstadig: this might not be so hard after all...

10:53 pjstadig: dooooo iiiiiiiit

10:53 cemerick: you can make compiler changes, i know you can :)

10:53 Anderkent: AtKaaZ: I figured out your problem - in '(clojure.test/is ...) java.lang.RuntimeException is a symbol, in the result of your macro it's a class

10:53 cemerick: hah

10:53 pjstadig: I've done so before, I just try to not make it a habit

10:54 I feel like I'm blowing time when I'm this low in the stack.

10:54 Might as well start writing device drivers.

10:54 But, yes, I'm doing it. Will hopefully have a changeset on github ~20m.

10:57 AtKaaZ: Anderkent, ok I'm looking into it, but great find!

10:59 oh that makes sense

11:00 can I transform that class into a symbol?

11:07 Anderkent: AtKaaZ: I'm not sure why you want to use eval there

11:07 AtKaaZ: what else could I use?

11:07 Anderkent: AtKaaZ: I'd think (defmacro isthrown? [cls & body] `(is (~'thrown? ~cls ~@body)) would do it

11:08 pepijndevos: rawr. sometimes there are just so many data dependencies that tearing out small functions only hurts.

11:08 AtKaaZ: but if I don't pass a class it will fail, since I pass a symbol to a class ie. (def a RuntimeException)

11:08 Unable to resolve classname: a,

11:10 ravster: hello all

11:12 S11001001: ,(first (apply concat (cycle ['greetings])))

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

11:12 S11001001: ,(first (apply concat (cycle [['greetings]])))

11:12 clojurebot: greetings

11:12 S11001001: eh, types

11:12 AtKaaZ: ,'hi

11:12 clojurebot: hi

11:32 pepijndevos: dnolen, okay, Now I see why one would want to do fresh in dcg, and why it takes so much code. awww.

11:34 dnolen: pepijndevos: yep

11:37 pepijndevos: DCGs aren't really usable in core.logic or miniKanren so I haven't done much w/ that code.

11:37 pepijndevos: dnolen, why arn't they usable?

11:38 speedwise, syntaxwise, or ohterwise?

11:38 dnolen: pepijndevos: speed & memory

11:39 pepijndevos: to actually use them DCGs we need environment trimming

11:40 pepijndevos: dnolen, why does this work in prolog? and... what is environment trimming?

11:42 or does it only work in prologs dat do environment trimming?

11:42 dnolen: pepijndevos: Prolog have many optimizations in place including environment trimming

11:43 pepijndevos: problem for DCGs is you have a unification per character, this means for your substitution map will contain as many bindings as characters you want to parse

11:43 pepijndevos: hrm :(

11:43 dnolen: so for anything but the smallest inputs, DCGs are useless in miniKanren & core.logic

11:44 pepijndevos: dnolen, oh, I'm parsing word by word, on single sentences.

11:44 dnolen: pepijndevos: so less of problem, but still a problem.

11:44 pepijndevos: dnolen, where can I read about this trimming?

11:45 dnolen: pepijndevos: the solution is to have something that looks more like an interpreter environment instead of a big substitution map.

11:46 pepijndevos: I think "Warren's Abstract Machine: A Tutorial Reconstruction" covers it

11:47 pepijndevos: thanks :)

11:50 dnolen: pepijndevos: I haven't looked into it much, it would require some dramatic refactoring.

11:50 pepijndevos: dnolen, I suppose. For now I'm just curious what it is.

11:50 dnolen: but perhaps not ... ? I've only thought about it a little bit.

11:51 pepijndevos: it just about discarding variables once you leave a goal scope

11:51 pepijndevos: dnolen, I'm having tons of fun writing a DCG impl and a system that you can ask simploe questions

11:51 dnolen: pepijndevos: sweet!

11:52 pepijndevos: for interactive small inputs, yeah, I imagine they're fun and work well!

11:52 pepijndevos: dnolen, I'm thinking I should write a redis connector for core.logic :)

11:52 dnolen: pepijndevos: rad!

11:54 pepijndevos: dnolen, if either the redis or the dcg turn out nicely, is that something to contribute?

11:55 I know you have a dcg already, but if I get fresh to work nicely, it's a lot simpler to look at the code and see what it is doing.

11:55 dnolen: pepijndevos: the DCG code isn't exactly complicated, if it's not marked improvement - I don't think so. no on including anything to do w/ redis.

11:56 pepijndevos: ok

11:56 I though since you have datomic in there already..

11:56 alexnixon: I have two threads, each with a reference to the same atom. If one thread reset!'s the value of the atom, then afterwards the other thread reads the value of the atom, is it *guaranteed* that the second thread read see the updated value?

11:57 pepijndevos: define afterwards

11:58 alexnixon: the first thread called .interrupt on the second, causing an InterruptedException

11:58 dnolen: pepijndevos: datomic was just there as simple example of how to integrate, it's also experimental

11:59 pepijndevos: ok, sure. I'll just put it on it's own then.

11:59 alexnixon, you know you cna also at watchers to an atom?

11:59 but ye, I do believe it should be reset always

11:59 an atom is not async

12:00 alexnixon: pepijndevos: thanks - I'll take a look at watchers

12:02 pepijndevos: yeah it isn't async, but I couldn't find any documentation to explicitly say whether writes are immediately visible on all threads (even though I strongly suspect they are)

12:04 cemerick: OK, who's the local asm expert? pjstadig, hiredman?

12:04 pjstadig: expert no

12:04 but i could try to answer a question

12:05 cemerick: one sec, pushing

12:11 spligak: Is this a reasonable approach for supplying the first parameter to a batch of functions? https://gist.github.com/4692634

12:15 cemerick: nm, I got it; had a hard time remembering the .newInstance, .dup, .invokeConstructor dance

12:15 pjstadig: ^^

12:16 pjstadig: cool

12:18 alexnixon: spligak: an alternative would be to make with-connection bind a dynamic var, and have "query" use that instead.

12:22 spligak: alexnixon, I'm unfamiliar with dynamic vars. Reading the doc page on them now.

12:23 so this would allow me to make a thread-local top-level connection value?

12:24 alexnixon: spligak: a dynamically-scoped binding (which IIRC is conveyed to futures et al spawned from within the scope)

12:25 seems like you want something similar to this: https://github.com/aboekhoff/congomongo/blob/master/src/somnium/congomongo.clj#L163

12:27 spligak: ahihi, interesting, he's pulling in that *mogo-config* from his config over here https://github.com/aboekhoff/congomongo/blob/master/src/somnium/congomongo/config.clj

12:27 whoa. I meant to say "aha"

12:27 I suppose I also meant to say "mongo"

12:29 alexnixon, This is pretty neat. I'll play with this. You didn't find my example horrifying, though?

12:30 alexnixon: spligak: not horrifying at all, just a bit awkward to use as you'd (due to familiarity with other with-xxx scopes) assume that you could stick arbitrary clojure inside the macro

12:33 spligak: alexnixon, I'll keep that in mind. I appreciate your help.

12:33 jchauncey: anyone know of a guide for attaching the intellij debugger to a leiningen process thats running?

12:35 alexnixon: spligak: np

12:47 brainproxy: jimduey: great! well, whenever you get done writing it, i look forward to reading it!

12:49 aaelony: does clj-time support converting unix timestamps to readable date strings?

12:50 ldh: yep! see the clj-time.coerce namespace

12:51 aaelony: ldh: works! thanks :))

12:57 ldh: aaelony: np :)

12:59 Thallasios_Xelon: hello guys :)

13:06 ravster: hello all

13:07 Thallasios_Xelon: helo ravster

13:08 i am confused about using lazy sequence,my code doesnt work with normal concat,but with a hand-made concat it works...

13:08 pppaul: hey

13:09 Thallasios_Xelon: when you write code with lazy-seq you have to think about it,or think them as normal sequences?

13:09 pppaul: i'm trying to make a route in ring/compojure with a wildcard at the end… not having any luck

13:09 tried (GET ["/documents/*] [] myfun)

13:09 it's not matching, though

13:10 alexnixon: Thallasios_Xelon: can you post code to illustrate your problem?

13:12 Thallasios_Xelon: alexnixon when you use lazy-seq you think of them as normal sequence when you write code?

13:13 alexnixon: Thallasios_Xelon: depends what you mean by a "normal sequence"

13:15 ldh: ppaul: have you tried (GET "/documents/*" [] myfun) ?

13:28 daviddpark: I am hoping to get a little help with destructuring. In using carmine to work with Redis on a different host than localhost, I need to invoke (make-conn-spec) with some arguments and I cannot get it right. Details at https://gist.github.com/4693104 for anyone who can give me a quick pointer.

13:29 gtrak: daviddpark: you're using the varargs trick when you don't mean to, get rid of &

13:29 then your first example should work

13:30 daviddpark: gtrak: not my code... that is the function definition in carmine. I'll ask the author of the code. Thanks for your quick feedback!

13:30 alexnixon: daviddpark: (make-conn-spec :host "example.com" :port 9999 :password "insecure" :timeout 900 :db 1)

13:31 daviddpark: alexnixon: Thanks! I did not try that. Would not have thought to...

13:31 TimMc: ~mapply

13:31 clojurebot: You could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))

13:31 gtrak: mapply?

13:31 clojurebot: You could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))

13:35 gtrak: daviddpark: the trick is to understand the difference between an arglist of [{}] and [& {}], the second is implemented as applying hash-map to the args seq, which splits the arglist into pairs of kv's

13:37 TimMc: [& {}] is a toothy gremlin disguised as a clever convenience.

13:38 thalassios_xelon: (apply clojure.set/intersection (set (map to_keep set1 (repeat (count set1) set1)))))

13:38 it has lazy sequence and it doesnt work

13:39 gtrak: it's explained about halfway down in this post: http://clojure.com/blog/2012/02/17/clojure-governance.html

13:39 daviddpark: gtrak: Thank you for that explanation. I see the difference now.

13:40 thalassios_xelon: its say clojure.set/intersection zero arguments............

13:40 as if the lazy seq did not produce anything

13:40 do you know why?

13:41 hiredman: ,(apply intersection ())

13:41 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: intersection in this context, compiling:(NO_SOURCE_PATH:0)>

13:41 hiredman: '(require 'clojure.set)

13:41 ,(require 'clojure.set)

13:41 clojurebot: nil

13:41 hiredman: ,(apply clojure.set/intersection ())

13:41 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: set$intersection>

13:42 hiredman: (apply clojure.set/intersection '(1 2)) => (clojure.set/intersection 1 2)

13:42 (apply clojure.set/intersection ()) => (clojure.set/intersection)

13:42 thalassios_xelon: is it possible that the problem comes from lazy-seq

13:42 or my code just returns () and its a error?

13:42 gtrak: thalassios_xelon: you're applying the contents of a set... you want to intersect two sets

13:43 it makes no sense what you want to do there from what you wrote

13:43 thalassios_xelon: i want to interset a list of sets

13:43 gtrak: a set of sets?

13:43 gfredericks: ,(apply clojure.set/intersection [#{1 2 3} #{2 3 4} #{3 4 5}])

13:43 clojurebot: #{3}

13:44 amalloy: TimMc: i read the first half of that and was trying to see how [& {}] was shaped like a gremlin

13:44 TimMc: amalloy: What, you still don't see it? :-P

13:44 gtrak: ,(apply clojure.set/intersection (set [#{1 2 3} #{1 2 3} #{1 2 3}]))

13:44 clojurebot: #{1 2 3}

13:45 thalassios_xelon: is it possible that the lazy-seq causes the arguments to be (), or my code is producing the ()

13:45 gtrak: ,(set [#{1 2 3} #{1 2 3} #{1 2 3}])

13:45 clojurebot: #{#{1 2 3}}

13:45 gtrak: does that make sense?

13:45 thalassios_xelon: i dont know how to use lazy sequences,is it hard?

13:46 dabd: anyone knows if the cond-let macro that was in clojure.contrib.cond move to somewhere else?

13:46 moved*

13:46 gtrak: thalassios_xelon: lazy-seq is fine here. The higher level structure makes no sense.

13:48 thalassios_xelon: can it happen to need the value of a lazy-seq ,and dont have it?

13:48 gtrak: not in the way I think you mean

13:49 thalassios_xelon: using lazy-seq is something that i need to take care of,or is automatic?

13:49 gtrak: I've never once had to write lazy-seq to use lazy-seqs

13:49 thalassios_xelon: ok gtrak thx ,i am totally new in clojure :)

13:49 i will read more

13:50 gtrak: laziness isn't the culprit here, I think it's a misunderstanding of what map and apply do

13:50 thalassios_xelon: ok :) i will try again

13:57 gfredericks: I'm curious what (^:once fn* [] ...) is supposed to accomplish

13:58 my guess so far is that it's used on functions that are guaranteed to be called once

13:58 ravster: How do I set langohr up so that it doesn't error and die when I get a connectionrefused error?

13:59 hiredman: gfredericks: it causes closed over values to be cleared after the first call, I believe

13:59 ravster: I don't think I want to do a try/catch over the entire file.

14:00 hiredman: avoids head holding by delays and lazy seqs

14:00 gfredericks: oh fascinating; I don't get the error I would expect by calling such a function more than once though :/

14:00 e.g., (let [x 10] (^:once fn* [a] (+ x a)))

14:00 hiredman: ravster: don't use global connection objects like that

14:01 gfredericks: not sure, but it may also cache the result

14:01 a classical fp thunk

14:01 gfredericks: I called it with different args even

14:02 hiredman: huh

14:02 looks like :once is actually no longer used, it may be left over from before the more aggresive locals clearing went in to the compiler

14:04 all the :once/oneTimeUse stuff in the compiler is commented out

14:04 frozenlock: Raynes: Any opinion on mongodb? I see you used it on refheap.

14:06 amalloy: hiredman: really? i thought i found one spot somewhere

14:06 ivaraasen: argh, profiling macros is hard

14:07 gerunddev: frozenlock: I've used mongo with congomongo a bit.  I've also used mongo a fair amount and Couch DB a lot.

14:08 hiredman: amalloy: could be, I just did a cursory look, and I'm not sure how up to date my checkout is

14:08 frozenlock: gerunddev: What do you think of it? Seems HN hates it to death.

14:08 amalloy: no, i think you're right

14:08 frozenlock: gerunddev: I do use it with congomongo and find it really convenient, but I wonder for the long term. (bigger DB)

14:08 amalloy: i just looked even more cursorily last time, apparently

14:09 frozenlock: HN hates everything to death

14:09 eventually, HN will hate itself to death

14:09 technomancy: amalloy: that's already well under way

14:11 ravster: hiredman: okay, will try to change that. thanks.

14:12 gerunddev: frozenlock: I like elements of Couch and mongo.  Document stores are so great that the pro / cons of each seem to mean less.

14:14 kaoD: document stores are not great, they're just convenient... in some cases :P

14:14 gerunddev: frozenlock: Mongo has horizontal scalability baked into the design more than Couch (which had it added in Big Couch).

14:15 amendment - great for the kinds of problems I'm solving

14:15 kaoD: I once worked (for profit) in a project based around MongoDB

14:15 what's fun about it is that it didn't need scalability

14:15 but actually needed ACID

14:15 frozenlock: gerunddev: Nice. Thank you, I appreciate your input.

14:16 ,ACID

14:16 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ACID in this context, compiling:(NO_SOURCE_PATH:0)>

14:16 hiredman: ~apropos ACID

14:16 clojurebot: Hydrochloric acid is a Chemical Compound. (http://www.freebase.com/view//m/0dc0x)

14:16 bpr: kaoD: seems like noSQL is a poor choice then?

14:16 amalloy: good try, clojurebot

14:16 hiredman: clojurebot: maybe next time

14:16 clojurebot: multimethods are http://clojure.org/multimethods

14:16 gerunddev: frozenlock: http://en.wikipedia.org/wiki/ACID

14:16 kaoD: bpr: it was indeed, but apparently NoSQL is fashionable now among project managers

14:16 TimMc: hiredman: Is ~apropos new?

14:17 hiredman: yes

14:17 ivaraasen: ah, managers

14:17 kaoD: that's why "I hate MongoDB" or "I love NoSQL" make no sense at all

14:17 the right tool for the right job

14:17 but I'm just a codemonkey, who cares

14:21 gtrak: maybe there are more markets for negations? I love NoCurlyBraces

14:23 or notAgile

14:24 frozenlock: What style is preferred, (fn [a &[b]] ...), or (fn [a & b] (first b) ...) ?

14:24 technomancy: noXML

14:24 amalloy: neither of those

14:24 (fn ([a] ...) ([a b] ...))

14:24 gtrak: noPreference

14:25 amalloy: but if you really can't bear to have multiple arities, certainly the first of your suggestions

14:25 gtrak: just go with the flow man...

14:25 kaoD: technomancy: NoXML was actually JSON's original name

14:26 ChongLi: way better name

14:26 frozenlock: amalloy: thanks, I'll try with multiple arities to see what it looks like in my fns.

14:30 gerunddev: Has anyone used datomic?

14:30 bpr: a little

14:31 SegFaultAX: kaoD: When is Mongodb the right tool, though? (I'm not anti-mongo, I just have a hard time coming up with a case for it a lot of the time)

14:32 kaoD: SegFaultAX: when your data is mainly documents

14:32 ACID is not needed

14:32 and scalability is important

14:33 splunk: right, it seems like there are cases when an app's domain logic maps very closely to "document store"

14:33 gerunddev: SegFaultAX: If the bulk of your queries are not aggregate operations (like show me the average of all X)

14:33 kaoD: data mainly documents means you're not going to do much in your queries besides projection (no fancy shit like grouping and so)

14:33 gerunddev: If you want to enforce schema when you consume data, not write it

14:34 DaoWen: are there any other languages that do multimethods like clojure (i.e. on a dispatch function)?

14:34 bpr: common lisp

14:34 kaoD: DaoWen: all do, but the dispatch function is fixed :P

14:34 SegFaultAX: The only time I've really had use for mongo is when I wanted to throw a whole shitload of data somewhere and I didn't care if it was consistent at all.

14:35 kaoD: SegFaultAX: well, that's a good use case for MongoDB

14:35 gerunddev: Also if you would like to precompute much of the needed outputs and being stale is OK.

14:35 SegFaultAX: kaoD: Garbage data that you want to make queryable? Sure.

14:35 kaoD: another common use case: documents

14:36 DaoWen: bpr: what is it called in common lisp? I was looking at defmethod but it looks like it only dispatches based on the types of the parameters.

14:36 dnolen: do CL generic methods allow provide a dispatch fn?

14:36 * nDuff tends to use BaseX for places where he has a ton of documents and wants to be able to run random queries against them (including joins &c).

14:36 S11001001: dnolen: no

14:36 dnolen: yeah I didn't think so

14:36 bpr: no, they don't

14:37 i misread the question and conflated the dispatch fn with multiple dispatch

14:37 ivaraasen: dnolen: ordering the Reasoned Schemer ATM :)

14:37 dnolen: ivaraasen: cool! fun stuff

14:37 SegFaultAX: ivaraasen: I just picked that up to! :)

14:38 gerunddev: dnolen: I've been using core.logic in multimethods a lot lately.  Specifically to look at maps with complex logic that infers schema on read and passes to a version of the function that appears to be able to handle the data you are passing in.

14:38 dnolen: brain melting stuff (if you don't already know Prolog)

14:38 gerunddev: very cool

14:39 kaoD: is there a prolog-like library for clojure ?

14:39 DaoWen: kaoD: have you looked at core.logic?

14:39 hiredman: https://github.com/clojure/core.logic

14:39 gerunddev: dnolen: Fun to work in.  Thanks for all your work!

14:39 kaoD: hmmm

14:40 dnolen: gerunddev: no problem, happy to hear you're finding it useful!

14:41 SegFaultAX: dnolen: Are you talking at Clojure/West?

14:41 kaoD: conso, resto, membero, lol

14:41 dnolen: SegFaultAX: only at the miniKanren confo

14:42 SegFaultAX: dnolen: Cool!

14:42 dnolen: Did core.logic start as a port of miniKanren?

14:42 [into Clojure]

14:42 ivaraasen: dnolen: definitely looking forward to it. I read too few books anyway

14:42 dnolen: SegFaultAX: it did, the original version 2 years ago was more or less a direct translation

14:43 ~200 lines of code

14:43 clojurebot: all ur code r belong to us

14:43 AimHere: Reasoned schemer is one of the oddest tech books you'll ever read

14:43 SegFaultAX: ivaraasen: You bought the paperback version right? I bought it for kindle and it's just awful. Had to return it and order the paperback version.

14:43 dnolen: SegFaultAX: it's about 20X bigger now of course. But it also contains every major version of miniKanren in one system.

14:44 plus lots of Clojure specific niceties optimizations etc

14:44 ivaraasen: SegFaultAX: I tend to avoid Kindle books in general for the same reason

14:44 SegFaultAX: ivaraasen: Well I mean it's great for novels and stuff. But for books that you expect to have eg formatted code, I definitely agree.

14:46 dnolen: this is too good - http://twitter.com/swannodette/status/297430540959752192

14:49 ivaraasen: I wonder if I could use core.logic to implement a strategy pattern for geophysics data. would be pretty awesome

14:51 gerunddev: bpr: Sorry I dropped the thread there, but did you get to use datomic for something that went out or for exploration?

14:51 SegFaultAX: IIRC ro_st is using Datomic for his project.

14:51 bpr: gerunddev: the project i'm using datomic on is in alpha testing atm

14:52 gerunddev: i'm using it with dynamodb as storage

14:53 gerunddev: Any specific attributes of it that served your needs better than other DBs?

14:53 bpr: gerunddev: my experience with it isn't too large atm, but i do have to say that it's a joy to use from clojure

14:54 gerunddev: adding transactions back into very scalable storage is the biggest

14:55 kaoD: bpr: transactions and scalable sound antagonic to me

14:55 how does DynamoDB resolve the issue?

14:55 bpr: kaoD: if you need high write throughput, then maybe

14:55 kaoD: aaah, good point

14:57 gerunddev: brp: Cool, thanks for the info.

14:57 bpr: kaoD: we chose dynamo b/c it's hosted, and b/c it's easy to tune the throughput characteristics

14:57 that's something else that may be very nice. With datomic you can swap out your storage pretty easily

14:58 (well, relatively speaking)

14:58 kaoD: I don't know datomic, let me Google it a bit

15:00 bpr: gerunddev: i hope it's useful.

15:03 gerunddev: one pain point is that, as far as i can see, there isn't much knowledge/guidance about how to structure queries to be performant.

15:03 gerunddev: that said, queries are horizontally scalable, so that eases that pain somewhat

15:05 SegFaultAX: And also local to the querying process.

15:05 bpr: yes

15:07 gfredericks: does anybody know why this cheshire function isn't done purely with a protocol? https://github.com/dakrone/cheshire/blob/master/src/cheshire/generate.clj#L82

15:07 it has a check for the protocol at the beginning (line 85) but then a whole bunch of manual type dispatch

15:09 amalloy: gfredericks: it looks to me like he wants to include a default jsonable implementation but let you override it

15:09 gfredericks: amalloy: but you can already override protocol impls, no?

15:09 amalloy: i think so, but i doubt if it's recommended practice

15:10 gfredericks: hmm

15:10 does that suggest some sort of double protocol pattern?

15:11 amalloy: curiously, it looks like he might be failing to handle objects that implement the JSONable backing interface instead of extending the protocol

15:11 SegFaultAX: amalloy: Would a multimethod work well here?

15:11 gfredericks: too slow I imagine

15:11 amalloy: yes, probably too slow

15:12 dnolen: gfredericks: it seems weird to me - I don't see why he doesn't do all those cases in a default and then you can override by implementing the protocol for your own types.

15:12 gfredericks: dnolen: so a giant cond in an (extend-type Object ...)?

15:13 dnolen: gfredericks: yes, and then people can override if they like w/ extend-type for PersistentVector etc

15:14 dakrone: gfredericks: because it's faster than protocol dispatch

15:15 dnolen: though even that is questionable in my opinion, I think best to just have defaults like I've said and only implement JSONable on types you've constructed yourself.

15:15 dakrone: you mean non-inline implementations of a protocol

15:16 though I'd be surprised if the difference is really really large

15:16 gfredericks: dnolen: you're saying the library author or the user should avoid extending JSONable to 3rd-party types?

15:16 dakrone: dnolen: difference is about 2x

15:16 dnolen: gfredericks: if it's avoidable yes

15:16 dakrone: yeah that's about what I'd expect

15:16 gfredericks: dnolen: I'm curious why; I thought that use case was half the point of protocols over interfaces

15:17 dakrone: "I don't see why he doesn't do all those cases in a default and then you can override by implementing the protocol for your own types" - because it's slower to do that

15:17 dnolen: ^

15:18 dnolen: gfredericks: extend-type w/ protocols & types you don't control is still very close to monkey patching.

15:18 S11001001: dnolen: the haskell name for this is very good

15:18 gfredericks: it doesn't have the name-collision problem of monkey patching

15:19 S11001001: adapted here, "orphan extensions"

15:19 clojurebot: I don't understand.

15:19 gfredericks: or the "possibly mucking with internal state"

15:19 clojurebot: I have a "while" loop. Where I check some statements. If one of them is true then i need to increase one of my local var by other var.

15:19 dnolen: dakrone: yes it makes sense - you wanted that last bit of perf

15:19 amalloy: chill out, clojurebot

15:19 gfredericks: I don't think I've seen a criticism of this more-limited definition of monkey-patching

15:19 dnolen: gfredericks: it has implementation collision problems tho - key point is manipulating types *and* protocols you don't control.

15:20 gfredericks: are the downsides related to two libraries trying to make the same protocol extension?

15:20 dnolen: gfredericks: yes that's what I was referring to

15:21 gfredericks: if the user is the one doing it (rather than a 3rd-party library author) there's not much danger is there? if a 3rd-party lib were interested in the same extension that would be hard to miss I would think

15:23 dnolen: gfredericks: no I don't think the danger is very big - just pointing out there is a still some issues to consider. I think the Rust folks came up w/ a solution for this? maybe not ...

15:23 * TimMc perks up at a mention of Rust

15:23 hiredman: I had a sort of multimethod looking set of macros that would inline as a big cond

15:25 https://gist.github.com/1856326 definline for multimethods

15:26 ivaraasen: hiredman: nice

15:26 dakrone: hiredman: suppose I could give it a try with pjstadig's polyfns too now that that's out

15:27 hiredman: it is pretty gross

15:27 borkdude: what's the best source for clojure yasnippets?

15:27 hiredman: I guess the impl of defdispatched isn't in there

15:27 I wonder what happened to it

15:27 https://gist.github.com/1856336 heh, next gist

15:28 ivaraasen: hiredman: yeah, looks slightly evil. I have some horrible macros for doing operations on double arrays myself.

15:29 hiredman: you can do some neat stuff there

15:29 https://github.com/hiredman/ed25519/blob/master/src/ed25519/core.clj#L122 reads like a normal clojure for, and the code runs fine if it is

15:29 but it is actually this https://github.com/hiredman/ed25519/blob/master/src/ed25519/replacements.clj#L5

15:29 ravster: how do I get lein to remove all old versions of libraries in my ~/.m2?

15:30 ucb: borkdude: I started collecting some myself and then realised you don't really need them (maybe try/catch constructs). What sort of snippets would you have use for?

15:30 ravster: lein clean doesn't seem to do it.

15:30 borkdude: ucb I actually don't know, but I just discovered yasnippet (can you believe it) and I wanted to see what people have already made

15:30 gfredericks: clearly the best answer is ruby refinements

15:31 ucb: borkdude: ah, I see. Writing your own snippets is really easy mind you.

15:33 ivaraasen: hiredman: looks nice. these are mine: https://www.refheap.com/paste/74154847eed5cc99ddb1bf687

15:33 afill! is extremely handy

15:34 hiredman: ivaraasen: the for example there is not really intend as an array operations library, it is an experiment in optimizing clojure without rewriting it

15:48 janiczek: hi guys, i got somehow tangled in macros ... is there a normal way to do (eval `(sorted-set ~@some-map)) ? when i do (sorted-set some-map), the set has only one element - the map ... i would like its contents

15:48 mattmoss: (apply sorted-set some-map) ?

15:49 janiczek: oh! :)

15:49 thanks

15:49 mattmoss: np

15:49 gfredericks: so I'm trying to figure out how to use cheshire's generate-stream to send a JSON response without having to buffer the whole thing in memory first; it seems like this requires executing generate-stream on another thread, does that sound right?

15:49 (i.e., "after" returning the ring response with an InputStream in it)

15:52 amalloy: gfredericks: it looks like it, annoying as that is. it kinda seems like json *could* have been written to return an InputStream that produces data on demand

15:52 dakrone: gfredericks: amalloy: patches/issues welcome :)

15:52 amalloy: dakrone: nah, it's probably the fault of jackson or whatever you use, not cheshire

15:53 gfredericks: you can steal the async-sending code from https://github.com/amalloy/ring-gzip-middleware/blob/master/src/ring/middleware/gzip.clj#L10 if you want

15:53 though maybe you need something totally different; it seemed relevant but i haven't looked very closely

15:54 weavejester: There's a function in Ring piped-input-stream that allows you to connect an outputstream to an inputstream

15:54 gfredericks: that's probably the next thing I need

15:54 weavejester: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/io.clj#L10

15:54 Ring also accepts a lazy seq for its body

15:55 gfredericks: yeah that would seem like a useful feature for cheshire

15:56 dakrone: gfredericks: if you put an issue in with exactly what you need I can work on that

15:56 tmciver: weavejester: I'm trying to find a ring middleware I swear I've seen that added a content type to the Accept header based on the file extension of a uri . . .

15:56 weavejester: To the accept header?

15:57 gfredericks: dakrone: sure

15:57 tmciver: yes, of the request map

15:57 Did I dream it?

15:57 weavejester: So if someone went for /foo.txt, it would add an Accept header of text/plain to the request?

15:57 tmciver: Yes

15:58 I've written such middleware for myself but I thought I saw it in an official place. Maybe not.

15:58 weavejester: tmciver: I've heard that discussed, but I don't know if it was implemented.

15:59 tmciver: Would something like that be a sensible addition to standard ring middleware?

16:00 weavejester: tmciver: Maybe. Implement it as a third-party library first, though. See if people use it.

16:00 tmciver: Sounds good, thanks.

16:00 gfredericks: dakrone: thanks!

16:21 pppaul: i'm using ring, attempted to pipe a couchdb attachment stream (png) to my client… having issues doing this

16:21 anyone can point me in the direction of an example?

16:21 gfredericks: pppaul: what kind of stream object do you have?

16:21 pppaul: no idea

16:21 using clj-http.client

16:22 gfredericks: have you tried returning the stream directly as the :body of the ring response?

16:22 pppaul: i have tried returning the response i get from couchdb (as a whole) with and without the (response) helper functions

16:24 just tried returning the :body of my clj-http response. that didn't work

16:24 gfredericks: and what happens?

16:24 pppaul: 500 error

16:25 oh, the error may have been from #spy/d

16:25 dakrone: pppaul: are you sending {:as :stream} with your clj-http response so the result is a stream instead of a string?

16:26 pppaul: no

16:26 didn't know of this

16:26 ppppaul: (response (:body couch-response) :as :stream)

16:26 that look ok?

16:26 dakrone: something like (let [resp (:body (http/get "http://aoeu.com" {:as :stream}))] {:status 200 :body resp})

16:27 pppaul: getting 500 errors for that

16:27 dakrone making my code look like yours

16:27 works

16:27 thanks :D

16:28 dakrone: pppaul: np, glad it works for you

16:56 Foxboron: Using NREPL, how do i hide the Nrepl Error buffer when evaluation with -

16:56 C-Mx*

16:57 (with emacs ofc)

17:14 ToBeReplaced: Foxboron: not sure if it's what you mean, but maybe look at nrepl-popup-stacktraces

17:19 Foxboron: ToBeReplaced: if you evaluate a form inside a .clj file with nrepl, and its wrong. It just straight too the nRepl error buffer. nrepl-popup-stacktrace set as nil dosnt solve it either.

17:25 dabd: how to submit a bug report on a core library function?

17:25 S11001001: ~where jira

17:25 clojurebot: to be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks

17:25 S11001001: ok clojurebot

17:25 dabd: http://dev.clojure.org/jira/secure/Dashboard.jspa

17:26 amalloy: really? i'd say step one is to mention it in #clojure and find out it's not a bug at all

17:26 dabd: i found that re-seq will stack overflow if given a regex with a repetition operator {} relatively large.

17:27 S11001001: amalloy: yeah

17:27 dabd: reproduce with raw java.util.regex fns?

17:27 amalloy: dabd: (a) re-seq delegates directly to java, so it will never get fixed in clojure

17:27 dabd: say (re-seq #"someregex{1000}" somestring) -> boom

17:27 ah nvm then

17:27 hyPiRion: It's generally java's fault

17:27 S11001001: I blame java for stuff

17:27 sshack: Question. In a lein project, can I add to the class path. I'm trying to add mathematica's jlink jar file to my project so I can use clojuratica.

17:28 S11001001: it's pretty cold in Boston again

17:28 damn Java

17:28 dabd: so re-seq will compile the regex during read time

17:28 hyPiRion: Kind of like how you shouldn't do #"(a|b)+", as #"[ab]+" is better

17:28 dabd: it invokes a non tail recursive java function?

17:28 hyPiRion: Well, won't stack overflow at least

17:28 amalloy: &(re-seq #"x{1000}" (apply str (repeat 1000 "x")))

17:28 hyPiRion: yeah, that's just a known-bad regex

17:28 S11001001: ,(java.util.regex.Pattern/compile "someregex{1000}")

17:28 clojurebot: #"someregex{1000}"

17:29 dabd: amalloy actually i tried larger than 1000. It works for 1000 lol

17:29 amalloy: or, well, at least (a|aa)* is bad

17:29 dabd: i tried 1326

17:30 amalloy: dabd: works fine for me. i think the regex you posted is fine, and you're having trouble with some other regex you haven't mentioned

17:30 dabd: weird it works for your example but not in my code

17:30 amalloy: or with something else

17:30 dabd: yes probably that

17:30 hyPiRion: amalloy: Any form containing pipes are bad if they can be converted into non-pipes. In general.

17:31 Actually, I got a heisenbug due to those darn pipes

17:31 amalloy: hyPiRion: hogwash. character classes might be a little faster, but that's not the problem; (aa?)* is the same problem

17:32 hyPiRion: amalloy: That would expand to (a(|a))*, wouldn't it?

17:32 * hyPiRion shrugs

17:32 hyPiRion: Anyhow, the Java regex compiler isn't exactly superb.

17:33 dabd: maybe someone can help me with the regex?

17:33 here is the example that is blowing up the stack (re-seq #"N(:(([0]*?\.\d*)|1|0|1\.0)){1326}" (apply str "N" (repeat 1326 ":1")))

17:34 the regex is supposed to recognize N: followed by floats between 0 and 1 separated by colons

17:34 amalloy: hyPiRion: java's is as good as anyone else's, really

17:34 technomancy: I forget, is it PCRE-compatible?

17:34 amalloy: it says it is, but i know of at least one problem

17:35 sshack: Uh. Hi, is there a way to modify the classpath in a lein project?

17:35 amalloy: (perl-compatible regular expression compatible, indeed)

17:35 technomancy: amalloy: I prefer perl-compatible-compatible

17:36 sshack: who is trying to give you a jar to use that isn't in a repository?

17:36 hyPiRion: amalloy: Oh right, not many implement Thompson. Shame.

17:36 sshack: technomancy: Wolfram mathematica.

17:37 amalloy: hyPiRion: i agree, it would be nice if they could recognize when it's possible to do that

17:37 technomancy: ok, step 1 is to tell them they're wrong. =) step 2 is to get it into the local repo; that can be done with the lein-localrepo plugin or mvn install:install-file

17:38 lazybot: ⇒ ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... failed to paste: Connection to https://www.refheap.com refused

17:39 amalloy: uhoh, really? that should have timed out a long time ago

17:39 sshack: technomancy:#1, have you tried telling Stephen Wolfram he's wrong?

17:39 technomancy: #2, sounds like a solution. Okay.

17:39 technomancy: heh

17:40 clojurebot: same reason we don't hunt the wooly mammal

17:40 clojurebot: reason is , and ought only to be the slave of the passions, and can never preted to any other office than to serve and obey them -- Hume

17:40 sshack: Lein-localrepo would let me keep my jar artificet in scm, right?

17:40 technomancy: clojurebot: same reason we don't hunt the wooly mammoth?

17:40 clojurebot: the reason to use the immutable types is that it saves you from all that stuff; if you don't use them you don't get the benefit.

17:40 technomancy: grrrr

17:40 clojurebot: same reason we don't wear animal skins

17:40 clojurebot: Reason is, and ought only to be the slave of the passions, and can never preted to any other office than to serve and obey them -- Hume

17:40 technomancy: clojurebot: you're hopeless; falling back to google

17:40 clojurebot: No entiendo

17:41 amalloy: ~mammoth

17:41 clojurebot: It's greek to me.

17:41 hyPiRion: ~greek

17:41 clojurebot: I don't understand.

17:41 hyPiRion: muha.

17:41 technomancy: http://www.penny-arcade.com/comic/2005/06/06

17:41 abp: ~greek

17:41 clojurebot: No entiendo

17:42 technomancy: sshack: theoretically you can do that if you use a file:// URL in :repositories, but git is abysmally bad at storing binary files

17:42 sshack: I'm using mercurial. It's in a similar boat.

17:42 technomancy: clojurebot: woolly mammoth is <reply>same reason we don't wear animal skins or hunt the woolly mammoth: because we're not savages! http://www.penny-arcade.com/comic/2005/06/06

17:42 clojurebot: Roger.

17:43 technomancy: clojurebot: next time you better have that ready for me so I can appear quick-witted. don't screw this up.

17:43 clojurebot: multimethods are awesome!

17:43 technomancy: yes, they are, clojurebot. they are.

17:43 amalloy: ignore him, technomancy. he's just trying to get back on your good side

17:43 technomancy: haha

17:44 amalloy: i've noticed if you ask him anything about time, he finds an excuse to mention mulTIMEthods

17:44 technomancy: whoa

17:44 amalloy: clojurebot: what time is lunch?

17:44 clojurebot: time is limited

17:44 amalloy: oh well

17:44 technomancy: also a good point though

17:45 well, for us carbon-based life forms anyway

17:45 gfredericks: more importantly it wasn't what amalloy wanted

17:45 dabd: is there a way to apply reduce indexed. That is as I am reducing the sequence I also have access to the index of the current item?

17:45 hiredman: good point

17:45 clojurebot: botsnack

17:45 clojurebot: Thanks! Can I have chocolate next time

17:45 technomancy: gfredericks: yeah, he's following some twisted N laws of trolling robotics

17:45 mattmoss1: claw shrimp

17:45 amalloy: dabd: one way is to reduce over a sequence that includes indexes

17:46 dabd: but that way I have to traverse the sequence twice

17:46 hyPiRion: dabd: (reduce (fn [a [i b]]) (map-indexed vector original-seq))

17:46 amalloy: no you don't

17:46 (reduce (fn [acc [i x]] ...) 0 (map list (range) coll))

17:46 clojurebot: laziness |means| not traversing anything twice

17:46 clojurebot: You don't have to tell me twice.

17:47 gfredericks: I think he did that on purpose.

17:47 hiredman: must be

17:47 pppaul: thank you so much dakrone <3

17:48 hyPiRion: gfredericks: He dies everything on purpose.

17:48 *does

17:48 amalloy: (inc clojurebot)

17:48 lazybot: ⇒ 17

17:48 dakrone: pppaul: sure! ...err for what? :)

17:48 pppaul: ring stuff an hour ago

17:49 dabd: amalloy: thanks

17:54 sshack: technomancy: It was a good idea. But now I have to figure out some JNI stuff. It wants to interface with a native library. Sigh.

18:10 frozenlock: interesting java->clojure http://tapestryjava.blogspot.se/2013/02/crafting-code-in-clojure.html

18:24 seangrove: Hrm, curious what a clojure-first angular.js would look like

18:28 rplaca: question: what is the approved way to use rlwrap with lein repl in lein2?

18:29 and is rlwrap considered the best choice?

18:29 amalloy: rplaca: lein should bundle whatever readline behavior you need

18:29 rplaca: it doesn't seem to

18:30 hyPiRion: rplaca: REPL-y has some history bundled

18:30 rplaca: at least, up arrow does nothing when I run lein repl by itself

18:30 technomancy: that's an improvement over clojure, which does something like ^[[ when you hit up arrow =\

18:31 rplaca: technomancy: perhaps, but not exactly what I was looking for

18:31 technomancy: rplaca: what terminal emulator are you using? $TERM value?

18:31 rplaca: :)

18:31 technomancy: xterm

18:31 technomancy: do you have an ~/.inputrc?

18:32 rplaca: nope, should I?

18:32 technomancy: no, but sometimes it can interfere

18:33 does M-f, M-b, C-f, etc work?

18:34 rplaca: technomancy: yes!

18:34 how about that

18:34 is it just not remembering history somehow?

18:34 technomancy: so does history work in a single session and just gets forgotten when you restart?

18:35 rplaca: no, I was just trying it in a single session

18:35 i figure inter-session is the advanced case :)

18:35 technomancy: might raise an issue in https://github.com/trptcolin/reply

18:36 rplaca: lein repl is just launching reply with the right environment?

18:36 technomancy: more or less

18:37 rplaca: technomancy: k, thanks

18:37 technomancy: np

18:45 wizmonkyw: I have never written any clojure but I have wanted for quite some time. is the books any good or what is the best resource channel for learning clojure?

18:46 nDuff: wizmonkyw: There are several good books.

18:46 SegFaultAX: Several of the books are quite good.

18:46 nDuff: wizmonkyw: Do you find that you personally learn best starting with high-level concepts, practice, or a mix?

18:46 wizmonkyw: they arent outdated?

18:46 nDuff: wizmonkyw: Not really.

18:46 wizmonkyw: ...the language doesn't change that quickly.

18:46 wizmonkyw: I don't know.. maybe a mix

18:47 SegFaultAX: wizmonkyw: http://www.amazon.com/Clojure-Programming-Chas-Emerick/dp/1449394701/ is really good.

18:47 nDuff: http://www.clojurebook.com/ then

18:47 (same one)

18:47 SegFaultAX: wizmonkyw: For that matter so is http://www.amazon.com/Joy-Clojure-Thinking-Way/dp/1935182641/

18:48 wizmonkyw: have any of you read both?

18:48 nDuff: wizmonkyw: ...I tend to recommend JoC for folks who learn best with the high-level overview first (that includes me), Clojure Programming for everyone else.

18:48 * nDuff has read both.

18:48 SegFaultAX: wizmonkyw: I have.

18:48 nDuff: ...and they're both worth reading.

18:48 wizmonkyw: ok cool

18:48 SegFaultAX: I concur with nDuff

18:49 wizmonkyw: It also sorta depends on what kinds of projects you want to work on.

18:49 wizmonkyw: Or what stuff you find interesting.

18:49 wizmonkyw: I did some haskell for a couple of weeks, just playing and I loved it. and I write as much functional javascript style as I can. as I work with javascript single page web apps mostly. so want to learn more about functional in a modern language

18:50 gtrak: technomancy: grrrrr on slime removal from clojure-mode, took me an hour to figure out :-)

18:50 wizmonkyw: its a general purpose language right?

18:50 gtrak: but now I know how that works

18:50 nDuff: wizmonkyw: Very much so, yes.

18:51 wizmonkyw: would love to make some os x apps

18:51 palango: hey, I just read about lazy evaluation on wikipedia and tried the following: (count [1 2 3 (/ 1 0)]) and that throws and exception

18:51 wizmonkyw: that is possible through jvm right?

18:51 palango: shouldn't a lazy language run this?

18:51 wizmonkyw: or can clojure handle gui in os x?

18:51 amalloy: palango: clojure has eager evaluation

18:52 wizmonkyw: or.. is there any famous libs/frameworks for that

18:52 nDuff: wizmonkyw: Once upon a time, Apple made a big deal about the effort they were investing into making the Java experience on OS X a good one. I haven't tracked how that's held up over time.

18:52 wizmonkyw: ...that said, it's certainly possible.

18:52 wizmonkyw: ok cool will have to check

18:52 AimHere: wizmonkyw, clojure's OSX GUI support is likely the same as Java's

18:53 nDuff: Last I remember, the core Overtone folks were mostly using OS X

18:53 gtrak: palango: you'd have to thunk it all to lazy-eval it

18:53 SegFaultAX: And you know how beautiful Java's native look and feel is. Mmmm good.

18:54 nDuff: palango: ...in terms of GUI libraries, Seesaw is the premier thing.

18:54 err.

18:54 wizmonkyw: ^^

18:54 wizmonkyw: cool

18:54 clojure it is :)

18:54 back to use my emacs skills :)

18:54 used to write ruby at my last work but changed some months ago

18:54 so not the same use for emacs anymore

18:55 nDuff: wizmonkyw: The screenshots in the presentation at http://darevay.com/talks/clojurewest2012/ are taken on OS X.

18:56 wizmonkyw: ...also, that talk as a whole should give you an idea of some of the differences between what Java-interop code in Clojure looks like, vs code using native Clojure libraries.

18:56 wizmonkyw: nDuff: damn cool pictures. liked what I saw!

18:56 will really give it an honest try. looks a lot of fun

18:57 the OO languages are so the same. want to think in another way etc when I code at home

18:57 and possible future projects

18:57 there is clojurescript right? :) might do something in that but I understand it has not so much to do with clojrue but some parts rights

18:57 right

18:58 nDuff: wizmonkyw: It's a subset of the full language, pretty much.

18:58 wizmonkyw: ...there's something to be said for writing both the client and server sides of your code in Clojure. :)

18:58 gtrak: wizmonkyw: you could do like light table and run an embedded node+webkit

18:58 wizmonkyw: nDuff how is clojure (with the libs around the language etc..) as a REST api webservice?

18:59 nDuff: wizmonkyw: There are plenty of libraries/frameworks to choose from there.

18:59 wizmonkyw: cool, because I make mostly web stuff but 90% on the client

18:59 so just need web services really so could come in to use early then

18:59 anyone standing out a bit longer then the rest?

19:05 nDuff: wizmonkyw: Pretty much everything builds on Compojure, and Compojure builds on top of Ring.

19:05 wizmonkyw: ...so, even if you're going to use higher-level libraries on top of it, I suggest learning Compojure.

19:20 desertmonad: keep calm, compoje yourself, and everything will be alright.

19:22 firefux: wizmonkyw: and learn jetty

19:25 desertmonad: wizmonkyw: btw, there are several clojure books, including the one recommended earlier on Safari Books Online. The free trial is a pretty limited as I recall, but the subscription is monthly and might be worth it to you.

19:43 is there a way to reference the last evaluation result in the repl?

19:43 amalloy: *1

19:43 desertmonad: amalloy: thanks

19:47 hyPiRion: also note down *2 and *3. I'd guess you know what those stand for.

20:56 hiredman: is there an nrepl proxy/demultiplexer yet? I want to have a single nrepl end point, but route to another nrepl based on session id (or something)

23:06 john2x: what's clojure's equivalent to python's PIL (Python Imaging Library)?

23:07 ChongLi: you could use imageJ or fiji

23:07 it'

23:07 it's not the greatest

23:08 fiji might be better

23:08 http://fiji.sc/

23:18 nodename: Can anyone tell me how to create an entity with Korma and save it as a table into the database?

Logging service provided by n01se.net