#clojure log - Mar 11 2015

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

0:33 cshell: Has anyone had problems with clojure.xml and clojure.zip and clojure.data.zip with using a ton of memory even for a 3k XML doc?

1:42 tinkertron: hi does anyone here know anything about hash array mapped tries?

1:44 amalloy: cshell: how much is "a ton"? i wouldn't be surprised if it used, i dunno, a meg or so?

1:44 and how do you even know it's using up memory irretrievably, vs the garbage collector just not running yet?

1:45 cshell: amalloy: upwards of a GB - it’s more of a REPL problem I think - when you navigate down and print the children, the REPL output increases significantly

1:46 so i was navigating down to where I had 187 children - these children printed to the REPL (as they were returned from a fn i called there) had the entire zipper

1:47 amalloy: okay, so the problem is that your repl buffers output indefinitely, or what?

1:48 cshell: yeah

1:48 if I add a zip selector to just select an attribute name that’s much better

1:48 rather than the zip location

1:49 so a ton of output to the REPL

1:49 amalloy: okay, so fix your repl

1:49 the amount of stuff printed to the repl should not be a concern

1:50 macknees: hello, I am looking at using the java method .readPassword in a simple project. I do not know java.

1:50 When I call the method in my repl I get an error unless I wrap the call inside another call to

1:50 (String/valueOf call.

1:51 Even when I do the wrapping, my .readPassword method returns after I type 1 character.

1:51 cshell: amalloy: I’m not super familiar with the REPL configurations - is there a way to prevent it from spewing endless data?

1:51 macknees: I am not sure what to make of this.

1:52 I am guessing that .readPassword returns a datatype that clojure doesn't directly understand, is that correct?

1:55 ncthom91: hey all. I'm working on a project to learn clojure, and I'm doing a lot with trees and tree traversals. What's the idiomatic clojure way to approach working with trees? Represent a tree as data (i.e. nested maps) and write functions to operate on them, or somethign more like this (http://macromancy.com/2014/04/09/data-structures-clojure-trees.html) which is kind of an OO approach expressed in clojure

1:56 some of the reading I've been doing suggests that identifying a tree node as a record (defined with defrecord) will have better perf characteristics than the OO approach described in that article

1:56 cshell: ncthom91: I’ve been using Clojure Zippers (clojure.zip and clojure.data.zip) for working with my trees

1:56 amalloy: cshell: what i'm getting at is, i don't know of any repls where output buffering is a major concern. i don't know what repl you are running, so i don't know how you would fix it if it were a problem, but i kinda suspect you are running a common repl and some misunderstanding has caused you to think it is buffering too much data

1:57 cshell: amalloy: I’m using Cursive

1:57 amalloy: maybe it’s because it’s doing a walk of the tree upwards and it’s exploding exponentially

1:58 ncthom91: cshell woah. Never seen clojure.zip before, this looks sweet

1:58 cshell: :)

1:58 amalloy: cshell: talk to cfleming

1:58 since it's embedded in an ide, for all i know it does buffer indefinitely

1:59 cshell: yeah, probably :) thanks amalloy :)

2:02 macknees: Can anyone recommend an active channel for newbies?

2:03 I've tried clojure-beginners on multiple occasions, there is never any chat going on when I'm there

2:03 I have no idea where I should try

2:04 ncthom91: cshell so with clojure.zip, your trees are just raw data? like nested maps or vectors?

2:05 cshell: I think so - each call to a function returns a new structure

2:05 macknees: If you want someone to help you, you should be more descriptive or put your code example in pastebin and then paste the link here

2:05 macknees: thanks cshell, will do

2:10 here's a simple example of the .readPassword code I'm trying to get working: http://pastebin.com/QZh6fX7p

2:18 Can anyone help me understand why I can call (String/valueOf but for readPassword I have to call (.readPassword (System/console) ? I'm a bit confused by namespaces in java, I don't know what is "included by default" when I run my repl.

2:18 why does readpassword need the . macro but String/valueOf does not?

2:20 I was trying to resist learning java first, because I worried that it might make the idiomatic clojure way more foreign to me

2:20 I want to learn clojure because I have a personal interest in lisp and because clojure looked very active with lots of libraries

2:21 Jaood: macknees: only java.lang is imported by default

2:21 macknees: I started reading about it, watching rich on youtube, and looking at code and it appeals to me

2:22 thanks Jaood. I will look at java.lang and see what is included there.

2:23 I only need the .readpassword because my project will interact with a web service and I don't want the password to be saved or exposed in plaintext

2:24 when the application runs it will prompt for the password on the command line

2:25 I have done this in python and it was very easy. I think I am missing something obvious here...

2:26 Jaood, do you have any idea how a proficient java programmer would know if System.console was included under java.lang? I can look on google, but is there a more concise search engine to answer this type of question?

2:28 engblom: macknees: I have a suggestion: It looks like nobody is around able to help at this point. Just use read-line for now and later add that java thing later...

2:28 macknees: In that way you can continue with your project

2:30 macknees: engblom: thank you for that. I will look at read-line.

2:32 Jaood: macknees: they use the api docs

2:32 http://docs.oracle.com/javase/7/docs/api/

2:33 macknees: Jaood - I think there is no shortcut for me, but it was worth a try :-)

2:33 In the end at some point I will probably need more knowledge of Java

3:33 luxbock: should I read The Little Schemer before The Reasoned Schemer, or does it matter?

3:33 I see The Reasoned Schemer has a Kindle edition but The Little Schemer doesn't

3:34 actually it looks like the reviews say that the Kindle version is not very good

4:49 borkdude: has anyone here played with modules in cljsbuild? my config isn't working for me

4:49 https://www.refheap.com/98297

4:50 it ouput a single file to /target currently with the prod build

5:23 justin_smith: I thought I understood metadata, but I don't understand this error

5:23 ,(with-meta (var +) {:foo true})

5:23 clojurebot: #error{:cause "clojure.lang.Var cannot be cast to clojure.lang.IObj", :via [{:type java.lang.ClassCastException, :message "clojure.lang.Var cannot be cast to clojure.lang.IObj", :at [clojure.core$with_meta__4097 invoke "core.clj" 216]}], :trace [[clojure.core$with_meta__4097 invoke "core.clj" 216] [sandbox$eval25 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6784] [clojur...

5:24 justin_smith: how is metadata attached to vars?

5:27 zot: jkkkkjjjjkkkjjjkkkkkkkjkkj

5:27 !@#!@$!. sorry.

5:27 dysfun: anyone familiar with avout?

5:27 justin_smith: yeah, I've used it, it's pretty cool if you don't need watches of any sort

5:27 _2_tuliver: hello am new here

5:28 dysfun: justin_smith: and thereby you answer the question i was going to follow up with

5:28 well, one of them

5:28 _2_tuliver: how do we use this app

5:28 justin_smith: watches in avout don't really work

5:28 dysfun: the other one is "i can't see ensure anywhere"

5:28 _2_tuliver: helllloooooii

5:28 is anyone listining

5:28 justin_smith: _2_tuliver: clojure is a programming language

5:28 dysfun: _2_tuliver: don't be rude

5:29 justin_smith: does the lack of 'ensure' cause a problem?

5:29 _2_tuliver: so those here aint reall people?

5:29 dysfun: not everyone pays attention all the time

5:30 if you have a question, please ask with more detail than "how do we use this app?" which doesn't make any sense on its own

5:30 justin_smith: dysfun: hmm... I haven't used the avout refs to be honest.

5:30 dysfun: oh, just the atoms?

5:31 justin_smith: yeah, I used the atoms for sharing of state between app instances

5:31 it works well for small amounts of data that don't need to be instantly acted on

5:31 variations from that, ymmv

5:31 dysfun: yeah, i have...higher throughput needs

5:32 justin_smith: yeah, avout is not made for throughput

5:32 you may want to look into zeromq, hornetmq, redis...

5:32 _2_tuliver: hmmm i seee guys are very boring

5:32 you are boring

5:32 dysfun: _2_tuliver: this is a programming themed channel. what did you expect?

5:34 justin_smith: well i was hoping avout would be fact enough :/

5:34 justin_smith: dysfun: oh, it's fast

5:35 it's just not high throughput

5:35 dysfun: heh

5:35 see i'd rather have it the other way

5:35 justin_smith: latency vs. throughput is a classic optimization problem

5:35 dysfun: i'm happy for writes to take a little while

5:35 justin_smith: yeah, I think some of those other IPC options are more throughput oriented, or at least more tunable

5:36 dysfun: *sigh* i'm going to have to roll my own on top of zookeeper aren't i?

5:52 justin_smith: dysfun: no, what I am describing is a limitation due to zookeeper

5:52 zookeeper is not designed for throughput

5:52 engblom: luxbock: Regarding your question about Little Schemer, I want to first ask how well you know Clojure?

5:53 luxbock: Actually, if you want to learn Clojure by reading Little Schemer?

5:54 luxbock: Scheme and Clojure are similar in many ways, but they are not the same language at all

5:55 justin_smith: dysfun: hmm, I may need to eat my words on that - it could be that avout is more limited for throughput than zookeeper, or is not as limited as I had come to understand

5:55 dysfun: mayber I misidentified a bottleneck in my code - wouldn't be the first time

5:55 haha, mayber

6:04 cfleming: dysfun: The problem with being happy for writes to take a little while is that then they're not consistent - it goes against what something like zookeeper is designed to do. I haven't used avout, but given that it talks about MVCC and STM I guess that consistency is an important goal for them

6:09 dysfun: Actually, feel free to ignore me - that's not right at all

6:10 dysfun: isn't it?

6:10 so i'm prepared for eventual consistency and i'm willing to perform manual merges

6:10 borkdude: the embedded jetty that is run by lein ring uberjar doesn't do gzip compression by default, right?

6:11 dysfun: borkdude: you need a middleware for that

6:11 borkdude: ok

6:11 dysfun: unless you can tap into it with options. i can't remember

6:13 you can probably configure it in. it seems like something i'd expect jetty to support

6:15 cfleming: dysfun: No, it's almost exactly wrong. More consistent writes take longer - a major goal of most eventually consistent systems is write availability (Dynamo is the classic example). Datomic is probably write limited since to achieve consistency all writes go through the transactor - this makes consistency easy(ier) but limits write throughput.

6:15 dysfun: *nod*

6:16 cfleming: dysfun: If you're really ready for manual merges, what about something like cassandra? I haven't used it but I believe it exposes write consistency knobs, and those must include application merging

6:17 dysfun: cfleming: i've been put off cassandra since i've been reading aphyr's "call me maybe" series

6:17 cfleming: dysfun: I haven't read the cassandra entry there

6:17 dysfun: ah, well it rather points out that it's an AP system not a CP system

6:18 cfleming: Which is what you want if you're prepared for eventual consistency and merging, right?

6:19 dysfun: it would be, except that it just outright drops some acknowledged data

6:19 if it guaranteed at least once delivery, that'd be fine

6:19 once it's been acked, i mean

6:19 i'm perfectly happy for the db to refuse to run something

6:20 cfleming: Ok, that's not a required feature of AP systems :)

6:20 dysfun: but once something has gone in, i expect it to not be lost

6:20 cfleming: Riak, maybe?

6:20 dysfun: riak is the best off the shelf fit, yes

6:22 the weak point as far as i can see is merging. i could use avout to regulate that case

6:23 and a library for working with CRDTs

6:26 cfleming: I thought I heard that Riak supported CRDTs out of the box? Or did I imagine that?

6:26 What's the issue with merging?

6:26 iany: hi. is it possible to write a simple task scheduling library like quartz, using core.async timeout channels? just a thought.

6:27 dysfun: the only way to operate riak safely is to allow multiple versions to coexist and then merge. this is going to happen on every *read* after conflict so you'll want to update it, but you'll now do that many times and create race conditions

6:28 cfleming: dysfun: IIRC that's pretty common - Dynamo also resolved on reads

6:29 dysfun: yes. but zookeeper could be useful in dealing with that problem

6:29 cfleming: dysfun: Are you sure about the race conditions? That seems like a pretty big hole in riak, I'd be surprised.

6:29 dysfun: well it's not a hole in riak, is it?

6:29 your code dealing with it may create a race condition

6:30 distributed systems are hard, and all that

6:30 cfleming: If you can't resolve your data correctly on write conflict, then yes it is

6:30 Is it just that that code is tricky to get right, or that riak makes it impossible to do correctly?

6:30 dysfun: the former

6:30 cfleming: Ah

6:30 Then yes, it is :)

6:30 dysfun: so there's a simple strategy

6:31 you could just never delete multiple versions

6:31 but then you'll have to merge on every read request

6:31 yay

6:31 hope you don't have any hot data ;)

6:31 cfleming: Don't those merged versions get written back? It's been a while since I looked at this stuff.

6:32 dysfun: it has for me too. but as i recall you just write another version to replace them

6:32 cfleming: And that merging will also only happen on any elements that had write conflicts, correct?

6:32 Right - I don't know your use case, but that doesn't sound too bad.

6:33 dysfun: well if you want your database to always return correct answers

6:34 but you can easily see what happens when two threads try to merge the value. what if one gets hit by a GC pause and another one comes and writes another value?

6:34 where threads can be 'processes on other machines'

6:34 cfleming: Well, your merge has to be deterministic

6:35 dysfun: of course. but the point is that you have to deal with the problem

6:35 zookeeper might be a good option

6:35 cfleming: Right. That's why eventual consistency sucks from an app developer POV - they talked about this in the Dynamo paper, and said that the merging code was some of the most brittle and difficult to get right.

6:36 You're essentially pushing the consistency code from the database up to the application, where everyone has to get it right for every data model.

6:37 dysfun: which is why i'm going to record everything as CRDTs

6:37 cfleming: Once you put zookeeper in there you're forcing consistency - wouldn't a database or datomic be a better option at that stage?

6:37 (again, no idea of your use case, just asking)

6:38 dysfun: well, datomic isn't open source or even free to use in production (heh, no, i'm not running transactor-local storage in production), so it's out

6:39 given that this is a hobbyist thing

6:39 cfleming: Interesting, I thought Riak was too - I see I was wrong

6:39 commercial, that is

6:40 dysfun: you can do pretty well without commercial support

6:42 and the reason i'm looking at this is that i want to do the 'all history' thing that datomic does

6:42 postgres doesn't work terribly well for that

6:49 * dysfun has just had an evil idea

6:50 algernon: FWIW, Riak's CRDTs work fine, but Clojure library support for them isn't all that great.

6:51 with CRDTs you don't need to have multiple versions, either.

6:52 dysfun: algernon: thanks. i'll have a play

6:53 algernon: dysfun: https://github.com/bluemont/kria is the library I had reasonable success with, if you want to play with Riak from Clojure

6:54 (Welle is <3, but doesn't support a lot of Riak 2.0 things, including CRDTs, last I checked)

6:54 dysfun: thanks. i was using well before

6:54 welle*

6:54 kras: Hi everyone, I have a single datastructure which I pass it to several functions, all these functions work independently. What is the best way to parallelize these functions?

6:55 dysfun: do you require to tie the results together afterwards?

6:55 or do you just want them all to be executed?

6:56 kras: yeah, I need to collect all the results

6:56 something like fork and join

6:56 dysfun: clojure.core.reducers is pretty easy for that use case

6:56 it's a very quick win when they're truly parallelisable

6:57 justin_smith: kras: by "single datastructure" do you mean that every function uses the same immutable input data?

6:57 kras: justin_smith: yeah

6:58 dysfun: thanks I will read about it

7:05 dysfun: reducers seem to be for large collections where a single reducing function or filter function can be parallelized

7:06 justin_smith: kras: I thought you said all the functions took the same input, if so why can't they be run in parallel?

7:07 dysfun: kras: yes, it's just that in this case you generate a list of the same object and reduce that

7:07 justin_smith: dysfun: sounds like someone needs to invent pjuxt

7:07 dysfun: heh

7:07 that sounds useful actually. let me go do that now

7:08 kras: yeah pjuxt is what I am looking for

7:08 justin_smith: kras: prismatic/plumbing has something that can do this (or something very much like it)

7:08 kras: fnk

7:09 https://github.com/Prismatic/plumbing

7:09 kras: given my track record of inventing functions and then realizing that they are already in core, I thought I should ask first

7:09 justin_smith: let me check it out

7:09 justin_smith: kras: the first example for "graph" on that readme looks apropos

7:10 it can optionally be "normal", or lazy, or parallelized

7:13 kras: justin_smith: thank you

7:15 mpenet: kras: there's also tesser https://github.com/aphyr/tesser

7:16 justin_smith: mpenet: is that for parallelizing onto multiple machines?

7:16 mpenet: it supports local too

7:17 there's an explaination of pros/cons vs reducers and transducers in the readme

7:18 justin_smith: ahh, yeah fuse looks like something similar to what a parallelized fnk would do (if you fuse on one box I guess)

7:22 dysfun: roshi looks cool https://github.com/soundcloud/roshi

7:23 they're serving audio over that, which is mega cool

7:24 justin_smith: dysfun: why would they need something like that for their audio? It's not like the contents of any audio file on their system changes after initial upload.

7:24 dysfun: ah no, i misunderstood

7:24 they said 'stream', they meant more like the twitter feed sort of thing

7:25 justin_smith: yeah, different kind of stream :)

7:25 stream is so overloaded

7:26 InputStream, streaming data, event streams...

7:26 but can you cross the same event stream twice?

7:26 dysfun: that rather depends which stream came first, the chicken stream or the egg stream

7:50 TimMc: I think those are costreams.

7:53 justin_smith: just be careful not to cross the streams

8:18 AeroNotix: https://groups.google.com/forum/#!topic/clojure/UtnchSngQAY anyone got any idea for this? Been stuck on it for a day, can't think why it could be

8:21 justin_smith: AeroNotix: in the gist, you don't run rm -rf target before running make, and iclient is not compiled a second time

8:21 I have no idea what the effect of these things might be

8:21 also, any chance there is a clock skew that would effect make on the centos machine?

9:18 AeroNotix: justin_smith: I did clear target.

9:18 justin_smith: weirdly, it's not centos :P it's debian called centos for some reason

9:19 justin_smith: and what's up with the files being compiled twice anyway?

9:19 AeroNotix: justin_smith: unk, seems weird right?

9:19 I'm totally lost with this and I really am under pressure to get this working :(

9:19 justin_smith: yeah

9:19 what does the makefile do?

9:20 AeroNotix: justin_smith: lein deps uberjar

9:20 justin_smith: you don't ever need to call deps btw, it's implicit in just about every task

9:20 AeroNotix: yeah I just have it because it's easier to write the makefile explicitly (non-clojure users)

9:22 justin_smith: https://gist.github.com/AeroNotix/f65a846781357db59ced

9:22 justin_smith: calling `lein uberjar` on its own produces the same

9:22 justin_smith: I think your explicit compile step is why the files are being compiled more than once

9:22 because lein compile and lein uberjar do not use the same profile

9:23 try dropping the compile step

9:23 AeroNotix: sure

9:23 justin_smith: and it could easily happen that something compiled with the dev profile is not compatible with something compiled with prod profile

9:23 AeroNotix: hmm

9:23 justin_smith: leading to eg. two classes with the same name being compiled

9:23 AeroNotix: justin_smith: same outcome with just lein uberjar

9:23 justin_smith: weird issues like that

9:23 OK

9:23 AeroNotix: in fact, no

9:24 it fails quicker

9:24 justin_smith: heh

9:24 AeroNotix: as in, I don't think it's trying to compile them in the same way

9:24 justin_smith: anyway, the compile step is not explicitly needed either

9:24 AeroNotix: so lein compile succeeds

9:26 justin_smith: want to see the project.clj?

9:26 justin_smith: yeah

9:26 AeroNotix: https://gist.github.com/AeroNotix/711906da803cbc24260a

9:27 justin_smith: AeroNotix: I find it disturbing that your uberjar-name has the same name as the regular jar, that uberjar must generate before forming the uber

9:28 I would not be surprised if that misbehaved

9:29 AeroNotix: hmm, ok, let me try changing that too

9:29 justin_smith: oh wait, the regular jar will have the version string

9:29 AeroNotix: ok

9:29 justin_smith: just looking for anything weird here...

9:29 AeroNotix: renaming that jar didn't do anything different

9:29 it seems that uberjar is trying to compile things in the wrong order

9:29 as in, client.clj before iclient.clj

9:29 justin_smith: I wonder how :aot [...] and :profiles {:uberjar {:aot :all}} interact

9:30 AeroNotix: indeed - that's what I am thinking now

9:30 but the lein versions are the same

9:30 on my local box, it works

9:30 https://gist.github.com/AeroNotix/3f7fb81fe54b9bdd56d3

9:30 justin_smith: local machine^^

9:31 justin_smith: interesting

9:31 AeroNotix: justin_smith: https://gist.github.com/AeroNotix/19b637932d614ff4a58d other machines

9:32 for some reason it's trying to compile airos-websocket-client.client first

9:32 justin_smith: this probably isn't it, but when you have a SNAPSHOT plugin, that can cause different machines to see different versions of the deps

9:32 AeroNotix: which requires iclient.clj

9:32 justin_smith: if something was up with cider...

9:32 AeroNotix: ok sec

9:32 justin_smith: can't hurt to rule it out

9:32 AeroNotix: sure

9:33 justin_smith: no dice

9:33 justin_smith: yeah, I didn't think that one was likely

9:33 AeroNotix: oke

9:33 justin_smith: any plugins defined in profiles.clj?

9:33 AeroNotix: on my local box I've commented them all out and there's none on the other box

9:33 justin_smith: ~/.lein/profiles.clj that is, of course

9:34 clojurebot: Titim gan éirí ort.

9:34 justin_smith: plugins/deps

9:34 OK

9:34 ~/.lein/profiles.clj that

9:34 clojurebot: Huh?

9:34 justin_smith: haha

9:43 AeroNotix: what *else* could be mismatching!?

9:43 so confused

9:43 * AeroNotix reaches for strace in a confused state

9:43 justin_smith: have you compared the lein deps :tree output on both machines? I mean it *should* be identical, but couldn't hurt to check

9:43 AeroNotix: justin_smith: checking, good idea

9:43 justin_smith: yeah identical

9:43 justin_smith: I got up too early, napping. Good luck man. Sorry I couldn't be more help.

9:43 AeroNotix: justin_smith: thanks anyway

9:43 lein install works on the other machine

9:43 compiles in the correct order, for some reason uberjar isn't working on there.

9:45 justin_smith: removing the profiles section works on the other box

9:45 for some reason it was not taking into account the :aot key when doing the uberjar

10:21 fellipebrito: I'm trying to write a simple json on clojure. What I've seen so far is that clojure.data.json is a good kickstart for simple examples, however I can't use it on lein ring

10:21 AeroNotix: fellipebrito: hi, what did you try?

10:21 fellipebrito: I've added the dependence in project.clj

10:21 [org.clojure/data.json "0.2.6"]

10:21 and tried to lein ring and

10:21 user=> (:require [clojure.data.json :as json])

10:21 this is the error

10:22 CompilerException java.lang.ClassNotFoundException: clojure.data.json, compiling:(/tmp/form-init1871899143900987437.clj:1:1)

10:30 hyPiRion: fellipebrito: (require '[clojure.data.json :as json])

10:31 unless this is in the ns form

10:31 fellipebrito: thank you!

10:31 hyPiRion: no probs

10:34 dukerutledge: Morning All

10:34 quick question

10:34 I'm trying to find all of the predefined protocols in clojure

10:34 there does not seem to be a list anywhere

10:34 would anyone mind pointing me in the right direction?

10:35 eric_normand: dukerutledge: good morning

10:35 I'm not sure that exists

10:36 dukerutledge: hmm, that seems like it might be a helpful bit of documentation.

10:36 eric_normand: yeah

10:36 tyson2: should be extractable from the source code, no?

10:36 eric_normand: yeah, definitely

10:36 dukerutledge: well while I have you, do you know if there is a protocol for ordering? Akin to Haskell's Ord type class?

10:36 eric_normand: I just ran `grep -R defprotocol src` and got back a nice list

10:37 dukerutledge: good idea

10:37 eric_normand: no protocol,

10:37 but it uses the built in Java Comparable interface

10:38 dukerutledge: so it is not possible to extend data types for use in ordered maps

10:38 eric_normand: http://clojuredocs.org/clojure.core/comparator

10:38 which data types?

10:39 dukerutledge: no data type in particular, I'm just trying to understand the mechanics of these things.

10:39 eric_normand: https://clojuredocs.org/clojure.core/sorted-map-by

10:39 fellipebrito: hey folks, how can I create a string with quotes? I mean, of course I can use the \", but the return is a \" string, I'd like it to be only "

10:40 eric_normand: ,(println "\"")

10:41 clojurebot: "\n

10:42 dukerutledge: eric_normand: do you know of any reason why a protocol was not provided for ordering to simplify the interface of these functions?

10:42 eric_normand: yes

10:43 it was done for compatibility with Java, and also before protocols existed

10:43 fellipebrito: @eric_normand how can I add this into a defn

10:44 @eric_normand how can I add this into a def

10:44 eric_normand: fellipebrito: I'm not sure what you're asking

10:44 fellipebrito: (def s-with-quotes ("\""))

10:44 eric_normand: when a string is printed, it's going to show the escaped quote so it can be read back in

10:45 it does not mean the slash is in there

10:45 fellipebrito: ok

10:45 thank you! eric_normand

10:45 eric_normand: ,(count "\"")

10:45 clojurebot: 1

10:45 eric_normand: to put an actual slash, you need to escape it, too

10:46 (def s "\"") is all you need

10:46 dukerutledge: eric_normand: so it is an artifact of history. Is there any reason to not push these functions towards polymorphism? Dynamism could add a complication in evaluating ordering, but that problem already exists in the current implementation.

10:48 eric_normand: dukerutledge: I'm not sure if there is or is not a good reason, besides the limitations of the JVM

10:48 dukerutledge: I believe there are decent workarounds

10:48 about making protocols for everything, there are some who want that, but compatibility with Java interfaces is really nice

10:49 clojurescript took the notion of protocols and ran with it much farther than JVM Clojure because cljs was written after protocols

10:49 dnolen: dukerutledge: Clojure isn't built on protocols, it's built on Java interfaces - I suspect this won't change anytime soon

10:49 dukerutledge: it seems compatability could be maintained with Java interfaces. Since clojure is not self hosted it can make exceptions like this.

10:50 dnolen: dukerutledge: as eric_normand points out, for this reason rhickey bootstrapped ClojureScript on protocols

10:51 eric_normand: if you're making a new type, you can extend Comparable

10:52 dukerutledge: So is there a disconnect in how this is handled via clojurescript?

10:52 dnolen: dukerutledge: compiling to JavaScript and generating JVM bytecode or two very different implementation details

10:52 s/or/are

10:53 dukerutledge: ah I was under the impression that vanilla clojure should work across both compilation targets.

10:53 eric_normand: dukerutledge: Clojure / ClojureScript takes a very interesting (and I believe novel) approach to being hosted

10:54 it's more about having certain core features, but the host is still very much present and available

10:54 dukerutledge: are there any articles or papers that go into more depth about the varried decisions made for each of these targets and how that affects the core?

10:55 eric_normand: there's a lot written and spoken

10:55 dnolen: dukerutledge: there is a portable intersection, but Clojure can do many things that ClojureScript cannot (multithreading) and ClojureScript has a few things that are not worth breaking binary compat for (protoocols) a bear on the JVM (specify)

10:56 eric_normand: I like this talk where Rich Hickey releases cljs: https://www.youtube.com/watch?v=tVooR-dF_Ag

10:56 dukerutledge: eric_normand, dnolen: thanks for entertaining my questions.

10:57 eric_normand: this talk goes into a lot of interesting justifications for jvm decisions: https://www.youtube.com/watch?v=cPNkH-7PRTk

10:57 they both seem like "duh" now; clojure has come a long way

10:57 dukerutledge: you're welcome!

10:58 dnolen: dukerutledge: no articles or papers, lots of talks - also Clojure & ClojureScript are both fairly simplistic compilers - recursive descent mostly single pass - ClojureScript is still only a long weekend read

10:58 eric_normand: dukerutledge: someone at the react.js conference said it was "learn once, write anywhere" instead of "write once, run anywhere"

10:58 dukerutledge: dnolen: Good to know, I'll have to dig in and check it out.

11:01 eric_normand: dnolen: that reminds me of a conversation you and Will Byrd had about a spec for Clojure

11:01 dnolen: any plans for that?

11:01 dnolen: eric_normand: I already talked to Will about this

11:02 doesn't seem useful or interesting to me

11:02 it's the kind of thing academics like, that doesn't buy you much

11:02 eric_normand: I see

11:02 mdrogalis: I'm trying to come up with a way to pass a Clojure function to a Java method expecting a lambda. My idea is to find an interface, like Callable, and use proxy to instantiate it - passing a partially applied Clojure function to its constructor. Callable doesn't take any params though. Has anyone come up with a good solution for this?

11:02 dnolen: like most language specs punt on numerics

11:02 which is like pretty much what every engineer cares about!

11:03 chouser: I'm trying clj-refactor for the first time, and cljr-thread is giving me errors. Anyone have any suggestions?

11:04 mdrogalis: doesn't the Java method expect an object of a specific type? What method is it?

11:04 mdrogalis: chouser: I don't think that's the case. Are you certain?

11:04 eric_normand: mdrogalis: doesn't IFn extend Callable?

11:04 chouser: mdrogalis: Do you have a javadoc for the Java method you're trying to call?

11:05 mdrogalis: eric_normand: IFn can't act as a lambda because Java lambda's are classes with exactly one method. IFn has > 1.

11:05 eric_normand: oh

11:05 mdrogalis: chouser: I was playing around with this guy: https://github.com/real-logic/Aeron/blob/master/aeron-samples/src/main/java/uk/co/real_logic/aeron/samples/SamplesUtil.java#L129

11:06 Returns a function of 4 (untyped?) args.

11:06 dnolen: mdrogalis: why can't you just reify the interface you need and wrap the fn?

11:07 chouser: mdrogalis: I think that's returning a DataHandler

11:07 mdrogalis: dnolen: Yeah, hm. I was attempting something like that - but I didn't pick up reify.

11:07 chouser: mdrogalis: reify this: https://github.com/real-logic/Aeron/blob/master/aeron-common/src/main/java/uk/co/real_logic/aeron/common/concurrent/logbuffer/DataHandler.java

11:08 mdrogalis: Ahh. I faked myself out last night - I thought Java got a little voodoo on me and inferenced what the types ought to have been.

11:08 Thanks chouser / dnolen. That'll fix my problem.

11:10 chouser: anyone know how to work around clj-refactor errors?

11:11 mdrogalis: What errors are you seeing?

11:12 chouser: clj-refactor.el:32:1:Error: Wrong number of arguments: (lambda (old new) (\` (progn (defalias (\, old) (\, new)) (put (\, old) (quote byte-obsolete-variable) (\, new))))), 3

11:13 mdrogalis: Not even sure where to start with that one.

11:14 chouser: yeah, me either. oh well.

11:21 fellipebrito: Does anyone know how to make the lein-ring start in a different port than 3000?

11:22 kungi: fellipebrito:

11:22 clojurebot: Titim gan éirí ort.

11:22 kungi: lein ring server 4000

11:22 fellipebrito: https://github.com/weavejester/lein-ring

11:22 mpenet: anyone with experience using Selmer (good or bad)?

11:23 fellipebrito: kungi thanks

11:53 nmeum: Is there a way to find out if a character is a unicode letter?

11:54 e.g 'c', 'a' and 'ö' are unicode letters, but '1' is a digit and not a letter

11:54 {blake}: nmeum: Well, isn't it easier just to find the digits?

11:54 nmeum: I mean, since there are only 10 of those.

12:01 raek: nmeum: perhaps using Character/getType

12:01 chronno: nmeum: You can do it via interop

12:01 raek: ,(Character/getType \ö)

12:01 chronno: ,(Character/isLetter \ö)

12:02 clojurebot: 2

12:02 false

12:02 raek: ,(seq "ö")

12:02 clojurebot: (\ö)

12:02 chronno: um... weird... in my repl the isLetter call returns "true"

12:03 fellipebrito: I'm looking for a way to return a json header instead plain/text using compojure, does anyone have a start point so I can follow it? Everything I found online so far is old

12:03 nmeum: chronno: yeah, thanks

12:03 raek: ,Character/LOWERCASE_LETTER

12:03 clojurebot: 2

12:06 fellipebrito: this is my handler right now http://pastebin.com/Q0NrWhQe

12:10 ARM9: http://clojurepastebin.appspot.com/11669001 any thoughts on this behaviour?

12:10 also didn't know you could :key a deftype

12:10 jdludlow: Does anyone know of a decent example of testing a clojure web app with a test database and fixtures? The docs on use-fixtures are pretty sparse.

12:12 AeroNotix: jdludlow: what do you want to know?

12:16 jdludlow: Mainly I’m trying to figure out how to have tests that will (1) have some known data populated before and (2) have those tables truncated afterwards. In Rails terms it would be like using transactional fixtures, with either the built-in fixtures or something like FactoryGirl.

12:20 gfredericks: jdludlow: the word "fixtures" is misleading there

12:20 fixtures in clojure.test are just arbitrary functions that do things around your tests; they don't do anything specific to test data at all

12:22 jdludlow: That makes sense. So if I think of them as a generic callback I could just have my own functions that clear out my database and/or set up test data?

12:25 gfredericks: yep

12:26 also see test.check as an alternative/supplement to having lots of static test data

12:26 jdludlow: Cool, thank you

12:56 gfredericks: puredanger: looks like local vars might still print #<>

12:57 ,(with-local-vars [x 12] x)

12:57 clojurebot: #<Var: --unnamed-->

12:57 gfredericks: ^ like that

12:57 ,(atom nil) ;; checking if clojurebot is on newest code

12:57 clojurebot: #<Atom@75f250ac: nil>

12:57 gfredericks: haven't verified yet, still trying to build master

13:01 verified

13:02 magnars: chouser: that's an elisp error. Please open an issue on the github repo.

13:12 ARM9: anyone know of a fast way to get a clojure repl, lein takes like 500 years to start anything

13:13 and the clojure.jar isn't much faster

13:13 Frozenlock: ARM9: I personally have a repl running in the background at all times.

13:13 ARM9: that's nice

13:13 not a solution I'm afraid

13:13 I mean I guess hdd cache sort of helps but it's still quite slow

13:13 Frozenlock: Well, if your problem is "I don't want to wait to execute a command", yes, it's a solution.

13:14 {blake}: ARM9: SSD.

13:14 ARM9: soon blake, soon

13:14 chouser: magnars: Thanks. Looks like it's actually coming from yasnippet

13:14 ARM9: I guess I'll try to hold out until then

13:14 {blake}: ARM9: I use Cursive and it only takes a few seconds to open a REPL in it.

13:15 (On this craptastic work machine.)

13:15 ARM9: oh the jetbrains thing

13:15 I've heard about that, it's out?

13:15 puredanger: gfredericks: I didn't see anything in the commit to handle that so I assume you're right

13:15 ARM9: nvm early access

13:15 {blake}: It's in "early experience", but I've been using it exclusively for development for months.

13:16 ARM9: cool I'll give it a spin

13:17 gfredericks: puredanger: definitely a much rarer use case

13:24 ARM9: I guess I'll just try to avoid leiningen whenever possible

13:31 justin_smith: fellipebrito: print it to see the printed form

13:31 never mind, I was scrolled!

13:32 fellipebrito: justin_smith np

13:43 BigBoy0113: hey

14:09 ortuna: Is there a guide to testing core.async code with clojure.test ?

14:12 kungi: ortuna: if you find one please tell me

14:16 ortuna: @kungi I havn't found anything but I've searched. So it was leading me to believe I'm doing something wrong? Like I shouldn't test the async code directly?

14:17 justin_smith: ortuna: things I find helpful: a counter in an atom, to see how many times a loop runs, a delay or promise and a test of whether it is realized (this can effectively tell you if certain code has run or not)

14:20 seangrove: Is there a tool to visualize ns dependencies nicely? ns-dependencies is fast, but the visualization is pretty tough to use

14:21 gfredericks: I made something a while ago that emitted graphviz; it might be currently broken now though

14:22 I can't remember in what way I misused the different analyzer libs and how I was supposed to fix that

14:22 https://github.com/gfredericks/clj-usage-graph

14:22 but if you understand how to use tools.analyzer then I bet it'd be easy enough to fix

14:22 seangrove: gfredericks: I don't, but now is as good a time as any to learn, I suppose

14:23 gfredericks: by "easy" I mean that the analysis code is nicely separated from the visualization code

14:23 there were also problems with things like defrecord but hopefully it was the sort of thing that goes away when you use recent versions of the analyzer

14:24 Bronsa: gfredericks: I'll fix what needs to be fixed & open a PR

14:26 gfredericks: oh man you guys are the best

14:29 pjstadig: is anyone aware of a library that defines a tagged reader and print method for double arrays?

14:35 gfredericks: pjstadig: I suggest a pirated-themed library

14:47 shem: pjstadig: i used to frequent those libraries, but my skin just can't take it these days.

14:54 sorry about that.

15:02 Bronsa: gfredericks: there you go

15:10 gfredericks: Bronsa: omg omg omg thanks

15:11 seangrove: I'll be trying out Bronsa's PR shortly and will make a release if it works like at all

15:19 TEttinger: pjstadig: if you don't care about extreme efficiency, you can serialize it as an eval-able string

15:20 justin_smith: TEttinger: if you don't care about extreme efficiency, you can just use a vector.

15:20 TEttinger: https://github.com/tommyettinger/Ravager/blob/master/ravager/desktop/src-common/ravager/core.clj#L22-L25

15:20 that's what I did here

15:21 I'm sure there's a better way

15:21 justin_smith: I guess that sacrifices serialization / deserialization speed, but keeps the runtime perf

15:22 TEttinger: an edn reader literal would make more sense

15:31 iwillig: is there is a for version of mapv ?

15:32 forv

15:32 gfredericks: Bronsa: having trouble getting this to finish on a large project, but works great on simpler libraries

15:37 TEttinger: iwillig, seems like a simple enough macro to call vec on the result of for

15:37 but I'm half asleep still

15:39 iwillig: TEttinger: good point… i was checking to see if there was anything the standard lib

15:40 Frozenlock: iwillig: your question made me discover there is such a thing as `filterv'.

15:41 TEttinger: (doc filterv)

15:41 clojurebot: "([pred coll]); Returns a vector of the items in coll for which (pred item) returns true. pred must be free of side-effects."

15:41 TEttinger: whaaaaat

15:41 Frozenlock: And there I thought mapv was all alone. How wrong I was...

15:41 justin_smith: ,(clojure.repl/apropos #"v$")

15:41 TEttinger: (inc Frozenlock) ; I learned something new!

15:41 lazybot: ⇒ 5

15:41 clojurebot: (clojure.core/filterv clojure.core/mapv clojure.core/reduce-kv)

15:41 justin_smith: apropos is great

15:46 gfredericks: seangrove: try version 0.2.0 and let me know how it breaks :)

15:51 ane: is there a shorter way to get the first truthy from a sequence instead of (first (filter identity (...))

15:52 justin_smith: ane: some identity is slightly better

15:52 ,(some identity [nil false :a])

15:52 clojurebot: :a

15:52 justin_smith: ,(some identity [nil false nil])

15:52 clojurebot: nil

15:59 ane: sweet

16:19 gfredericks: bronsa: core.async uses [org.clojure/tools.analyzer.jvm "0.1.0-beta12"]

16:19 any guesses if I can safely override that and force it to use the newest version?

16:19 arohner: clj-http question: When I request https://ssl.google-analytics.com/ga.js (google analytics) from chrome, I get "content-encoding: gzip" in the response. When I request from clj-http, I get back uncompressed. I think I'm setting Accept-Encoding properly. any ideas why I'm getting uncompressed?

16:22 wei_: ,nil

16:22 clojurebot: nil

16:23 hiredman: https://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj#L267

16:27 arohner: hiredman: I'm setting :decompress-body false

16:29 hiredman: arohner: if you don't set any options, what does :orig-content-encoding in the response say?

16:30 arohner: :orig-content-encoding nil

16:31 appears I get the same behavior using clj-http.core/request, i.e. content-encoding header isn't set

16:31 hiredman: so google is deciding (maybe based on user agent or something?) not to serve you gzipped data

16:31 arohner: ah, user agent is an interesting idea. I'll try that

16:32 hiredman: yup. spoofing chrome properly gives me gzipped data. sigh

16:33 hiredman: those guys

16:34 arohner: https://developers.google.com/discovery/v1/performance#gzip

16:36 https://stackoverflow.com/questions/7140035/http-server-not-honoring-accept-encoding-gzip-unless-user-agent-is-known-browse

16:55 borkdude: hmm... I just discovered that symbols as functions also take a default argument... (:foo nil 1)

16:55 after 5 years of clojure...

16:55 justin_smith: and symbols even ##('foo nil 1)

16:55 lazybot: ⇒ 1

16:55 Frozenlock: s/symbols/keywords :-p

16:55 waaa

16:56 borkdude: ehm keywords yes

16:56 justin_smith: and symbols too!

16:56 borkdude: but symbols do too, wow

16:56 Frozenlock: I'm pretty sure justin_smith is a witch...

16:56 leandro713: hi, some gentleman can tell me why this doesn't works → (for [[v] (.split "abcde" "")] (keyword v))

16:56 amalloy: every couple months there's a mailing list thread like "why does ('+ 2 2) return 2?"

16:57 justin_smith: Frozenlock: no, just very curious, and I try lots of weird things, some of them even work

16:57 leandro713: ##(keyword "")

16:57 lazybot: ⇒ :

16:58 borkdude: ,(for [v (.split "abcde" "")] (keyword v))

16:58 clojurebot: (: :a :b :c :d ...)

16:58 justin_smith: it works, but that first keyword is super weird

16:58 borkdude: justin_smith it is the empty keyword

16:58 leandro713: thanks sirs

16:58 borkdude: justin_smith you don't know that? :P

16:58 justin_smith: haha

16:59 ,(symbol "")

16:59 the empty symbol is even better :)

16:59 ,((juxt identity count) (list (symbol "")))

16:59 clojurebot: [() 1]

17:00 justin_smith: rofl

17:00 ,((juxt identity count) (repeat 1000 (symbol "")))

17:00 clojurebot: [( ...) 1000]

17:01 justin_smith: for some reason I find that very funny right now

17:01 borkdude: justin_smith the empty symbol is used extensively to optimize clojurescript, in case you wondered

17:02 jk of course

17:02 justin_smith: of course

17:03 ,(eval `(def ~(symbol "") 42))

17:03 clojurebot: #'sandbox/

17:04 justin_smith: OK, that is funny

17:04 borkdude: json in clojure:

17:04 ,(let [k (keyword " foo")] {"a" k "b" k})

17:04 clojurebot: {"a" : foo, "b" : foo}

17:04 justin_smith: that's kind of evil

17:05 borkdude: even better:

17:05 ,(let [k (keyword " \"foo\"")] {"a" k "b" k})

17:05 clojurebot: {"a" : "foo", "b" : "foo"}

17:05 Frozenlock: ,(resolve (symbol ""))

17:05 clojurebot: #error{:cause "String index out of range: 0", :via [{:type java.lang.StringIndexOutOfBoundsException, :message "String index out of range: 0", :at [java.lang.String charAt "String.java" 658]}], :trace [[java.lang.String charAt "String.java" 658] [clojure.lang.Compiler maybeResolveIn "Compiler.java" 7041] [clojure.core$ns_resolve invoke "core.clj" 4202] [clojure.core$ns_resolve invoke "core.clj" 41...

17:05 Frozenlock: woops

17:05 borkdude: lol

17:06 justin_smith: Frozenlock: given the def I made, that should have worked

17:06 haha

17:06 Frozenlock: justin_smith: that's what I was counting on.

17:06 We must open bug reports at once! :-p

17:07 borkdude: Frozenlock I think I have mentioned this once to stuartsierra or someone else in the past, but then the reply was:

17:07 kidding.

17:07 justin_smith: ,@(resolve (symbol "sandbox/"))

17:07 clojurebot: 42

17:07 borkdude: the reply was: clojure doesn't prevent you from doing things wrong

17:07 Frozenlock: Why the deref?

17:08 justin_smith: Frozenlock: otherwise you just get the var

17:08 borkdude: you can fuck up things if you want

17:08 justin_smith: ,(resolve (symbol "sandbox/"))

17:08 clojurebot: #'sandbox/

17:08 Frozenlock: borkdude: yeah, using empty symbols is probably the definition of doing the wrong thing...

17:08 justin_smith: Ah right

17:08 justin_smith: classic case "doctor, it hurts when I do this" -- "OK, then don't do that"

17:12 Frozenlock: usually when you call resolve, it's to get something you can call, and that will deref automatically in the call position

17:12 well, a var will at least :)

17:13 borkdude: another way to write json:

17:13 ,{(symbol "a:") 1, (symbol "b:") 2}

17:13 clojurebot: {a: 1, b: 2}

17:14 justin_smith: ,{(symbol "a :") 1 (symbol "b :") 2}

17:14 clojurebot: {a : 1, b : 2}

17:15 justin_smith: ,(def w (symbol "{}"))

17:15 clojurebot: #'sandbox/w

17:15 justin_smith: ,w

17:15 clojurebot: {}

17:15 justin_smith: ,(type w)

17:15 clojurebot: clojure.lang.Symbol

17:21 Frozenlock: ,(w :a)

17:21 clojurebot: nil

17:21 Frozenlock: Full circle! :-p

17:21 justin_smith: ,(assoc w :a 0)

17:21 clojurebot: #error{:cause "clojure.lang.Symbol cannot be cast to clojure.lang.Associative", :via [{:type java.lang.ClassCastException, :message "clojure.lang.Symbol cannot be cast to clojure.lang.Associative", :at [clojure.lang.RT assoc "RT.java" 750]}], :trace [[clojure.lang.RT assoc "RT.java" 750] [clojure.core$assoc__4093 invoke "core.clj" 189] [sandbox$eval165 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Com...

17:26 paulswilliamsesq: Hi all

17:26 justin_smith: hello paulswilliamsesq

17:27 paulswilliamsesq: justin_smith hi

17:29 borkdude: hello paulswilliamsesq

17:29 justin_smith: ,(symbol (apply str "ba" (take (rand-int 5) (repeat "na"))))

17:29 clojurebot: banana

17:29 paulswilliamsesq: borkdude hiya

17:30 I was going to ask a question but remembered I had a REPL in which to play ;-) Might be able to answer it myself

17:30 borkdude: meanwhile I was trying to figure out how to reify/proxy Symbol to it prints differently

17:30 but I could not get it to work

17:30 justin_smith: borkdude: proxy Symbol and override to-string?

17:30 err toString

17:31 or maybe you want print-method

17:31 borkdude: justin_smith yes

17:34 eric_normand: paulswilliamsesq: that's great!

17:35 paulswilliamsesq: eric_normand hehe, yeah, I forget the repl. As a recovering imperative coder, I sometimes need a reminder ;-)

17:36 nicferrier: I need to match one of these weird symbols that the xml parser makes, eg: :a:link

17:36 core.match is barfing because the reader barfs

17:36 and when I use a match with (symbol ":a:link") in it it also barfs.

17:36 I'm guessing core.match needs static symbols.

17:37 eric_normand: paulswilliamsesq: whenever I pair, I'm always like "don't ask me, you've got the entire system right there!"

17:37 justin_smith: ,(proxy [Object] [] (toString [] "woof"))

17:37 clojurebot: #object[sandbox.proxy$java.lang.Object$ff19274a "woof"]

17:38 justin_smith: ,(str (proxy [Object] [] (toString [] "woof")))

17:38 clojurebot: "woof"

17:39 paulswilliamsesq: eric_normand yeah, it's a revelation. I hear a REPL is coming to Java but i just don't see how that will work in an statically typed OO language.

17:44 iwillig: how does one use map in the thread macro ? (-> value fn fn2 (map %())) since needs the map the coll in the last position of the s-exp

17:44 is there a good way of putting map into -> or some-> ?

17:45 gfredericks: iwillig: embed a ->>

17:45 iwillig: oh right

17:45 of course

17:45 thanks

17:45 gfredericks: ,(-> 5 inc (range) (->> (map #(* % 2))))

17:45 clojurebot: (0 2 4 6 8 ...)

17:45 iwillig: thanks gfredericks

17:47 amalloy: paulswilliamsesq: scala already has a repl. it should be fine for java really

17:47 and eclipse has had something repl-y for like a decade

17:47 justin_smith: there's beanshell, but beanshell is weird and old

17:48 borkdude: the JRuby repl is nice for Java too

17:48 justin_smith: there's also groovy

17:49 paulswilliamsesq: amalloyeah, but JRuby and Groovy are more dynamic.

17:52 amalloy: i didn't say anything about either of those

17:52 paulswilliamsesq: I can see REPL use for instantiating objects, and querying them etc.

17:52 amalloy sorry, my bad irc client use ;-)

17:53 But whilst I can declare and use functions in the clojure repl, declaring a class seems too much effort.

17:53 Saying that, I've not tried it.

17:59 gfredericks: $mail Bronsa this might constitute a bug report? https://github.com/gfredericks/tmp-bronsa

17:59 lazybot: Message saved.

18:11 nicferrier: is there a clojure (not script) dom implementation?

18:13 Bronsa: gfredericks: hah, can you see what's going wrong? https://github.com/gfredericks/clj-usage-graph/blob/master/src/com/gfredericks/clj_usage_graph/usages.clj#L21-L22

18:15 gfredericks: Bronsa: did I write this code?

18:15 Bronsa: no, I did

18:16 gfredericks: s/and/do and it should be fine, sorry :P

18:16 gfredericks: actually no it looks fine to me

18:16 oh lol

18:16 Bronsa: gfredericks: assert returns nil

18:16 gfredericks: cool thanks

18:37 justin_smith: the other day someone was asking a question about frequency detection, but I misplaced my log of it. If whoever it was is around, I just found a really good description on how to measure a single frequency bin of a fft by hand

18:40 aaelony: is there anything like http://www.clojure-toolbox.com/ for the cljs world or clj+cljs world?

18:42 justin_smith: *an fft

18:42 aaelony: justin_smith: it wasn't me but sounds interesting

18:43 justin_smith: (defn bin-level [signal probe] (apply + (map * bin probe)))

18:43 aaelony: or core.matrix perhaps?

18:43 justin_smith: where probe contains a sine wave of the frequency you want to measure, padded to the length of the signal, and signal is a sub-array of your input

18:43 you don't even need core.matrix for that, but sure

18:44 there are optimizations you can do, knowing that you are measuring multiple, related probe inputs

18:44 (also s/bin/signal in my function above)

18:44 but the basic concept is really just a sum over an element by element multiply

18:44 aaelony: very cool. wonder how performance would fare

18:45 justin_smith: this is probably the most naive way to do it possible :)

18:45 aaelony: :)

18:45 justin_smith: but it is clear, and shows exactly what the algorithm measures, which is cool

18:46 it's a specific way of testing the correlation of the input to the probe

18:46 aaelony: sounds interesting, but more interesting to me at a matrix level

18:46 mmult perhaps

18:47 justin_smith: sure, in real DSP you would be doing all of this in matrix math

18:47 you would calculate multiple probe frequencies at once, thanks to some helpful math

18:47 aaelony: agree

18:48 justin_smith: fftw - the leading impl out there - uses ocaml at compile time to derive the best coefficients for the transform

18:48 the ocaml code generates the c code when you compile

18:48 the math going on there is *way* over my head

18:49 aaelony: me too, can never know enough...

18:50 justin_smith: http://www.fftw.org/doc/Generating-your-own-code.html

18:50 "a rather sophisticated program that generates directed acyclic graphs of FFT algorithms and performs algebraic simplifications on them"

18:50 aaelony: French!

18:51 justin_smith: oh yeah, ocaml is french

18:51 aaelony: ;)

18:51 didn't know that

18:52 justin_smith: I like how they are basically like "here's the big picture, if you want to know the details, send us an email"

18:52 turbofail: i thought the fftw authors were italian

18:52 justin_smith: they're probably like "OK, how many math PHDs do you have, we need to know how much to dumb down the answer"

18:52 aaelony: hehe

18:52 justin_smith: turbofail: they use ocaml, a cousin of haskell, to generate partial calculations for their matrix ops at compile time

18:53 and yeah, it looks like you are right, at least a few of the guys behind fftw are Italian

18:53 turbofail: i was aware of that partial evaluation step

18:54 but it looks like only one of the two main authors is italian

18:55 justin_smith: aaelony: turbofail: they wacky algo they use http://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm

18:56 haha, they really have "twiddle factors" http://en.wikipedia.org/wiki/Twiddle_factor

18:56 I love that that is a real technical term

18:57 aaelony: fairly apt

18:59 justin_smith: wow, they even transpose data in the matrix in order to improve the cache coherency... fascinating stuff - faster to scramble, operate, and descramble than to do the repeated jumps

19:17 aaelony: premultiplying transposes is magical

19:27 {0}grant: Did anything come about that SICP introduction/rehashing and exercise sample book in Clj?

19:28 justin_smith: {0}grant: last I saw it was still in progress

19:29 {0}grant: MAL kinda got me interested in Clojure again, generally.

19:29 justin_smith: aaelony: it was kind of a breakthrough for me to see exactly what the fft algo does - makes me think I could pick up pink and try a few variations - gabor wavlets etc.

19:30 * {0}grant also has no idea what the deal with "Lighttable" is. Is it becoming "Eve" or is that a separate project?

19:32 justin_smith: I think eve is really separate

19:33 {0}grant: justin_smith: Interesting. Any idea if it's going to be FOSS too?

19:33 justin_smith: no, not at all. but cgranger is sometimes around here

19:33 err wait, that's not the author is it...

19:34 {0}grant: probably, if you aren't tied to a particular way of doing things too strongly, cursive + intellij is the most featureful clojure platform right now

19:35 gfredericks: does anybody know what *ns* is set to when an (ns ...) form gets eval'd?

19:35 I assume either clojure.core or user

19:35 Bronsa: user

19:35 justin_smith: I would guess user...

19:35 Bronsa: or the requiring namespace

19:35 justin_smith: but go with Bronsa's knowledge over my guess :)

19:35 {0}grant: justin_smith: I"m pretty invested in Emacs at this point; Generally interested in playing with alternatives ... doubt I'll really switch of it though. Any experience with Cider?

19:36 justin_smith: {0}grant: cider is my worst emacs experience ever. I'm a long time emacs user and gave up on cider, I just use inferior lisp now

19:36 Bronsa: e.g. in (ns foo (:require bar)) (ns bar), (ns foo) is evaluated with *ns* set to user, (ns bar) is evaluated with *ns* set to bar

19:36 gfredericks: Bronsa: my new bug is that I have to be careful what *ns* is when backticks get read :)

19:36 {0}grant: justin_smith: That's very disheartening ... I thought it tried to clone Slime's usability?

19:36 Bronsa: heh

19:37 gfredericks: I can't just slurp a whole file up through the reader at once

19:37 turbofail: justin_smith: i still use nrepl.el on a bunch of machines

19:37 Bronsa: gfredericks: true, but it looked to me that `forms` was lazy, isn't that the case?

19:38 ah, uhm

19:38 justin_smith: turbofail: yeah, I used to do that, but I just threw in the towel, there's nothing I really need that inferior lisp can't do

19:38 aaelony: justin_smith: I agree, those kind of breakthroughs are the best. There is nothing like strong coffee and deep thoughts ;)

19:39 Bronsa: gfredericks: just wrap the whole fn body in a (binding [*ns* *ns*] ..), I believe that should do it

19:39 * {0}grant guesses he'll play around with Cider and see if it's worth it, if he does side on the side of Clojure.

19:39 turbofail: justin_smith: meh. i like my autocomplete, eldoc, and source popups

19:40 Bronsa: gfredericks: and remove the doall in forms :P

19:40 uh, I already bound *ns*.

19:41 turbofail: justin_smith: i also like being able to put the result of C-x C-e into the buffer that i'm evaluating in

19:42 justin_smith: turbofail: fair enough, at this rate I'll just be shelling out to ed from the repl, then reloading the ns after editing it

19:42 (that's the likely end point, that is)

19:43 turbofail: even better would be editing using slurp and clojure.string/replace

19:44 * justin_smith is off to write a helper function that uses clojure.java.shell to open the file that defines a function, with cursor at function's definition.

19:44 justin_smith: using ed, of course

19:48 gfredericks: Bronsa: I dn't want to rely on laziness

19:50 Bronsa: gfredericks: then read a form after analyzing+eval the previous one.. cljs uses a lazy `forms-seq` btw (or used to, at least)

19:51 gfredericks: yeah I'll do something to that effect

19:56 TEttinger2: Bronsa: which awesome clojure project are you the dev of again? I can't keep track of how many cool things go on in here :)

19:56 Bronsa: TEttinger2: a bunch of tools.* contrib libraries

19:57 TEttinger2: neat

19:57 Bronsa: namely tools.reader, tools.analyzer, tools.analyzer.jvm, tools.analyzer.js and tools.emitter.jvm

19:57 TEttinger2: I'm making a super hacky hack on lazybot to get it to reconnect on network outage

20:05 gfredericks: Bronsa: is the a/empty-env a mutable thinger that gets mutateded by calling a/analyze+eval?

20:07 Bronsa: gfredericks: no it's an immutable hashmap

20:08 gfredericks: hokay

20:09 Bronsa: why did you claim that you already did (binding [*ns* *ns*])?

20:10 Bronsa: gfredericks: because I'm tired and didn't realize I wrote that in my local copy earlier while trying to figure out the cause of your exception :P

20:12 so yeah, you need to bind *ns*

20:12 gfredericks: roger

20:31 TEttinger: justin_smith: my lazybot just reconnected on its own and plugins work

20:31 the solution is the hackiest hack possible

20:32 TEttinger2: (.exec (Runtime/getRuntime) "cmd /c start cmd /c java -jar lazybot.jar")

20:33 that executes after 6 minutes of nothing being written

20:33 (no pings or pongs, no messages)

20:33 then it kills the current process

20:34 the new process then will wait 6 minutes if it fails to connect, then do the same thing, spawning a new cmd window and a new lazybot, then killing the current one

20:35 if it succeeds on a connection, it resets the timer every time it writes something, and if the timer hits 6 minutes since receiving anything or sending anything, it proceeds to spawn a new cmd, new lazybot, and kill the current one

20:54 Shayanjm: Question - isn't ((complement n) x) the same as (not (n x))?

20:55 gfredericks: I can't think of a difference

20:55 Bronsa: Shayanjm: it is

20:55 Shayanjm: so why is having complement useful?

20:55 gfredericks: you're not always calling it that way

20:55 Shayanjm: seems like another hoop to generate another function all together

20:56 Bronsa: Shayanjm: it's useful when you need to use a hof

20:56 gfredericks: it's in a family of higher order functions that are useful in certain contexts

20:56 Shayanjm: hof, Bronsa?

20:56 Bronsa: higher order function

20:56 Shayanjm: oic

20:56 gfredericks: along with partial, juxt, um

20:56 I'm blanking on the rest of them

20:56 Bronsa: comp

20:56 gfredericks: comp

20:57 Shayanjm: oh i understand now

20:59 jmpavon: hi, I made a small clojure prog to scrap a web. It works on 'lein run' but not on uberjar... looks like a laziness problem, how can I debug it? I put doall before every map and pmap but still doesn't work

21:00 gfredericks: jmpavon: why do you say it looks like a laziness problem?

21:00 it's possible, I think `lein run' tries to print the result

21:01 jmpavon: gfredericks: because it works perfect on 'lein run', I read somewhere that could mean I need to 'realize' the lazy seqs

21:01 gfredericks: problem is... I don't know where

21:04 gfredericks: jmpavon: you have a main function?

21:05 jmpavon: gfredericks: yes

21:05 gfredericks: try wrapping the last thing in that function with (prn ...)

21:05 and see if that helps

21:05 but the real fix is to change your style of code so that you don't have to worry about laziness

21:06 jmpavon: gfredericks: hmmm, last thing is a call to a function which actually prints (with print)

21:10 gfredericks: jmpavon: guess it wouldn't help then

21:10 jmpavon: so in what way doesit not work when you run the uberjar?

21:11 jmpavon: gfredericks: it doesn't print anything, but it seems to do all the queries (for the time it takes to run)

21:12 gfredericks: jmpavon: how are you running the jar?

21:13 jmpavon: gfredericks: java -jar uberjar.jar args

21:14 gfredericks: if you (println "Hallo!") at the top of main do you see that?

21:15 if the last thing your main does is print then there's no good reason for it being different from lein run

21:18 jmpavon: gfredericks: that's what I thought, actually, with doall before every map, should realize the lazy seqs, but still...

21:20 gfredericks: the only difference between lein run and the uberjar should be right at the end, so the internal doalls shouldn't make a difference

21:28 jmpavon: gfredericks: thx, I think I know where the problem might be...

21:32 enn: I have a library X which wraps Y. Ideally users of X should not need to require Y directly. However, there is a dynamic var *foo* which Y defines which I would like to be available to users of X as X/*foo*. Is there a way to "re-export" a symbol like this?

21:32 gfredericks: geez

21:33 that's a tricky one

21:33 you might be better off trying not to use dynamic vars; what sort of lib is it?

21:34 enn: an advice/tracing library

21:35 gfredericks: what's the dynamic var do?

21:35 amalloy: enn: why make it available as a dynamic var at all? if you need to allow access to it you can simply write a function (get-foo) and a macro (with-foo new-foo & body)

21:35 enn: It's bound to the currently-advised var, in the context of any advice code that is running

21:36 gfredericks: seangrove: okay 0.2.1 is pretty good I think

21:36 enn: amalloy: my plan b is (def get-foo [] y/*foo*) in x. But it would be a little nicer to just expose the var directly.

21:39 (since consumers of this library should only ever need to read the value of *foo*, never to bind it)

22:19 mmitchell: anyone know of a good way to use a java servlet filter within a ring app?

22:48 justin_smith: TEttinger2: glad that works, it would be nice to be able to reconnect the current instance instead (rebinding the connection I guess?

22:48 )

23:28 cnb_: I'm trying to create a ws using jax-ws but there is no examples on how this is done, who has created a ws using jax-ws?

23:35 sejje: What's the best way to determine if you have a dependency conflict? Some googling makes me suspect that's my issue.

23:38 justin_smith: sejje: lein deps :tree

23:38 it will show your conflicts, and suggest how to pick explicit versions

23:39 sejje: justin_smith: how does it highlight/designate conflicts?

23:39 justin_smith: sejje: it explicitly lists all conflicts

23:40 sejje: clojure won't use two versions of the same dep, "deps :tree" will tell you which version lein is choosing, and show other versions that it could have picked

23:40 Oladon: I'm attempting to follow https://mmcgrana.github.io/2010/07/develop-deploy-clojure-web-applications.html, though I realize it's somewhat out of date, but I'm getting a weird error: java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V... anyone have any ideas?

23:41 sejje: justin_smith: I don't see anything about conflicts. I'm using lein-git-deps for the newest (breaking) library--is that perhaps why I don't see conflicts?

23:43 justin_smith: sejje: I'm not sure, I have never used lein-git-deps

23:43 sejje: my standard way of using a bleeding edge lib is to check out the code, edit the version string to make it clear it is unofficial and installed locally, and run "lein install" so that I can use it as a normal dep

23:44 sejje: that way it follows the same rules everything else does in terms of dependency resolution

23:44 I have no idea what lein-git-deps does

23:44 sejje: justin_smith: alright, i'll look into that. lein-git-deps was the only/first way i could get it working, obv a new guy here. i'll look into lein install

23:45 justin_smith: much appreciated.

23:45 TEttinger: (inc justin_smith)

23:45 lazybot: ⇒ 206

23:45 justin_smith: sejje: lein install is pretty simple. You don't need to edit the version string (which is in project.clj), but that can be a sanity saving measure

23:45 sejje: eg. if someone else tries to build your code and wonders why it doesn't work, they can see from the version string it's not canonical

23:52 Oladon: Anyone?

23:53 amalloy: Oladon: get a version of clojure that's up to date. you're trying to uise some library that expects a more modern version of clojure, on a version of clojure that's five years old

23:53 sejje: justin_smith: that was simple, glad to know about it, thanks again. now back to my lein deps :tree---i'm still not seeing any explicit "conflict" messages. I get lots of "consider using these exclusions" and at least one "possibly confusing dependencies found"

23:53 amalloy: eg, depend on 1.6.0 instead of 1.2.0-beta1

23:54 Oladon: amalloy: I'm using 1.6.0

23:54 amalloy: okay, then it's the opposite. get newer versions of your libraries

23:54 the project.clj in that blog post is very outdated

23:54 Oladon: Nods, I figured it would be -- thanks, amalloy!

23:55 (inc amalloy)

23:55 lazybot: ⇒ 235

23:56 justin_smith: sejje: oh, sorry, "possibly confusing dependencies" and "consider using these exclusions" are how it describes conflicts

23:56 I forgot that it does not use the word conflict

23:57 sejje: justin_smith: haha, i have about way too many of those. i'll sort through them. in other news, grep does not seem to filter lein deps :tree output...unless these are ungodly long lines.

23:59 justin_smith: sejje: lein deps :tree 2>&1

23:59 (if you are using bash that is)

23:59 it puts some output on stderr, other on stdout, that will merge both to stdout so you can filter etc.

Logging service provided by n01se.net