#clojure log - Nov 05 2015

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

0:03 gfredericks: maybe that will help me sleep extra effectively

0:04 goodnight internet

0:04 rhg135: Night

0:04 justin_smith: (Human/sleep (* 8 60 60 1000))

2:15 owlbird: WARNING: get already refers to: #'clojure.core/get in namespace:

2:15 (:require [console.app :as app])

2:16 (app/get "xx") is still conflict with clojure.core/get, how to fix that?

2:16 opqdonut: it shouldn't

2:16 perhaps you're also use'ing console.app?

2:18 owlbird: after 'lein ring server', api works fine, server only shows a warning message

3:05 how to call a 'get' func of current *ns*, not clojure.core/get ?

3:07 TEttinger: ,(defn get [coll k] "hey guys!")

3:07 clojurebot: #error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb...

3:07 owlbird: I (defn get [code] ...) and call is like (if (get code) ...), but it failed

3:07 ArityException Wrong number of args (1) passed to: core/get

3:08 TEttinger: you can call it with your current ns

3:08 owlbird: it seems called clojure.core/get, not my 'get'

3:08 TEttinger: ,*ns*

3:08 clojurebot: #object[clojure.lang.Namespace 0x7b36f42a "sandbox"]

3:08 TEttinger: ,(defn reductions [f coll] "hey guys!")

3:08 clojurebot: #error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb...

3:08 TEttinger: sigh

3:09 I don't know what it denies, but I guess "everything"

3:09 hm

3:09 that core/get

3:09 that doesn't sound like clojure.core/get

3:09 ,(get {})

3:09 clojurebot: #error {\n :cause "Wrong number of args (1) passed to: core/get"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/get"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval91 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval91 invo...

3:09 TEttinger: nvm

3:10 but you can call it with your own ns

3:10 (my.namespace.core/get {})

3:11 owlbird: that's too long, i mean, is there some namespace indicator? like :: in c or dot in python?

3:12 TEttinger: what is your ns here?

3:12 you can also alias an ns

3:12 or alias your get fn

3:12 ,(alias get2 get)

3:12 clojurebot: #error {\n :cause "Unable to resolve symbol: get2 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: get2 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: get2 in this co...

3:12 TEttinger: ,(doc alias)

3:12 clojurebot: "([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly."

3:13 TEttinger: what am I thinking of...

3:13 owlbird: OK I know why

3:13 TEttinger: also, why does it need to be called get?

3:13 owlbird: I'm using ac-cider in emacs, and *ns* is user>

3:13 TEttinger: user/get ?

3:15 ,(alias cs clojure.string)

3:15 clojurebot: #error {\n :cause "Unable to resolve symbol: cs in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: cs in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: cs in this context"...

3:15 TEttinger: ,(alias 'cs 'clojure.string)

3:15 clojurebot: nil

3:15 owlbird: when I call a function, which then call 'get', it failed

3:15 TEttinger: ,(cs/join " " [:hey :people])

3:15 clojurebot: ":hey :people"

3:15 owlbird: ac-cider's default ns is user

3:15 TEttinger: your ns should never be clojure.core I Think

3:16 that

3:16 that's used for the clojure language

3:16 owlbird: en, that's right

3:17 then, it's ignoring to switch ns, if I want to test a function in repl after executing C-c C-c in emacs

3:24 adamz: Hi. Im using a clojure application (Riemann) and it defines an internal variable as `defonce`. I was wondering it it was possible to redefine a `defonce` variable, as odd as that sounds?

3:27 kungi: adamz: As far as I know you can only redefine vars with the ^:dynamic metadata.

3:27 adamz: darn

3:31 schaueho: kungi: not true

3:31 kungi: schaueho: Ok? Enlighten me?

3:31 schaueho: you can only rebind vars that have ^:dynamic

3:31 also, calling defonce twice will not lead to a re-definition

3:32 but you can, of course, call def again

3:32 ,(defonce onceonly 123)

3:32 clojurebot: #'sandbox/onceonly

3:32 schaueho: ,onceonly

3:32 clojurebot: 123

3:32 schaueho: ,(def onceonly 125)

3:32 clojurebot: #'sandbox/onceonly

3:32 schaueho: ,onceonly

3:32 clojurebot: 125

3:33 adamz: interesting…

3:33 i went looking for crazy solutions and it might be really simple

3:34 schaueho: all the caveats of http://http://clojure.org/special_forms#def apply, though

3:39 adamz: thanks, that worked

5:14 jonathanj: i'm having some trouble figuring out bidi route parameters in conjunction with liberator parameterized resources

5:17 tdammers: question here; is there a difference in how dynamic variable binding works in the context of deftype vs. defrecord?

5:18 because I have this codebase here where it seems like a dynamic variable binding is resolved at definition time for a defrecord, but at method call time for a deftype

5:21 jonathanj: i have a bidi route something like: ["/foo/" {[:id] my-resource}]

5:22 and a liberator resource defined like: (defresource foo [x] ...)

5:22 but trying to access /foo/1234 in my browser results in an error i don't understand: java.lang.ClassCastException: documint.handler$session_resource$fn__10377 cannot be cast to clojure.lang.Associative

5:26 tdammers: wait, nm

5:27 the binding is resolved at call time for both

5:27 is there a way to have it happen when the constructor is called instead, without explicitly passing it to the constructor?

5:29 amalloy: no

5:30 tdammers: dayum

5:30 can I have optional constructor args?

5:39 mpenet: for records kinda using map->Foo, and types just pass nil and wrap this in a function to hide the ugly

5:40 I mean use a function wrapper to handle this stuff

5:41 jonathanj: oh... my bidi handler has to be something like: (fn [req] ((foo (get-in req [:params :something])) req))

5:42 i don't know if there is a better way of writing that, but it's kind of ugly

5:43 tdammers: mpenet: yeah, that's what I'm setting out to do now

5:43 mpenet: having some trouble wrapping it in a macro though

5:44 I want to generate something like `(fn [& args] (apply new ~class-name *my-dyn-var* args))

5:45 but new isn't a fn, so I can't apply it, can I

5:50 mpenet: why a macro?

5:51 just use a fn

5:54 tdammers: I want a macro that I can use instead of deftype

5:55 so that I don't have to write the boilerplate for 16 types by hand

5:55 that macro is supposed to do two things: one, pass everything to deftype to generate the type, and two, generate the fn that does the "capture dynamic var and pass it implicitly as the first arg"

6:00 mpenet: then you don't need apply in your macro template, you can just have the macro generate the proper (new ... ) call for you

6:02 tdammers: then the macro needs to know the arity of the constructor

6:03 but nevermind, I found a solution

6:03 I just use the ->TypeName factory fn that deftype generates

6:05 mpenet: if you generate the deftype with the macro you know the arity :], but good that you found an alternative, it sounded hairy

6:05 tdammers: hehe, no, I don't know the arity - the entire macro is (defmacro defnode [class-name & args] )

6:06 and I just pass args to deftype unchanged

6:06 I could, like, inspect the first element of args, count its elements, and generate a suitable (new), but this is much easier

6:37 Glenjamin: are there any libraries which provide higher-level assertions than (is) ? Someone on our team was asking if there's an AsserJ equivalent

6:38 their example was having (is (= 2 (count some-vec))) showing the vector contents if the count is wrong

6:43 noncom: Glenjamin: haven't seen anything like that, but i too would like to know if that exists...

6:44 however, if it doesn't, there won't be a big problem implementing it....

6:44 an interesting approach would be to use core logic for that, although i still could not verify that it is stabile enough for production

7:48 rhall`: /who #clojure

8:00 dnolen: Glenjamin: test.check does stuff like that

8:01 Glenjamin: dnolen: oh, good point

8:01 wait, hang on - it'll show you inputs

8:01 but not derived outputs in assertions?

8:01 dnolen: it will show you the minimal failing value for your test (= count 2)

8:02 Glenjamin: eg (= 1 (count (function-under-test input))) ; if that fails, i won't be shown the value of (function-under-test input)

8:02 but i can still call it myself once i know the input, outside the test

8:02 dnolen: ah the return value no it won't

8:13 jonathanj: why would i choose to use core.async over something like Manifold deferreds?

8:14 the common "call f with the value when it arrives" case seems to be a lot more boilerplatey with core.async

8:18 am i right in saying that the spelling of "call f with the value when it arrives" in core.async is (go (while true (let [[v ch] (alts! [c1])] (f v))))?

8:21 stain: what about (async/map f c1) ?

8:42 mpenet: in both libs there are many ways to do this

8:42 ex: (go-loop [] (f (<! ch)))

8:43 manifolds seems to have more "knobs" (ex: with the use of the underlying thread)

8:44 jonathanj: how do you construct a processing pipeline with core.async?

8:44 like, to build up several functions that process the result sequentially

8:45 this seems like a really long way of going about it: http://www.braveclojure.com/core-async/#Escape_Callback_Hell_with_Process_Pipelines

8:46 mpenet: you can use transducers to do this

8:49 jonathanj: so how would you write that example with transducers?

8:50 it's not clear to me how you turn clojure.string/upper-case into a transducer

8:50 mpenet: (map clojure.string/upper-case)

8:51 you can then pass it to the chan constructor directly or via other c.c.async function ex pipeline if you want it connected to another chan

8:53 jonathanj: so in that example the xform is (comp (map s/upper-case) (map s/reverse))

8:54 but what is the reducing function?

8:54 maybe i don't want to call (transduce)

8:55 maybe (sequence xform [...])?

8:55 mpenet: you don't have to

8:55 this is the signature of `chan` for instance ([] [buf-or-n] [buf-or-n xform] [buf-or-n xform ex-handler])

8:56 you can create a chan that will transform it's input as you feed to it

8:56 or as I said connect it to another chan and have the transformation done when msgs move from one to antoher

8:56 via pipeline

8:58 jonathanj: do i just pass nil for any of those parameters i don't want to specify?

8:58 like if i wanted to pass ex-handler without xform or buf-or-n

8:58 mpenet: ex: (def c (clojure.core.async/chan 1 (map clojure.string/lower-case)))

8:59 try without the buff-size but I think it will throw

9:03 jonathanj: okay, so buf-or-n must be supplied if you have a transducer, but you can pass only ex-handler by filling the others with nil

9:05 mpenet: then this example is with map, but you can fold over values, filter, etc...

9:08 jonathanj: this still doesn't really help me understand why to choose core.async over manifold

9:08 or vice versa

10:06 jjttjj: anyone know if there are any idioms for working with arithmatic with NAs in incanter, similar to how it's done in R? specifically, i want to add multiple columns of a dataset, where some will start later than others but are backfilled with NAs (nils?), and i want the result to have NAs/nils in these spots. Seems like this should be a fairly common problem but I can't really find a "standard" way to do it? should i just wrap the inc

10:32 jonathanj: is there a comprehensive core.async guide that goes through some of the more obscure parts? like (mix) etc.

10:40 http://martintrojer.github.io/clojure/2014/03/09/working-with-coreasync-chaining-go-blocks/ :(

11:08 sdegutis: How do you sort by two things? Like, if you wanted to sort [[1 2] [2 1] [3 3] [2 3] [3 2]] by first and then second, so you would get [[1 2] [2 1] [2 3] [3 2] [3 3]]?

11:09 llasram: sdegutis: yes. be warned though of the surprising-to-me behavior that Clojure vectors sort first by length, *then* by successive elements

11:09 justin_smith: sdegutis: sort

11:09 ,(sort [[1 2] [2 1] [3 3] [2 3] [3 2]])

11:10 clojurebot: ([1 2] [2 1] [2 3] [3 2] [3 3])

11:10 justin_smith: llasram: or sort-by #(take 2 %) - good point

11:10 sdegutis: No but I mean technically I'm sorting by :queued-email/date and then queued-email/priority.

11:10 So that's what confuses me beyond reason.

11:10 That's what `first` and `second` represent here.

11:11 But f/s are easier to experiment with in samples.

11:11 justin_smith: sdegutis: (sort-by (juxt :queued-email/date :queued-email/priority) mails)

11:11 cichli: (sort-by (juxt :queued-email/date :queued-email/priority) coll))?

11:11 sdegutis: s/s/ex/g

11:11 justin_smith: is that even right? will it truly work?

11:11 justin_smith: sdegutis: yes

11:11 sdegutis: ,(sort-by (juxt first second) [[1 2] [2 1] [3 3] [2 3] [3 2]])

11:11 clojurebot: ([1 2] [2 1] [2 3] [3 2] [3 3])

11:12 sdegutis: ,(sort-by (juxt second first) [[1 2] [2 1] [3 3] [2 3] [3 2]])

11:12 clojurebot: ([2 1] [1 2] [3 2] [2 3] [3 3])

11:12 sdegutis: Now I'm confusing myself by mixing sort with sort-by.

11:12 justin_smith: ,(sort-by (juxt :a :b) [{} {:a 0 :b 1} {:b 3} {:a 12 :b 1}])

11:12 clojurebot: ({} {:b 3} {:a 0, :b 1} {:a 12, :b 1})

11:12 sdegutis: Great.

11:12 justin_smith: sdegutis: those results were all correct

11:12 sdegutis: Thanks justin_smith.

11:12 You're rock.

11:12 justin_smith: haha, I try

11:15 sdegutis: Oh I see justin_smith.

11:15 Juxt forces it to take advantage of how sort automatically sorts seqs in order with respect to all elements from left to right.

11:15 justin_smith: exactly

11:15 clojurebot: excusez-moi

11:15 sdegutis: (IF THERE EVEN IS SUCH A THING AS LEFT TO RIGHT IN SEQS HAHA)

11:16 justin_smith: beginning / end left / right, it works unless you're speaking Hebrew or Chinese or Japanese or whatever I guess

11:16 they actually do have ttys that go right to left

11:16 or back and forth for Arabic

11:19 jjttjj: Is there a reason not to just use Double/NaN all over the place with clojure.core.matrix so i can do vector math with missing values? ie (add [1 2 Double/NaN] [1 1 1]) => [2 3 NaN]

11:21 justin_smith: jjttjj: iirc hitting a NaN tends to make things slower - like the math unit does more work when it hits a nan or something

11:21 jjttjj: maybe there is a sparse matrix lib that would work?

11:22 jjttjj: justin_smith: cool thanks, I'll look into that

11:22 justin_smith: otherwise, if the perf is OK and it gives the right answer, go for it I guess?

12:23 sdegutis: justin_smith: thanks

12:24 for the helpful answer -- you are helpful as always

12:24 Is there something I can do to repay you for your generous help? Maybe you have a link I can advertise on my twitter account?

12:24 justin_smith: haha, not really, but I appreciate the gratitude

12:25 sdegutis: Are you sure I have 13 followers

12:25 I think one of them still uses twittr

12:25 justin_smith: lol

12:30 Weebz`: I'm having trouble figuring out how to do interop with Node.js libraries, could someone explain why I keep getting a no such namespace/use of undeclared var with this?

12:30 http://paste2.org/6mx8AA1k

12:30 i know in js it would be new sql.Connection(...)

12:32 merp. doing (new sql.Connection ...) seems to work

12:47 justin_smith: Weebz`:

12:47 err

12:47 Weebz`: (sql.Connection. ...) is more idiomatic though

12:53 ,(java.util.Date. 0) ; vs (new java.util.Date 0)

12:53 clojurebot: #inst "1970-01-01T00:00:00.000-00:00"

13:13 Glenjamin: hi all, i'm experimenting with using clojure to write tests for a java app - is there any way to get leiningen to pull in dependencies from the "test" scope of a pom?

13:52 is there any way to pass values created in clojure.test fixtures into tests

13:52 or should i just use (binding) ?

13:59 sdegutis: I recently developed need for an email queue that runs in the background written in Clojure. However, I'm coming up with difficulties knowing how to communicate with such a background thread in a queue-like way.

14:00 Is there any such tools that help alleviate such technical difficulties of implementation for the burden of the developer?

14:00 Mitigation of any difficulty would be appreciated. Thanks.

14:02 justin_smith: do you ever write something like this and have recommendations?

14:05 Oh. Looks like core.async helps with this I think?

14:06 Reading https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj suggests so.

14:14 jakedust: sdegutis: I'd say core.async + channels

14:14 sdegutis: Are channels part of core.async?

14:14 jakedust: yup

14:14 if you are familiar with Go channels, they are very similar

14:14 sdegutis: Perfect, thanks!

14:14 Yep, I am.

14:14 Not 100% the same?

14:15 jakedust: I'm not knowledgeable enough to say if they are 100% the same, but I've never had problems so far assuming so

14:16 sdegutis: Cool, thanks jakedust!

14:16 jakedust: there's a lot more in core.async, but I basically just use goroutines and channels for everything

14:16 sdegutis: Sounds like a good plan.

14:27 carkh: sdegutis: core.async is nice, but not the only tool. channels are blocking, there are also agents which are not, but provide no control on the size of the queue (afaik)

14:27 sdegutis: carkh: I thought channels only block when unbuffered?

14:27 carkh: they will block on the size of your lossless buffer

14:28 i mention agents because i find them easier than channels for many tasks

14:28 sdegutis: Realistically though, all I need to do is tell a continuous background job to do something. I literally only need to send half a bit (a full bit could mean true/false, I only need to send "hey you, do your thing"). In which case, are channels overkill?

14:28 So maybe I do need agents.

14:29 carkh: you only need a thread then =)

14:29 sdegutis: How so?

14:29 carkh: why do you need a queue ? are you cosntrained by the possibility of too many "requests" ?

14:30 sometimes just fire and forget is enough

14:30 sdegutis: I just need to tell the background job "hey you got another job to do", and it knows where to find it. It'll keep doing jobs as long as there are some left. When there's none, it just waits for this message.

14:30 But it has to do them sequentially.

14:30 That's the difficult part. It can't do any of these jobs simultaneously, even though it can get simultaneous requests to do it.

14:31 carkh: with agents you have the risk of filling the memory with more requests than you can process, but it's sequential all right

14:31 norton-: I want to create my own project which uses code from this project, https://github.com/adamtornhill/code-maat , but it seems like it's not available as a library on clojars. Is there a simple way I can use the code? Copying all code into my own project perhaps works but it feels like there should be a better way.

14:31 carkh: with core.async you _can_ have backpressure

14:32 lxsameer: is it safe to derefrence an atom inside swap! of other atom ?

14:33 tcrawley: norton-: you can deploy to clojars under org.clojars.your-user-name/code-maat and use that

14:34 amalloy: lxsameer: it's safe in that you are guaranteed to get the current value of that atom. but it might well have a different value the very next instant, so any decision you make based on that value may be out of date

14:34 lxsameer: thanks

14:35 carkh: lxsameer: the best woudl be to deref outside of it though

14:35 lxsameer: carkh: awesome thanks

14:35 norton-: tcrawley: thanks

14:35 carkh: (swap! atom1 do-it @atom2) is correct

14:35 tcrawley: norton-: my pleasure!

14:44 jonathanj: liberator allows you to return a map from a handler which it will turn into JSON in the case of application/json media, but it's not clear how you have it encode some non-standard value into JSON

14:44 clojure.data.json/encode requires an additional arg that you don't have access to when using liberator like this

14:44 cheshire has a way to add an encoder globally but liberator isn't using cheshire

14:59 gfredericks: jonathanj: I swear data.json has a similar global mechanism

15:19 jonathanj: gfredericks: i don't know if i'm looking in the wrong place then but there doesn't seem to be anything like that here: http://clojure.github.io/data.json/

15:20 maybe JSONWriter? but what happens if i want to encode one of the existing types in a different way?

15:30 i feel a bit stupid: i don't understand how to invoke to-hex-string with clj-uuid

15:31 amalloy: carkh: that has exactly the same problem as derefing inside

15:31 jonathanj: (clj-uuid/to-hex-string (clj-uuid/v4)) tells me: java.lang.IllegalArgumentException: No implementation of method: :to-hex-string of protocol: #'clj-uuid/UUIDRfc4122 found for class: java.util.UUID

15:32 amalloy: you can't make a coordinated decision based on the instantaneous state of two different atoms: there is just no way to do it, because they are uncoordinated. if you need to do that, you want refs

15:32 carkh: amalloy: maybe for your concern, but the function should be pure, which it isn't when derefing inside

15:32 amalloy: true

15:33 amalloy: it's true you do avoid one problem by derefing outside, although it's not one that i find usually matters

15:33 carkh: amalloy: true again, i'm just blindly following the doc recommendation =)

15:45 jonathanj: gfredericks: so if i do something like: (extend java.util.UUID JSONWriter {:-write (fn [x ^PrintWriter out] (.print out (uuid/to-string x)))})

15:45 gfredericks: then i get json that looks like: {"foo": 1234-arst-uuid-goes-here}

15:46 and the "write-string" implementation in data.json is private

15:59 *oh* i have to import -write from clojure.data.json, that was not very obvious to me at all :(

16:02 gfredericks: jonathanj: yeah, or you can write the double-quotes yourself (which is what I did, but I like yours better)

17:28 uptown: in a cider REPL, can I hook namespace changes?

18:15 Frozenlock: uptown: hook namespace change?

18:17 uptown: execute a function when the user types (ns some.ns) in the REPL

18:21 Frozenlock: uptown: Hmm... ns is a macro, so I'm not sure this will work: https://github.com/technomancy/robert-hooke/.

18:22 Otherwise you can jump through some hoops and do something similar I did to redefine 'fn' in https://github.com/Frozenlock/force-serialize

18:23 justin_smith: and you can also switch namespaces via in-ns, which is not a macro, it's a special form I think

18:23 maybe not

18:23 Frozenlock: uptown: put the hook on in-ns, ns calls in-ns

18:24 uptown: aha

18:24 Frozenlock: justin_smith: hooks work with special forms?

18:25 justin_smith: Frozenlock: it's not implemented in clojure, but it's also not a special form, it's just a function

18:25 so you can totally hook on it

18:25 amalloy: i don't think you really want to hook in-ns

18:25 justin_smith: oh?

18:25 amalloy: i mean, that will impact every namespace that gets loaded

18:25 justin_smith: that's true

18:27 amalloy: totally works though https://www.refheap.com/111402

18:28 Frozenlock: Btw, is technomancy still alive? I think the last time I heard of him he was moving to another country or something...

18:29 justin_smith: Frozenlock: he pops up in #leiningen sometimes

18:29 he just dropped out of the high-pace #clojure lifestyle

18:29 uptown: for clarity, the point of this is to print a count and abbreviated list of publics when i switch namespaces as a sanity / typo check

18:30 justin_smith: uptown: that should be pretty easy with alter-var-root if you don't mind a permanent change, but robert.hooke does it much more elegantly, if you don't mind this printing every time a namespace gets loaded

18:31 uptown: justin_smith: i think the point is print it every time i change

18:31 which i understand would annoy most people but

18:32 Frozenlock: uptown: many editors will also autocomplete and offer the list of known functions/variables if you are worried about typos.

18:32 uptown: i seem to make enough typos to justify it

18:33 my emacs setup seems not to do that for me? perhaps that's my real problem

18:33 Frozenlock: Yeah, I'd check that first :-p

18:33 Cider?

18:34 uptown: an excellent point. got frustrated and started treating symptoms

18:34 yes, cider / emacs

18:36 Frozenlock: uptown: I'm using Cider with Company-mode: http://i.imgur.com/5aTa1N2.png

18:38 So I've got the dropdown menu as shown, TAB autocomplete, and in some cases hippie-expand (meta-/). I ain't got any typos :-p

18:38 uptown: company-mode offers me namespaces i've previously mentioned but does not expand to a list of funtions

18:39 but you have fewer cider / nrepl warnings on startup than i do

19:02 noncom|3: i am working on a PC with limited caps, and eclipse is getting very hungry, it can eat like 400-800mb. i am thinking about moving to emacs on this machine, how do you think, will it be more feasible?

19:02 oddcully: Eight Megs And Constantly Swaping - should work fine then!

19:03 Frozenlock: noncom|3: It will most probably work. The only question is 'are you read for Emacs?'

19:03 *ready

19:03 justin_smith: emacs is much weirder, but yeah, it can also run with less heap

19:03 noncom|3: yeah, i got some experience with emacs

19:04 on my last emacs usage though, i remember the weirdness - the linum mode was taking up to 15% CPU !

19:04 Frozenlock: o_O

19:04 noncom|3: i remember discussing that on #emacs and people said, like yeah, well, linum eats that much

19:04 and i was like WTF

19:04 maybe even up to 25 CPU, i don't recall exactly.

19:04 i can check tomorrow

19:05 i got to know this by some inbuilt emacs profiler..

19:05 i dont remember how to call for it, but someone on #emacs guided me

19:05 that's the story..

19:06 *it was taking that much on scrolling

19:07 justin_smith: btw, what about that hang in your app? did you nail it down?

19:07 Frozenlock: How do you use linum? I don't use it and I might be missing on some nice wizardry...

19:07 noncom|3: Frozenlock: i just hardcodely enable it in init.el for everything

19:08 you know, i like having line numbers everywhere

19:08 Frozenlock: But it only shows the line number?

19:08 noncom|3: no, it shows a column of numbers to the left

19:08 like that: http://joxi.ru/82QVZ9eIYO4QAd

19:08 (it's eclipse)

19:09 Frozenlock: Yes... what I'm asking is how do use that in your workflow.

19:09 noncom|3: for navigation, for stack traces

19:09 somehow i feel better with it

19:09 oddcully: Frozenlock: some folks need that to see... others just tell the editor

19:09 noncom|3: tried to work without it, but found that i always turn it on

19:11 Frozenlock: I see. Yeah I just tell emacs to go to line when I have a stacktrace. 'M-g g'

19:12 noncom|3: i know, eclipse can do this too

19:12 Frozenlock: I hope so :-p

19:12 noncom|3: :D

19:27 the_nonameguy: hey, has anyone written a test.check generator based on a schema from the 1.0 prismatic/schema release?

19:30 http://blog.getprismatic.com/schema-1-0-released/

19:30 it states that it 'provides way to plug in custom generators', but I couldn't figure out how, based on the source

20:06 gfredericks: the_nonameguy: haha I just figured that out today

20:07 (cgen/generator the-schema {SomeSchema some-generator})

20:41 bluezone: OH my GOD. How on EARTH do I erase brackets around an expression in Cursive ?!?!

20:41 cfleming: bluezone: https://cursiveclojure.com/userguide/paredit.html :)

20:43 bluezone: GOD BLESS YOU!

20:43 gfredericks: ~GOD |BLESS| cfleming

20:43 clojurebot: 'Sea, mhuise.

20:44 * cfleming waves hands benignly

20:51 TEttinger: to the tune of god bless america: GOD BLESS G. FREDERICKS / TESTS CAN BE CHUCKED / MAKE EXPRESSIONS / AND DOUBLES / FROM THE NAN TO THE HASH DOUBLE QUOTE

20:52 sorry cfleming, your name doesn't have the extra syllable to fit the scheme

20:53 cfleming: It would have to be a fle-he-ming - worse things have been done to make something scan

20:53 TEttinger: phlegming

20:54 really appreciate what you wonderful tools authors do

20:54 I'm so glad clojure has a good community of people making productivity better for everyone

20:57 cfleming: I notice that only gfredericks gets a song, though.

20:57 I mean, I'm just saying.

21:05 TEttinger: to the tune of god bless america: GOD BLESS INTELLI J/ CURSIVE WE LOVE / USE PAREDIT / AND EDIT / ALL YOUR CLOJURE WITH C FLEMING'S HUG

21:06 cfleming: TEttinger: That's awesome. I'm going to make Cursive play that at startup.

21:06 TEttinger: haha

21:07 cfleming: It'll be like the pledge of allegiance

21:08 I wonder if I could remix it to the tune of God save the Queen

21:08 gko: Is there a way to have a Cursive REPL in a single window?

21:09 cfleming: gko: How do you mean, in a single window?

21:09 gko: I mean not a "output window on top / input window at the bottom"

21:10 one window with both input and output

21:10 like most REPL

21:10 like in cider or SLIME

21:12 cfleming: gko: No, there isn't

21:12 bluezone: https://www.refheap.com/111403 I'm trying to have the function accept a vector. I believe I am doing something wrong :/

21:13 cfleming: It's because in IntelliJ editors are strongly typed, so the input editor has to be a Clojure editor, but the output isn't actually Clojure, it's arbitrary text

21:13 gko: So I have to separate them.

21:14 That said, it's actually quite nice, especially for editing multi-line forms.

21:14 gko: cfleming: oh, so if you insert random text it will actually try to parse the colors, etc...

21:15 cfleming: gko: Right. There's actually a problem with that, which is that if you try to (read) in a Cursive REPL, it currently won't work well.

21:15 Since Cursive will always try to treat it as Clojure code.

21:17 There are some potential hacks to get around that, but I haven't implemented anything yet.

21:17 gko: OK, too bad... fortunately, there's cider for the REPL side...

21:20 gfredericks: wow a lot of singing happened here while I wasn't looking

21:20 bluezone: It's telling me on line 7 that i'm passing 4 arguments https://www.refheap.com/111404

21:20 I'm just trying to pass [1 2 3 4 5] into the vect parameter :(

21:20 gfredericks: bluezone: that's not causing the error

21:20 it's happening on line 5

21:21 cfleming: gfredericks: It was great.

21:21 bluezone: Why doesn't the stack trace tell me that :(

21:21 gfredericks: bluezone: what's the stack trace look like? it ought to

21:22 cfleming: gfredericks: Are you going to be at the conj?

21:22 gfredericks: cfleming: absolutamente

21:22 cfleming: gfredericks: Muy bien

21:22 We can sing odes to each other.

21:22 bluezone: gfredericks: https://www.refheap.com/111406 (in my code, line 5 is line 7)

21:22 cfleming: TEttinger has given us some great material

21:22 badatclojure: Hey guys! Quick question about multimethods. I'm wanting to dispatch off a map containing a certain property (params request in Compojure). Is there a good way to do that?

21:23 gfredericks: I'll sing you your song if you sing me mine

21:23 badatclojure: certain key* sorry

21:23 gfredericks: bluezone: looks like the problem is you're not seeing the stack trace at all -- try typing *e at the repl

21:24 bluezone: oh, heh nice

21:25 gfredericks: this year will be my first conj since maybe the first one

21:25 or maybe the second one

21:25 they were so long ago now I can't remember

21:28 * bluezone is so fcking URGHHHH Can't grasp the syntax to save his life

21:30 Frozenlock: bluezone: the clojure syntax?

21:30 bluezone: yes

21:31 never sure when to put brackets

21:32 Frozenlock: Do you have an editor that highlights the brackets?

21:32 TEttinger: unless you have ' quotes involved, () starts with a function to call and anything else in it is an argument

21:32 that's most of it

21:32 bluezone: hmm

21:32 badatclojure: brackets are basically used to separate functionality. In Java, you'd type something like cons(a,b). In clojure, you move the name inside the parens and drop the comma (cons a b).

21:32 TEttinger: (function or macro)

21:33 Frozenlock: It's like math :-p

21:33 bluezone: if I want to pass rest vect as one parameter I need to do (rest vect) ?

21:33 badatclojure: same thing for deeper function stacks. Java: cons(a, something(b)) Clojure: (cons a (something b))

21:33 TEttinger: ,(let [vect [1 2 3 4 5]] (map inc (rest vect)))

21:33 clojurebot: (3 4 5 6)

21:34 bluezone: hmm

21:35 TEttinger: inc is sorta like ++, it increments (but doesn't change any existing variables, things that do that are rare)

21:35 bluezone: I think I'm just unaware of something special i need to do for recursion

21:35 TEttinger: ,(let [vect [1 2 3 4 5]] (rest vect))

21:35 clojurebot: (2 3 4 5)

21:36 TEttinger: bluezone, usually you don't directly do recursion in clojure

21:36 there's loop and recur, which are pretty much always used together

21:36 bluezone: wat

21:36 Frozenlock: bluezone: Don't listen to him, recursions are cool :-D

21:36 badatclojure: Bluezone: Direct recurson doesn't happen much. You'll see loop and recur. Oh, and you'll see map a lot too.

21:36 TEttinger: tail recursion can blow the stack if you don't use loop/recur

21:37 badatclojure: Yeah, make sure to use loop/recur.

21:37 TEttinger: (also non-tail recursion)

21:37 bluezone: I guess they aren't using java8? I think they removed that problem in java8

21:37 badatclojure: Learned that the hard way.

21:37 TEttinger: nope

21:37 java8 still lacks TCO

21:37 bluezone: java8 still lacks a language

21:37 badatclojure: I dont really know when Java8 will have TCO.

21:37 TEttinger: it as under consideration

21:37 *was

21:37 Frozenlock: I use recursions when I know my dataset will be small-ish. loop/recur is... not pretty.

21:38 jasonx2: in some ways recur is nicer than tail recursion. you get a compile-time check if your function is tail recursive

21:38 badatclojure: People dont really write recursive Java to my knowledge though. Or really even try. Stateful recursion is scary anyways.

21:38 TEttinger: I strongly recommend trying to phrase things with map, filter, recur, and other common fns like that before you start doing loop/recur

21:38 *map, filter, reduce

21:39 bluezone: I just don't understand why it's still passing 4 arguments https://www.refheap.com/111407

21:39 badatclojure: Shameless self-plug. Could someone explain how to setup multimethods that dispatch off of a key existing in a map parameter?

21:40 bluezone: like it takes the rest of vect, but instead of passing it as a vect it passes each value individually

21:40 Frozenlock: bluezone: https://www.refheap.com/111408

21:41 And you don't need the 'apply', unless I misunderstood what you are trying to do.

21:41 netrobyatmobile: who know how to compile Clojure code into Executable Binary ELF file?

21:42 bluezone: Well

21:42 shit

21:43 Frozenlock: (first-element) is like calling the function 'first-element' which doesn't exist.

21:43 bluezone: yeah, hmm

21:43 Thanks

21:46 TEttinger: netrobyatmobile: you would need to get the JVM bundled in there too

21:47 bluezone: Seems the solution works in my environment but not on 4clojure <3

21:47 netrobyatmobile: Thanks, i hate JVM , it will takes more than 200MB space.

21:47 Download, Upload the whole distribution was huge packages.

21:47 TEttinger: there's clojurescript and clojure CLR

21:47 netrobyatmobile: Long time to waiting it deliveried

21:48 Frozenlock: bluezone: link?

21:48 bluezone: Frozenlock: https://www.4clojure.com/problem/19

21:49 TEttinger: netrobyatmobile: Pixie is similar to Clojure in lots of ways but doesn't use the JVM

21:49 it also is not very finished yet I think, though it's getting better

21:50 Frozenlock: bluezone: If you are not using 'defn', I suppose you are using 'fn'?

21:50 bluezone: it tells me I tripped the alarm? O.o I dunno wtf

21:50 Frozenlock: Ah ok

21:50 So yeah, you can't define functions.

21:50 bluezone: err

21:50 Frozenlock: But you can create one that will be used immediately with 'fn'.

21:51 "define function" -> defn | "function" -> fn

21:52 bluezone: well How can i use recursion if I don't have the function name

21:52 cfleming: netrobyatmobile: Check out Avian, it's an alternative lightweight JVM which can compile an executable

21:52 Frozenlock: bluezone: fn accepts an optional name.

21:52 cfleming: It's not high performance, depends on your use case

21:52 Frozenlock: Type (doc fn) in your repl.

21:53 (fn last-e [vect]...

21:54 bluezone: so what would be the difference between (defn last-e) and (fn last-e)

21:55 ah

21:55 nevermind, fn is used immediately I guess

21:55 defn creates a function for later use

21:59 jakedust: not really that Clojure-related, but does anybody have any recommendations of readings/code on building "services"? i.e. I want to build a data processing service with a REST API for both task-related commands (do task A as soon as you can) and "lifecycle" commands (finish all the jobs you have right now and exit as soon as you can)

22:00 my original idea was writing everything around an event loop and core.async channels, but I'm not sure if that's a good idea or not, I'm really not familiar with this

22:01 netrobyatmobile: Thanks /msg cfleming

22:10 bluezone: Well this seems like a really sexy language so far

22:11 I love that-I-Can-do-this insteadOfThisCamelFatassAnnoyance

22:12 jakedust: bluezone: I have to confess that seeing * in names is confusing, but still lovely

22:20 Frozenlock: bluezone: be warned, this is a one way trip.

22:20 bluezone: Frozenlock: away from what? java?

22:20 Frozenlock: It's like going from 56k to broadband.

22:21 All-the-things!

22:22 bluezone: eh, I don't care anymore lol. Prefer to be a bum than to fall asleep coding in boring languages

22:22 jakedust: Frozenlock: I've been bitten by the Clojure bug.

22:22 Frozenlock: jakedust: https://mlpforums.com/uploads/monthly_06_2015/post-20300-0-98845900-1435445700.jpg

22:23 jakedust: heh, I though it'd be a parasprite, given the URL

22:23 but yeah

22:24 Frozenlock: Pff, that's URLism

22:24 Don't judge based on URL dude.

22:26 jakedust: weirdly enough, it feels like I was on another extreme, using scalaz everyday

22:33 bluezone: I keep tripping the alarm -.-

22:33 They have so many restrictions on identifier names

22:35 TEttinger: cfleming: does avian work with clojure now?

22:36 I tried it a while ago, it didn't support some java data structures clojure needed

22:36 (also, netrobyatmobile, there's zulu builds of OpenJDK that are much less than 200MB)

22:37 (and you are allowed to take stuff out of those)

22:44 cfleming: TEttinger: I believe it does, but you might have to use a different class library

22:44 The default one is very limited, but you can use OpenJDK classes or the Android ones IIRC

23:32 jeaye: ,(-> [:foo] first name symbol list str)

23:32 clojurebot: "(foo)"

23:32 jeaye: ^ is there a cleaner way to get the same result, given [:foo]?

23:34 irctc: hi guys does anyone know how to run om-next-demo project

23:34 https://github.com/swannodette/om-next-demo

23:34 I have managed to get all the deps working, it seems we need to run some kind of script instead lf lein run.

23:35 I have read this https://github.com/clojure/clojurescript/wiki/Quick-Start, but it's a bit confused. Any help would be appreciated.

23:38 TEttinger: ,(map symbol [:foo])

23:39 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String>

23:39 TEttinger: hm

23:39 ,(map (comp symbol name) [:foo])

23:39 clojurebot: (foo)

23:39 TEttinger: ,(str (map (comp symbol name) [:foo]))

23:39 clojurebot: "clojure.lang.LazySeq@9e9a82cb"

23:39 jeaye: apply str

23:40 ,(apply str (map (comp symbol name) [:foo]))

23:40 clojurebot: "foo"

23:40 jeaye: ah

23:40 Well, maybe what I have isn't so bad then.

23:41 TEttinger: ,(map #(str "(" (name %) ")") [:foo])

23:41 clojurebot: ("(foo)")

23:42 jeaye: heh

23:42 There's a lot more syntax there.

23:42 TEttinger: ,(apply str (map name [:foo]))

23:42 clojurebot: "foo"

23:43 jeaye: ,(apply str (map (comp list name) [:foo]))

23:43 clojurebot: "(\"foo\")"

23:43 jeaye: ,(apply str (map (comp list symbol name) [:foo]))

23:43 clojurebot: "(foo)"

23:43 jeaye: Correct result, not any cleaner.

23:44 TEttinger: ,(pr-string (map name [:foo]))

23:44 clojurebot: #error {\n :cause "Unable to resolve symbol: pr-string in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: pr-string in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: pr-st...

23:44 TEttinger: ,(pr-str (map name [:foo]))

23:44 clojurebot: "(\"foo\")"

23:44 TEttinger: hm

23:45 ,(pr-str (map str [:foo]))

23:45 clojurebot: "(\":foo\")"

23:45 TEttinger: ,(pr-str (map (comp symbol name) [:foo]))

23:45 clojurebot: "(foo)"

23:52 TEttinger: ,(apply str (nfirst (map name [:foo])))

23:52 clojurebot: "oo"

23:55 TEttinger: ,(apply str (nfirst [:foo]))

23:55 clojurebot: #error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.lang.RT next "RT.java" 682]\n [clojure.core$n...

23:55 TEttinger: ,(apply str (nnext (str [:foo])))

23:55 clojurebot: "foo]"

23:55 TEttinger: damn

23:57 ,(str "(" (name (first [:foo])) ")")

23:57 clojurebot: "(foo)"

23:57 TEttinger: ,[(count "(str \\( (name (first [:foo])) \\))") (count "(-> [:foo] first name symbol list str)")]

23:58 clojurebot: [33 38]

23:58 TEttinger: so there's some teensy golf

23:58 the list threw me off initially, so in my mind the explicit str with parens shows the end result

Logging service provided by n01se.net