#clojure logs

2013-12-15

00:00andyf_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.
00:01andyf_another short way is (zipmap (keys my-map) (map f (vals my-map)))
00:01rovarooh
00:01rovarzipmap
00:02rovarme likey
00:02rovarvery haskellish
00:02rovarmy existing implementation was the into.. for comprehension
00:02rovarI just figured such an operation is common, and would have a clever combinator..
00:04andyf_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
00:04rovarsomeone on stackoverflow had one using reduce, which might do well for large values of m
00:06andyf_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.
00:11coventryandrei: You can do something like htis, though. https://www.refheap.com/21941
00:12rovarandyf_, ya.. constructing two new lists to make a 3rd new list is most definitely slow.
00:14andreicoventry: Thanks!
00:21seangrovetechnomancy: Any thoughts on improving the `heroku run lein repl` experience? Or do you recommend live-repls to the running app instead?
00:24rukorinteresting 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?
00:26dsrx,(doc zipmap)
00:26clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
00:30murtaza52needed help on core.async
00:31murtaza52I wanted to broadcast a msg on two different channels, how do I do that ?
00:32bbloommurtaza52: you can just write in to two different channels, unless you really need it to appear "simultaneous"
00:32bbloommurtaza52: but there is also some new stuff: https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L635
00:33bbloommurtaza52: i'd be cautions however, you *probably* don't need that
00:33murtaza52I have a program which receives some input from http, these have to be then processed by two different fns independently
00:33murtaza52so I wanted to relay the data to the 2 diff fns, and then get it back
00:33rovarmurtaza52, sounds like a job for mult
00:34rovarwhat do you mean get it back, exactly?
00:34coventryIs mult preferred to broadcast in core.async.lab? http://clojure.github.io/core.async/#clojure.core.async.lab/broadcast
00:34murtaza52I mean after the data is processed, send it back on another channel, where the main thread of the program is listening
00:34rovarmurtaza52, 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
00:35rovarso 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
00:36rovarbroadcast is very sweet, but if you don't need arbitrary topics, it might be overkill
00:36rovarpub/sub against topics, instead of just tapping into channels..
00:37rovarif you want to get crazy, you can even 'mix' the two output channels from your functions
00:37rovarinto a single channel
00:39murtaza52rovar: thanks
00:40murtaza52currently 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 ?
00:40murtaza52how do u separate out the concerns
00:46alewis there a good way to test lein plugins that use eval-in-project?
01:39logic_prog_does clojurescript have something like refer-clojure :exclude ?
01:48tonya
02:32dnolenlogic_prog_: yes
02:33dnolenbbloom: todomvc in cljs is awesome
03:58andreiHow can I get the version number of a loaded library in the repl?
03:58justin_smithandrei: I don't know that that is possible
03:59justin_smithlein classpath will show you the jar versions that would be pulled in
04:00andreijustin_smith: Ah. So version numbers are just in the filenames and are not recorded in the jars themselves?
04:01justin_smiththey are in the project.clj
04:01andreiI 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?
04:01justin_smiththe classpath reveals it via the path to the jar
04:01andreijustin_smith: Yup, I understand. But if it was recorded in the jar it should be available somehow
04:01justin_smithproblem is project.clj has the same name
04:01justin_smithin every resource
04:02justin_smithhow would you find the right one?
04:02justin_smithmost projects don't define the version outside that (or the pom.xml that is generated from it)
04:03andreijustin_smith: Ah, oh well. Thanks!
04:04andreijustin_smith: And clojure doesn't read in the pom.xml file?
04:04justin_smithit does
04:04justin_smithbut it uses it for resolving the dep
04:04andreijustin_smith: And then discards it?
04:04justin_smithit is not stored in the namespaces of the project anywhere
04:04justin_smithnot that I know of
04:04andreijustin_smith: Oh ok. That's kinda strange. Seems like useful information to have around
04:05justin_smithregarding the private fn (in-ns 'other-ns) (def now-public private-fn) ; now "now-public" can be called from anywhere
04:06justin_smithalso you could alter the var metadata and set :private false I think, but I find the above easier
04:06andreijustin_smith: Ah, awesome. Thanks!
04:17AlfredCan 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 ...) "?
04:19progoAlfred: rand-int is right-exclusive so the seq is bound to converge at some point
04:19progo(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.
04:21Alfredthank you for your explanation, any solution to this problem?
04:21progoAlfred: do you want a steady stream of random numbers? Try 'repeatedly'
04:23Alfredyes, steady series of random. but does 'repeatedly' behaves differently from 'iterate'?
04:24progo'iterate' reuses the result of the last function call to the next iteration. 'Repeatedly' is more for side-effects and so
04:25Alfredbingo. you bring up an important point of 'iterate' which i missed, thank you very much!
04:25progoie. (iterate f 0) => (0 (f 0) (f (f 0)) ...); while (repeatedly f) = ((f) (f) (f) ...)
04:26progoyou're welcome.
04:49markusXYHi, 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?
04:49nopromptbitemyapp: ah! i'm having a good time with this! wee!
04:50nopromptbitemyapp: i guess i just couldn't appreciate it before.
04:59bitemyappnoprompt: :D
05:00nopromptbitemyapp: the only thing that's been irritating is some minor things about haskell mode.
05:01bitemyappnoprompt: highly fixable, keep an eye on chris done's github
05:14markusXYI guess i'll just rewrite my code to fit it to clojure.xml.data.
09:27ddellacostawhy is the second argument to subvec exclusive?
09:28ddellacostaany particular reason? Seems counter-intuitive to me
09:28opqdonutbecause half-open intervals make sense
09:28opqdonuta) if it were inclusive, you couldn't have an empty subvec (without using e.g. -1 as the pair for 0)
09:29opqdonutb) (subvec v start (+ start len)) is pretty elegant
09:29opqdonutc) see also http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
09:30progogood stuff.
09:30ddellacostaopqdonut: checking out that link now, thanks
09:30ddellacostaopqdonut: re: a, sorry I don't get it--what do you mean an empty subvec? Like, (subvec v 4) or something?
09:31opqdonutddellacosta: like (subvec v 0 0) will give you []
09:32progoand that's rather elegant for some of the recursive applications.
09:32opqdonutyeah, it's a useful corner case often
09:33opqdonutyou don't have to treat the empty case specially
09:33ddellacostaopqdonut: okay, that is helpful, thank you! #clojure is full of awesome, as usual...
09:48danielszmulewiczhowy
09:48danielszmulewicz*howdy*
10:38edwAnyone (else) having cider blow up on them with a stack overflow when you try to eval `ns` forms in a file?
10:46luxbockis there a way to call an anonymous function from inside of itself?
10:47justin_smithluxbock: (fn named [n] (named (dec n)))
10:47justin_smiththat of course will go infinitely, but you get the idea
10:47luxbockah great
10:47luxbockhow did I not think to try that
10:48justin_smiththe extra name arg is not intuitive, I found it in some docs at some point
10:50luxbockalso wanted to ask if doing stuff like this is considered bad style: https://gist.github.com/7974531
10:50luxbockthe (eval `(mget ~@indices)) part
10:51Bronsaluxbock: that's (apply mget indices)
10:52pdkanything involving eval is bad style
10:52luxbockah right
10:52luxbockdurr
10:52Bronsaassuming mget is a function and not a macro
10:52luxbockyep, it is
10:58pepijndevoshow do I convert a js datastructure to cljs?
11:00luxbockhttps://gist.github.com/luxbock/6d8250cdc12b9eb27567
11:00brainproxypepijndevos: tried js->clj ?
11:00luxbockdoes this happen because I gave the anonymous function a name? how would I fix this?
11:01pepijndevosbrainproxy, yes. gives nil
11:02pepijndevosoh durr... string keys
11:04brainproxyyeah, I've made that mistake too
11:04justin_smithluxbock: keyword application does not work that way
11:05justin_smith(:utility-fn pd [:confess :confess]) says look for :utility-fn and return [:confess :confess] if not found
11:05justin_smithyou want ((:utility-fn pd) [:confess :confess])
11:06justin_smith,(:a {} :b) ; viz
11:06clojurebot:b
11:06justin_smith,(:a {:a 0} :b)
11:06clojurebot0
11:06luxbockah right, thanks
11:35supersymanyone 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:36seangrovesupersym: They're not especially nice
11:37jonasenBronsa: andyf: experimenting with ast-indexing in eastwood https://github.com/jonase/eastwood/compare/indexing
11:37seangrovesupersym: They're on maven though, you'll need something like https://www.refheap.com/ea915eb226642598ecfeb5ab9 in your lein dependencies
11:37jonasenBronsa: andyf: It's a port of an old project of mine (https://github.com/jonase/scape)
11:38supersymseangrove: thank you... I figured about as much (that they weren't friendly and all... ^^)
11:54Bronsajonasen: uuh nice!
11:59adomokos#clojure
12:07instilledanyone 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:16xcthulhuIs there a way to insert if not exists in clojure?
12:16xcthulhuErm, korma
12:18logic_progfor 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:18logic_progwrong channel, sorry
12:19logic_progthough if you're an svg expert, you're welcome to answer
12:20munderwoHi 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:24supersymerh...clojure 'import' doesn't error on ficticious names?
12:24supersymno way of telling
12:27supersymoh... only on ns directives it does I see
12:28instilledxcthulhu: you can use a raw query to achieve that.
12:28xcthulhulogic_prog: For a <g> in sag, you can set it's dimensions, and you can also set its scale using a transformation attribute
12:28xcthulhus/sag/svg/
12:29xcthulhustupid auto-correct
12:29xcthulhuAlso its*, but that's just me being bad at grammar so I can't blame autocorrect on that one
12:30xcthulhuYou can't set the background in a <g>; I recommend using a <rect> for that
12:30andyf_Bronsa: ping
12:31Bronsaandyf_: pong
12:31xcthulhuinstilled: Yeah, whenever I'm using an ORM, part of me just wants to cut to the chase and use RAW SQL
12:31andyf_jonasen: That use of datomic looks interesting. I'll have to understand it some day, but not today :-)
12:32xcthulhuBut then someone always complains about Little Bobby Tables...
12:33andyf_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:34Bronsaandyf_: basically emit-form transforms an AST back into a clojure form
12:34Bronsaandyf_: the problem was this: suppose you have (defmacro x [] (println "foo"))
12:34andyf_Bronsa: Would you expect a CinC compiler to need emit-form? Or is it intended for debugging purposes?
12:35Bronsawhen you call (analyze '(x) (empty-env)) it gets macroexpanded and "foo" gets printed
12:35Bronsathen we eval that, we macroexpand it again and print "foo" twice
12:35Bronsacalling emit-form on the AST returns an already macroexpanded ofmr
12:36Bronsaandyf_: I don't use emit-form in t.a.jvm or t.e.jvm, it's there for convenience
12:36andyf_OK, so this is part of the changes you made where the commit comment mentioned macros with side effects.
12:36LordVanSprangRaynes, ping
12:37Bronsaandyf_: 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:37xcthulhuBronsa: Looks like you want "once-only" semantics for macros:
12:37Bronsathis makes it crash instead of simply accepting a wrong AST
12:37xcthulhuhttp://tsdh.wordpress.com/2011/09/23/once-only-evaluation-for-clojure-macros/
12:37Bronsaand i can fix it.
12:37xcthulhuDoug Hoyt would be pleased
12:38instilledxcthulhu: i suggest you write it as raw sql and forget about it :)
12:38xcthulhuinstilled: Yeah, someone's gonna complain about Little Bobby Tables probably
12:38andyf_Bronsa: So this way of doing it should also give more complete test coverage of tools.analyzer. That's good.
12:38xcthulhuBut so much for ORMs
12:39Bronsaandyf_: yeah, the failures you're seeing on core.async have nothing to do with TANAL-30, I'm investigating now the cause
12:40andyf_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:41Bronsayeah, 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:43andyf_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:43Bronsayes
12:45andyf_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:46Bronsayeah, don't spend too much time on that.
12:47andyf_Most of my time on Eastwood now is spent finding new categories of crashes :-)
12:47Bronsaand I thank you for that :P
12:47RaynesLordVanSprang: Hi.
12:50LordVanSprangRaynes, would you know where Chousuke the Finn is at?
12:51LordVanSprangAlso, I Worship His Shadow.
12:51Rayneslol
12:51Raynesgg
12:51RaynesBronsa: How comes the Clojure in Clojuring?
12:53BronsaRaynes: working mostly on the analyzer these days, will go back on the emitter once the analyzer is stable :P
12:57bbloomBronsa: mmm decomplection
13:08pcnRaynes: Sorry to bother you, but I have a question about importing your fs module
13:08pcnrather requiring it
13:09RaynesSure, shoot
13:09pcnI've got it in my project.clj: [me.raynes/fs "1.4.5"]
13:09pcnbut 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:10RaynesWhat code are you typing?
13:10Raynes(require '[me.raynes.fs :as fs])
13:11pcnThe core.clj has a (ns [...] :require [me.raynes/fs :as mrfs]
13:11pcnAh me.raynes.fs not /fs
13:12Raynes:)
13:13pcnIs there a doc about what that means - the difference between lein's dependencies syntax and the require syntax?
13:13pcnOr as in this case how they're probably only tenuously connected?
13:14andyf_pcn: require uses Clojure namespaces. Leiningen uses Maven artifact/<something>
13:14andyf_Probably Maven <group>/<artifact>
13:14andyf_A single line in the project.clj file could pull in many many namespaces
13:16pcnI 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:16pcnandyf_ thanks though, that does give me a point of reference.
13:27pcn'10
13:29andyf_pcn: If you want a form to be evaluated in the IRC channel, put a , first
13:31egosumandyf_: he was quoting it; he wanted to prevent evaluation ;)
13:31pcnSorry, that was my tmux binding for commands leaking out :(
13:32pcnRaynes: really, java 1.6 doesn't have methods for hard links?
13:32pcnWow
13:34pcnIt 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:34pcnWhat can I do to check that?
13:35bbloomi wish my file browser could topologically sort files by the dependency tree, rather than alphabetically
13:36bbloomi've gotten so used to reading big clojure files in order. i dunno what to do when there are like 10 files :-P
13:36Raynespcn: Check ns-publics.
13:36pcn(ns-publics fs) seems to fail: CompilerException java.lang.RuntimeException: Unable to resolve symbol: fs in this context [etc.]
13:36pcnbut the namespace is otherwise valid
13:37TEttingerquote it?
13:37RaynesThat isn't a namespace. That's a symbol.
13:37Raynes&(doc ns-publics)
13:37lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
13:37Raynesugh
13:37pcnl0l
13:37TEttinger,(doc ns-publics)
13:37clojurebot"([ns]); Returns a map of the public intern mappings for the namespace."
13:37Raynes,(doc the-ns)
13:37clojurebot"([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:37Raynes(ns-publics (the-ns 'me.raynes.fs))
13:41pcnOK, I'll put the difference between the local binding and the ns on my list of things for deep thought. Thanks!
13:42alewCan I rely on the lein function eval-in-project to return the last form evaluated?
13:44pepijndevosprobably
13:44alewIt seems to want to return nil... and looking at the source I can't figure out why that would be
13:45Bronsaandyf_: mhph this is a problem ##`(~Object ~'Object)
13:45lazybot⇒ (java.lang.Object Object)
13:46Bronsa,#`(~Object ~'Object)
13:46clojurebot#<RuntimeException java.lang.RuntimeException: Reader tag must be a symbol>
13:46TEttinger,`(~Object ~'Object)
13:46clojurebot(java.lang.Object Object)
13:47Bronsa,#((juxt identity (partial mapv class)) `(~Object ~'java.lang.Object))
13:47clojurebot#<sandbox$eval115$fn__116 sandbox$eval115$fn__116@16e6127>
13:47TEttingerone # will return the anon fn
13:47Bronsa,((juxt identity (partial mapv class)) `(~Object ~'java.lang.Object))
13:47clojurebot[(java.lang.Object java.lang.Object) [java.lang.Class clojure.lang.Symbol]]
13:48TEttingerthat's uh interesting
13:48TEttingerone has Object and one has java.lang.Object...
13:48andyf_Bronsa: Did you find an example of that in the wild?
13:48coventryIn what context is that a problem? Isn't it what you'd expect?
13:49Bronsaandyf_: yeah, this is what's breaking core.async
13:50Bronsabecause the defprotocol macro returns {:on the.protocol :on-interface the.protocol ..}
13:50Bronsaexcept one is a symbol, the other a class
13:50coventryOh, I see.
13:50Bronsabut when we eval that, they both get evalauted as a Class
13:50hyPiRionWell
13:50hyPiRion,(binding [*print-dup* true] (pr-str `(~Object ~'java.lang.Object)))
13:50clojurebot"(#=java.lang.Object java.lang.Object)"
13:51Bronsaandyf_: 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:51BronsahyPiRion: yeah well, the problem is we need to eval the form
13:52andyf_"We" meaning in the context of Eastwood linting
13:52hyPiRionoh, hm.
13:55BronsaA 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:55Bronsaso clojure.walk is a no-go there
13:56coventryriddley will avoid walking into quoted forms.
14:00andyf_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:01Bronsano, the opposite. the tag should get qualified
14:04andyf_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:05andyf_Pardon my ignorance, but fully qualified package.classnames can be used without importing them?
14:05Bronsaandyf_: it should be qualified in the def
14:06Bronsae.g. you have (ns foo (:import bar.Baz)) (defn x ^Baz [])
14:06Bronsaandyf_: sure
14:06Bronsa,Collection
14:06clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Collection in this context, compiling:(NO_SOURCE_PATH:0:0)>
14:06Bronsa,java.util.Collection
14:06clojurebotjava.util.Collection
14:07andyf_Got it. I've got to leave now. Thanks for the info.
14:07Bronsanp
14:12ksauasay 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:13bbloomksaua: did you say that right? B is going to return something from itself?
14:14ksauaB is another function that returns a lazy seq
14:14ksauaso, yes?
14:14bbloomcan you be more concrete about what you want? ie provide an example
14:14ksauasure
14:15ksauaI 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:16ksauaif A had instead returned [1 1 1 1] B(A) would return the lazy seq [1 2 3 4]
14:16bbloomfirst, vectors with square brackets are not lazy. you're looking for parens :-)
14:17ksauaheh, yeah, i mean parens
14:17bbloomso you want to basically want to sum A0+A1, A1+A2, A2+A3 ... etc yes?
14:17ksauaYup
14:18coventry,(doc reductions)
14:18ash__^-- any storm users here?
14:18clojurebot"([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:18bbloom,(let [a [1 2 3 4 5 7]] (map + a (cons 0 a)))
14:18clojurebot(1 3 5 7 9 ...)
14:19AeroNotixEmacs/Clojure/Flymake, what do people use?
14:19bbloomsomething like that?
14:19bbloombut yeah, reductions is awesome too
14:19bbloomoh you don't want parallel sums, you want successive sums
14:20bbloomyeah, use reductions
14:20ksauaHm, sure, as long as that works where a is a lazy sequence, which i guess it does because map and cons is lazy?
14:20bbloomcons is not lazy
14:20bbloom,(reductions + 0 [1 2 3 4 5 7])
14:20clojurebot(0 1 3 6 10 ...)
14:21bbloom,(next (reductions + 0 [1 2 3 4 5 7]))
14:21clojurebot(1 3 6 10 15 ...)
14:21bbloomcons will preserve laziness past the non-lazy, prepended head
14:21ksauaokay
14:21ksauaI'll try reductions, seems to be what im looking for, thank you so much
15:21logic_proghow does parsec handle operator precedence?
15:27pepijndevoslogic_prog #haskell?
15:28coventryIncidentally, what *is* the right channel for svg questions?
15:29hyPiRionthe graphics format?
15:29logic_progpepijndevos: good call
15:29logic_prog#svg
15:29coventrylogic_prog: Thanks. hyPiRion: Yeah.
15:29rovarI'm trying to work through the clojure emacs to tutorial.. and it's telling me to execute tests via C-x C--
15:30hyPiRioncoventry: 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:30hyPiRiontheir IRC channel, that is
15:30rovarooh nm
15:31noncom,(name nil)
15:31clojurebot#<NullPointerException java.lang.NullPointerException>
15:31davIs there a way to get lein test to print even when a test succeeds?
15:31davSome verbosity level or something?
15:31noncomthere 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:32noncomwithout risking an excetion
15:32noncomoh just realized that i can put (or) inside (name)!
15:32noncomnevertheless, it is weird that it gives an NPE
15:33eric_normandnoncom: (if x (name x) "default")
15:33coventry,(doc fnil)
15:33clojurebot"([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:33justin_smith,((fnil name "nil") nil)
15:33clojurebot"nil"
15:33justin_smith,((fnil name "nil") :ok)
15:33clojurebot"ok"
15:34noncomyes, i know the (if) approach but it is not as cool as (or)!
15:34eric_normandnoncom: fnil is good, too
15:35noncomhmmm (fnil).. never heard of that.. but actually i just realized i can do (name (or smth "default")).
15:35noncomhowwever thanks for the insight on fnil
15:35noncomis there any library for clojure that performs intelligent seatch like one in SublimeText?
15:35noncoms/seatch/search
15:36noncomlike picking strings by relevence from a pool of strings
15:39pepijndevosdefine relevance
15:40noncompepinjndevos: 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:41noncomthe 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:42justin_smithsounds like levenstein difference
15:42justin_smithhttp://en.wikipedia.org/wiki/Levenshtein_distance sp. sic
15:42justin_smithhttp://clojuredocs.org/incanter/1.2.3-SNAPSHOT/incanter.stats/levenshtein-distance
15:42justin_smithlooks like it comes with incanter?
15:43amalloyi doubt if it's levenshtein distance, since then "id" would sort before "pocket", which seems pretty rubbish
15:43justin_smithahh
15:43justin_smithgood point
15:43justin_smithI wonder how iswitchb does it
15:44justin_smithit reminds me of that behavior
15:44pepijndevosi remember fish does this too
15:44coventryjustin_smith: I haven't looked, but my impression is that time of last visit plays a big role there.
15:45justin_smithcoventry: fair enough, but even on a virgin checkout it does sort matches based on character subset
15:45cYmenHow do I install cider when this marmelade thing doesn't work?
15:46coventryjustin_smith: Is it doing some kind of fuzzy matching? I thought it was just exact substrings.
15:46justin_smithcYmen: wait for them to fix it, or install package from a git checkout
15:46justin_smithcoventry: it does fuzzy matching with my config
15:46justin_smiththough that may be because of some customization I forgot I did
15:47noncomhmm, people menthion Levenshtein distance here too : https://www.sublimetext.com/forum/viewtopic.php?t=5661
15:47noncommabye it is some superset of it
15:47noncomor a subset :D
15:47justin_smithyeah, some parameterized generalization from it maybe
15:48hyPiRionI'd guess they use Damerau-Levenshtein
15:48hyPiRionAnd perhaps take into account keyboard layout
15:48davIs there a way to get lein test to print even when a test succeeds?
15:49coventrycYmen: https://github.com/clojure-emacs/cider#manual
15:50hyPiRiondav: Are you interested in feedback from a test, or actually doing printing?
15:51davhyPiRion: having some generic printing while tests are running
15:51hyPiRionah
15:52davhyPiRion: I ended up writing this macro: http://paste.debian.net/71019/
15:52davhyPiRion: wondering if there's a better way.
15:53hyPiRiondav: huh, `lein test` would print out e.g. "lein test my-lib.test.combined" whenever running that test namespace
15:54cYmencoventry: My lack of prior emacs knowledge makes it hard to fill in the gaps. :)
15:54hyPiRionalong with total tests + assertions, plus failures and errors
15:55coventrycYmen: Try this: mkdir -p ~/.emacs.d/vendor && cd ~/.emacs.d/vendor && git clone https://github.com/clojure-emacs/cider.git
15:55coventrycYmen: Then put (add-to-list 'load-path "~/emacs.d/vendor") (require 'cider) in your ~/.emacs file.
15:56coventryOh, you'll have to install clojure-mode, dash.el and pkg-info the same way. What a pain.
15:56cYmenOh, I can't use the ones from marmalade?
15:56coventryIf they install, that should be fine.
15:57cYmenIn that case I don't understand what's wrong.
15:57cYmenFile error: Cannot open load file, cider
15:57pinkwerksI'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:58cYmenOh wait, I put it in my init.el
15:59cYmenAs expected that didn't change anything.
15:59amalloypinkwerks: 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:59amalloyinstead, hiccup lets you use lists to group things: (let [dbval 1] (list [:h1 dbval] [:h2 dbval]))
16:00coventrycYmen: 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:00pinkwerksamalloy : now I understand thanks
16:01cYmencoventry: I tried that as well, didn't work either. d)
16:01cYmen:)
16:02coventryC-h v load-path RET. Check that it's actually getting on the load-path.
16:03cYmenHm..that list is very long.
16:03coventrySearch with C-s. :-)
16:04xeqicYmen: are you using ~/emacs.d or ~/.emacs.d ?
16:05xeqiin the (add-to-list load-path ..)
16:05cYmenxeqi: That was exactly the error that I just corrected. How do you know? :)
16:05xeqiran through the manual install yesterday
16:05cYmenhaha
16:06xeqisomething else to be PR/fixed in the cider readme
16:06cYmenxeqi: Other things I should know? Like why can't I just M-x cider-jack-in now? :/
16:07cYmenIs that some shortcut that marmalade has added on my other machines?
16:07xeqiI usually open a clojure file and C-c C-j
16:07emaphisin reference to cYmen's question, would it be unwise to install cider from Melpa?
16:08xeqiworks for me with the clojure-mode, dash.el and pkg-info from marmalade, and cider manually downloaded off melpa
16:08coventryIn nrepl, at least, C-c M-j just does nrepl-jack-in.
16:08xeqiemaphis: I'm not big on running from master (like melpa does)
16:09cYmenWell, according to my emacs that symbols definition is void.
16:09xeqiC-c M-j is what I mean
16:09emaphisYes, I just leave Melpa alone. :-)
16:09cYmenC-c M-j in a clojure file seems to work.
16:10cYmen*sigh*
16:10cYmenUsing tools you only understand a fraction of, so much fun.
16:10justin_smithand what function does that run?
16:10justin_smithM-x describe-key
16:11cYmennrepl-jack-in
16:13cYmenSo...what does this mean?
16:13amalloyjustin_smith: why M-x describe-key rather than C-h k?
16:13justin_smiththey do the same thing, no?
16:13justin_smithI find for learners presenting the name rather than mnemonic helps
16:13justin_smithjust a style thing I guess
16:14amalloymakes sense, i suppose
16:14coventrycYmen: 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:14cYmenThe first time I tried cider-jack-in.
16:14justin_smithamalloy: also it will tell you the key shortcut after any m-x command, so that info is still provided
16:14coventryAh, right.
16:14Bronsame too.
16:15cYmenWhich works on the machines where I installed it with marmalade.
16:15justin_smithsounds like version skew
16:16cYmenProbably. Anyway, as usual, thanks for the great support.
16:18bbloom,(bit-or 5) ; aw sad face
16:18clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/bit-or>
16:21letstestHi - 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&quot;
16:21letstestwhat do I have to do in the repl to have access to it?
16:23justin_smithletstest: I would say adding the maven coords to your project.clj :dependencies vector
16:23justin_smith(in a project)
16:23letstestoh ok. I have to add it to a project. I can't just try using it without that
16:23justin_smithand then setting up the credentials in your ~/.lein/profiles.clj as they show in their readme
16:23justin_smithwell you CAN, but that is not easier
16:24letstestalright. I will do that
16:24justin_smith(there is alembic / pomegranate)
16:24letstesti.e put it in project.clj
16:24letstestthank you
16:24justin_smiththen for the key, probably easier to go the env var way, if you know how to set a shell environment variable
16:24justin_smithnp
16:25letstestgoing to try it now
16:30letstestjustin_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:31coventryletstest: successful import.
16:31letstestoh! thanks coventry but when i use it (forecast "37.8267" "-122.423")
16:32letstesti get this CompilerException java.lang.RuntimeException: Unable to resolve symbol: forecast in this context, compiling:(/tmp/form-init1327445774299770078.clj:1:1)
16:32letstestshouldnt that have worked?
16:32coventryletstest: The readme is wrong. Try replacing forecast with forecast/forecast (guessing.)
16:33letstesti get back nil if i do that
16:33letstestuser=> (forecast/forecast "37.8267" "-122.423") nil
16:35coventryProbably means the api call failed somehow. https://github.com/jdhollis/forecast-clojure/blob/master/src/forecast_clojure/core.clj#L14
16:35letstestoh
16:35letstesti may have set my environment variable wrong
16:35letsteststrange error if that is the case
16:37noncomwhy it is not that a namespace is a clojure datastructure, why is it something so different?
16:37bbloomnoncom: a few reasons. for one thing, they are mutable
16:37bbloomby design
16:38bbloomnoncom: also, they exist before clojure is fully bootstrapped, so there's that too
16:38justin_smithletstest: you can set env variables with (System/setenv "var" "new-value")
16:38justin_smithwithout restarting that is
16:39noncomhmm, i see, yes that makes..
16:39noncomi have to learn more about environments though
16:40noncomoh you were talking to a different person1
16:45letstest_justin_smith - do i need someting in my project.clj to do that?
16:46justin_smithno, that works right in the repl
16:46justin_smithas long as the library looks in the env for the credentials that should work
16:46letstest_i get "CompilerException java.lang.IllegalArgumentException: No matching method: setenv, compiling:(/tmp/form-init1327445774299770078.clj:1:1) "
16:46justin_smitherm...
16:47justin_smithI could have sworn there was a setenv
16:47justin_smithI was likely confused, sorry
16:47letstest_np
16:48letstest_would be useful if there was :)
16:48justin_smithI guess as far as the jvm is concerned mutating the env is non-portable
16:49letstest_oh
16:50hyPiRionjustin_smith: yes, that's exactly the reason
16:52letstest_i still cant get that library to work, just gives me nil
16:53letstest_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:53justin_smithif you do (System/getenv "FORECAST_KEY") does that show your api key?
16:53letstest_let me try
16:53letstest_oh - nope
16:53letstest_gives me nil
16:53justin_smithenv FORECAST_KEY=supersecret lein repl
16:54letstest_ok
16:54justin_smithtry that from the command line in the top level of your project
16:54justin_smithand in the repl that runs you should be able to use the API
16:55letstest_That worked!!
16:55letstest_thank you!
16:55justin_smithawesome
16:55justin_smithnp
16:55justin_smithso 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:56letstest_i actually did try profiles.clj but it didnt work. Will fool around with the environment variables. i have had similar problems before
16:57letstest_now that i know this works. The issue is on my end
17:26rukorqz: /quit
17:31noncomhow do i stop a server in nrepl?
17:32noncom(stop-server) accepts some args map but not what (start-server) returns
17:32justin_smith(System/exit 0) ?
17:32noncom:)
17:32justin_smithor do you mean some subprocess?
17:32noncomyeah, in my app i start an nrepl server
17:32justin_smithahh
17:33justin_smithdoes it have a .stop method by any chance?
17:33justin_smiththere should be a thread / process like object somewhere in what it returns, I would assume
17:34noncom(start-server) returns something like #clojure.tools.nrepl.server.Server{:server-socket ..bunch of stufff goes here ...}
17:34noncomwhat is that?
17:34noncom#Server{} what datatype is this?
17:35noncomoh its a defrecord..
17:35noncomnever used one
17:35justin_smitha record from defrecord
17:35justin_smithhttps://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/server.clj#L52
17:35justin_smiththis is the code for stop-server
17:35justin_smithmay help
17:35noncomso you were completely right, it is Cloaseble
17:36justin_smithwell my first guess was .stop
17:36justin_smithbut yeah
17:37justin_smithyeah, now that I look at the definition for Server defstruct, it implements close from Closeable
17:38noncomand i look too and see that (stop-server) must work with it. so it is a mistake somewhere in my code
17:39justin_smith.close calls stop-server
18:00danielszmulewicztechnomancy: ping
18:06logic_progis there a good explaination somewhere of how clojure's ident rules work (as implemented in emacs) ?
18:12logic_progis there a way I can construct a symbol/object/something-magical that clojure.edn/read-string can not construct?
18:12logic_progcontext: 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:12bbloomlogic_prog: trivially:
18:12bbloom,(Object.)
18:12clojurebot#<Object java.lang.Object@844a08>
18:13logic_prog*thinking*
18:13bbloomspecifically, that's what the #<...> syntax is for
18:13logic_progbbloom: googling for "#<...>" might be slightly troublesome
18:13logic_progcan you point me at readin gmaterial?
18:14emaphislogic_prog: the rules for indenting lisp have aways been what emacs does. :-)
18:14logic_progemphais: it's like how python the interpreter is python the spec?
18:15bbloomlogic_prog: the magic word you're looking for is "unreadable"
18:15bbloomlogic_prog: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L109
18:15emaphislogic_prog: good analogy. ;)
18:16hyPiRion,#<this is not readable by the reader>
18:16clojurebot#<RuntimeException java.lang.RuntimeException: Unreadable form>
18:19logic_progdoes clojure provide some type of ordered list that has an O(log n) time insert?
18:20logic_progvector's insert into the middle is O(n) time afaik
18:20logic_progI want an ordered list where I can say "insert this after the n-th element" and have it be O(log n) time
18:23akhudeklogic_prog: sorted-may or sorted-set
18:24akhudeklogic_prog: that should be lorted-map
18:24logic_progyou may wish to invest in a new keyboard :-)
18:24akhudeklogic_prog: work fingers, sorted-map
18:24logic_progor a spell checker
18:24`cbpor invest less in alchohol
18:26bbloomlogic_prog: see also https://github.com/clojure/data.avl
18:26logic_proghttps://github.com/clojure/data.avl <-- is this meant to be empty?
18:26justin_smithlogic_prog: insertion in a vector is guaranteed O(<7)
18:26justin_smithnot O(n)
18:27logic_progit's not O(length of vector?) ?
18:27justin_smithno
18:27logic_progoh, this is chunks o 32 ?
18:27justin_smithO(7) is the worst case
18:27justin_smithyeah
18:27gozalaBronsa: I’d like to ask a question about tools.reader
18:27bbloomlogic_prog: heh, sorry. guess michal didn't move the code over yet: https://github.com/michalmarczyk/avl.clj
18:27logic_progso it can use chunks of 32 even if I don't insert 32 elements at once?
18:27justin_smithwait this has nothing to do with chunking
18:27gozalaBronsa: where does it saves column, line info for booleans and nil ?
18:27Bronsagozala: tell me
18:27justin_smithit is the same tree structure used to implement persistent hashmaps
18:27Bronsagozala: it doesn't
18:28Bronsagozala: booleans and nil cannot have metadata attached to them
18:28akhudekthere is also https://github.com/clojure/data.priority-map
18:28logic_progbbloom: interesting, I always thought people used red-back trees, not avl for persistent trees
18:28justin_smithlogic_prog: it uses a tree, max 7 levels deep, so assoc to a random index is at worst O(7)
18:28gozalaBronsa: so there is no source map for those then ?
18:28bbloomlogic_prog: if you need sorted with nth, that's what AVL is for
18:28Bronsagozala: there's no way to attach such info to objects that cannot have metadata attached to them
18:28bbloomlogic_prog: clojure does use red/black trees
18:28logic_progjustin_smith : sure, but how do you get that insertion is only O(7) ?
18:28amalloyO(7) is like...a crime against notation
18:28justin_smithO(<7)
18:28logic_progsay, I have a list of 3200 elements
18:29justin_smith7 is the worst case
18:29justin_smithbecause it is a tree
18:29logic_progand I insert a element at index 6
18:29amalloyO(<7) is even worse
18:29justin_smith7 levels deep max
18:29gozalaBronsa: yeah I was hoping there was some clever hack I could not come up with :/
18:29logic_progit seems like that all the remainig elemnts gets "shifted"
18:29pcnIs there a way to loop, and ahve the initial bindings replaced, that doesn't rely on recur being in tail position?
18:29logic_progI can believe that replace an elemento f a vector is O(log_32 n)
18:29justin_smithamalloy: just qouting "clojure high performance programming"
18:29Bronsagozala: no I'm sorry
18:29logic_progbut I'm not convinced that insertion is O(log_32 n)
18:29justin_smithlogic_prog: why would assoc shift anything?
18:30justin_smithyo uare replacing a single index
18:30amalloyjustin_smith: all of those directly translate to "O(1) but i don't understand big-O notation"
18:30justin_smithamalloy: OK
18:30logic_progbecause I'm inserting into an array, it had 3200 elements. Now it has 3201 elements
18:30justin_smithlogic_prog: it is not an array
18:30logic_progand if I insert at index 6, it seems that indices 7 to 3200 might all get shifted
18:30justin_smithit is a tree
18:30gozalaBronsa: tnx
18:30justin_smithno, no shifting
18:30logic_progdamn it, where is the source for clojure vectors ? :-)
18:30justin_smiththat is the point of the tree
18:30hyPiRionclojurebot: PersistentVector.java?
18:30clojurebotCool story bro.
18:31amalloylogic_prog: you can't insert-and-shift into a vector cheaply, only insert-replacing
18:31logic_progamalloy: so "insert-and-shift" is O(n), correct?
18:31justin_smithamalloy: I think he knows that, and that's why he thought insert would not be cheap
18:31logic_progthis is what I'm confused about
18:31hyPiRionlogic_prog: yes
18:31justin_smithlogic_prog: I thought you meant insert as in "put this at that index", not "shift everything else to the right"
18:31logic_progokay. 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:32hyPiRionclojurebot: PersistentVector is https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentVector.java
18:32clojurebotYou don't have to tell me twice.
18:32logic_progjustin_smith: sorry for not being clear, I meant "insert" not as in "replace"
18:32hyPiRionoh man
18:32logic_progclojurebot has attitude
18:32logic_prognext thing you know, it's going to pass the turing test
18:32andyf_amalloy: I know what you mean, but O(7) = O(1) clearly from the definition of big-O notation.
18:32amalloyandyf_: yes, of course
18:32hyPiRionlogic_prog: ordered structure or sorted?
18:33logic_proghyPiRion: imagine I'm implementing a really giantass todo list
18:33logic_progand I click on an item, and I say "insert todo right below this item"
18:33amalloybut equally it's O(1024), and introducing arbitrary integers doesn't make things any clearer
18:33hyPiRionlogic_prog: ordered then
18:33andyf_By the same argument O(log_32 n) is a crime against big-O notation.
18:33hyPiRionlogic_prog: http://infoscience.epfl.ch/record/169879/files/RMTrees.pdf
18:33logic_progandyf_: how is O(log_32 n) bad? it's the same as O(log n)
18:33hyPiRionO(log_32 n) insert-at times
18:33andyf_but often constant factors are important to call out explicitly
18:33akhudekhttps://github.com/clojure/core.rrb-vector
18:34hyPiRion(inc akhudek)
18:34lazybot⇒ 1
18:34andyf_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:34logic_progO(<7) is weird
18:34bbloomlogic_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:35andyf_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:35andyf_When there are hash collisions, hash sets and hash maps can be O(n).
18:35justin_smithandyf_: if you are using numeric index, how would you collide?
18:35justin_smithwe were talking vectors
18:35andyf_justin_smith: Sorry, I didn't read carefully enough which data structures the O(7) was being applied to.
18:36logic_proghyPiRion, akhudek: nice, thanks, rrb vectors look like what I want
18:36andyf_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:38andyf_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:39joshua___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:44logic_progrrb-vectors are badas
18:44logic_progs
18:46andyf_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:48justin_smithandyf_: maybe you need to set the :src-path for leiningen?
18:48andyf_justin_smith: I have :source-paths set to ["src/main/clojure"], which works for other Contrib libs
18:49justin_smithyeah, that looks right for clojure.data.zip
18:49andyf_There is something different about data.zip, though.
18:50Bronsaandyf_: I was wondering why that didn't work too
18:51andyf_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:51lazybotandyf_: Oh, absolutely.
18:52Bronsaif lazybot says so.
18:52andyf_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:53andyf_Yep, removing that empty file and the require works fine.
18:54andyf_back later...
19:12joshua___Are there any good tutorials on setting up Clojure in Eclipse?
19:26coventryjoshua___: I hear Cursive Just Works.
19:46justin_smithcursive is intellij, but yeah I have heard good things about it
19:47justin_smithit is only available as a preview beta that you have to sign up for at the moment
19:50akhudekI 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:51joshua___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:51akhudekIt'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:00bitemyappyissss, have Halloway's attention on the Datomic documentation issues.
20:00bitemyappI have a glimmer of hope, once again!
20:02taliosis datomic's documentation as wonderful as clojures then?
20:03bitemyappDatomic is really nice, but there is some implicit/semi-implicit information that needs documented.
20:25logic_progwhy is (. js/console log (= :asdf "asdf")) false if cljs treats keywords as strings
20:26logic_prog[edit: in the context of cljs, not clj] ==> why is (. js/console log (= :asdf "asdf")) false if cljs treats keywords as strings
20:26justin_smithlogic_prog: does it treat them as (name kw) or as (str kw)?
20:26amalloylogic_prog: "cljs treats keywords as strings" is very inaccurate
20:26justin_smithbecause if it treats them as (str kw) you want ":asdf"
20:26logic_progamalloy: how are keywords stored in cljs?
20:26logic_progI thought they were just js strings, but apparently not
20:27logic_progcljs ==> (. js/console log (= :asdf ":asdf")) <- also returns false
20:27amalloyi 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:27amalloythere was some talk about making them real objects; i don't know if that ever happened
20:28amalloyin 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:28logic_proghttps://groups.google.com/forum/#!topic/clojurescript/bSFK6CEE3PE <-- has this been integrated into mainline?
20:29logic_progI have another dumbass question
20:29logic_progin practice, when do "cljs treats keywords as strings" actually matter ?
20:31amalloylogic_prog: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/compiler.clj#L206 is how cljs emits keyword literals
20:31Bronsaandyf_: I just used eastwood on tools.analyzer[.jvm] and found out some misplaced docstrings :)
20:32amalloynew cljs.core.Keyword(...)
20:32bbloomlogic_prog: even before keywords were reified, that wouldn't have worked
20:33bbloomlogic_prog: previously, keywords had some marker bytes in the front of the string
20:33logic_prog(thinking)
20:33logic_progsuppose I have a = :abc
20:33logic_progis there a way to define b = "some crap"
20:33logic_progsuch that (= a b) returns true?
20:33logic_prog(in cljs)
20:33bbloomlogic_prog: no. why do you want that anyway?
20:34logic_progbbloom: good. I don't want that.
20:34logic_prog"keywords are implemented as strings" confused me
20:34bbloomwhere does it say that?
20:34bbloomit's outdated
20:35logic_progdamn it, I actually can't find a refenrece
20:35logic_progI thought it was https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure , but it no longer states that
20:35logic_progI am happy now.
20:35bbloomlogic_prog: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure/_compare/2b66b7399e036d0703a07dd94f07bf7489b4579f...e524b1bf81bf1f14c06689670f77585816c653e2
20:36logic_progbbloom: ah, thanks :-)
20:37bitemyappnew hpmor.com chapters out.
20:45andyf_Bronsa: Yep, there are a fair number of those throughout Clojure contrib libraries, and even one in Clojure itself.
20:46andyf_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:47Bronsayeah, I just ran ./lint.sh. Looks like all the failing libraries now are due to known bugs/limitations
20:47bbloomandyf_: have you submitted patches for the misplaced docstrings? :-)
20:47andyf_bbloom: I could, but that might lead them to believe there was no use to adopt a linter for regular automated checks :-)
20:48bbloomandyf_: i ran a blame & it makes me feel better about myself that rich screws up the docstring order sometimes too :-P
20:48andyf_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:49andyf_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:50bbloomandyf_: have you talked to alex miller? he's probably the place to start w/ discussions about improving process
20:50andyf_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:51ddellacostaeavesdropping on you guys...what is Eastwood?
20:51andyf_A lint tool for Clojure
20:51bbloomandyf_: always good to start conversations early. i'd tell him your goal & ask him what it would take to get you there
20:51andyf_https://github.com/jonase/eastwood
20:51ddellacostaah, https://github.com/jonase/eastwood
20:51ddellacostaright, thanks andyf_
20:51bbloomandyf_: 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:51andyf_bbloom: I am used to waiting 1 year for things
20:51bbloomandyf_: i think the lines not dots thing applies here too :-)
20:52andyf_bbloom: Lines not dots thing?
20:52bbloomandyf_: 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:53andyf_bbloom: I am mentally and emotionally prepared for Clojure core never to adopt an automated process for this, ever.
20:54andyf_I just hope they do.
20:54bbloomandyf_: so then you won't be disappointed now, just like you won't be disappointed later :-)
20:55bbloomandyf_: 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:55andyf_bbloom: If they don't within a year or so, I'll consider it.
20:55bbloomheh ok
20:57amalloywas eastwood always based on tools.analyzer? i thought it was around before then
20:58bbloomamalloy: appears not https://github.com/jonase/eastwood/commit/3789514b6729f0dd15ee01443207cfef0cbafdd6
20:58amalloyoh wow, that's a really recent change
20:58andyf_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:58bbloom(inc bronsa)
20:58lazybot⇒ 14
21:00andyf_Look at the graph on this page: http://dev.clojure.org/jira/browse/TANAL
21:01andyf_Every time the green line goes up, that is Bronsa's work :-)
21:02hyPiRionAnd by the looks of it, every time the red line goes up, that is andyf_'s work :p
21:02Bronsaandyf_: looks like eastwood just found a bug in core.logic *highfive*
21:02Bronsa(inc andyf_)
21:02lazybot⇒ 1
21:03joshua___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:03Bronsawell.
21:03Bronsa(inc andyf)
21:03lazybot⇒ 1
21:03andyf_Yeah, I haven't been on IRC much.
21:03andyf_*highfive* Which bug?
21:04bbloomBronsa: 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:04hyPiRion,(.. Runtime getRuntime maxMemory) ; joshua___
21:04clojurebot#<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>
21:04hyPiRionwell, that should work in a repl
21:06Bronsaandyf_: 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:06andyf_Oh, yeah, I've seen that one before. It seems to be buried in a macro somewhere.
21:06Bronsabbloom: 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:07joshua___Thanks hyPirion
21:07bbloomBronsa: what causes the debugging challenge?
21:07Bronsabbloom: this https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/jvm.clj#L349-L355
21:08Bronsabbloom: in short, there are some passes that depend on each other so multiple runs are required
21:08Bronsawhen a bug is buried in one of those passes, it's difficult to reproduce the exact condition that caused the bug
21:08bbloomBronsa: hmm, i'd imagine
21:09bbloomBronsa: do you have a validation pass of some sort?
21:09bbloomor multiple, a la the nanopass language definitions idea?
21:10Bronsabbloom: I have a validation pass but that's probably not what you're thinking
21:10bbloomif i'm reading this correctly, "cycling" is just a fixed point rewrite?
21:10Bronsait checks for wrong arities & throws, tries to reflect methods etc
21:11bbloomah ok so that's user level validation, not internal consistency checks for the analyzer
21:11bbloommakes sense
21:11bbloomBronsa: typeos: https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/passes.clj#L67-L72
21:12bblooms/Shortrand/Shorthand/g
21:12bblooms/typeos/typos
21:12Bronsaduh. thanks
21:13bbloomBronsa: i'd be interested to know if some of the "cyclic" passes would be better addressed with a dynamic reference attribute grammar
21:14bbloommy experiments there: https://github.com/brandonbloom/ascribe
21:14bbloomi didn't do a cyclic evaluator, but it's pretty straightforward
21:14Bronsabbloom: I'll look into that and let you know
21:15BronsaI'm off to sleep now
21:15bbloomBronsa: the literature is a pretty deep rabbit hole
21:15bbloom"Extensible Compiler Construction" is a good entry point
21:15Bronsanoted
21:15bbloomand this is a good practical implementation: https://code.google.com/p/kiama/wiki/Attribution
21:16bbloom(scala)
21:16joshua___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:16bbloomBronsa: gnight
21:17hyPiRionjoshua___: may be that you're using an old leiningen version. Try out :jvm-opts ^:replace ["-d64" "-Xmx2g"]
21:20pcnHeya, 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:21hyPiRionpcn: maybe agents? See http://clojure.org/agents
21:24joshua___hyPiRion: thank you for trying to help, unfortunately adding the :^replace didn't seem to do anything. Still getting the same totaltMemory
21:27pcnhyPiRion: 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:28pcnIs there an easy way to just start a thread aside from agents?
21:30ddellacostacompsci 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:31amalloyddellacosta: i can't imagine why the answer would be no
21:31amalloy"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:33ddellacostaamalloy: okay, thank you. I think I'm struggling with the definition of "stability," so this is helpful.
21:34amalloyhttp://en.wikipedia.org/wiki/Sorting_algorithm#Stability
21:34hyPiRionjoshua___: I guess it's not a problem with the jvm opts, but how the jvm tends to ignore memory bounds
21:34ddellacostaamalloy: yeah, I was looking at that, thanks
21:35hyPiRionddellacosta: 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:37ddellacostahyPiRion: 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:37ddellacostanew 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:38hyPiRionddellacosta: exactly :)
21:38andyf_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:38amalloyindeed. 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:39ddellacostaandyf_: gotcha...thanks.
21:39andyf_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:40ddellacostaoh, I was just reading about radix sort in the Cormen book...very cool. Would love to see that.
21:40andyf_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:41andyf_Recursion on the next digit position requires manual intervention :-)
21:41ddellacostaoh wow, haha
21:51pcnIs there a way to start a polling thread instead of a reactive thread?
21:52coventryWhat is the difference between the two types?
21:53pcnMy understanding of an async thread per an agent is that it's waiting for activity
21:54pcnI want a thread that will run a loop
21:54coventryYou can use the java thread API as you can in java.
21:55pcnI was hoping there was something as simple as core.async/thread
21:57hyPiRionWell, a Thread isn't necessarily hard in Clojure
21:58hyPiRion(doto (Thread. #(if (wait-condition) (recur) (do-something-and-quit))) (.start))
22:00pcnOK, I'll broaden my horizons
22:00bbloomis 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:04amalloyhyPiRion: why would you (doto (Thread. f) (.start)) rather than (future (f))? the only difference i know of is bindings conveyance
22:06hyPiRionamalloy: If you want to interrupt the Thread or need some other means to poke around at it?
22:07hyPiRionWell, I guess cancel and isCancelled would provide that too
22:22bbloom$mail tbaldridge I need http://golang.org/pkg/time/#Tick please :-)
22:22lazybotMessage saved.
22:23amalloybbloom: 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:24coventryYeah, that go code looks pretty easy to translate.
22:24bbloomamalloy: it is easy enough to build yourself, however depends on a platform specific clock
22:24bbloomcoventry: it uses the internal clock facilities to deal with period drift
22:24bbloomthe interesting bit is the dropping to handle slow consumers
22:24bbloomyou need to measure how much time has passed & schedule your next timeout accordingly
22:25rovarwouldn't ticking into a bounded channel do the same job?
22:25bbloomit's pretty easy to implement, but needs to use either (System/getCurrentMilliseconds) or (js/Date.)
22:25bbloomrovar: no, because the interval needs to be adjusted
22:25rovardoes go's Tick really adjust its interval?
22:26bbloomrovar: read the comments on the NewTicker function: http://golang.org/src/pkg/time/tick.go?s=1482:1515#L40
22:26rovarthe challenging part is actually understanding when the consumer consumes..
22:26bbloomhttp://golang.org/pkg/time/#NewTicker specifically
22:26bbloomthat's not tricky if you have a 1 item buffer
22:27bbloomamalloy: also, it's much less efficient to build it in terms of timeout channels b/c you allocate a channel every tick
22:27bbloomamalloy: if you have a high frequency timer, that's a non-trivial savings you can have by using a non-allocating underlying timer
22:27rovarfair enough, so you just need to count the interval between the blocking write success
22:28amalloyfair enough
22:28rovarso you're basically getting as fast as the consumer but no faster than n
22:28rovarseems like a reasonable thing to have for UI's
22:28bbloomrovar: precisely why i want it :-)
22:31rovarso you'll need to be able to measure intervals of 16ms accurately
22:47rovarhow does one get cider to connect to an existing nrepl?
22:47rovarI am running a webserver process which also spins up an nrepl port
22:48rovarbut cider doesn't pick up on that and spins up its own process.
22:49coventryrovar: Try M-x nrepl (works in nrepl.el)
22:53rovarah
22:53rovarinstead of running cider-jack-in, I just run cider
22:54rovarwhich seems counterintuitive
22:54coventryYes, the inconsistent name-change policy is frustrating.
22:59rovarhmm
22:59rovarso i'm attached to the nrepl for my web server.. but I can't access any of my symbols..
23:00rovareven though I've loaded the bufer with C-c C-k
23:00rovarnot that I think I'd have to..
23:00coventryrovar: Have you set the namespace with something like C-c M-n in the buffer where you ran C-c C-k?
23:02rovarthat doesn't seem to do anything..
23:03coventryWhat does *ns* return in the repl?
23:03rovarhum
23:03rovarthe correct thing
23:03rovarI guess it did behave correctly
23:04coventryCan you access the symbols in that ns, now?
23:13rovarcoventry, yea. it's just wierd that there is no response from the UI when one types C-c M-n
23:16coventryWhat happens if you type (in-ns 'user) at the repl?
23:18rovarclojuremud.core> (in-ns 'user)
23:18rovar#<Namespace user>
23:18coventryYeah, that is weird.
23:19rovarit all works now.. so I'm not too concerned
23:21v4nAny recommendations for handling hmac-sha256 with clojure?
23:22v4nI saw clj-oauth, but it is an overkill for what I need.
23:54SegFaultAXv4n: javax.crypto has everything you need to do hmac sha256
23:54SegFaultAXv4n: If you can't find a self contained example already written in Clojure, try your hand at translating a Java implementation.
23:56v4nSegFaultAX: Thanks, just got it working with javax.crypto.