#clojure log - Jun 17 2015

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

0:35 tmtwd: * Connecting to chat.freenode.net (

0:35 * * Certification info:

0:35 * Subject:

0:35 * OU=Domain Control Validated

0:35 * OU=Gandi Standard Wildcard SSL

0:35 * CN=*.freenode.net

0:35 * Issuer:

0:35 * C=FR

0:35 * O=GANDI SAS

0:35 * CN=Gandi Standard SSL CA

0:35 * Public key algorithm: rsaEncryption (2048 bits)

0:35 * Sign algorithm sha1WithRSAEncryption

0:35 * Valid since Jan 3 00:00:00 2015 GMT to Jan 15 23:59:59 2016 GMT

0:35 * * Cipher info:

0:35 * Version: TLSv1/SSLv3, cipher DHE-RSA-AES256-GCM-SHA38 (256 bits)

0:35 * Connected. Now logging in.

0:35 * *** Looking up your hostname...

0:35 * *** Checking Ident

0:35 * *** Found your hostname

0:35 * *** No Ident response

0:35 * Capab

0:35 oops

0:35 is that any sensitive information?

0:36 TEttinger: tmtwd, I don't see anything bad

0:37 so, https://scontent-sjc2-1.xx.fbcdn.net/hphotos-xfa1/v/t1.0-9/11390060_3127051372334_2540245238860767788_n.jpg?oh=5f45dea77976c3b70b8b3a62b7872fb7&oe=5624C30F

0:37 tmtwd: heh

0:39 TEttinger: nice story behind that cat, she is a feral who was trapped to be spayed, but she had to give birth to her kittens first. she was extremely defensive of the little ones (that explains the photo), but now she's spayed and back where she wants to be in the forest, and her babies are getting adopted soon

0:40 but it's really a "blood is thicker than water, and if you touch my family there WILL be blood" type of cat face

0:56 Surgo: bit of a strange question...I know it's really hackish, but is there any particular reason it would be bad to add entries to default-data-readers? I can't see any other way to transparently effect both clojure.core/read{,-string} and clojure.edn/read{,-string}

4:08 benhuda: helo

4:09 im migrating code from windows to the JVM (clojure and java), and wondering -- is there a good way to run processes like windows services in java?

4:09 aside from the obvious main while(true) loop... CLI daemons that have a lifecycle and can be managed and introspected

4:10 maybe i should take a look at how Storm and Cassandra run

4:10 p_l: benhuda: two different things - wrappers that run Java applications as services (Jsvc?) and for hosting multiple applications/services in one process, a Java application server, afaik there's a clojure-oriented package based on JBoss

4:11 benhuda: well it will be a service that runs and never quits... its a poller service. every X minutes it will perform DB queries forever

4:11 so it has no Web / such concerns, just database

4:11 p_l: benhuda: for something simple, Jsvc or similar will be enough

4:12 benhuda: i'm aware i can just do an endless loop, but i'm looking for something more infrastructural to enjoty

4:19 zot: i'm editing a bunch of files in emacs, and usually re-eval after mkaing changes, but sometimes forget. is there a simple way to eval all open clj files, so that my cider/repl is up-to-date with my source?

4:26 scottj: zot: maybe M-x cider-refresh

4:26 bound to C-c C-x

4:27 zot: scottj: clever, if i read that code right if will reset, and force all deps to get reloaded along the way :)

4:28 (inc scottj)

4:28 lazybot: ⇒ 4

7:32 justin_smith: zot: there is also tools.namespace.repl/refresh

7:33 which will reload code, but only from your current project, and will also delete vars that no longer exist

7:33 zot: justin_smith: thanks. i knew about namespace, but curiously hadn't seen how to just execute arbitrary code in the repl until seeing the cider-refresh code (which calls namespace/refresh first). so cider-refresh solved 2 problems for me at the same time :)

8:26 Chaze: Hi. I want to implement a relatively generic function "parallel", which is basically the same as the Haskell arrow (&&&) - in case you're familiar with this. I got this, but its ugly: https://www.refheap.com/f8071392381918fae31dbf568

8:28 more simple, why doesn't the following work? let functions be a list of unary functions and arguments a list of arguments for them, I want to do (map apply functions arguments)

8:29 justin_smith: Chaze: apply requires its last arg to be in a list

8:29 or, more precisely, in a collection

8:30 Chaze: ah, so (map apply functions (map list arguments)) may work?

8:30 justin_smith: ,(map apply [inc dec + -] [[1] [43] [8 17] [1000 33]])

8:30 clojurebot: (2 42 25 967)

8:30 justin_smith: Chaze: if arguments is a list of single items for unary functions, yes

8:31 Chaze: perfect, thank you

8:42 justin_smith: Chaze: another option would have been (map #(%1 %2) functions arguments) because map is varargs

8:43 Chaze: justin_smith: strange, that there is no predefined function #(%1 %2)

8:44 jonathanj: i can't recur with a different arity to the function i'm recurring from?

8:44 justin_smith: jonathanj: that's true, you cannot

8:44 jonathanj: okay

8:46 justin_smith: jonathanj: though you could do something similar to recurring on different arities with trampoline

8:46 trampoline can be weird to use at first though

8:52 ,(trampoline (fn bounce ([] #(bounce 1)) ([x] #(bounce 2 x)) ([x y] #(bounce x 3 y)) ([x y z] [z y x]))

8:52 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

8:52 justin_smith: oops

8:52 ,(trampoline (fn bounce ([] #(bounce 1)) ([x] #(bounce 2 x)) ([x y] #(bounce x 3 y)) ([x y z] [z y x])))

8:53 clojurebot: [1 3 2]

8:53 jonathanj: justin_smith: i think just kickstarting the recur with a lower arity version is probably good enough for what i want

8:53 justin_smith: OK

8:53 jonathanj: thanks

8:56 justin_smith: letfn / trampoline is a nice combo sometimes

9:06 kaiyin: It seems learning clojure web development is very difficult because everything is changing so fast. Books published only a few months ago are already outdated.

9:08 dagda1_: how can I use macroexpand to tell me how the thread-last macro will expand out, I've tried this (macroexpand (->> (iterate scratch.core/cuts [1 2 3 4]) (map count) (take-while pos?)))

9:08 but it gives me the result

9:08 lumafi: you need to quote the macro expression

9:09 justin_smith: ,(macroexpand '(->> (iterate scratch.core/cuts [1 2 3 4]) (map count) (take-while pos?)))

9:09 clojurebot: (take-while pos? (map count (iterate scratch.core/cuts [1 2 3 4])))

9:09 dagda1_: lumafi: thanks

9:17 phillord: If I want to install lein on windows, are there any standard locations that I can drop it, that don't require the use to fiddle with their path settings?

9:17 the windows installer looks nice, but installs 1.7

9:18 or am I wrong about this?

9:28 expez: anyone have time to take a look at https://github.com/expez/str before I announce? Any glaring omissions? I'm also not sure about aliasing clojure.string like this, but I find the alternatives unattractive :/

9:28 TEttinger: phillord, it shouldn't install an old version?

9:28 which link are you using, phillord?

9:29 expez, uh

9:29 ,str

9:29 clojurebot: #object[clojure.core$str 0x40de81f5 "clojure.core$str@40de81f5"]

9:29 TEttinger: that seems like a very strange choice for a library name

9:31 expez: TEttinger: well, it is a string manipulation library. Not sure a random girls name or literary character would be much better :p

9:31 TEttinger: https://github.com/expez/str/blob/master/src/str/core.clj#L107

9:31 typo there, not sure what needles are in the later fns

9:32 expez, true but it's confusing, "which str do you mean again?"

9:32 dagda1_: I think I am failing to see why the thread last macro is not called the thread first macro

9:33 TEttinger: dagda1_: thread last is ->> , and inserts the arg you give it as the last argument to each of the following forms

9:33 oddcully: dagda1_: last as in last argument. not from right to left

9:33 expez: TEttinger: needles are the thing we look for in the haystack (string). You're the second person to wonder about this. I stole it from s.el because I thought it was clever.

9:33 TEttinger: ,(->> [1 2 3] (map inc) (reduce +))

9:33 clojurebot: 9

9:36 TEttinger: expez, as for library names, there's possibly: textual , stringy , superstring (after the physics theory), wordsmith

9:37 I don't think str specifically is trouble here because it's always really str.core, it still seems confusing to me

9:37 dagda1_: TEttinger: so that expands to (reduce + (map inc [1 2 3])) where does the last come in because it calls reduce first?

9:38 TEttinger: dagda1_, not what it expands to

9:38 expez: TEttinger: https://github.com/expez/str/blob/master/src/str/core.clj#L34 what do you think of this?

9:38 TEttinger: the last argument passed to reduce is the threaded form

9:38 contrast with:

9:40 ,(-> [1 2 3] (concat [4]) (conj 5))

9:40 clojurebot: (5 1 2 3 4)

9:40 TEttinger: which is because concat returns a seq, and seqs append to beginning

9:41 which is the same as

9:41 ,(conj (concat [1 2 3] [4]) 5)

9:41 clojurebot: (5 1 2 3 4)

9:42 TEttinger: you can see that in the thread-first case, the [1 2 3] becomes the first arg to concat

9:42 in the thread-last case, it become the last arg to map and reduce

9:43 dagda1_: TEttinger: brilliant, thanks

9:43 TEttinger: expez, it doesn't strike me as a bad idea, especially since you aren't drawing in extra deps or anything

9:44 it seems a bit... I dunno, if you're using it in your code it's probably fine, if it's only for end users they could really just include clojure.string themselves

9:44 expez: TEttinger: I'd like to avoid having both clojure.string :as str superstring.core :as ss in the same namespace heh

9:45 TEttinger: ah ok, fair enough

9:45 expez: TEttinger: I also didn't want to re-implement clojure.string because that's a waste of time and if I change the semantics people will get tripped up

9:46 so aliasing seems like a good alternative

9:46 TEttinger: yeah, good points

9:46 expez: I think I like superstring because it's actually extending clojure.string :p

9:47 dagda1_: the penny has dropped :)

10:35 phillord: TEttinger: sorry, I realise that I was wrong -- the installer SAYS it is going to install Leiningen Version 1.0, but actually doesn't

10:37 Now, why does bitbucket not have a issue tracker!

10:38 TEttinger: hm, it should

10:38 pbx: phillord, it does

10:38 littleli: yeah, it does

10:38 pbx: can be enabled/disabled by the project owner though

10:39 oddcully: they even sell one ^_^

10:40 phillord: for the lein installer, I can't see one

10:40 PR yes, issues no

10:40 pbx: then they haven't enabled it.

10:40 TEttinger: it might use a different site to track issues

10:48 crocket: Does clojure have a decent reactive GUI library?

10:52 sm0ke: no

10:52 but there are some which are written in clojure/script

10:53 nothing inbuilt in clojure afaik

10:53 wasamasa: someone wrapped swing

10:53 https://github.com/daveray/seesaw

10:53 TEttinger: I believe quil may have reactive parts

10:53 sm0ke: for web side you have reagent om

10:54 TEttinger: the problem on desktop is that you mostly have to use java libs or wrappers around them to display fancy graphics with any performance, and most java libs are not written for reactive style, I think

10:54 sm0ke: hmm

10:54 actually facebook recently announced react native

10:55 crocket: GUI seems to be a mine field.

10:55 sm0ke: i am wondering if coljurescript -> js -> native

10:55 can be done

10:55 TEttinger: however, there's stuff like chromium embedded if you want to use cljs on desktop

10:55 $google chromium embdedded framework

10:55 lazybot: [chromiumembedded / cef — Bitbucket] https://bitbucket.org/chromiumembedded/cef

10:55 sm0ke: wow didnt know about that

10:55 must be awfully heavy though?

10:56 wasamasa: crocket: no shit

10:56 TEttinger: github for windows uses it, so does spotify, uplay, desura, steam client, recent AIM...

10:56 wasamasa: crocket: next thing you proclaim is that any real-world programming is

10:57 crocket: Is there a viable path toward applying reactive programming on native GUI programs?

10:57 chromium embedded?

10:57 sm0ke: https://github.com/atom/electron

10:57 crocket: There is JavaFX...

10:58 Would it be reasonable to write a reactive wrapper around JavaFX in clojure?

10:58 sm0ke: http://react-native.org/

10:58 TEttinger: atom looks nice

10:59 crocket: react-native, atom, blah blah, ..., chromium embedded

10:59 sm0ke: i guess react native would be perfect for you crocket

10:59 its reactive and native heh

10:59 crocket: sm0ke, After I try, I may change my mind.

10:59 It involves HTML and CSS.

11:00 sm0ke: you want to write in C?

11:00 crocket: ha

11:00 sm0ke, Some people are trying to write JavaFX bindings in clojure and frege.

11:00 sm0ke: is javafx reactive?

11:01 crocket: I don't know.

11:01 sm0ke: i thought you said reactive?

11:01 crocket: https://github.com/TomasMikula/ReactFX

11:02 I didn't say JavaFX was known to be reactive.

11:03 sm0ke: crocket: you want to write over jvm?

11:04 crocket: sm0ke, I don't know...

11:04 But, it's useful to know

11:04 sm0ke: :/

11:04 crocket: It's useful to know that clojure has decent GUI libraries on JVM.

11:05 There is https://github.com/aaronc/fx-clj

11:05 https://github.com/aaronc/fx-clj supports reactive programming over JavaFX.

11:05 Since JavaFX is compatible with Java 8 lambdas, it has a lot of callbacks.

11:10 voidnoid: is datomic OT in here?

11:11 crocket: It seems reactive native is for Mac OS.

11:11 React Native "Build native iOS and Android apps with JavaScript."

11:25 hmm

11:26 csd_: How might I check whether a vector is a subclass of java.util.Collection?

11:26 instance? doesn't seem like the right function

11:26 justin_smith: ,(isa? java.util.Collection [])

11:26 clojurebot: false

11:26 justin_smith: (doc isa?)

11:26 clojurebot: "([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"

11:26 justin_smith: oh

11:27 ,(isa? [] java.util.Collection)

11:27 clojurebot: false

11:27 csd_: that can't be correct

11:27 is it?

11:27 justin_smith: yeah, I am doing it wrong

11:28 csd_: ,(isa? () java.util.Collection)

11:28 clojurebot: false

11:29 csd_: ,(isa? clojure.lang.PersistentVector java.util.Collection)

11:29 clojurebot: true

11:29 justin_smith: oh, it needs the type

11:29 makes sense

11:29 Bronsa: ,(instance? [] java.util.Collection)

11:29 clojurebot: #error {\n :cause "clojure.lang.PersistentVector cannot be cast to java.lang.Class"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentVector cannot be cast to java.lang.Class"\n :at [clojure.core$instance_QMARK___4128 invoke "core.clj" 142]}]\n :trace\n [[clojure.core$instance_QMARK___4128 invoke "core.clj" 142]\n [sandbox$eval143 invoke "NO_SOURCE_FILE" 0]\n [...

11:30 Bronsa: ,(instance? java.util.Collection [])

11:30 clojurebot: true

11:30 Bronsa: (╯°□°)╯︵ ┻━┻

11:30 csd_: ah

11:30 justin_smith: (inc Bronsa)

11:30 lazybot: ⇒ 113

11:30 csd_: justin_smith: you use Cursive predominantly right?

11:30 justin_smith: Bronsa: that's what I was looking for, found it just after you shared that

11:30 csd_: no, I do not

11:30 I'm a fan, but I can't do IDEs

11:31 csd_: It feels really clunky to me but maybe that's just lack of experience with it. I think though that if I were working really closely with a Java project that it'd be essential

11:31 thoughts?

11:32 justin_smith: yeah, IDEs in general don't tend to work the way I want to work I think. I gave up on cider even.

11:32 csd_: what do you use now

11:32 justin_smith: a repl in a terminal

11:33 csd_: what if you need to traceback to the clojure Java code for example

11:33 justin_smith: stack traces / reflection + google

11:34 I'm basically a cave man

11:34 csd_: whatever works

12:14 crocket: What are good ways to write reactive GUI apps in clojure?

12:15 snowell: Reagent works well for me

12:15 http://reagent-project.github.io/

12:15 crocket: I think I heard a better alternative to react on clojure.

12:16 justin_smith: the two main ones are om and reagent

12:16 snowell: Om or re-frame are the only other ones I've heard of

12:17 oddcully: there is also rum, but thats not what you asked

12:17 blkcat: om looks very interesting

12:17 justin_smith: re-frame is a toolkit for reagent

12:18 CookedGryphon: Hey, found a weirdness with update, think I know what's happening, but if anyone could offer comment...

12:19 ,(update [] 0 (fnil inc 0))

12:19 clojurebot: [1]

12:19 CookedGryphon: ,(update [] 1 (fnil inc 0))

12:19 clojurebot: #error {\n :cause nil\n :via\n [{:type java.lang.IndexOutOfBoundsException\n :message nil\n :at [clojure.lang.PersistentVector assocN "PersistentVector.java" 183]}]\n :trace\n [[clojure.lang.PersistentVector assocN "PersistentVector.java" 183]\n [clojure.lang.PersistentVector assocN "PersistentVector.java" 21]\n [clojure.lang.APersistentVector assoc "APersistentVector.java" 333]\n [clojure....

12:19 csd_: what would be the best way to generalize a function so that if i call it in my production code it does X and if i call it in my test code it does Y?

12:19 justin_smith: ,(update [0] 1 (fnil inc 0))

12:19 clojurebot: [0 1]

12:20 justin_smith: CookedGryphon: I think it just doesn't know how to skip indexes, but it is happy to make the incremental next one

12:20 CookedGryphon: yeah

12:20 I just found it surprising

12:20 expected it to either blow up in both cases or simply return the input unchanged if it can't set the key

12:21 justin_smith: clojure is often surprising, while still being simple

12:22 snowell: csd_: If you're using leiningen, you can set up profiles. And you can pair that with something like environ to pull different environment variables

12:23 csd_: snowell: can you elaborate? im not sure how that would work

12:23 would i in my environ file declare the code?

12:23 snowell: csd_: https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md

12:24 justin_smith: csd_: I've used environ to set a key I can check, then switched implementation at runtime based on the key

12:24 snowell: And what justin_smith just said is what I was going to type next :)

12:24 csd_: justin_smith: but then i have a `cond` in my production code that says, if you're in a test environment, do this, right?

12:25 justin_smith: csd_: or a multimethod (defmulti run-server (fn [& args] (env :server-version)) (defmethod run-server "prod" ...) (defmethod run-server "dev" ...)

12:26 since defmethod can dispatch on an arbitrary function, it can ignore all the args and just use environ

12:26 csd_: oh thats cool

12:27 justin_smith: would you pick that over with-bindings?

12:27 crocket: Does react provide a decent variant of functional reactive programming?

12:27 justin_smith: csd_: with-bindings is for thread local stuff isn't it?

12:28 csd_: justin_smith: not sure

12:28 crocket: My gut feeling tells me that react doesn't promote FRP much.

12:28 justin_smith: crocket: there is no actual FRP for clojure as far as I know.

12:29 csd_: justin_smith: f its just for testing i don't see what it matters if its thread local

12:29 justin_smith: csd_: oh, I thought this was more general, like dev vs. staging vs. prod, sorr

12:30 csd_: yeah although i dont want it more coupled than it needs to be

12:30 justin_smith: crocket: I take that back, I forgot about zelkova https://github.com/jamesmacaulay/zelkova one of the talks I missed from clojure/west

12:30 csd_: justin_smith: with multimethods, id still have to have the test function in the namespace defining the multimethod, which increases coupling

12:30 justin_smith: csd_: the issue is that for with-bindings to work the var needs to be dynamic, are you willing to make the var dynamic just so it is testable?

12:32 csd_: i dont see an issue but that obviously doesnt mean there isnt one

12:33 iwillig: have a core.async question. I am a little confused over the correct usage of put! vs (go (>! ..

12:34 are they similar.. why would one want to use put over go >! or

12:34 crocket: justin_smith, Thanks

12:35 iwillig: to me it seems like put! allows you to introduction information into your async system without having to use go blocks. to they are usage at the edges of our async system.

12:35 is that correct ? or roughly correct ?

12:42 csd_: is it possible to define a function where it looks for a particular var in the namespace its being called from, rather than the ns its defined in

12:44 snowell: csd_: You could write a getter function in the other ns and just call it?

12:45 csd_: snowell: id have to pass it as an arg though right?

12:45 snowell: Unless you mean dynamically determine the ns from which it's being called, which I imagine is difficult at best

12:45 csd_: the latter

12:45 ok

12:46 snowell: I imagine you'd have to figure out a way into the stacktrace of your function call, and I can't think of many things that sound less fun

12:46 csd_: sounds like id be fighting the language

12:46 snowell: Unless, as you said, you pass in the ns (or the value) when you call the function

12:47 justin_smith: csd_: why would the test function need to be in the same ns as the multimethod?

12:47 csd_: you can define an implementation of a multimethod from anywhere you like

12:47 csd_: justin_smith: the defmethods dont have to be in the same ns as the defmulti?

12:47 justin_smith: csd_: the only precondition being you can access the namespace that defines the multi dispatch

12:47 csd_: absolutely not

12:48 they wouldn't be very useful if that were the case

12:48 csd_: oh well thats nice

12:48 yeah

12:49 justin_smith: csd_: so you can write code that expects a thing that implements that multimethod, and pass in your custom or mocked up thing

12:49 csd_: yeah that sounds like a good way to go

12:49 justin_smith: much more versatile / reliable than a thread local binding imho

13:58 tmtwd_: http://pastebin.com/gGkpFn9W

13:59 in this example "main" is the name of the html element, and it just coincidentally shares the name of the main function?

13:59 justin_smith: tmtwd_: that is what it looks like, yeah

13:59 main should do the same thing if you changed the name to foo

14:01 tmtwd_: ah, its just convention?

14:01 not like a c main functoin or java?

14:01 justin_smith: tmtwd_: as far as I know, unless there is some lib or framework I don't know about that looks for main...

14:13 atomi: what can I use to make lein watch for file edits and rerun on save?

14:13 amalloy: rerun what?

14:13 atomi: "lein run"

14:14 amalloy: you want it to kill your existing program and start a new one? or wait in the background even when nothing is running, and start up lein run every time you save a file, or what?

14:15 atomi: kill and relaunch run

14:15 when code is updated

14:21 noncom: i am sorry for being alittle off-topic, but idk where else to ask

14:22 sometimes when i come here after a logout, the system tells me i have some mail

14:22 i then type in some command to read the mail

14:22 so, how do i leave such a mail for someone who's currently offline?

14:22 justin_smith: $mail noncom LIKE THIS!

14:22 lazybot: Message saved.

14:22 noncom: is that exclusively a #clojure channel feature?

14:23 rihgt, that's lazybot

14:23 justin_smith: it's a lazybot feature, it will work on other channels lazybot is on

14:23 noncom: thanks! :)

14:23 $seen ztellman

14:23 lazybot: ztellman was last seen quittingQuit: Computer has gone to sleep. 8 hours and 10 minutes ago.

14:31 atomi: so can I use a task runner to kill and relaunch lein run on code updates?

14:34 hiredman: why would you do that? clojure has a repl

14:36 atomi: hiredman: yeah

14:39 justin_smith: atomi: is the relaunching something for prod? if so, you might want jsvc - and seriously consider not even having lein installed on prod

14:40 atomi: justin_smith: yeah that's super helpful thanks

14:42 tmtwd_: nvm

14:44 is there a rule of thumb for when we should or should not be returning values from functions?

14:44 justin_smith: tmtwd_: nil is a value, functions return values unless they throw an exception and thus never return

14:44 tmtwd_: ie (defn [x] (* x x) x) doesn't work, but in some functions we need to return values (mutable functions)?

14:45 justin_smith: (* x x) is a value

14:45 I don't get it

14:45 tmtwd_: (* x x) is the return value?

14:45 then what is the tailing x?

14:46 justin_smith: no, that's not what I meant

14:46 I mean (defn f [x] (* x x)) also returns a value

14:47 tmtwd_: ah yeah, I agree there

14:47 justin_smith: when working with something immutable, return the new constructed value, if any - otherwise there is no way to do any meaningful work

14:47 tmtwd_: but I've seen some functions that use set! functions to modify the argument then it returns the argument

14:48 it seemed kind of redundant to me

14:48 justin_smith: when working with something mutable, it can make sense to return the mutable thing after modifying it

14:48 tmtwd_: that's useful because of chaining

14:48 (-> x frob! munge! mangle!) for example

14:48 though of course we also have doto

14:49 tmtwd_: (defn [x] (* x x) x) so whats with this function, it doesn't crash

14:49 but it doesn't do anything

14:49 it just returns the input value?

14:49 justin_smith: it just does pointless work

14:49 tmtwd_: or the arg value?

14:50 ah, it squares x, then returns the original value?

14:50 hehe

14:50 justin_smith: right

14:50 tmtwd_: thanks

14:51 it looked kindof similar to (defn [x] (set! x (* x x)) x)

14:51 which I suppose would return the mutated value

14:51 amalloy: tmtwd_: that is just not a thing that is possible to do

14:51 tmtwd_: no, because clojure is immutable

14:51 but if it were mutable...

14:53 justin_smith: tmtwd_: set! only works on vars and fields, you would need to do something different for that function to work (like dereffing x if it were a var)

14:53 tmtwd_: ah okay

14:53 ah anyways, I now understand more than before thanks :)

14:55 Shayanjm: I want to write a set-of-maps output to stdout with formatting (i.e: strings should be wrapped in double quotes). If I println, I lose the double quote wrapping

14:55 how do I go about outputting the set of maps with formatting so it can then be re-consumed?

14:55 snowell: Shayanjm: Put a `pr-str` inside your println

14:56 yedi: is there such a thing as a 0 size buffer for a core async channel

14:57 Shayanjm: snowell so (println (pr-str <thing>))?

14:57 snowell: Yup!

14:57 Shayanjm: thanks so much, trying now

14:59 snowell: weird, that ends up printing an empty set for me

14:59 retrying with just println

14:59 justin_smith: Shayanjm: snowell: (println (pr-str x)) is (prn x)

15:00 (doc pr-str)

15:00 clojurebot: "([& xs]); pr to a string, returning it"

15:00 justin_smith: (doc prn)

15:00 clojurebot: "([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"

15:01 snowell: Huh. TIL

15:01 arohner: wasn't there a way to get prismatic/schema to return a validation error string, without throwing?

15:01 aha, s/check

15:02 justin_smith: arohner: oh nice, some of my unit tests are going to be much simpler / prettier now

15:02 (inc arohner)

15:03 lazybot: ⇒ 2

15:20 jaen: Any hint what causes a validation failure like this `[{:medical-visits [(not (has-extra-elts? 1))]} nil]` in Prismatic's schema? I can't quite figure it out what this means.

15:23 justin_smith: jaen: unknown keys in the map, where :medical-visits was the only allowed key? Just a guess.

15:24 jaen: Hmm... I'll double check the keys then, but I have this as `:medical-visits [Visit]`, where the `Visit` schema validates without problem on it's own, so that would surprise me. Maybe the Grails backend is doing something weird.

15:25 Thanks for the pointer

15:49 gfredericks: has anybody else experienced cider causing emacs to hang for several seconds periodically?

15:49 this happened before I upgrade from 0.8.2 to 0.9.0 and is still happening

15:50 I should probably enable some kind of nrepl debugger to find out if it's sending stuff to the clojure process and if so what

15:51 atomi: how is sublimerepol?

16:16 gfredericks: looks like it's probably the cider repl buffer in particuler

16:32 justin_smith: gfredericks: there's so many ways that could happen, emacs is single threaded

16:32 the real solution would be to port core.async to emacs

16:34 * wasamasa checks how large core.async is

16:35 wasamasa: oh, just around 2000 lines of clojurescript

16:35 clojurescript since as I understand it that's the portable variant since js implementations don't support threading either

16:36 justin_smith: right - I was at least half joking, but maybe it would work...

16:36 wasamasa: well, it would be interesting to have a macro compiling into all the callback hell you'd normally have

16:37 justin_smith: for sure

16:37 wasamasa: the other alternatives you have in emacs is using the abandoned threading branch, multiprocessing (which allows communication with the subprocess when emacs idles) and timer hacks to emulate deferred events

16:38 justin_smith: (dec timer hacks)

16:38 lazybot: ⇒ -1

16:38 wasamasa: the multiprocessing option is the only officially supported thing and has been explored the most

16:39 networking behaves similiarly and only freezes up for me when it runs into an error condition

16:39 so that's may be what's happening

17:05 Guest17477: Are Clojure's "falsey" values defined anywhere? Is it just `false` and `nil`?

17:06 scgilardi: yes, there are docs about it. yes, just false and nil

17:06 justin_smith: Guest17477: yes, false and nil is the complete set

17:06 Guest17477: Thanks

17:07 justin_smith: Guest17477: seq is often used to make empty collections falsey (the idiom in common lisp)

17:07 (if (sex x) ...)

17:07 er, (seq x) of course

17:33 TimMc: ...of course...

17:33 * TimMc fixes a few things in his code

17:38 justin_smith: haha

17:59 gfredericks: ,(defn =by ([k x] true) ([k x y] (= (k x) (k y))) ([k x y & zs] (apply = (map k (list* x y zs)))))

17:59 clojurebot: #'sandbox/=by

18:06 justin_smith: ,(=by =by =by)

18:06 clojurebot: true

18:07 justin_smith: sadly as it does not have a single arity version, I cannot add any further =by without an error

18:08 ,(=by (partial =by =by) =by =by =by =by =by =by)

18:08 clojurebot: true

18:08 gfredericks: (inc justin_smith)

18:08 lazybot: ⇒ 264

21:02 devn: I am officially at my wit's end

21:02 lein-environ and environ...

21:02 justin_smith: what are you trying to do?

21:02 devn: profiles.clj negates the use of jvm-opts in the project.clj

21:03 removing profiles.clj means .lein-env gets written to empty map

21:03 justin_smith: devn: for some things I have found the need to use ^:replace for :jvm-opts

21:03 devn: it's just weird -- i guess im still not quite sure i understand HOW this is happening

21:04 like, have i just missed the one permutation i haven't tried?

21:06 justin_smith: what's that look like?

21:07 justin_smith: :jvm-opts ^:replace ["opts that replace, not merge, other opts go here"]

21:07 for example the "-server" arg only works if you use ^:replace

21:07 devn: which direction does the merge happen in?

21:08 well, your stuff wins is what replace is, i guess

21:08 so the default is the base wins?

21:08 justin_smith: devn: the rule I have heard is "most specific always wins"

21:09 so from least to most - global profiles.clj, project.clj, project profiles.clj iirc

21:09 devn: justin_smith: ugh, still didn't work

21:09 so here's the specific setup -- i have lein-environ in my project plugins list

21:09 and i have environ in the dependencies

21:10 I need to set a java property in my project.clj so logback can pick it up for use in a configuration file

21:10 because logging will be different in dev

21:10 profiles.clj contains a couple of API keys

21:10 and is also in the project dir

21:22 so, lein-environ is the reaosn this is happening

21:22 reason*

21:23 https://github.com/weavejester/environ/blob/master/lein-environ/src/lein_environ/plugin.clj#L9

21:28 ...

21:28 and then, he thought of something...

21:28 so uh, im feeling kind of stupid, but man, why isn't this documented?

21:29 you put your :jvm-opts [] in your local profiles.clj

21:35 creese: Can I use transit to write plain old JSON?

21:41 williamtaft: Can anybody help me with a question?

21:41 justin_smith: I bet someone can if you ask it

21:43 gfredericks: ~anyone

21:43 clojurebot: anyone is anybody

21:43 gfredericks: ~anybody

21:43 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

21:43 vikaton: wats dis clojure

21:43 williamtaft: Sure, I'm just seeming to have a little trouble. I'm using leinengen, and made a new file with the namespace project.foo.core - Now when i run lein repl, and switch into the project.foo.core namespace, I can't seem to access my symbol definitions.

21:44 gfredericks: (doto 'project.foo.core require in-ns)

21:44 justin_smith: williamtaft: switching to a namespace does not load it

21:45 williamtaft: unless you set things up explicitly, none of your code is automatically loaded into a repl (but it is all available via require, or load)

21:45 (that's why gfredericks' suggestion works)

21:45 williamtaft: ompilerException java.lang.RuntimeException: Unable to resolve symbol: doto in this context,

21:46 whoops

21:46 my far

21:46 t

21:46 justin_smith: williamtaft: (clojure.core/refer-clojure)

21:47 williamtaft: using in-ns when a namespace has not been loaded creates a broken namespace, but the above at least partially fixes it

21:48 williamtaft: hm, i should be able to (use 'namespace) then?

21:48 justin_smith: williamtaft: in-ns creates a namespace if it does not exist yet, but doesn't do any of the defautl namespace setup, like making clojure.core available

21:48 use will not be mapped into a broken namespace

21:48 williamtaft: yeah

21:48 justin_smith: clojure.core/refer-clojure fixes that

21:48 williamtaft: I'm restarting

21:48 justin_smith: restarting works too :)

21:49 williamtaft: (clojure.core/doto 'hello-world.db.core require in-ns)

21:49 shouldn't that work?

21:50 user=> (use 'hello-world.db.core) ;and shouldn't this work in the default namespace?

21:50 *user

21:51 justin_smith: williamtaft: unless src/hello_world/db/core.clj has some error in it, or cannot be found

21:51 note it has to be hello_world in the directory name (historical reasons) - this is a common newcomer mistake

21:52 williamtaft: src/hello_world/db/core.clj is its location

21:53 justin_smith: so yeah, unless the code has some problem, using that namespace should work as expected

21:53 williamtaft: do i need to set :gen-class in order for it to work in the repl?

21:54 justin_smith: requiring or using a file with a :gen-class in the ns should work as expected

21:54 creese: If I want to marshal data from postgresql to JSON, what lib should I use?

21:55 justin_smith: creese: I have had good luck with clojure.java.jdbc and cheshire

21:55 creese: Some of the data comes out of postgresql as not-a-string (i.e. UUIDs). Other times, I need to marshal certain fields (unix time to ISO8601)

21:56 justin_smith: creese: cheshire is good at doing the right thing, or letting you define new rules so it knows what to do with unfamiliar classes

21:58 williamtaft: http://pastebin.com/MbanaMTr

21:58 justin_smith: williamtaft: what's the gen-class for?

21:59 williamtaft: user=> (use 'hello-world.db.core)

21:59 CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword, compiling:(hello_world/db/core.clj:1:1)

21:59 I didn't know if the repl needed to use it

21:59 justin_smith: williamtaft: the :require block needs to be inside parens

21:59 you only need :gen-class if you need a class that java code can call

22:00 williamtaft: i see

22:00 justin_smith: and even if calling from java, you will likely find it easier to write some java code that uses clojure.api

22:01 williamtaft: thank you! I'm pretty new to clojure, and still missing things

22:01 you need gen-class when making jars right?

22:01 justin_smith: yeah, and I know the error messages are often not particularly helpful (as seen above)

22:02 williamtaft: actually no - all you need to do is call "java -cp your-uber.jar clojure.main -m my.ns.core"

22:02 because clojure.main is a class java can invoke directly, and it knows how to load your code from source

22:03 williamtaft: ah

22:03 justin_smith: "lein uberjar" will complain that my.ns.core isn't a class in the compiled jar, but if invoked as above it just works

22:03 and not using gen-class actually makes things simpler

22:03 williamtaft: neat

22:07 monsta: good night, newbie here, question: how can I map a fn over a list of vectors lets say something like: ([1 2 3 4] [2 3 4])?

22:08 justin_smith: do you want to call the function once on each vector, or once on each element in each vector?

22:08 monsta: I would like to know both ways

22:09 justin_smith: ,(for [v [[1 2 3 4] [2 3 4]] e v] (* e 2))

22:09 clojurebot: (2 4 6 8 4 ...)

22:09 justin_smith: that's the each element version, for is better there

22:10 ,(map #(conj % :e) [[1 2 3 4] [2 3 4]])

22:10 clojurebot: ([1 2 3 4 :e] [2 3 4 :e])

22:10 justin_smith: each vector version, map works

22:11 monsta: hmmm, let say that a have a function that accept n arity of vectors and I would like to map * to each elements of them, example?

22:12 justin_smith: ,(for [v [[1 2 3 4] [2 3 4]] (apply * v))

22:12 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>

22:12 justin_smith: ,(for [v [[1 2 3 4] [2 3 4]]] (apply * v))

22:12 clojurebot: (24 24)

22:14 monsta: the thing I would like to return the product of each vector passed

22:14 justin_smith: monsta: that's what that just did

22:15 or you mean element-wise?

22:15 ,(map * [1 2 3 4] [2 3 4])

22:15 clojurebot: (2 6 12)

22:16 monsta: but isn't passing vectors to a defn give this example: ([1 2 3 4] [4 5 6]), not this [[1 2 3 ] [4 5 6]]

22:16 justin_smith: sure ##(apply map * [[1 2 3 4] [2 3 4]])

22:16 lazybot: ⇒ (2 6 12)

22:17 monsta: let me try

22:17 justin_smith: also remember that ([1 2 3 4] [2 3 4]) is not valid input syntax (which is why I use square braces all around, but you could use quoting or list instead)

22:18 monsta: thank you so, much it worked.

22:41 hadronzoo: Do the dependencies in deps.cljs have to reside in /src? Is it possible to reference files in /resources?

22:42 justin_smith: hadronzoo: yes, and you can reference files that are on the classpath via project.clj too - any particular reason to put something under resources/ rather than src/ ?

22:43 oh sorry, deps.cljs - I should read more carefully

22:43 hadronzoo: I'm using lein-bower to import javascript libraries, but I'm not having much success.

22:43 justin_smith: I don't know about deps.cljs

22:48 hadronzoo: Does anyone know if an om-based select component exists? Something similar to react-select?

23:03 kLooaa: Do you realize that basically after age 20 your body starts rotting, being worse and worser at everything? and that includes your brain too? you will eventually be stupid and naive just like children. or worse - you can get alzheimer's disease. If you are alive now, I guarantee you that you will die eventually. And it can be really painful dying. Just read news or statistics how many people die in what ways DAILY. You will become one of them eventually.

23:03 One of that statistics number. nothing more.

23:03 justin_smith: kLooaa: and a good evening to you too!

23:04 kLooaa: I hate evenings

23:04 justin_smith: kLooaa: do you have any plans to do anything interesting before you whither away and die?

23:05 kLooaa: justin_smith: what interesting can do? if you know your ending very bad soon

23:05 justin_smith: no, no, we are talking about your death, not mine

23:06 kLooaa: eating food? watching tv? thats what humans do

23:06 yes about mine

23:07 justin_smith: kLooaa: fyi this channel is about Clojure, the programming language, not clojure, the psychological sense of coming to peace

23:08 err, closure is the coming to peace one, I am too used to typing out clojure in this channel

23:08 kLooaa: cloujure devs will die

23:08 justin_smith: but that isn't very clojure specific, is it?

23:09 kLooaa: i dont care clousure or not

23:09 DEAD

23:10 justin_smith: you are very determined for someone who doesn't care, seems like there is something you care about

23:11 kLooaa: yes I care about world existing

23:11 need to stop

23:31 adammh: I'd appreciate if anybody could help me with a `core.typed` question... just starting out so it may be a bit obvious

23:31 why does (IPersistentMap Integer myapp.core/Thing) Integer

23:32 match (t/Option (ILookup t/Any x)) t/Any

23:32 do I need to explicitly lift the map into the `Option` type?

23:36 WickedShell: I have a def that builds a java mig-panel (through seesaw) when I add it to my GUI via code that is loaded by lein its size comes out totally wrong, but if I paste the def into the repl and rebuild the GUI it works. (just rebuilding the GUI it doesn't fix the problem) http://pastebin.com/uFvMZMpH anyone have any ideas why that might happen?

Logging service provided by n01se.net