#clojure logs

2015-06-17

00:35tmtwd* Connecting to chat.freenode.net (185.30.166.38:6697)
00:35tmtwd* * Certification info:
00:35tmtwd* Subject:
00:35tmtwd* OU=Domain Control Validated
00:35tmtwd* OU=Gandi Standard Wildcard SSL
00:35tmtwd* CN=*.freenode.net
00:35tmtwd* Issuer:
00:35tmtwd* C=FR
00:35tmtwd* O=GANDI SAS
00:35tmtwd* CN=Gandi Standard SSL CA
00:35tmtwd* Public key algorithm: rsaEncryption (2048 bits)
00:35tmtwd* Sign algorithm sha1WithRSAEncryption
00:35tmtwd* Valid since Jan 3 00:00:00 2015 GMT to Jan 15 23:59:59 2016 GMT
00:35tmtwd* * Cipher info:
00:35tmtwd* Version: TLSv1/SSLv3, cipher DHE-RSA-AES256-GCM-SHA38 (256 bits)
00:35tmtwd* Connected. Now logging in.
00:35tmtwd* *** Looking up your hostname...
00:35tmtwd* *** Checking Ident
00:35tmtwd* *** Found your hostname
00:35tmtwd* *** No Ident response
00:35tmtwd* Capab
00:35tmtwdoops
00:35tmtwdis that any sensitive information?
00:36TEttingertmtwd, I don't see anything bad
00:37TEttingerso, https://scontent-sjc2-1.xx.fbcdn.net/hphotos-xfa1/v/t1.0-9/11390060_3127051372334_2540245238860767788_n.jpg?oh=5f45dea77976c3b70b8b3a62b7872fb7&oe=5624C30F
00:37tmtwdheh
00:39TEttingernice 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
00:40TEttingerbut it's really a "blood is thicker than water, and if you touch my family there WILL be blood" type of cat face
00:56Surgobit 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}
04:08benhudahelo
04:09benhudaim 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?
04:09benhudaaside from the obvious main while(true) loop... CLI daemons that have a lifecycle and can be managed and introspected
04:10benhudamaybe i should take a look at how Storm and Cassandra run
04:10p_lbenhuda: 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
04:11benhudawell it will be a service that runs and never quits... its a poller service. every X minutes it will perform DB queries forever
04:11benhudaso it has no Web / such concerns, just database
04:11p_lbenhuda: for something simple, Jsvc or similar will be enough
04:12benhudai'm aware i can just do an endless loop, but i'm looking for something more infrastructural to enjoty
04:19zoti'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?
04:26scottjzot: maybe M-x cider-refresh
04:26scottjbound to C-c C-x
04:27zotscottj: clever, if i read that code right if will reset, and force all deps to get reloaded along the way :)
04:28zot(inc scottj)
04:28lazybot⇒ 4
07:32justin_smithzot: there is also tools.namespace.repl/refresh
07:33justin_smithwhich will reload code, but only from your current project, and will also delete vars that no longer exist
07:33zotjustin_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 :)
08:26ChazeHi. 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
08:28Chazemore 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)
08:29justin_smithChaze: apply requires its last arg to be in a list
08:29justin_smithor, more precisely, in a collection
08:30Chazeah, so (map apply functions (map list arguments)) may work?
08:30justin_smith,(map apply [inc dec + -] [[1] [43] [8 17] [1000 33]])
08:30clojurebot(2 42 25 967)
08:30justin_smithChaze: if arguments is a list of single items for unary functions, yes
08:31Chazeperfect, thank you
08:42justin_smithChaze: another option would have been (map #(%1 %2) functions arguments) because map is varargs
08:43Chazejustin_smith: strange, that there is no predefined function #(%1 %2)
08:44jonathanji can't recur with a different arity to the function i'm recurring from?
08:44justin_smithjonathanj: that's true, you cannot
08:44jonathanjokay
08:46justin_smithjonathanj: though you could do something similar to recurring on different arities with trampoline
08:46justin_smithtrampoline can be weird to use at first though
08:52justin_smith,(trampoline (fn bounce ([] #(bounce 1)) ([x] #(bounce 2 x)) ([x y] #(bounce x 3 y)) ([x y z] [z y x]))
08:52clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
08:52justin_smithoops
08:52justin_smith,(trampoline (fn bounce ([] #(bounce 1)) ([x] #(bounce 2 x)) ([x y] #(bounce x 3 y)) ([x y z] [z y x])))
08:53clojurebot[1 3 2]
08:53jonathanjjustin_smith: i think just kickstarting the recur with a lower arity version is probably good enough for what i want
08:53justin_smithOK
08:53jonathanjthanks
08:56justin_smithletfn / trampoline is a nice combo sometimes
09:06kaiyinIt seems learning clojure web development is very difficult because everything is changing so fast. Books published only a few months ago are already outdated.
09:08dagda1_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?)))
09:08dagda1_but it gives me the result
09:08lumafiyou need to quote the macro expression
09:09justin_smith,(macroexpand '(->> (iterate scratch.core/cuts [1 2 3 4]) (map count) (take-while pos?)))
09:09clojurebot(take-while pos? (map count (iterate scratch.core/cuts [1 2 3 4])))
09:09dagda1_lumafi: thanks
09:17phillordIf 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?
09:17phillordthe windows installer looks nice, but installs 1.7
09:18phillordor am I wrong about this?
09:28expezanyone 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 :/
09:28TEttingerphillord, it shouldn't install an old version?
09:28TEttingerwhich link are you using, phillord?
09:29TEttingerexpez, uh
09:29TEttinger,str
09:29clojurebot#object[clojure.core$str 0x40de81f5 "clojure.core$str@40de81f5"]
09:29TEttingerthat seems like a very strange choice for a library name
09:31expezTEttinger: well, it is a string manipulation library. Not sure a random girls name or literary character would be much better :p
09:31TEttingerhttps://github.com/expez/str/blob/master/src/str/core.clj#L107
09:31TEttingertypo there, not sure what needles are in the later fns
09:32TEttingerexpez, true but it's confusing, "which str do you mean again?"
09:32dagda1_I think I am failing to see why the thread last macro is not called the thread first macro
09:33TEttingerdagda1_: thread last is ->> , and inserts the arg you give it as the last argument to each of the following forms
09:33oddcullydagda1_: last as in last argument. not from right to left
09:33expezTEttinger: 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.
09:33TEttinger,(->> [1 2 3] (map inc) (reduce +))
09:33clojurebot9
09:36TEttingerexpez, as for library names, there's possibly: textual , stringy , superstring (after the physics theory), wordsmith
09:37TEttingerI don't think str specifically is trouble here because it's always really str.core, it still seems confusing to me
09:37dagda1_TEttinger: so that expands to (reduce + (map inc [1 2 3])) where does the last come in because it calls reduce first?
09:38TEttingerdagda1_, not what it expands to
09:38expezTEttinger: https://github.com/expez/str/blob/master/src/str/core.clj#L34 what do you think of this?
09:38TEttingerthe last argument passed to reduce is the threaded form
09:38TEttingercontrast with:
09:40TEttinger,(-> [1 2 3] (concat [4]) (conj 5))
09:40clojurebot(5 1 2 3 4)
09:40TEttingerwhich is because concat returns a seq, and seqs append to beginning
09:41TEttingerwhich is the same as
09:41TEttinger,(conj (concat [1 2 3] [4]) 5)
09:41clojurebot(5 1 2 3 4)
09:42TEttingeryou can see that in the thread-first case, the [1 2 3] becomes the first arg to concat
09:42TEttingerin the thread-last case, it become the last arg to map and reduce
09:43dagda1_TEttinger: brilliant, thanks
09:43TEttingerexpez, it doesn't strike me as a bad idea, especially since you aren't drawing in extra deps or anything
09:44TEttingerit 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
09:44expezTEttinger: I'd like to avoid having both clojure.string :as str superstring.core :as ss in the same namespace heh
09:45TEttingerah ok, fair enough
09:45expezTEttinger: 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
09:46expezso aliasing seems like a good alternative
09:46TEttingeryeah, good points
09:46expezI think I like superstring because it's actually extending clojure.string :p
09:47dagda1_the penny has dropped :)
10:35phillordTEttinger: sorry, I realise that I was wrong -- the installer SAYS it is going to install Leiningen Version 1.0, but actually doesn't
10:37phillordNow, why does bitbucket not have a issue tracker!
10:38TEttingerhm, it should
10:38pbxphillord, it does
10:38littleliyeah, it does
10:38pbxcan be enabled/disabled by the project owner though
10:39oddcullythey even sell one ^_^
10:40phillordfor the lein installer, I can't see one
10:40phillordPR yes, issues no
10:40pbxthen they haven't enabled it.
10:40TEttingerit might use a different site to track issues
10:48crocketDoes clojure have a decent reactive GUI library?
10:52sm0keno
10:52sm0kebut there are some which are written in clojure/script
10:53sm0kenothing inbuilt in clojure afaik
10:53wasamasasomeone wrapped swing
10:53wasamasahttps://github.com/daveray/seesaw
10:53TEttingerI believe quil may have reactive parts
10:53sm0kefor web side you have reagent om
10:54TEttingerthe 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:54sm0kehmm
10:54sm0keactually facebook recently announced react native
10:55crocketGUI seems to be a mine field.
10:55sm0kei am wondering if coljurescript -> js -> native
10:55sm0kecan be done
10:55TEttingerhowever, there's stuff like chromium embedded if you want to use cljs on desktop
10:55TEttinger$google chromium embdedded framework
10:55lazybot[chromiumembedded / cef — Bitbucket] https://bitbucket.org/chromiumembedded/cef
10:55sm0kewow didnt know about that
10:55sm0kemust be awfully heavy though?
10:56wasamasacrocket: no shit
10:56TEttingergithub for windows uses it, so does spotify, uplay, desura, steam client, recent AIM...
10:56wasamasacrocket: next thing you proclaim is that any real-world programming is
10:57crocketIs there a viable path toward applying reactive programming on native GUI programs?
10:57crocketchromium embedded?
10:57sm0kehttps://github.com/atom/electron
10:57crocketThere is JavaFX...
10:58crocketWould it be reasonable to write a reactive wrapper around JavaFX in clojure?
10:58sm0kehttp://react-native.org/
10:58TEttingeratom looks nice
10:59crocketreact-native, atom, blah blah, ..., chromium embedded
10:59sm0kei guess react native would be perfect for you crocket
10:59sm0keits reactive and native heh
10:59crocketsm0ke, After I try, I may change my mind.
10:59crocketIt involves HTML and CSS.
11:00sm0keyou want to write in C?
11:00crocketha
11:00crocketsm0ke, Some people are trying to write JavaFX bindings in clojure and frege.
11:00sm0keis javafx reactive?
11:01crocketI don't know.
11:01sm0kei thought you said reactive?
11:01crockethttps://github.com/TomasMikula/ReactFX
11:02crocketI didn't say JavaFX was known to be reactive.
11:03sm0kecrocket: you want to write over jvm?
11:04crocketsm0ke, I don't know...
11:04crocketBut, it's useful to know
11:04sm0ke:/
11:04crocketIt's useful to know that clojure has decent GUI libraries on JVM.
11:05crocketThere is https://github.com/aaronc/fx-clj
11:05crockethttps://github.com/aaronc/fx-clj supports reactive programming over JavaFX.
11:05crocketSince JavaFX is compatible with Java 8 lambdas, it has a lot of callbacks.
11:10voidnoidis datomic OT in here?
11:11crocketIt seems reactive native is for Mac OS.
11:11crocketReact Native "Build native iOS and Android apps with JavaScript."
11:25crockethmm
11:26csd_How might I check whether a vector is a subclass of java.util.Collection?
11:26csd_instance? doesn't seem like the right function
11:26justin_smith,(isa? java.util.Collection [])
11:26clojurebotfalse
11:26justin_smith(doc isa?)
11:26clojurebot"([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:26justin_smithoh
11:27justin_smith,(isa? [] java.util.Collection)
11:27clojurebotfalse
11:27csd_that can't be correct
11:27csd_is it?
11:27justin_smithyeah, I am doing it wrong
11:28csd_,(isa? () java.util.Collection)
11:28clojurebotfalse
11:29csd_,(isa? clojure.lang.PersistentVector java.util.Collection)
11:29clojurebottrue
11:29justin_smithoh, it needs the type
11:29justin_smithmakes sense
11:29Bronsa,(instance? [] java.util.Collection)
11:29clojurebot#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:30Bronsa,(instance? java.util.Collection [])
11:30clojurebottrue
11:30Bronsa(╯°□°)╯︵ ┻━┻
11:30csd_ah
11:30justin_smith(inc Bronsa)
11:30lazybot⇒ 113
11:30csd_justin_smith: you use Cursive predominantly right?
11:30justin_smithBronsa: that's what I was looking for, found it just after you shared that
11:30justin_smithcsd_: no, I do not
11:30justin_smithI'm a fan, but I can't do IDEs
11:31csd_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:31csd_thoughts?
11:32justin_smithyeah, IDEs in general don't tend to work the way I want to work I think. I gave up on cider even.
11:32csd_what do you use now
11:32justin_smitha repl in a terminal
11:33csd_what if you need to traceback to the clojure Java code for example
11:33justin_smithstack traces / reflection + google
11:34justin_smithI'm basically a cave man
11:34csd_whatever works
12:14crocketWhat are good ways to write reactive GUI apps in clojure?
12:15snowellReagent works well for me
12:15snowellhttp://reagent-project.github.io/
12:15crocketI think I heard a better alternative to react on clojure.
12:16justin_smiththe two main ones are om and reagent
12:16snowellOm or re-frame are the only other ones I've heard of
12:17oddcullythere is also rum, but thats not what you asked
12:17blkcatom looks very interesting
12:17justin_smithre-frame is a toolkit for reagent
12:18CookedGryphonHey, found a weirdness with update, think I know what's happening, but if anyone could offer comment...
12:19CookedGryphon,(update [] 0 (fnil inc 0))
12:19clojurebot[1]
12:19CookedGryphon,(update [] 1 (fnil inc 0))
12:19clojurebot#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:19csd_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:19justin_smith,(update [0] 1 (fnil inc 0))
12:19clojurebot[0 1]
12:20justin_smithCookedGryphon: I think it just doesn't know how to skip indexes, but it is happy to make the incremental next one
12:20CookedGryphonyeah
12:20CookedGryphonI just found it surprising
12:20CookedGryphonexpected it to either blow up in both cases or simply return the input unchanged if it can't set the key
12:21justin_smithclojure is often surprising, while still being simple
12:22snowellcsd_: 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:23csd_snowell: can you elaborate? im not sure how that would work
12:23csd_would i in my environ file declare the code?
12:23snowellcsd_: https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md
12:24justin_smithcsd_: I've used environ to set a key I can check, then switched implementation at runtime based on the key
12:24snowellAnd what justin_smith just said is what I was going to type next :)
12:24csd_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:25justin_smithcsd_: or a multimethod (defmulti run-server (fn [& args] (env :server-version)) (defmethod run-server "prod" ...) (defmethod run-server "dev" ...)
12:26justin_smithsince defmethod can dispatch on an arbitrary function, it can ignore all the args and just use environ
12:26csd_oh thats cool
12:27csd_justin_smith: would you pick that over with-bindings?
12:27crocketDoes react provide a decent variant of functional reactive programming?
12:27justin_smithcsd_: with-bindings is for thread local stuff isn't it?
12:28csd_justin_smith: not sure
12:28crocketMy gut feeling tells me that react doesn't promote FRP much.
12:28justin_smithcrocket: there is no actual FRP for clojure as far as I know.
12:29csd_justin_smith: f its just for testing i don't see what it matters if its thread local
12:29justin_smithcsd_: oh, I thought this was more general, like dev vs. staging vs. prod, sorr
12:30csd_yeah although i dont want it more coupled than it needs to be
12:30justin_smithcrocket: I take that back, I forgot about zelkova https://github.com/jamesmacaulay/zelkova one of the talks I missed from clojure/west
12:30csd_justin_smith: with multimethods, id still have to have the test function in the namespace defining the multimethod, which increases coupling
12:30justin_smithcsd_: 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:32csd_i dont see an issue but that obviously doesnt mean there isnt one
12:33iwillighave a core.async question. I am a little confused over the correct usage of put! vs (go (>! ..
12:34iwilligare they similar.. why would one want to use put over go >! or
12:34crocketjustin_smith, Thanks
12:35iwilligto 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:35iwilligis that correct ? or roughly correct ?
12:42csd_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:44snowellcsd_: You could write a getter function in the other ns and just call it?
12:45csd_snowell: id have to pass it as an arg though right?
12:45snowellUnless you mean dynamically determine the ns from which it's being called, which I imagine is difficult at best
12:45csd_the latter
12:45csd_ok
12:46snowellI 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:46csd_sounds like id be fighting the language
12:46snowellUnless, as you said, you pass in the ns (or the value) when you call the function
12:47justin_smithcsd_: why would the test function need to be in the same ns as the multimethod?
12:47justin_smithcsd_: you can define an implementation of a multimethod from anywhere you like
12:47csd_justin_smith: the defmethods dont have to be in the same ns as the defmulti?
12:47justin_smithcsd_: the only precondition being you can access the namespace that defines the multi dispatch
12:47justin_smithcsd_: absolutely not
12:48justin_smiththey wouldn't be very useful if that were the case
12:48csd_oh well thats nice
12:48csd_yeah
12:49justin_smithcsd_: so you can write code that expects a thing that implements that multimethod, and pass in your custom or mocked up thing
12:49csd_yeah that sounds like a good way to go
12:49justin_smithmuch more versatile / reliable than a thread local binding imho
13:58tmtwd_http://pastebin.com/gGkpFn9W
13:59tmtwd_in this example "main" is the name of the html element, and it just coincidentally shares the name of the main function?
13:59justin_smithtmtwd_: that is what it looks like, yeah
13:59justin_smithmain should do the same thing if you changed the name to foo
14:01tmtwd_ah, its just convention?
14:01tmtwd_not like a c main functoin or java?
14:01justin_smithtmtwd_: as far as I know, unless there is some lib or framework I don't know about that looks for main...
14:13atomiwhat can I use to make lein watch for file edits and rerun on save?
14:13amalloyrerun what?
14:13atomi"lein run"
14:14amalloyyou 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:15atomikill and relaunch run
14:15atomiwhen code is updated
14:21noncomi am sorry for being alittle off-topic, but idk where else to ask
14:22noncomsometimes when i come here after a logout, the system tells me i have some mail
14:22noncomi then type in some command to read the mail
14:22noncomso, how do i leave such a mail for someone who's currently offline?
14:22justin_smith$mail noncom LIKE THIS!
14:22lazybotMessage saved.
14:22noncomis that exclusively a #clojure channel feature?
14:23noncomrihgt, that's lazybot
14:23justin_smithit's a lazybot feature, it will work on other channels lazybot is on
14:23noncomthanks! :)
14:23noncom$seen ztellman
14:23lazybotztellman was last seen quittingQuit: Computer has gone to sleep. 8 hours and 10 minutes ago.
14:31atomiso can I use a task runner to kill and relaunch lein run on code updates?
14:34hiredmanwhy would you do that? clojure has a repl
14:36atomihiredman: yeah
14:39justin_smithatomi: is the relaunching something for prod? if so, you might want jsvc - and seriously consider not even having lein installed on prod
14:40atomijustin_smith: yeah that's super helpful thanks
14:42tmtwd_nvm
14:44tmtwd_is there a rule of thumb for when we should or should not be returning values from functions?
14:44justin_smithtmtwd_: nil is a value, functions return values unless they throw an exception and thus never return
14:44tmtwd_ie (defn [x] (* x x) x) doesn't work, but in some functions we need to return values (mutable functions)?
14:45justin_smith(* x x) is a value
14:45justin_smithI don't get it
14:45tmtwd_(* x x) is the return value?
14:45tmtwd_then what is the tailing x?
14:46justin_smithno, that's not what I meant
14:46justin_smithI mean (defn f [x] (* x x)) also returns a value
14:47tmtwd_ah yeah, I agree there
14:47justin_smithwhen working with something immutable, return the new constructed value, if any - otherwise there is no way to do any meaningful work
14:47tmtwd_but I've seen some functions that use set! functions to modify the argument then it returns the argument
14:48tmtwd_it seemed kind of redundant to me
14:48justin_smithwhen working with something mutable, it can make sense to return the mutable thing after modifying it
14:48justin_smithtmtwd_: that's useful because of chaining
14:48justin_smith(-> x frob! munge! mangle!) for example
14:48justin_smiththough of course we also have doto
14:49tmtwd_ (defn [x] (* x x) x) so whats with this function, it doesn't crash
14:49tmtwd_but it doesn't do anything
14:49tmtwd_it just returns the input value?
14:49justin_smithit just does pointless work
14:49tmtwd_or the arg value?
14:50tmtwd_ah, it squares x, then returns the original value?
14:50tmtwd_hehe
14:50justin_smithright
14:50tmtwd_thanks
14:51tmtwd_it looked kindof similar to (defn [x] (set! x (* x x)) x)
14:51tmtwd_ which I suppose would return the mutated value
14:51amalloytmtwd_: that is just not a thing that is possible to do
14:51tmtwd_no, because clojure is immutable
14:51tmtwd_but if it were mutable...
14:53justin_smithtmtwd_: 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:53tmtwd_ah okay
14:53tmtwd_ah anyways, I now understand more than before thanks :)
14:55ShayanjmI 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:55Shayanjmhow do I go about outputting the set of maps with formatting so it can then be re-consumed?
14:55snowellShayanjm: Put a `pr-str` inside your println
14:56yediis there such a thing as a 0 size buffer for a core async channel
14:57Shayanjmsnowell so (println (pr-str <thing>))?
14:57snowellYup!
14:57Shayanjmthanks so much, trying now
14:59Shayanjmsnowell: weird, that ends up printing an empty set for me
14:59Shayanjmretrying with just println
14:59justin_smithShayanjm: snowell: (println (pr-str x)) is (prn x)
15:00justin_smith(doc pr-str)
15:00clojurebot"([& xs]); pr to a string, returning it"
15:00justin_smith(doc prn)
15:00clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
15:01snowellHuh. TIL
15:01arohnerwasn't there a way to get prismatic/schema to return a validation error string, without throwing?
15:01arohneraha, s/check
15:02justin_smitharohner: oh nice, some of my unit tests are going to be much simpler / prettier now
15:02justin_smith(inc arohner)
15:03lazybot⇒ 2
15:20jaenAny 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:23justin_smithjaen: unknown keys in the map, where :medical-visits was the only allowed key? Just a guess.
15:24jaenHmm... 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:25jaenThanks for the pointer
15:49gfrederickshas anybody else experienced cider causing emacs to hang for several seconds periodically?
15:49gfredericksthis happened before I upgrade from 0.8.2 to 0.9.0 and is still happening
15:50gfredericksI 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:51atomihow is sublimerepol?
16:16gfrederickslooks like it's probably the cider repl buffer in particuler
16:32justin_smithgfredericks: there's so many ways that could happen, emacs is single threaded
16:32justin_smiththe real solution would be to port core.async to emacs
16:35wasamasaoh, just around 2000 lines of clojurescript
16:35wasamasaclojurescript since as I understand it that's the portable variant since js implementations don't support threading either
16:36justin_smithright - I was at least half joking, but maybe it would work...
16:36wasamasawell, it would be interesting to have a macro compiling into all the callback hell you'd normally have
16:37justin_smithfor sure
16:37wasamasathe 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:38justin_smith(dec timer hacks)
16:38lazybot⇒ -1
16:38wasamasathe multiprocessing option is the only officially supported thing and has been explored the most
16:39wasamasanetworking behaves similiarly and only freezes up for me when it runs into an error condition
16:39wasamasaso that's may be what's happening
17:05Guest17477Are Clojure's "falsey" values defined anywhere? Is it just `false` and `nil`?
17:06scgilardiyes, there are docs about it. yes, just false and nil
17:06justin_smithGuest17477: yes, false and nil is the complete set
17:06Guest17477Thanks
17:07justin_smithGuest17477: seq is often used to make empty collections falsey (the idiom in common lisp)
17:07justin_smith(if (sex x) ...)
17:07justin_smither, (seq x) of course
17:33TimMc...of course...
17:38justin_smithhaha
17:59gfredericks,(defn =by ([k x] true) ([k x y] (= (k x) (k y))) ([k x y & zs] (apply = (map k (list* x y zs)))))
17:59clojurebot#'sandbox/=by
18:06justin_smith,(=by =by =by)
18:06clojurebottrue
18:07justin_smithsadly as it does not have a single arity version, I cannot add any further =by without an error
18:08justin_smith,(=by (partial =by =by) =by =by =by =by =by =by)
18:08clojurebottrue
18:08gfredericks(inc justin_smith)
18:08lazybot⇒ 264
21:02devnI am officially at my wit's end
21:02devnlein-environ and environ...
21:02justin_smithwhat are you trying to do?
21:02devnprofiles.clj negates the use of jvm-opts in the project.clj
21:03devnremoving profiles.clj means .lein-env gets written to empty map
21:03justin_smithdevn: for some things I have found the need to use ^:replace for :jvm-opts
21:03devnit's just weird -- i guess im still not quite sure i understand HOW this is happening
21:04devnlike, have i just missed the one permutation i haven't tried?
21:06devnjustin_smith: what's that look like?
21:07justin_smith:jvm-opts ^:replace ["opts that replace, not merge, other opts go here"]
21:07justin_smithfor example the "-server" arg only works if you use ^:replace
21:07devnwhich direction does the merge happen in?
21:08devnwell, your stuff wins is what replace is, i guess
21:08devnso the default is the base wins?
21:08justin_smithdevn: the rule I have heard is "most specific always wins"
21:09justin_smithso from least to most - global profiles.clj, project.clj, project profiles.clj iirc
21:09devnjustin_smith: ugh, still didn't work
21:09devnso here's the specific setup -- i have lein-environ in my project plugins list
21:09devnand i have environ in the dependencies
21:10devnI need to set a java property in my project.clj so logback can pick it up for use in a configuration file
21:10devnbecause logging will be different in dev
21:10devnprofiles.clj contains a couple of API keys
21:10devnand is also in the project dir
21:22devnso, lein-environ is the reaosn this is happening
21:22devnreason*
21:23devnhttps://github.com/weavejester/environ/blob/master/lein-environ/src/lein_environ/plugin.clj#L9
21:28devn...
21:28devnand then, he thought of something...
21:28devnso uh, im feeling kind of stupid, but man, why isn't this documented?
21:29devnyou put your :jvm-opts [] in your local profiles.clj
21:35creeseCan I use transit to write plain old JSON?
21:41williamtaftCan anybody help me with a question?
21:41justin_smithI bet someone can if you ask it
21:43gfredericks~anyone
21:43clojurebotanyone is anybody
21:43gfredericks~anybody
21:43clojurebotJust 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:43vikatonwats dis clojure
21:43williamtaftSure, 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:44gfredericks(doto 'project.foo.core require in-ns)
21:44justin_smithwilliamtaft: switching to a namespace does not load it
21:45justin_smithwilliamtaft: 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:45justin_smith(that's why gfredericks' suggestion works)
21:45williamtaftompilerException java.lang.RuntimeException: Unable to resolve symbol: doto in this context,
21:46williamtaftwhoops
21:46williamtaftmy far
21:46williamtaftt
21:46justin_smithwilliamtaft: (clojure.core/refer-clojure)
21:47justin_smithwilliamtaft: using in-ns when a namespace has not been loaded creates a broken namespace, but the above at least partially fixes it
21:48williamtafthm, i should be able to (use 'namespace) then?
21:48justin_smithwilliamtaft: 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:48justin_smithuse will not be mapped into a broken namespace
21:48williamtaftyeah
21:48justin_smithclojure.core/refer-clojure fixes that
21:48williamtaftI'm restarting
21:48justin_smithrestarting works too :)
21:49williamtaft(clojure.core/doto 'hello-world.db.core require in-ns)
21:49williamtaftshouldn't that work?
21:50williamtaftuser=> (use 'hello-world.db.core) ;and shouldn't this work in the default namespace?
21:50williamtaft*user
21:51justin_smithwilliamtaft: unless src/hello_world/db/core.clj has some error in it, or cannot be found
21:51justin_smithnote it has to be hello_world in the directory name (historical reasons) - this is a common newcomer mistake
21:52williamtaftsrc/hello_world/db/core.clj is its location
21:53justin_smithso yeah, unless the code has some problem, using that namespace should work as expected
21:53williamtaftdo i need to set :gen-class in order for it to work in the repl?
21:54justin_smithrequiring or using a file with a :gen-class in the ns should work as expected
21:54creeseIf I want to marshal data from postgresql to JSON, what lib should I use?
21:55justin_smithcreese: I have had good luck with clojure.java.jdbc and cheshire
21:55creeseSome 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:56justin_smithcreese: cheshire is good at doing the right thing, or letting you define new rules so it knows what to do with unfamiliar classes
21:58williamtafthttp://pastebin.com/MbanaMTr
21:58justin_smithwilliamtaft: what's the gen-class for?
21:59williamtaftuser=> (use 'hello-world.db.core)
21:59williamtaftCompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword, compiling:(hello_world/db/core.clj:1:1)
21:59williamtaftI didn't know if the repl needed to use it
21:59justin_smithwilliamtaft: the :require block needs to be inside parens
21:59justin_smithyou only need :gen-class if you need a class that java code can call
22:00williamtafti see
22:00justin_smithand even if calling from java, you will likely find it easier to write some java code that uses clojure.api
22:01williamtaftthank you! I'm pretty new to clojure, and still missing things
22:01williamtaftyou need gen-class when making jars right?
22:01justin_smithyeah, and I know the error messages are often not particularly helpful (as seen above)
22:02justin_smithwilliamtaft: actually no - all you need to do is call "java -cp your-uber.jar clojure.main -m my.ns.core"
22:02justin_smithbecause clojure.main is a class java can invoke directly, and it knows how to load your code from source
22:03williamtaftah
22:03justin_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:03justin_smithand not using gen-class actually makes things simpler
22:03williamtaftneat
22:07monstagood 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:08justin_smithdo you want to call the function once on each vector, or once on each element in each vector?
22:08monstaI would like to know both ways
22:09justin_smith,(for [v [[1 2 3 4] [2 3 4]] e v] (* e 2))
22:09clojurebot(2 4 6 8 4 ...)
22:09justin_smiththat's the each element version, for is better there
22:10justin_smith,(map #(conj % :e) [[1 2 3 4] [2 3 4]])
22:10clojurebot([1 2 3 4 :e] [2 3 4 :e])
22:10justin_smitheach vector version, map works
22:11monstahmmm, 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:12justin_smith,(for [v [[1 2 3 4] [2 3 4]] (apply * v))
22:12clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
22:12justin_smith,(for [v [[1 2 3 4] [2 3 4]]] (apply * v))
22:12clojurebot(24 24)
22:14monstathe thing I would like to return the product of each vector passed
22:14justin_smithmonsta: that's what that just did
22:15justin_smithor you mean element-wise?
22:15justin_smith,(map * [1 2 3 4] [2 3 4])
22:15clojurebot(2 6 12)
22:16monstabut 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:16justin_smithsure ##(apply map * [[1 2 3 4] [2 3 4]])
22:16lazybot⇒ (2 6 12)
22:17monstalet me try
22:17justin_smithalso 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:18monstathank you so, much it worked.
22:41hadronzooDo the dependencies in deps.cljs have to reside in /src? Is it possible to reference files in /resources?
22:42justin_smithhadronzoo: 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:43justin_smithoh sorry, deps.cljs - I should read more carefully
22:43hadronzooI'm using lein-bower to import javascript libraries, but I'm not having much success.
22:43justin_smithI don't know about deps.cljs
22:48hadronzooDoes anyone know if an om-based select component exists? Something similar to react-select?
23:03kLooaaDo 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:03kLooaaOne of that statistics number. nothing more.
23:03justin_smithkLooaa: and a good evening to you too!
23:04kLooaaI hate evenings
23:04justin_smithkLooaa: do you have any plans to do anything interesting before you whither away and die?
23:05kLooaajustin_smith: what interesting can do? if you know your ending very bad soon
23:05justin_smithno, no, we are talking about your death, not mine
23:06kLooaaeating food? watching tv? thats what humans do
23:06kLooaayes about mine
23:07justin_smithkLooaa: fyi this channel is about Clojure, the programming language, not clojure, the psychological sense of coming to peace
23:08justin_smitherr, closure is the coming to peace one, I am too used to typing out clojure in this channel
23:08kLooaacloujure devs will die
23:08justin_smithbut that isn't very clojure specific, is it?
23:09kLooaai dont care clousure or not
23:09kLooaaDEAD
23:10justin_smithyou are very determined for someone who doesn't care, seems like there is something you care about
23:11kLooaayes I care about world existing
23:11kLooaaneed to stop
23:31adammhI'd appreciate if anybody could help me with a `core.typed` question... just starting out so it may be a bit obvious
23:31adammhwhy does (IPersistentMap Integer myapp.core/Thing) Integer
23:32adammhmatch (t/Option (ILookup t/Any x)) t/Any
23:32adammhdo I need to explicitly lift the map into the `Option` type?
23:36WickedShellI 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?