#clojure log - Dec 15 2013

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

0:00 andyf_: rovar: I have often defined a function map-vals defined as (into {} (for [[k v] my-map] [k (f v)])) where my-map and f are args.

0:01 another short way is (zipmap (keys my-map) (map f (vals my-map)))

0:01 rovar: ooh

0:01 zipmap

0:02 me likey

0:02 very haskellish

0:02 my existing implementation was the into.. for comprehension

0:02 I just figured such an operation is common, and would have a clever combinator..

0:04 andyf_: It is reasonably common, but there is nothing in the core library for it. I think flatland/useful might define the into/for version for map-vals, map-keys, and map-keyvals IIRC

0:04 rovar: someone on stackoverflow had one using reduce, which might do well for large values of m

0:06 andyf_: The into version uses transients, so I would guess it would be faster than the zipmap version, which doesn't use transients, for large maps.

0:11 coventry: andrei: You can do something like htis, though. https://www.refheap.com/21941

0:12 rovar: andyf_, ya.. constructing two new lists to make a 3rd new list is most definitely slow.

0:14 andrei: coventry: Thanks!

0:21 seangrove: technomancy: Any thoughts on improving the `heroku run lein repl` experience? Or do you recommend live-repls to the running app instead?

0:24 rukor: interesting situation with clojurescript. when i have a macro in the project sources, lein cljsbuild takes 18s to compile the first time and 9s for each subsequent compilation. If i move the macro file to a library or project inside checkouts, initial compile time returns to 8s with subsequent compile times in subsecond. Is this expected?

0:26 dsrx: ,(doc zipmap)

0:26 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

0:30 murtaza52: needed help on core.async

0:31 I wanted to broadcast a msg on two different channels, how do I do that ?

0:32 bbloom: murtaza52: you can just write in to two different channels, unless you really need it to appear "simultaneous"

0:32 murtaza52: but there is also some new stuff: https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L635

0:33 murtaza52: i'd be cautions however, you *probably* don't need that

0:33 murtaza52: I have a program which receives some input from http, these have to be then processed by two different fns independently

0:33 so I wanted to relay the data to the 2 diff fns, and then get it back

0:33 rovar: murtaza52, sounds like a job for mult

0:34 what do you mean get it back, exactly?

0:34 coventry: Is mult preferred to broadcast in core.async.lab? http://clojure.github.io/core.async/#clojure.core.async.lab/broadcast

0:34 murtaza52: I mean after the data is processed, send it back on another channel, where the main thread of the program is listening

0:34 rovar: murtaza52, this is the best examples I've found for async so far : https://github.com/halgari/clojure-conj-2013-core.async-examples/blob/master/src/clojure_conj_talk/core.clj

0:35 so if your functions are passed in and out channels, and the in channels have 'tap'ped into a mult, the you're good to go

0:36 broadcast is very sweet, but if you don't need arbitrary topics, it might be overkill

0:36 pub/sub against topics, instead of just tapping into channels..

0:37 if you want to get crazy, you can even 'mix' the two output channels from your functions

0:37 into a single channel

0:39 murtaza52: rovar: thanks

0:40 currently my fns only take a coll, however now I will create a higher order one which will also take in and out channels, isnt this complecting things ?

0:40 how do u separate out the concerns

0:46 alew: is there a good way to test lein plugins that use eval-in-project?

1:39 logic_prog_: does clojurescript have something like refer-clojure :exclude ?

1:48 tony: a

2:32 dnolen: logic_prog_: yes

2:33 bbloom: todomvc in cljs is awesome

3:58 andrei: How can I get the version number of a loaded library in the repl?

3:58 justin_smith: andrei: I don't know that that is possible

3:59 lein classpath will show you the jar versions that would be pulled in

4:00 andrei: justin_smith: Ah. So version numbers are just in the filenames and are not recorded in the jars themselves?

4:01 justin_smith: they are in the project.clj

4:01 andrei: I have a library with a function that isn't public, but I'd like to expose it anyway. Is there a way to mark it as public?

4:01 justin_smith: the classpath reveals it via the path to the jar

4:01 andrei: justin_smith: Yup, I understand. But if it was recorded in the jar it should be available somehow

4:01 justin_smith: problem is project.clj has the same name

4:01 in every resource

4:02 how would you find the right one?

4:02 most projects don't define the version outside that (or the pom.xml that is generated from it)

4:03 andrei: justin_smith: Ah, oh well. Thanks!

4:04 justin_smith: And clojure doesn't read in the pom.xml file?

4:04 justin_smith: it does

4:04 but it uses it for resolving the dep

4:04 andrei: justin_smith: And then discards it?

4:04 justin_smith: it is not stored in the namespaces of the project anywhere

4:04 not that I know of

4:04 andrei: justin_smith: Oh ok. That's kinda strange. Seems like useful information to have around

4:05 justin_smith: regarding the private fn (in-ns 'other-ns) (def now-public private-fn) ; now "now-public" can be called from anywhere

4:06 also you could alter the var metadata and set :private false I think, but I find the above easier

4:06 andrei: justin_smith: Ah, awesome. Thanks!

4:17 Alfred: Can someone explain why " (iterate #(rand-int %) 10) " produces result sequence like this: " (10 8 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...) "?

4:19 progo: Alfred: rand-int is right-exclusive so the seq is bound to converge at some point

4:19 (rand-int 10) produces numbers from 0 to 9. The next application will be atmost (rand-int 9) that produces numbers from 0 to 8. And so on.

4:21 Alfred: thank you for your explanation, any solution to this problem?

4:21 progo: Alfred: do you want a steady stream of random numbers? Try 'repeatedly'

4:23 Alfred: yes, steady series of random. but does 'repeatedly' behaves differently from 'iterate'?

4:24 progo: 'iterate' reuses the result of the last function call to the next iteration. 'Repeatedly' is more for side-effects and so

4:25 Alfred: bingo. you bring up an important point of 'iterate' which i missed, thank you very much!

4:25 progo: ie. (iterate f 0) => (0 (f 0) (f (f 0)) ...); while (repeatedly f) = ((f) (f) (f) ...)

4:26 you're welcome.

4:49 markusXY: Hi, what is the recommended way to output an xml file which i modified with clojure.xml and clojure.zip? clojure.xml/emit seems to be discouraged and i am getting a npe. Does clojure.data.xml have a function that takes the same datastructure?

4:49 noprompt: bitemyapp: ah! i'm having a good time with this! wee!

4:50 bitemyapp: i guess i just couldn't appreciate it before.

4:59 bitemyapp: noprompt: :D

5:00 noprompt: bitemyapp: the only thing that's been irritating is some minor things about haskell mode.

5:01 bitemyapp: noprompt: highly fixable, keep an eye on chris done's github

5:14 markusXY: I guess i'll just rewrite my code to fit it to clojure.xml.data.

9:27 ddellacosta: why is the second argument to subvec exclusive?

9:28 any particular reason? Seems counter-intuitive to me

9:28 opqdonut: because half-open intervals make sense

9:28 a) if it were inclusive, you couldn't have an empty subvec (without using e.g. -1 as the pair for 0)

9:29 b) (subvec v start (+ start len)) is pretty elegant

9:29 c) see also http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

9:30 progo: good stuff.

9:30 ddellacosta: opqdonut: checking out that link now, thanks

9:30 opqdonut: re: a, sorry I don't get it--what do you mean an empty subvec? Like, (subvec v 4) or something?

9:31 opqdonut: ddellacosta: like (subvec v 0 0) will give you []

9:32 progo: and that's rather elegant for some of the recursive applications.

9:32 opqdonut: yeah, it's a useful corner case often

9:33 you don't have to treat the empty case specially

9:33 ddellacosta: opqdonut: okay, that is helpful, thank you! #clojure is full of awesome, as usual...

9:48 danielszmulewicz: howy

9:48 *howdy*

10:38 edw: Anyone (else) having cider blow up on them with a stack overflow when you try to eval `ns` forms in a file?

10:46 luxbock: is there a way to call an anonymous function from inside of itself?

10:47 justin_smith: luxbock: (fn named [n] (named (dec n)))

10:47 that of course will go infinitely, but you get the idea

10:47 luxbock: ah great

10:47 how did I not think to try that

10:48 justin_smith: the extra name arg is not intuitive, I found it in some docs at some point

10:50 luxbock: also wanted to ask if doing stuff like this is considered bad style: https://gist.github.com/7974531

10:50 the (eval `(mget ~@indices)) part

10:51 Bronsa: luxbock: that's (apply mget indices)

10:52 pdk: anything involving eval is bad style

10:52 luxbock: ah right

10:52 durr

10:52 Bronsa: assuming mget is a function and not a macro

10:52 luxbock: yep, it is

10:58 pepijndevos: how do I convert a js datastructure to cljs?

11:00 luxbock: https://gist.github.com/luxbock/6d8250cdc12b9eb27567

11:00 brainproxy: pepijndevos: tried js->clj ?

11:00 luxbock: does this happen because I gave the anonymous function a name? how would I fix this?

11:01 pepijndevos: brainproxy, yes. gives nil

11:02 oh durr... string keys

11:04 brainproxy: yeah, I've made that mistake too

11:04 justin_smith: luxbock: keyword application does not work that way

11:05 (:utility-fn pd [:confess :confess]) says look for :utility-fn and return [:confess :confess] if not found

11:05 you want ((:utility-fn pd) [:confess :confess])

11:06 ,(:a {} :b) ; viz

11:06 clojurebot: :b

11:06 justin_smith: ,(:a {:a 0} :b)

11:06 clojurebot: 0

11:06 luxbock: ah right, thanks

11:35 supersym: anyone got experience with the googl api client libraries? whats the deal with them, since they aren't hosted on maven or anything... can I just include this with my app for redeployment? And if so, how do I ensure they are picked up by leiningen? Do I just do a mvn local install and its good or?

11:36 seangrove: supersym: They're not especially nice

11:37 jonasen: Bronsa: andyf: experimenting with ast-indexing in eastwood https://github.com/jonase/eastwood/compare/indexing

11:37 seangrove: supersym: They're on maven though, you'll need something like https://www.refheap.com/ea915eb226642598ecfeb5ab9 in your lein dependencies

11:37 jonasen: Bronsa: andyf: It's a port of an old project of mine (https://github.com/jonase/scape)

11:38 supersym: seangrove: thank you... I figured about as much (that they weren't friendly and all... ^^)

11:54 Bronsa: jonasen: uuh nice!

11:59 adomokos: #clojure

12:07 instilled: anyone knows how to exclude ns from being read with 'lein cloverage'? I've tried 'lein cloverage -n "some-regex" but that does not work. it seems that cloverage will read the lein's :source-paths property no matter what options i'm passing to lein cloverage. any idea?

12:16 xcthulhu: Is there a way to insert if not exists in clojure?

12:16 Erm, korma

12:18 logic_prog: for a svg group element, is it possible to (1) set it's size and (2) setup a background color? or do I have to (3) put a rectangle in the svg group element?

12:18 wrong channel, sorry

12:19 though if you're an svg expert, you're welcome to answer

12:20 munderwo: Hi all, I played around with the clojure koans a little while ago and in that the jam that ran the tests stayed running and re-ran the tests when a file changed? Is there a plugin that makes that happen?

12:24 supersym: erh...clojure 'import' doesn't error on ficticious names?

12:24 no way of telling

12:27 oh... only on ns directives it does I see

12:28 instilled: xcthulhu: you can use a raw query to achieve that.

12:28 xcthulhu: logic_prog: For a <g> in sag, you can set it's dimensions, and you can also set its scale using a transformation attribute

12:28 s/sag/svg/

12:29 stupid auto-correct

12:29 Also its*, but that's just me being bad at grammar so I can't blame autocorrect on that one

12:30 You can't set the background in a <g>; I recommend using a <rect> for that

12:30 andyf_: Bronsa: ping

12:31 Bronsa: andyf_: pong

12:31 xcthulhu: instilled: Yeah, whenever I'm using an ORM, part of me just wants to cut to the chase and use RAW SQL

12:31 andyf_: jonasen: That use of datomic looks interesting. I'll have to understand it some day, but not today :-)

12:32 xcthulhu: But then someone always complains about Little Bobby Tables...

12:33 andyf_: Bronsa: I haven't been understanding all of your (very welcome) changes to Eastwood's code for calling the analyzer, and was trying to a bit more. Do you consider 'emit-form' a phase of analysis, compilation, code generation, or something else? I know that there might not always be a clear bright line between those.

12:34 Bronsa: andyf_: basically emit-form transforms an AST back into a clojure form

12:34 andyf_: the problem was this: suppose you have (defmacro x [] (println "foo"))

12:34 andyf_: Bronsa: Would you expect a CinC compiler to need emit-form? Or is it intended for debugging purposes?

12:35 Bronsa: when you call (analyze '(x) (empty-env)) it gets macroexpanded and "foo" gets printed

12:35 then we eval that, we macroexpand it again and print "foo" twice

12:35 calling emit-form on the AST returns an already macroexpanded ofmr

12:36 andyf_: I don't use emit-form in t.a.jvm or t.e.jvm, it's there for convenience

12:36 andyf_: OK, so this is part of the changes you made where the commit comment mentioned macros with side effects.

12:36 LordVanSprang: Raynes, ping

12:37 Bronsa: andyf_: yes, the other part is, if analyze has a bug and returns a wrong AST, we're now trying to eval the form corresponding to that AST

12:37 xcthulhu: Bronsa: Looks like you want "once-only" semantics for macros:

12:37 Bronsa: this makes it crash instead of simply accepting a wrong AST

12:37 xcthulhu: http://tsdh.wordpress.com/2011/09/23/once-only-evaluation-for-clojure-macros/

12:37 Bronsa: and i can fix it.

12:37 xcthulhu: Doug Hoyt would be pleased

12:38 instilled: xcthulhu: i suggest you write it as raw sql and forget about it :)

12:38 xcthulhu: instilled: Yeah, someone's gonna complain about Little Bobby Tables probably

12:38 andyf_: Bronsa: So this way of doing it should also give more complete test coverage of tools.analyzer. That's good.

12:38 xcthulhu: But so much for ORMs

12:39 Bronsa: andyf_: yeah, the failures you're seeing on core.async have nothing to do with TANAL-30, I'm investigating now the cause

12:40 andyf_: Bronsa: I am going to try adding in some code to Eastwood to catch exceptions from emit-form, and eval, so that Eastwood's messages can give everyone (but especially us) a quick indication of where the exception is occurring.

12:41 Bronsa: yeah, that would be nice. right now most of the errors will be swallowed by a "no method in multimethod -emit-form for value null" or something like that

12:43 andyf_: Bronsa: I wasn't yet thinking of making it more refined than that, just give a likely guess as to why that exception is occurring. You are saying that sometimes that same exception is thrown for different root cause than TANAL-30 example?

12:43 Bronsa: yes

12:45 andyf_: OK, I will make sure to make any error message I make for now have weasel words like "this might be because of X, but there may be other reasons", and elaborate on those more later.

12:46 Bronsa: yeah, don't spend too much time on that.

12:47 andyf_: Most of my time on Eastwood now is spent finding new categories of crashes :-)

12:47 Bronsa: and I thank you for that :P

12:47 Raynes: LordVanSprang: Hi.

12:50 LordVanSprang: Raynes, would you know where Chousuke the Finn is at?

12:51 Also, I Worship His Shadow.

12:51 Raynes: lol

12:51 gg

12:51 Bronsa: How comes the Clojure in Clojuring?

12:53 Bronsa: Raynes: working mostly on the analyzer these days, will go back on the emitter once the analyzer is stable :P

12:57 bbloom: Bronsa: mmm decomplection

13:08 pcn: Raynes: Sorry to bother you, but I have a question about importing your fs module

13:08 rather requiring it

13:09 Raynes: Sure, shoot

13:09 pcn: I've got it in my project.clj: [me.raynes/fs "1.4.5"]

13:09 but when I lein repl, I keep getting this message#<FileNotFoundException java.io.FileNotFoundException: Could not locate fs__init.class or fs.clj on classpath: >

13:10 Raynes: What code are you typing?

13:10 (require '[me.raynes.fs :as fs])

13:11 pcn: The core.clj has a (ns [...] :require [me.raynes/fs :as mrfs]

13:11 Ah me.raynes.fs not /fs

13:12 Raynes: :)

13:13 pcn: Is there a doc about what that means - the difference between lein's dependencies syntax and the require syntax?

13:13 Or as in this case how they're probably only tenuously connected?

13:14 andyf_: pcn: require uses Clojure namespaces. Leiningen uses Maven artifact/<something>

13:14 Probably Maven <group>/<artifact>

13:14 A single line in the project.clj file could pull in many many namespaces

13:16 pcn: I feel like little pitfalls like this will be a fact of life. I've been dodging java since it was created, so I'm not particularly good with its ecosystems

13:16 andyf_ thanks though, that does give me a point of reference.

13:27 '10

13:29 andyf_: pcn: If you want a form to be evaluated in the IRC channel, put a , first

13:31 egosum: andyf_: he was quoting it; he wanted to prevent evaluation ;)

13:31 pcn: Sorry, that was my tmux binding for commands leaking out :(

13:32 Raynes: really, java 1.6 doesn't have methods for hard links?

13:32 Wow

13:34 It doesn't look like seq can be run on a namespace to check for functions existing? I want to issue a loud "fail" if I can't get fs/link.

13:34 What can I do to check that?

13:35 bbloom: i wish my file browser could topologically sort files by the dependency tree, rather than alphabetically

13:36 i've gotten so used to reading big clojure files in order. i dunno what to do when there are like 10 files :-P

13:36 Raynes: pcn: Check ns-publics.

13:36 pcn: (ns-publics fs) seems to fail: CompilerException java.lang.RuntimeException: Unable to resolve symbol: fs in this context [etc.]

13:36 but the namespace is otherwise valid

13:37 TEttinger: quote it?

13:37 Raynes: That isn't a namespace. That's a symbol.

13:37 &(doc ns-publics)

13:37 lazybot: java.lang.SecurityException: You tripped the alarm! ns-publics is bad!

13:37 Raynes: ugh

13:37 pcn: l0l

13:37 TEttinger: ,(doc ns-publics)

13:37 clojurebot: "([ns]); Returns a map of the public intern mappings for the namespace."

13:37 Raynes: ,(doc the-ns)

13:37 clojurebot: "([x]); If passed a namespace, returns it. Else, when passed a symbol, returns the namespace named by it, throwing an exception if not found."

13:37 Raynes: (ns-publics (the-ns 'me.raynes.fs))

13:41 pcn: OK, I'll put the difference between the local binding and the ns on my list of things for deep thought. Thanks!

13:42 alew: Can I rely on the lein function eval-in-project to return the last form evaluated?

13:44 pepijndevos: probably

13:44 alew: It seems to want to return nil... and looking at the source I can't figure out why that would be

13:45 Bronsa: andyf_: mhph this is a problem ##`(~Object ~'Object)

13:45 lazybot: ⇒ (java.lang.Object Object)

13:46 Bronsa: ,#`(~Object ~'Object)

13:46 clojurebot: #<RuntimeException java.lang.RuntimeException: Reader tag must be a symbol>

13:46 TEttinger: ,`(~Object ~'Object)

13:46 clojurebot: (java.lang.Object Object)

13:47 Bronsa: ,#((juxt identity (partial mapv class)) `(~Object ~'java.lang.Object))

13:47 clojurebot: #<sandbox$eval115$fn__116 sandbox$eval115$fn__116@16e6127>

13:47 TEttinger: one # will return the anon fn

13:47 Bronsa: ,((juxt identity (partial mapv class)) `(~Object ~'java.lang.Object))

13:47 clojurebot: [(java.lang.Object java.lang.Object) [java.lang.Class clojure.lang.Symbol]]

13:48 TEttinger: that's uh interesting

13:48 one has Object and one has java.lang.Object...

13:48 andyf_: Bronsa: Did you find an example of that in the wild?

13:48 coventry: In what context is that a problem? Isn't it what you'd expect?

13:49 Bronsa: andyf_: yeah, this is what's breaking core.async

13:50 because the defprotocol macro returns {:on the.protocol :on-interface the.protocol ..}

13:50 except one is a symbol, the other a class

13:50 coventry: Oh, I see.

13:50 Bronsa: but when we eval that, they both get evalauted as a Class

13:50 hyPiRion: Well

13:50 ,(binding [*print-dup* true] (pr-str `(~Object ~'java.lang.Object)))

13:50 clojurebot: "(#=java.lang.Object java.lang.Object)"

13:51 Bronsa: andyf_: I don't know if I can "fix" the emit-form pass to wrap symbols with a (quote the-sym), we may need to use a different fix for avoiding a doubl eevaluation

13:51 hyPiRion: yeah well, the problem is we need to eval the form

13:52 andyf_: "We" meaning in the context of Eastwood linting

13:52 hyPiRion: oh, hm.

13:55 Bronsa: A possible solution would be to walk the form replacing all the symbols with (list 'quote symbol), but we need to do that only outside of a (quote ..) form

13:55 so clojure.walk is a no-go there

13:56 coventry: riddley will avoid walking into quoted forms.

14:00 andyf_: Bronsa: Don't mean to distract you, but regarding TANAL-30, when you say that this is a Clojure bug, do you mean that you believe that correct Clojure code for calling a fn in another namespace that is type-hinted with a Java class return value, that Java class must be imported wherever that function is called?

14:01 Bronsa: no, the opposite. the tag should get qualified

14:04 andyf_: Bronsa: Qualified meaning a full Java package.classname ? But if it is not imported, in the calling namespace, how would fully qualifying it in that way help it compile?

14:05 Pardon my ignorance, but fully qualified package.classnames can be used without importing them?

14:05 Bronsa: andyf_: it should be qualified in the def

14:06 e.g. you have (ns foo (:import bar.Baz)) (defn x ^Baz [])

14:06 andyf_: sure

14:06 ,Collection

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

14:06 Bronsa: ,java.util.Collection

14:06 clojurebot: java.util.Collection

14:07 andyf_: Got it. I've got to leave now. Thanks for the info.

14:07 Bronsa: np

14:12 ksaua: say i have a function, A, which returns a lazy sequence of numbers. How do I then create another function, B, which takes this function and lazily returns latest element of function A + last element of function B?

14:13 bbloom: ksaua: did you say that right? B is going to return something from itself?

14:14 ksaua: B is another function that returns a lazy seq

14:14 so, yes?

14:14 bbloom: can you be more concrete about what you want? ie provide an example

14:14 ksaua: sure

14:15 I have a function, A, which returns the following lazy sequence [1 2 3 4 5 7 ...], How do I create a function B, which takes A and returns [1 3 6 10 15 22 ..]

14:16 if A had instead returned [1 1 1 1] B(A) would return the lazy seq [1 2 3 4]

14:16 bbloom: first, vectors with square brackets are not lazy. you're looking for parens :-)

14:17 ksaua: heh, yeah, i mean parens

14:17 bbloom: so you want to basically want to sum A0+A1, A1+A2, A2+A3 ... etc yes?

14:17 ksaua: Yup

14:18 coventry: ,(doc reductions)

14:18 ash__: ^-- any storm users here?

14:18 clojurebot: "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."

14:18 bbloom: ,(let [a [1 2 3 4 5 7]] (map + a (cons 0 a)))

14:18 clojurebot: (1 3 5 7 9 ...)

14:19 AeroNotix: Emacs/Clojure/Flymake, what do people use?

14:19 bbloom: something like that?

14:19 but yeah, reductions is awesome too

14:19 oh you don't want parallel sums, you want successive sums

14:20 yeah, use reductions

14:20 ksaua: Hm, sure, as long as that works where a is a lazy sequence, which i guess it does because map and cons is lazy?

14:20 bbloom: cons is not lazy

14:20 ,(reductions + 0 [1 2 3 4 5 7])

14:20 clojurebot: (0 1 3 6 10 ...)

14:21 bbloom: ,(next (reductions + 0 [1 2 3 4 5 7]))

14:21 clojurebot: (1 3 6 10 15 ...)

14:21 bbloom: cons will preserve laziness past the non-lazy, prepended head

14:21 ksaua: okay

14:21 I'll try reductions, seems to be what im looking for, thank you so much

15:21 logic_prog: how does parsec handle operator precedence?

15:27 pepijndevos: logic_prog #haskell?

15:28 coventry: Incidentally, what *is* the right channel for svg questions?

15:29 hyPiRion: the graphics format?

15:29 logic_prog: pepijndevos: good call

15:29 #svg

15:29 coventry: logic_prog: Thanks. hyPiRion: Yeah.

15:29 rovar: I'm trying to work through the clojure emacs to tutorial.. and it's telling me to execute tests via C-x C--

15:30 hyPiRion: coventry: Well, I'd guess if there's not a lot of activity within #svg, you could piggyback on some JS framework using svg for visualisation.

15:30 their IRC channel, that is

15:30 rovar: ooh nm

15:31 noncom: ,(name nil)

15:31 clojurebot: #<NullPointerException java.lang.NullPointerException>

15:31 dav: Is there a way to get lein test to print even when a test succeeds?

15:31 Some verbosity level or something?

15:31 noncom: there is a problem ^ (name nil) gives up an exception. is there a way to write something like (or (name passed-name-maybe-nil) "default-name") ?

15:32 without risking an excetion

15:32 oh just realized that i can put (or) inside (name)!

15:32 nevertheless, it is weird that it gives an NPE

15:33 eric_normand: noncom: (if x (name x) "default")

15:33 coventry: ,(doc fnil)

15:33 clojurebot: "([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."

15:33 justin_smith: ,((fnil name "nil") nil)

15:33 clojurebot: "nil"

15:33 justin_smith: ,((fnil name "nil") :ok)

15:33 clojurebot: "ok"

15:34 noncom: yes, i know the (if) approach but it is not as cool as (or)!

15:34 eric_normand: noncom: fnil is good, too

15:35 noncom: hmmm (fnil).. never heard of that.. but actually i just realized i can do (name (or smth "default")).

15:35 howwever thanks for the insight on fnil

15:35 is there any library for clojure that performs intelligent seatch like one in SublimeText?

15:35 s/seatch/search

15:36 like picking strings by relevence from a pool of strings

15:39 pepijndevos: define relevance

15:40 noncom: pepinjndevos: uhm.. it is hard to explain exactly.. just if you have used SublimeText 2 text search, then you would know. in its menus, it sorts items in the menu list in the order starting from the best matches

15:41 the point is that if you enter like "pc" and you have "popcorn" and "peach cake" and "pc" and "pocket" then the order will be like "pc" "pocket" "popcorn" "peach cake"

15:42 justin_smith: sounds like levenstein difference

15:42 http://en.wikipedia.org/wiki/Levenshtein_distance sp. sic

15:42 http://clojuredocs.org/incanter/1.2.3-SNAPSHOT/incanter.stats/levenshtein-distance

15:42 looks like it comes with incanter?

15:43 amalloy: i doubt if it's levenshtein distance, since then "id" would sort before "pocket", which seems pretty rubbish

15:43 justin_smith: ahh

15:43 good point

15:43 I wonder how iswitchb does it

15:44 it reminds me of that behavior

15:44 pepijndevos: i remember fish does this too

15:44 coventry: justin_smith: I haven't looked, but my impression is that time of last visit plays a big role there.

15:45 justin_smith: coventry: fair enough, but even on a virgin checkout it does sort matches based on character subset

15:45 cYmen: How do I install cider when this marmelade thing doesn't work?

15:46 coventry: justin_smith: Is it doing some kind of fuzzy matching? I thought it was just exact substrings.

15:46 justin_smith: cYmen: wait for them to fix it, or install package from a git checkout

15:46 coventry: it does fuzzy matching with my config

15:46 though that may be because of some customization I forgot I did

15:47 noncom: hmm, people menthion Levenshtein distance here too : https://www.sublimetext.com/forum/viewtopic.php?t=5661

15:47 mabye it is some superset of it

15:47 or a subset :D

15:47 justin_smith: yeah, some parameterized generalization from it maybe

15:48 hyPiRion: I'd guess they use Damerau-Levenshtein

15:48 And perhaps take into account keyboard layout

15:48 dav: Is there a way to get lein test to print even when a test succeeds?

15:49 coventry: cYmen: https://github.com/clojure-emacs/cider#manual

15:50 hyPiRion: dav: Are you interested in feedback from a test, or actually doing printing?

15:51 dav: hyPiRion: having some generic printing while tests are running

15:51 hyPiRion: ah

15:52 dav: hyPiRion: I ended up writing this macro: http://paste.debian.net/71019/

15:52 hyPiRion: wondering if there's a better way.

15:53 hyPiRion: dav: huh, `lein test` would print out e.g. "lein test my-lib.test.combined" whenever running that test namespace

15:54 cYmen: coventry: My lack of prior emacs knowledge makes it hard to fill in the gaps. :)

15:54 hyPiRion: along with total tests + assertions, plus failures and errors

15:55 coventry: cYmen: Try this: mkdir -p ~/.emacs.d/vendor && cd ~/.emacs.d/vendor && git clone https://github.com/clojure-emacs/cider.git

15:55 cYmen: Then put (add-to-list 'load-path "~/emacs.d/vendor") (require 'cider) in your ~/.emacs file.

15:56 Oh, you'll have to install clojure-mode, dash.el and pkg-info the same way. What a pain.

15:56 cYmen: Oh, I can't use the ones from marmalade?

15:56 coventry: If they install, that should be fine.

15:57 cYmen: In that case I don't understand what's wrong.

15:57 File error: Cannot open load file, cider

15:57 pinkwerks: I'm missing some basic let usage and hiccup, how do i get both :h1 & :h2 to generate with this form? I only get the :h2 back : (let [dbval 1] [:h1 dbval] [:h2 dbval])

15:58 cYmen: Oh wait, I put it in my init.el

15:59 As expected that didn't change anything.

15:59 amalloy: pinkwerks: the forms in a 'let are evaluated for side effects, and only the last one is actually returned, so of course hiccup can't render the :h1 (which you never returned)

15:59 instead, hiccup lets you use lists to group things: (let [dbval 1] (list [:h1 dbval] [:h2 dbval]))

16:00 coventry: cYmen: Oh, you'll probably need (add-to-list 'load-path "~/emacs.d/vendor/cider") if that's the path you put the cider repository on. Someone should PR the README to clarify.

16:00 pinkwerks: amalloy : now I understand thanks

16:01 cYmen: coventry: I tried that as well, didn't work either. d)

16:01 :)

16:02 coventry: C-h v load-path RET. Check that it's actually getting on the load-path.

16:03 cYmen: Hm..that list is very long.

16:03 coventry: Search with C-s. :-)

16:04 xeqi: cYmen: are you using ~/emacs.d or ~/.emacs.d ?

16:05 in the (add-to-list load-path ..)

16:05 cYmen: xeqi: That was exactly the error that I just corrected. How do you know? :)

16:05 xeqi: ran through the manual install yesterday

16:05 cYmen: haha

16:06 xeqi: something else to be PR/fixed in the cider readme

16:06 cYmen: xeqi: Other things I should know? Like why can't I just M-x cider-jack-in now? :/

16:07 Is that some shortcut that marmalade has added on my other machines?

16:07 xeqi: I usually open a clojure file and C-c C-j

16:07 emaphis: in reference to cYmen's question, would it be unwise to install cider from Melpa?

16:08 xeqi: works for me with the clojure-mode, dash.el and pkg-info from marmalade, and cider manually downloaded off melpa

16:08 coventry: In nrepl, at least, C-c M-j just does nrepl-jack-in.

16:08 xeqi: emaphis: I'm not big on running from master (like melpa does)

16:09 cYmen: Well, according to my emacs that symbols definition is void.

16:09 xeqi: C-c M-j is what I mean

16:09 emaphis: Yes, I just leave Melpa alone. :-)

16:09 cYmen: C-c M-j in a clojure file seems to work.

16:10 *sigh*

16:10 Using tools you only understand a fraction of, so much fun.

16:10 justin_smith: and what function does that run?

16:10 M-x describe-key

16:11 cYmen: nrepl-jack-in

16:13 So...what does this mean?

16:13 amalloy: justin_smith: why M-x describe-key rather than C-h k?

16:13 justin_smith: they do the same thing, no?

16:13 I find for learners presenting the name rather than mnemonic helps

16:13 just a style thing I guess

16:14 amalloy: makes sense, i suppose

16:14 coventry: cYmen: It's unclear why nrepl-jack-in failed the first time and C-c M-j worked the second, since they are apparently doing the same thing.

16:14 cYmen: The first time I tried cider-jack-in.

16:14 justin_smith: amalloy: also it will tell you the key shortcut after any m-x command, so that info is still provided

16:14 coventry: Ah, right.

16:14 Bronsa: me too.

16:15 cYmen: Which works on the machines where I installed it with marmalade.

16:15 justin_smith: sounds like version skew

16:16 cYmen: Probably. Anyway, as usual, thanks for the great support.

16:18 bbloom: ,(bit-or 5) ; aw sad face

16:18 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/bit-or>

16:21 letstest: Hi - I am bumbling along trying to learn clojure. I am trying to use a clojure library in the repl. how would I use a particular library. The one I am trying to use is this - "https://github.com/jdhollis/forecast-clojure"

16:21 what do I have to do in the repl to have access to it?

16:23 justin_smith: letstest: I would say adding the maven coords to your project.clj :dependencies vector

16:23 (in a project)

16:23 letstest: oh ok. I have to add it to a project. I can't just try using it without that

16:23 justin_smith: and then setting up the credentials in your ~/.lein/profiles.clj as they show in their readme

16:23 well you CAN, but that is not easier

16:24 letstest: alright. I will do that

16:24 justin_smith: (there is alembic / pomegranate)

16:24 letstest: i.e put it in project.clj

16:24 thank you

16:24 justin_smith: then for the key, probably easier to go the env var way, if you know how to set a shell environment variable

16:24 np

16:25 letstest: going to try it now

16:30 justin_smith - i did that and got into the repl and saw it being downloaded. But, when I do (require '[forecast-clojure.core :as forecast]) - i get back nil. What does that mean?

16:31 coventry: letstest: successful import.

16:31 letstest: oh! thanks coventry but when i use it (forecast "37.8267" "-122.423")

16:32 i get this CompilerException java.lang.RuntimeException: Unable to resolve symbol: forecast in this context, compiling:(/tmp/form-init1327445774299770078.clj:1:1)

16:32 shouldnt that have worked?

16:32 coventry: letstest: The readme is wrong. Try replacing forecast with forecast/forecast (guessing.)

16:33 letstest: i get back nil if i do that

16:33 user=> (forecast/forecast "37.8267" "-122.423") nil

16:35 coventry: Probably means the api call failed somehow. https://github.com/jdhollis/forecast-clojure/blob/master/src/forecast_clojure/core.clj#L14

16:35 letstest: oh

16:35 i may have set my environment variable wrong

16:35 strange error if that is the case

16:37 noncom: why it is not that a namespace is a clojure datastructure, why is it something so different?

16:37 bbloom: noncom: a few reasons. for one thing, they are mutable

16:37 by design

16:38 noncom: also, they exist before clojure is fully bootstrapped, so there's that too

16:38 justin_smith: letstest: you can set env variables with (System/setenv "var" "new-value")

16:38 without restarting that is

16:39 noncom: hmm, i see, yes that makes..

16:39 i have to learn more about environments though

16:40 oh you were talking to a different person1

16:45 letstest_: justin_smith - do i need someting in my project.clj to do that?

16:46 justin_smith: no, that works right in the repl

16:46 as long as the library looks in the env for the credentials that should work

16:46 letstest_: i get "CompilerException java.lang.IllegalArgumentException: No matching method: setenv, compiling:(/tmp/form-init1327445774299770078.clj:1:1) "

16:46 justin_smith: erm...

16:47 I could have sworn there was a setenv

16:47 I was likely confused, sorry

16:47 letstest_: np

16:48 would be useful if there was :)

16:48 justin_smith: I guess as far as the jvm is concerned mutating the env is non-portable

16:49 letstest_: oh

16:50 hyPiRion: justin_smith: yes, that's exactly the reason

16:52 letstest_: i still cant get that library to work, just gives me nil

16:53 is there a tutorial or article that that someone can point me to show how to write a similar library? Maybe I have to write my own

16:53 justin_smith: if you do (System/getenv "FORECAST_KEY") does that show your api key?

16:53 letstest_: let me try

16:53 oh - nope

16:53 gives me nil

16:53 justin_smith: env FORECAST_KEY=supersecret lein repl

16:54 letstest_: ok

16:54 justin_smith: try that from the command line in the top level of your project

16:54 and in the repl that runs you should be able to use the API

16:55 letstest_: That worked!!

16:55 thank you!

16:55 justin_smith: awesome

16:55 np

16:55 so you can start your process with the var explicitly that way, or put the env key in your profiles.clj (as it mentions in that project's docs)

16:56 letstest_: i actually did try profiles.clj but it didnt work. Will fool around with the environment variables. i have had similar problems before

16:57 now that i know this works. The issue is on my end

17:26 rukor: qz: /quit

17:31 noncom: how do i stop a server in nrepl?

17:32 (stop-server) accepts some args map but not what (start-server) returns

17:32 justin_smith: (System/exit 0) ?

17:32 noncom: :)

17:32 justin_smith: or do you mean some subprocess?

17:32 noncom: yeah, in my app i start an nrepl server

17:32 justin_smith: ahh

17:33 does it have a .stop method by any chance?

17:33 there should be a thread / process like object somewhere in what it returns, I would assume

17:34 noncom: (start-server) returns something like #clojure.tools.nrepl.server.Server{:server-socket ..bunch of stufff goes here ...}

17:34 what is that?

17:34 #Server{} what datatype is this?

17:35 oh its a defrecord..

17:35 never used one

17:35 justin_smith: a record from defrecord

17:35 https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/server.clj#L52

17:35 this is the code for stop-server

17:35 may help

17:35 noncom: so you were completely right, it is Cloaseble

17:36 justin_smith: well my first guess was .stop

17:36 but yeah

17:37 yeah, now that I look at the definition for Server defstruct, it implements close from Closeable

17:38 noncom: and i look too and see that (stop-server) must work with it. so it is a mistake somewhere in my code

17:39 justin_smith: .close calls stop-server

18:00 danielszmulewicz: technomancy: ping

18:06 logic_prog: is there a good explaination somewhere of how clojure's ident rules work (as implemented in emacs) ?

18:12 is there a way I can construct a symbol/object/something-magical that clojure.edn/read-string can not construct?

18:12 context: I'm annotating some clojure sexps, and I need certain annotations (that include data) that can not be part of any valid clojure sexp

18:12 bbloom: logic_prog: trivially:

18:12 ,(Object.)

18:12 clojurebot: #<Object java.lang.Object@844a08>

18:13 logic_prog: *thinking*

18:13 bbloom: specifically, that's what the #<...> syntax is for

18:13 logic_prog: bbloom: googling for "#<...>" might be slightly troublesome

18:13 can you point me at readin gmaterial?

18:14 emaphis: logic_prog: the rules for indenting lisp have aways been what emacs does. :-)

18:14 logic_prog: emphais: it's like how python the interpreter is python the spec?

18:15 bbloom: logic_prog: the magic word you're looking for is "unreadable"

18:15 logic_prog: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L109

18:15 emaphis: logic_prog: good analogy. ;)

18:16 hyPiRion: ,#<this is not readable by the reader>

18:16 clojurebot: #<RuntimeException java.lang.RuntimeException: Unreadable form>

18:19 logic_prog: does clojure provide some type of ordered list that has an O(log n) time insert?

18:20 vector's insert into the middle is O(n) time afaik

18:20 I want an ordered list where I can say "insert this after the n-th element" and have it be O(log n) time

18:23 akhudek: logic_prog: sorted-may or sorted-set

18:24 logic_prog: that should be lorted-map

18:24 logic_prog: you may wish to invest in a new keyboard :-)

18:24 akhudek: logic_prog: work fingers, sorted-map

18:24 logic_prog: or a spell checker

18:24 `cbp: or invest less in alchohol

18:26 bbloom: logic_prog: see also https://github.com/clojure/data.avl

18:26 logic_prog: https://github.com/clojure/data.avl <-- is this meant to be empty?

18:26 justin_smith: logic_prog: insertion in a vector is guaranteed O(<7)

18:26 not O(n)

18:27 logic_prog: it's not O(length of vector?) ?

18:27 justin_smith: no

18:27 logic_prog: oh, this is chunks o 32 ?

18:27 justin_smith: O(7) is the worst case

18:27 yeah

18:27 gozala: Bronsa: I’d like to ask a question about tools.reader

18:27 bbloom: logic_prog: heh, sorry. guess michal didn't move the code over yet: https://github.com/michalmarczyk/avl.clj

18:27 logic_prog: so it can use chunks of 32 even if I don't insert 32 elements at once?

18:27 justin_smith: wait this has nothing to do with chunking

18:27 gozala: Bronsa: where does it saves column, line info for booleans and nil ?

18:27 Bronsa: gozala: tell me

18:27 justin_smith: it is the same tree structure used to implement persistent hashmaps

18:27 Bronsa: gozala: it doesn't

18:28 gozala: booleans and nil cannot have metadata attached to them

18:28 akhudek: there is also https://github.com/clojure/data.priority-map

18:28 logic_prog: bbloom: interesting, I always thought people used red-back trees, not avl for persistent trees

18:28 justin_smith: logic_prog: it uses a tree, max 7 levels deep, so assoc to a random index is at worst O(7)

18:28 gozala: Bronsa: so there is no source map for those then ?

18:28 bbloom: logic_prog: if you need sorted with nth, that's what AVL is for

18:28 Bronsa: gozala: there's no way to attach such info to objects that cannot have metadata attached to them

18:28 bbloom: logic_prog: clojure does use red/black trees

18:28 logic_prog: justin_smith : sure, but how do you get that insertion is only O(7) ?

18:28 amalloy: O(7) is like...a crime against notation

18:28 justin_smith: O(<7)

18:28 logic_prog: say, I have a list of 3200 elements

18:29 justin_smith: 7 is the worst case

18:29 because it is a tree

18:29 logic_prog: and I insert a element at index 6

18:29 amalloy: O(<7) is even worse

18:29 justin_smith: 7 levels deep max

18:29 gozala: Bronsa: yeah I was hoping there was some clever hack I could not come up with :/

18:29 logic_prog: it seems like that all the remainig elemnts gets "shifted"

18:29 pcn: Is there a way to loop, and ahve the initial bindings replaced, that doesn't rely on recur being in tail position?

18:29 logic_prog: I can believe that replace an elemento f a vector is O(log_32 n)

18:29 justin_smith: amalloy: just qouting "clojure high performance programming"

18:29 Bronsa: gozala: no I'm sorry

18:29 logic_prog: but I'm not convinced that insertion is O(log_32 n)

18:29 justin_smith: logic_prog: why would assoc shift anything?

18:30 yo uare replacing a single index

18:30 amalloy: justin_smith: all of those directly translate to "O(1) but i don't understand big-O notation"

18:30 justin_smith: amalloy: OK

18:30 logic_prog: because I'm inserting into an array, it had 3200 elements. Now it has 3201 elements

18:30 justin_smith: logic_prog: it is not an array

18:30 logic_prog: and if I insert at index 6, it seems that indices 7 to 3200 might all get shifted

18:30 justin_smith: it is a tree

18:30 gozala: Bronsa: tnx

18:30 justin_smith: no, no shifting

18:30 logic_prog: damn it, where is the source for clojure vectors ? :-)

18:30 justin_smith: that is the point of the tree

18:30 hyPiRion: clojurebot: PersistentVector.java?

18:30 clojurebot: Cool story bro.

18:31 amalloy: logic_prog: you can't insert-and-shift into a vector cheaply, only insert-replacing

18:31 logic_prog: amalloy: so "insert-and-shift" is O(n), correct?

18:31 justin_smith: amalloy: I think he knows that, and that's why he thought insert would not be cheap

18:31 logic_prog: this is what I'm confused about

18:31 hyPiRion: logic_prog: yes

18:31 justin_smith: logic_prog: I thought you meant insert as in "put this at that index", not "shift everything else to the right"

18:31 logic_prog: okay. great. Now, back to earlier question: is there some sorted-structure, where I can say "insert after k-th" elemnet, and it takes me only O(log n), where there is n elmeents in the collection.

18:32 hyPiRion: clojurebot: PersistentVector is https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentVector.java

18:32 clojurebot: You don't have to tell me twice.

18:32 logic_prog: justin_smith: sorry for not being clear, I meant "insert" not as in "replace"

18:32 hyPiRion: oh man

18:32 logic_prog: clojurebot has attitude

18:32 next thing you know, it's going to pass the turing test

18:32 andyf_: amalloy: I know what you mean, but O(7) = O(1) clearly from the definition of big-O notation.

18:32 amalloy: andyf_: yes, of course

18:32 hyPiRion: logic_prog: ordered structure or sorted?

18:33 logic_prog: hyPiRion: imagine I'm implementing a really giantass todo list

18:33 and I click on an item, and I say "insert todo right below this item"

18:33 amalloy: but equally it's O(1024), and introducing arbitrary integers doesn't make things any clearer

18:33 hyPiRion: logic_prog: ordered then

18:33 andyf_: By the same argument O(log_32 n) is a crime against big-O notation.

18:33 hyPiRion: logic_prog: http://infoscience.epfl.ch/record/169879/files/RMTrees.pdf

18:33 logic_prog: andyf_: how is O(log_32 n) bad? it's the same as O(log n)

18:33 hyPiRion: O(log_32 n) insert-at times

18:33 andyf_: but often constant factors are important to call out explicitly

18:33 akhudek: https://github.com/clojure/core.rrb-vector

18:34 hyPiRion: (inc akhudek)

18:34 lazybot: ⇒ 1

18:34 andyf_: logic_prog: O(log_32 n) = O(log n), I know. I'm just commenting on amalloy's comment that O(7) is a crime against the notation.

18:34 logic_prog: O(<7) is weird

18:34 bbloom: logic_prog: use a sorted set and simply set the new item's key to the average of the target item & next item's keys

18:35 andyf_: Oh, and if O(7) is being used to apply to hash sets and hash maps in Clojure, they are only that *if* there are no hash collisions.

18:35 When there are hash collisions, hash sets and hash maps can be O(n).

18:35 justin_smith: andyf_: if you are using numeric index, how would you collide?

18:35 we were talking vectors

18:35 andyf_: justin_smith: Sorry, I didn't read carefully enough which data structures the O(7) was being applied to.

18:36 logic_prog: hyPiRion, akhudek: nice, thanks, rrb vectors look like what I want

18:36 andyf_: Also anyone who wants to use the avl.clj library should do some performance testing -- last time I checked (but didn't publish results), their constant factors make them noticeably slower than other Clojure data structures I was comparing against.

18:38 amalloy: I don't think the 7 is arbitrary. We often use instructions executed as a time measurement, but on most recent processors the number of accesses to DRAM, i.e. cache misses, is often a far better measure of observed performance. I know that doesn't alter your argument on big-O notation abuse, but 7 cache misses is a lot better than 25 cache misses in practice.

18:39 joshua___: Hmm. I'm using lighttable and running functions that take a while to finish. Lighttable seems to be quitting mid-computation. Do I have to use a different IDE or have I just done something wrong?

18:44 logic_prog: rrb-vectors are badas

18:44 s

18:46 andyf_: The answer is probably staring me right in the face, but I don't see it. If I clone the Github repo for contrib lib data.zip, create a simple project.clj for it, start 'lein repl', and (require '[clojure.data.zip :as z]) it gives an error. There is no such error in a different project if I make data.zip a dependency.

18:48 justin_smith: andyf_: maybe you need to set the :src-path for leiningen?

18:48 andyf_: justin_smith: I have :source-paths set to ["src/main/clojure"], which works for other Contrib libs

18:49 justin_smith: yeah, that looks right for clojure.data.zip

18:49 andyf_: There is something different about data.zip, though.

18:50 Bronsa: andyf_: I was wondering why that didn't work too

18:51 andyf_: Hmm. Could it be because there is an empty file src/test/clojure/clojure/data/zip.clj, and I also have :test-paths set to ["src/test/clojure"] ???

18:51 lazybot: andyf_: Oh, absolutely.

18:52 Bronsa: if lazybot says so.

18:52 andyf_: That empty file should probably be removed from the repo, or filled in with something useful, but it does seem odd that this happens as it is.

18:53 Yep, removing that empty file and the require works fine.

18:54 back later...

19:12 joshua___: Are there any good tutorials on setting up Clojure in Eclipse?

19:26 coventry: joshua___: I hear Cursive Just Works.

19:46 justin_smith: cursive is intellij, but yeah I have heard good things about it

19:47 it is only available as a preview beta that you have to sign up for at the moment

19:50 akhudek: I use cursive, it's very good. Don't think you need to sign up. Just follow the instructions in the getting started docs of the EAP.

19:51 joshua___: Oh no. I think I found out why my long running function wasn't returning results in lighttable. Tried the same thing in Eclipse and got: OutOfMemoryError Java heap space org.sqlite.NativeDB.column_text (NativeDB.java:-2).

19:51 akhudek: It's aimed to eventually be a paid plugin though, good to know if you were expecting something open source. Think it's worth the money though.

20:00 bitemyapp: yissss, have Halloway's attention on the Datomic documentation issues.

20:00 I have a glimmer of hope, once again!

20:02 talios: is datomic's documentation as wonderful as clojures then?

20:03 bitemyapp: Datomic is really nice, but there is some implicit/semi-implicit information that needs documented.

20:25 logic_prog: why is (. js/console log (= :asdf "asdf")) false if cljs treats keywords as strings

20:26 [edit: in the context of cljs, not clj] ==> why is (. js/console log (= :asdf "asdf")) false if cljs treats keywords as strings

20:26 justin_smith: logic_prog: does it treat them as (name kw) or as (str kw)?

20:26 amalloy: logic_prog: "cljs treats keywords as strings" is very inaccurate

20:26 justin_smith: because if it treats them as (str kw) you want ":asdf"

20:26 logic_prog: amalloy: how are keywords stored in cljs?

20:26 I thought they were just js strings, but apparently not

20:27 cljs ==> (. js/console log (= :asdf ":asdf")) <- also returns false

20:27 amalloy: i know at one time they were implemented such that :foo was a string containing some wild unicode character followed by the characters f o o

20:27 there was some talk about making them real objects; i don't know if that ever happened

20:28 in any case how they're stored in the underlying representation isn't very important; what matters is that the clojure functions such as = treat them as keywords

20:28 logic_prog: https://groups.google.com/forum/#!topic/clojurescript/bSFK6CEE3PE <-- has this been integrated into mainline?

20:29 I have another dumbass question

20:29 in practice, when do "cljs treats keywords as strings" actually matter ?

20:31 amalloy: logic_prog: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/compiler.clj#L206 is how cljs emits keyword literals

20:31 Bronsa: andyf_: I just used eastwood on tools.analyzer[.jvm] and found out some misplaced docstrings :)

20:32 amalloy: new cljs.core.Keyword(...)

20:32 bbloom: logic_prog: even before keywords were reified, that wouldn't have worked

20:33 logic_prog: previously, keywords had some marker bytes in the front of the string

20:33 logic_prog: (thinking)

20:33 suppose I have a = :abc

20:33 is there a way to define b = "some crap"

20:33 such that (= a b) returns true?

20:33 (in cljs)

20:33 bbloom: logic_prog: no. why do you want that anyway?

20:34 logic_prog: bbloom: good. I don't want that.

20:34 "keywords are implemented as strings" confused me

20:34 bbloom: where does it say that?

20:34 it's outdated

20:35 logic_prog: damn it, I actually can't find a refenrece

20:35 I thought it was https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure , but it no longer states that

20:35 I am happy now.

20:35 bbloom: logic_prog: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure/_compare/2b66b7399e036d0703a07dd94f07bf7489b4579f...e524b1bf81bf1f14c06689670f77585816c653e2

20:36 logic_prog: bbloom: ah, thanks :-)

20:37 bitemyapp: new hpmor.com chapters out.

20:45 andyf_: Bronsa: Yep, there are a fair number of those throughout Clojure contrib libraries, and even one in Clojure itself.

20:46 I am (perhaps unrealistically) hoping to get Clojure core to adopt Eastwood or some variation of it for running automated checks on contrib libraries at some point.

20:47 Bronsa: yeah, I just ran ./lint.sh. Looks like all the failing libraries now are due to known bugs/limitations

20:47 bbloom: andyf_: have you submitted patches for the misplaced docstrings? :-)

20:47 andyf_: bbloom: I could, but that might lead them to believe there was no use to adopt a linter for regular automated checks :-)

20:48 bbloom: andyf_: i ran a blame & it makes me feel better about myself that rich screws up the docstring order sometimes too :-P

20:48 andyf_: bbloom: Call it passive aggressive or whatever you like, but I'd prefer if they were able to see that there are things that could bear cleaning up, and an automated process in place going forward is a good idea worth putting in place.

20:49 My original motivation for this was not the misplaced docstrings, but the deftest's with repeated names that silently cause some unit tests never to be run.

20:50 bbloom: andyf_: have you talked to alex miller? he's probably the place to start w/ discussions about improving process

20:50 andyf_: bbloom: I agree, and he and I have a good working relationship. I don't think I'm ready to approach him on this topic just yet, until Eastwood is a bit more tested.

20:51 ddellacosta: eavesdropping on you guys...what is Eastwood?

20:51 andyf_: A lint tool for Clojure

20:51 bbloom: andyf_: always good to start conversations early. i'd tell him your goal & ask him what it would take to get you there

20:51 andyf_: https://github.com/jonase/eastwood

20:51 ddellacosta: ah, https://github.com/jonase/eastwood

20:51 right, thanks andyf_

20:51 bbloom: andyf_: if you wait until you feel it's 100% done, you'll just be disappointed when you sit around waiting for them to act

20:51 andyf_: bbloom: I am used to waiting 1 year for things

20:51 bbloom: andyf_: i think the lines not dots thing applies here too :-)

20:52 andyf_: bbloom: Lines not dots thing?

20:52 bbloom: andyf_: http://www.bothsidesofthetable.com/2010/11/15/invest-in-lines-not-dots/ <- it's about investments/startups, but it's true of mental/emotional investments too :-)

20:53 andyf_: bbloom: I am mentally and emotionally prepared for Clojure core never to adopt an automated process for this, ever.

20:54 I just hope they do.

20:54 bbloom: andyf_: so then you won't be disappointed now, just like you won't be disappointed later :-)

20:55 andyf_: set up a cron job to run it yourself, then submit a dozen patches & label each one with "This was discovered by Eastwood. A tools.analyzer based lint tool."

20:55 andyf_: bbloom: If they don't within a year or so, I'll consider it.

20:55 bbloom: heh ok

20:57 amalloy: was eastwood always based on tools.analyzer? i thought it was around before then

20:58 bbloom: amalloy: appears not https://github.com/jonase/eastwood/commit/3789514b6729f0dd15ee01443207cfef0cbafdd6

20:58 amalloy: oh wow, that's a really recent change

20:58 andyf_: I started updating it to tools.analyzer about 2 weeks ago, and Nicola has been fixing tools.analyzer bugs like a man possessed since then.

20:58 bbloom: (inc bronsa)

20:58 lazybot: ⇒ 14

21:00 andyf_: Look at the graph on this page: http://dev.clojure.org/jira/browse/TANAL

21:01 Every time the green line goes up, that is Bronsa's work :-)

21:02 hyPiRion: And by the looks of it, every time the red line goes up, that is andyf_'s work :p

21:02 Bronsa: andyf_: looks like eastwood just found a bug in core.logic *highfive*

21:02 (inc andyf_)

21:02 lazybot: ⇒ 1

21:03 joshua___: How do I check the amount of memory java has in clojure. I'd be trying to say something like long heapMaxSize = Runtime.getRuntime().maxMemory(); but can't figure out how to write the first part of that in Clojure

21:03 Bronsa: well.

21:03 (inc andyf)

21:03 lazybot: ⇒ 1

21:03 andyf_: Yeah, I haven't been on IRC much.

21:03 *highfive* Which bug?

21:04 bbloom: Bronsa: how is having all the separate components working out? i'd imagine well, but i'm wondering if there were some subtle circular references lurking in clojure in a way that is annoying

21:04 hyPiRion: ,(.. Runtime getRuntime maxMemory) ; joshua___

21:04 clojurebot: #<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>

21:04 hyPiRion: well, that should work in a repl

21:06 Bronsa: andyf_: I have absolutely no idea what's the cause, but it looks like some macro in core.logic is emitting a (partition some-var), and partition doesn't have a 1-arity

21:06 andyf_: Oh, yeah, I've seen that one before. It seems to be buried in a macro somewhere.

21:06 Bronsa: bbloom: it's definitely easier to develop this way as every component is a box -- not as easy to debug as I would have imagined though

21:07 joshua___: Thanks hyPirion

21:07 bbloom: Bronsa: what causes the debugging challenge?

21:07 Bronsa: bbloom: this https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/jvm.clj#L349-L355

21:08 bbloom: in short, there are some passes that depend on each other so multiple runs are required

21:08 when a bug is buried in one of those passes, it's difficult to reproduce the exact condition that caused the bug

21:08 bbloom: Bronsa: hmm, i'd imagine

21:09 Bronsa: do you have a validation pass of some sort?

21:09 or multiple, a la the nanopass language definitions idea?

21:10 Bronsa: bbloom: I have a validation pass but that's probably not what you're thinking

21:10 bbloom: if i'm reading this correctly, "cycling" is just a fixed point rewrite?

21:10 Bronsa: it checks for wrong arities & throws, tries to reflect methods etc

21:11 bbloom: ah ok so that's user level validation, not internal consistency checks for the analyzer

21:11 makes sense

21:11 Bronsa: typeos: https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/passes.clj#L67-L72

21:12 s/Shortrand/Shorthand/g

21:12 s/typeos/typos

21:12 Bronsa: duh. thanks

21:13 bbloom: Bronsa: i'd be interested to know if some of the "cyclic" passes would be better addressed with a dynamic reference attribute grammar

21:14 my experiments there: https://github.com/brandonbloom/ascribe

21:14 i didn't do a cyclic evaluator, but it's pretty straightforward

21:14 Bronsa: bbloom: I'll look into that and let you know

21:15 I'm off to sleep now

21:15 bbloom: Bronsa: the literature is a pretty deep rabbit hole

21:15 "Extensible Compiler Construction" is a good entry point

21:15 Bronsa: noted

21:15 bbloom: and this is a good practical implementation: https://code.google.com/p/kiama/wiki/Attribution

21:16 (scala)

21:16 joshua___: Has anyone else had the problem that the :jvm-opts ["-d64" "-Xmx2g"] part of there lein project file was being ignored when using Eclipse as the IDE?

21:16 bbloom: Bronsa: gnight

21:17 hyPiRion: joshua___: may be that you're using an old leiningen version. Try out :jvm-opts ^:replace ["-d64" "-Xmx2g"]

21:20 pcn: Heya, I've got a function that I want to run in a thread, and have it handle I/O. Most of the program is using core.async, and I'm wondering if I should be able to do this with thread from core.async, or if there's a better way to have something sit on a channel and perform disk I/O based on that?

21:21 hyPiRion: pcn: maybe agents? See http://clojure.org/agents

21:24 joshua___: hyPiRion: thank you for trying to help, unfortunately adding the :^replace didn't seem to do anything. Still getting the same totaltMemory

21:27 pcn: hyPiRion: Maybe? I want this to close a file if it's not written to in a very short time, so I don't think I want it to be an agent since it responds to async events as well as looping

21:28 Is there an easy way to just start a thread aside from agents?

21:30 ddellacosta: compsci question: if I have a sorting algorithm, like an insertion sort, which is considered stable, but then I go and use Clojure's immutable data structures to implement it, can it still be considered stable? Seems like the answer would be "no," but I'm not sure it's even a meaningful distinction when using immutable data structures, is it?

21:31 amalloy: ddellacosta: i can't imagine why the answer would be no

21:31 "stable" doesn't mean something like "moves no memory around", it means that an already-sorted list, if sorted again, will not be reordered

21:33 ddellacosta: amalloy: okay, thank you. I think I'm struggling with the definition of "stability," so this is helpful.

21:34 amalloy: http://en.wikipedia.org/wiki/Sorting_algorithm#Stability

21:34 hyPiRion: joshua___: I guess it's not a problem with the jvm opts, but how the jvm tends to ignore memory bounds

21:34 ddellacosta: amalloy: yeah, I was looking at that, thanks

21:35 hyPiRion: ddellacosta: it just means that if an element a appears before another element b in the list, and they "are equal", then, a will be before b in a sorted list

21:37 ddellacosta: hyPiRion: yes, I think I was getting confused by all the examples I've been reviewing, which exclusively seem to use c/c++ pointer semantics to move things around. But after considering what you and amalloy are saying, I realize that I'm confused about the difference between where things reside in memory and the implications of the algorithm itself--it doesn't matter so much *how* you swap something--whether that be by generating a

21:37 new immutable data structure that swaps the elements vs. swapping their pointer addresses--but where you place them relative to other elements, in terms of what the sorting algorithm dictates.

21:38 hyPiRion: ddellacosta: exactly :)

21:38 andyf_: ddellacosta: You can force any sorting algorithm to be stable by first comparing the items, and if they are equal, compare their original indices in the input list as a tie-breaker. But some sorting algorithms can be made stable without adding that extra info or doing the extra comparison.

21:38 amalloy: indeed. sorting algorithms really can't have anything to do with memory, since you can apply the same algorithm to bits of paper in the real world

21:39 ddellacosta: andyf_: gotcha...thanks.

21:39 andyf_: The Computer History Museum in San Jose has a great collection of mechanical radix sorters built by IBM in the early and mid 20th century

21:40 ddellacosta: oh, I was just reading about radix sort in the Cormen book...very cool. Would love to see that.

21:40 andyf_: You feed it a stack of punched cards, and adjust a setting to indicate which 'column' contains the digit you want to sort on, and it takes an input stack of cards and sorts them into 10 separate piles.

21:41 Recursion on the next digit position requires manual intervention :-)

21:41 ddellacosta: oh wow, haha

21:51 pcn: Is there a way to start a polling thread instead of a reactive thread?

21:52 coventry: What is the difference between the two types?

21:53 pcn: My understanding of an async thread per an agent is that it's waiting for activity

21:54 I want a thread that will run a loop

21:54 coventry: You can use the java thread API as you can in java.

21:55 pcn: I was hoping there was something as simple as core.async/thread

21:57 hyPiRion: Well, a Thread isn't necessarily hard in Clojure

21:58 (doto (Thread. #(if (wait-condition) (recur) (do-something-and-quit))) (.start))

22:00 pcn: OK, I'll broaden my horizons

22:00 bbloom: is there an easy core.async equiv for Go's Ticker? specifically with these properties: http://golang.org/src/pkg/time/tick.go?s=765:917#L1

22:04 amalloy: hyPiRion: why would you (doto (Thread. f) (.start)) rather than (future (f))? the only difference i know of is bindings conveyance

22:06 hyPiRion: amalloy: If you want to interrupt the Thread or need some other means to poke around at it?

22:07 Well, I guess cancel and isCancelled would provide that too

22:22 bbloom: $mail tbaldridge I need http://golang.org/pkg/time/#Tick please :-)

22:22 lazybot: Message saved.

22:23 amalloy: bbloom: that's a channel that emits a message every X timeunits? why do you need that from tbaldridge? seems like it's easy enough to build yourself

22:24 coventry: Yeah, that go code looks pretty easy to translate.

22:24 bbloom: amalloy: it is easy enough to build yourself, however depends on a platform specific clock

22:24 coventry: it uses the internal clock facilities to deal with period drift

22:24 the interesting bit is the dropping to handle slow consumers

22:24 you need to measure how much time has passed & schedule your next timeout accordingly

22:25 rovar: wouldn't ticking into a bounded channel do the same job?

22:25 bbloom: it's pretty easy to implement, but needs to use either (System/getCurrentMilliseconds) or (js/Date.)

22:25 rovar: no, because the interval needs to be adjusted

22:25 rovar: does go's Tick really adjust its interval?

22:26 bbloom: rovar: read the comments on the NewTicker function: http://golang.org/src/pkg/time/tick.go?s=1482:1515#L40

22:26 rovar: the challenging part is actually understanding when the consumer consumes..

22:26 bbloom: http://golang.org/pkg/time/#NewTicker specifically

22:26 that's not tricky if you have a 1 item buffer

22:27 amalloy: also, it's much less efficient to build it in terms of timeout channels b/c you allocate a channel every tick

22:27 amalloy: if you have a high frequency timer, that's a non-trivial savings you can have by using a non-allocating underlying timer

22:27 rovar: fair enough, so you just need to count the interval between the blocking write success

22:28 amalloy: fair enough

22:28 rovar: so you're basically getting as fast as the consumer but no faster than n

22:28 seems like a reasonable thing to have for UI's

22:28 bbloom: rovar: precisely why i want it :-)

22:31 rovar: so you'll need to be able to measure intervals of 16ms accurately

22:47 how does one get cider to connect to an existing nrepl?

22:47 I am running a webserver process which also spins up an nrepl port

22:48 but cider doesn't pick up on that and spins up its own process.

22:49 coventry: rovar: Try M-x nrepl (works in nrepl.el)

22:53 rovar: ah

22:53 instead of running cider-jack-in, I just run cider

22:54 which seems counterintuitive

22:54 coventry: Yes, the inconsistent name-change policy is frustrating.

22:59 rovar: hmm

22:59 so i'm attached to the nrepl for my web server.. but I can't access any of my symbols..

23:00 even though I've loaded the bufer with C-c C-k

23:00 not that I think I'd have to..

23:00 coventry: rovar: Have you set the namespace with something like C-c M-n in the buffer where you ran C-c C-k?

23:02 rovar: that doesn't seem to do anything..

23:03 coventry: What does *ns* return in the repl?

23:03 rovar: hum

23:03 the correct thing

23:03 I guess it did behave correctly

23:04 coventry: Can you access the symbols in that ns, now?

23:13 rovar: coventry, yea. it's just wierd that there is no response from the UI when one types C-c M-n

23:16 coventry: What happens if you type (in-ns 'user) at the repl?

23:18 rovar: clojuremud.core> (in-ns 'user)

23:18 #<Namespace user>

23:18 coventry: Yeah, that is weird.

23:19 rovar: it all works now.. so I'm not too concerned

23:21 v4n: Any recommendations for handling hmac-sha256 with clojure?

23:22 I saw clj-oauth, but it is an overkill for what I need.

23:54 SegFaultAX: v4n: javax.crypto has everything you need to do hmac sha256

23:54 v4n: If you can't find a self contained example already written in Clojure, try your hand at translating a Java implementation.

23:56 v4n: SegFaultAX: Thanks, just got it working with javax.crypto.

Logging service provided by n01se.net