#clojure logs

2013-04-30

00:00technomancypostgres devs should know better =\
00:00callenI really wish Clojure on Android didn't have such a slow startup time.
00:01hiredmanto be fair 1.5 is pretty old
00:01hiredmaneven 1.6 is supposed to be EOL any day now
00:02j4x0nApparently they've done it before. It was fixed then someone must have recompiled.
00:02technomancyhiredman: actually it's just Oracle's JDK that is going to be EOLed
00:02technomancyOpenJDK has no such plans
00:04callenOpenJDK performs just fine as well, anecdotally.
00:09tieTYThere's some code I converted from java. How could this be changed to be more idiomatic? https://www.refheap.com/paste/43d1ca29fe152a2cd3f80f1cb
00:11callentieTYT: the manual type-checking and dorun usage is very meh.
00:11callenas is the direct interaction with Swing.
00:12callentieTYT: http://daveray.github.io/seesaw/ at least use it pedagogically, if not actually in your thing.
00:12tieTYTcallen: I don't think I can use seesaw for this
00:12tieTYTif you assume that, how could I avoid the manual type-checking?
00:13callentieTYT: that is very unfortunate. learn from seesaw then.
00:13callentieTYT: learn more Clojure and you'll get your answers re: avoid manual type-checking.
00:14tieTYTcallen: I've been reading seesaw source for days now
00:15brehauttieTYT: is the purpose of the type check to ensure that its not nil or something?
00:15brehautand if you want real type checking, theres a library for that
00:15tieTYTbrehaut: it's to ensure that it is a JComponent. If it's not a JComponent, it won't have a getInputMap
00:15callenbrehaut: (instance? ...)
00:15tieTYTand getComponents returns Component, not JComponent
00:16brehautcallen: obvious its instance at the moment, but i presume theres a reson for the check if its ported from java
00:17tieTYTif I don't do that check, it could try to call getInputMap on an instance that doesn't have that method
00:23brehautwell, if you need polymorphic functions, protocols are probably a better way to go about it
00:23brehautyou can implement protocols for nil or object if needed
00:23brehautfor your default behaviours
00:23brehautthis is assuming you are passing non-compliant objects into the function
00:24tieTYTi'm always passing a JComponent in
00:24tieTYTdoes that mean i shouldn't use protocols?
00:25brehautif you always pass in something that supports that method then no protocols, no type checks
00:25brehautjust dont go passing the wrong thing in
00:26tieTYTline 11 may pass in a Component that's not a JComponent
00:26tieTYTi thought you meant me as in what the programmer passes in
03:04nopromptdoes anyone use pre/post conditions?
03:05noprompti rarely see them used "in the wild" but the seem useful.
03:06Raynesnoprompt: Not really.
03:07murtaza52is it possible to short circuit a `reduce`, like what `some` does
03:10Raynesmurtaza52: In Clojure 1.5 you can return (reduced) to stop the reduce.
03:10RaynesBut only in 1.5+
03:11nopromptRaynes: yeah. so i take it no one uses them.
03:12nopromptwell, what's a clean way to assert arguments meet a certain criteria?
03:12Raynes&(doc assert)
03:12lazybot⇒ "Macro ([x] [x message]); Evaluates expr and throws an exception if it does not evaluate to logical true."
03:12Raynesnoprompt: But if you're gonna use assert, might as well use pre conditions and shit.
03:12RaynesI mean, just because nobody uses them doesn't mean they aren't perfect for your usecase.
03:12RaynesThey were added for a reason.
03:13RaynesVery little is in Clojure that Rich didn't think was useful.
03:14sw2wolfDoes Rich has id in this channel ?
03:14nopromptthe AssertionError could be a bit cryptic though for a function in a public api.
03:14tgoossenssw2wolf: yes
03:14sw2wolfIs it Rich ?
03:15sw2wolfi just want to highlight it in my ERC configuration
03:15Raynesnoprompt: Well, then throw ex-info instead.
03:15Raynesrhickey
03:15tgoossensI know that rich has been on IRC in the past. But I don't know about now
03:15RaynesHe isn't here right now. Doesn't come very often.
03:15RaynesWhen he does it's rhickey.
03:16tgoossenswhats with all the 'idiomatic'. I seriously never encountered a community that used the word 'idiomatic' so often
03:16nopromptRaynes: ex-info?
03:16Raynes&(doc ex-info)
03:16sw2wolfNow i have erc-pals '("Hindley" "rhickey")
03:16lazybot⇒ "([msg map] [msg map cause]); Alpha - subject to change. Create an instance of ExceptionInfo, a RuntimeException subclass that carries a map of additional data."
03:16Foxborontgoossens: you can't come from Python.
03:16RaynesYou're not very good at this, are you noprompt?
03:17Raynes:p
03:17Foxborontgoossens: the Python community uses "idiomatic" all the time.
03:17Foxboron"idiomatic python! idiomatic classes! idiomatic this and that!"
03:17noprompttgoossens: so does the Ruby community too.
03:17Foxboronhttp://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
03:17nopromptRaynes: my brain is a little fried i guess. :/
03:18Raynesnoprompt: <3
03:18noprompti've been working on porting this legacy application at work to Clojure.
03:18Raynes&(throw. (ex-info {:some :data :about :the :exception})
03:18lazybotjava.lang.RuntimeException: Map literal must contain an even number of forms
03:18Raynes&(throw. (ex-info {:some :data :about :the :exception}))
03:18lazybotjava.lang.RuntimeException: Map literal must contain an even number of forms
03:18RaynesFUUUU
03:18Raynes&(throw. (ex-info {:some :data :about :the :exception :okay}))
03:18lazybotjava.lang.IllegalArgumentException: Unable to resolve classname: throw
03:18Raynesffffffffffuuuuuuuuuu
03:18Raynes&(throw (ex-info {:some :data :about :the :exception :okay}))
03:18lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: core$ex-info
03:18nopromptRaynes: that happened to me last week. :P
03:19Raynes&(throw (ex-info "Goddamn it." {:some :data :about :the :exception :okay}))
03:19lazybotclojure.lang.ExceptionInfo: Goddamn it. {:about :the, :some :data, :exception :okay}
03:19RaynesThank you.
03:19Raynes&(try (throw (ex-info "Goddamn it." {:some :data :about :the :exception :okay})) (catch ExceptionInfo e (ex-data e)))
03:19lazybotjava.lang.SecurityException: You tripped the alarm! catch is bad!
03:19RaynesOh blow me lazybot.
03:20nopromptbut gawd. the application is a maze of 6-year-old php and javascript (interleaved of course).
03:20murtaza52I have a seq of vectors. I want to iterate through them. Modify only the first vector that meets a pred. Return back the coll with the modified vector.
03:21Raynes&(doc ex-data)
03:21lazybot⇒ "([ex]); Alpha - subject to change. Returns exception data (a map) if ex is an ExceptionInfo. Otherwise returns nil."
03:21murtaza52How do I do the above? bcoz all methods such as for and reduce will modify all vectors that meet the pred, while I want to modify only the first that meets the criteria.
03:21Raynesnoprompt: So my code should work. As an example.
03:21Raynesnoprompt: ExceptionInfo is basically an exception that doesn't suck and allows you to pass data out.
03:21tgoossensand with idiomatic i guess you mean "conventional" ?
03:22nopromptRaynes: that's neat-o.
03:23nopromptgonna try it out in the repl real quick.
03:23itemadhttp://www.youtube.com/watch?v=UrMWRAaFdIc&amp;feature=youtu.be
03:23itemadops! :-P
03:26noprompthmm... i'm debating whether i should add a dependency, steal code, or hand-roll a color lib for garden.
03:27tomojmurtaza52: https://www.refheap.com/paste/7dc0b0d3e81f5ed63c7b4d589 hmm, surely there is a better way?
03:27nopromptaren't those always the choices? geeze. i think i need a drink...
03:28Foxborontgoossens: idiomatic is an idiom. It could be obscure code which is widely known to be the "right" way. Think of it as language idioms. "Break a leg" is an idiom.
03:28tomojI would like to write it as something like (update-in vecs [map (some pred)] f)
03:29tomoj(hypothetical)
03:29tomoj(.. and probably confusing because the names 'map and 'some are taken. ignore me)
03:32nopromptRaynes: i guess what i like about the pre conditions is that it can make something like (if (meets-criteria x) do-stuff (throw ...)) a bit cleaner.
04:12OdinodinGiven I run lein test, when a test fails, the process just hangs and I have to manually stop it. Does anyone know if there is anything to get around that?
04:13noprompt /quit
04:20noidiOdinodin, maybe you have a thread that's still alive and blocking the app from exiting
04:22noidiI think you can use VisualVM to see what's going on while the process hangs http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/
04:23Odinodinnoidi: ah, thanks, that seems very probable. We have a jetty server running during the tests thats probably the culprit
04:26nbeloglazovWhat is the usage of symbols in edn format? I cannot find any real use case for them.
04:29tomojdatomic is an example where they are used
04:30tomojthe rest interface accepts queries like [:find ?x :where [?x :foo]] as edn
04:33tomojI guess datomic shows two use cases: representing binding in edn, and referring to clojure vars
04:37tomojmy intuition is that the space of symbols in a language encoded in edn will tend to be more closed (less open) than the space of keywords
04:38tomojhmm
04:39tomojI guess the difference is really more just that keywords are supposed to mean themselves where symbols can be assigned particular meanings
04:48nbeloglazovtomoj: thank you
05:09no7hingdoes anybody know of a java/clojure lib similar to https://github.com/jubos/fake-s3 ?
05:11jaleyno7hing: are you just trying to stub out an S3 server for testing purposes?
05:11jaleyno7hing: jClouds' blobstore abstraction has a stub provider implementation, which can be useful for that
05:12no7hing@jaley yes
05:12no7hing@jaley i'll have a look at it, thanks
05:16jaleyno7hing: if you depend on [org.jclouds/jclouds-blobstore "1.6.0"] in your project.clj
05:17jaleyno7hing: you can then (:require [org.jclouds.blobstore2 :as blob]) and use (blobstore "transient" "" "") to get a fake instance
05:17jaleyno7hing: all of the blob/put-blob blob/get-blob will work with it, storing entries in ram
05:18jaleyno7hing: I believe there's also a filesystem implementation if you need it
05:18no7hingram only sounds perfect for my needs
05:19no7hingi'll just pre-populate the blobstore with my data and don't need to tamper with the application code, as it's tested from another vm
05:20jaleyno7hing: presumably you also want your code to actually talk to S3 later?
05:20jaleyno7hing: when you want to plug into s3, you need to add a dependency on the s3 "blobstore" provider to your project and create an instance of that with (blobstore "aws-s3" "access-key" "secret-key") instead
05:20no7hingalready doing it
05:20jaleyno7hing: cool
05:21no7hingthanks for your help!
05:21jaleyno7hing: no problem
05:49nbeloglazovIs there some clojure expression that is not valid edn expression?
06:00tomojnbeloglazov: ::foo
06:00tomojamong others..
06:00tomoj#(foo)
06:00tomoj@foo
06:01tomoj#'foo
06:01nbeloglazov:) Ok, thanks
06:01tomojthough
06:01tomojthose last ones are all sort of cheats
06:01tomoj(fn [] (foo))) and (deref foo) and (var foo) are all valid edn..
06:02tomoj#java.net.URI["/foo"]
08:48CookedGryphonHey all. So I don't much like the try/catch form in clojure. I find it always produces ugly, hard to follow, hard to re-use and hard to compose code. What i do instead is in this gist: https://gist.github.com/AdamClements/5488162 what do people think of this? I'm tempted to make it a library, but a dependency and a require feel like overkill for one/two macros!
08:51clgvCookedGryphon: probably, you do not know "dire" https://github.com/MichaelDrogalis/dire
08:52clgvCookedGryphon: that lib allows you to decouple error handlers from the functions they might appear in
08:53clgvCookedGryphon: as well as pre-/post-hooks
08:53CookedGryphonclgv: I do know dire, I find it's overkill for most of my use cases
08:53CookedGryphonand does var rebinding, which I don't really like
08:54CookedGryphonas it's all too easy to miss that your error handling is subverting your code path, making it hard to read
08:55clgvCookedGryphon: but you can really dcouple the handlers from code which is one step further than your macros
08:55CookedGryphonif you see (defn times [a b] ...) and then something which calls (times 2 3), you'd expect it to go straight into that function, which could lead to unpredictable behaviour if you've actually rebound the times var
08:56CookedGryphonI feel it's a step too far and has the potential to reduce readability, especially if you're reading someone else's code and aren't used to dealing with errors in that way
08:56clgvCookedGryphon: well, that's what documentation is for. if you have a coding guideline for error handlers of this kind in your project - you'll expect that those handlers will kick in
08:57clgvCookedGryphon: it is certainly a matter of personal taste. but I'd choose dire before those macros in the gist, since using them consistently also makes the code quiet complex.
08:58CookedGryphonmy point is, someone's going to see this, think great, write a separate namespace for handlers (to keep similar things bundled together), gleefully rebind these variables. Someone else comes along and they're missing half the code but don't even realise it because there's no reference to the error stuff
08:58clgvCookedGryphon: but that is a documentation problem.
08:59CookedGryphonnot really, it's an evident code problem
08:59CookedGryphonI don't want to have to read a manual on how this particular codebase handles errors, that sounds like the java way of doing things
09:00Morgawrwhat function can I use if I want to update all the values of a hashmap without touching the keys?
09:00Morgawrlike a map but only on the values
09:00clgvMorgawr: there is none. you can build it via reduce-kv
09:01MorgawrI'll try, thanks
09:01CookedGryphonMorgawr: I believe there's something in the flatland/useful library which does that
09:01MorgawrCookedGryphon: I'm using ClojureScript so I can't really rely on external libraries
09:02clgvMorgawr: if you change all values you actually build a new map even if you use assoc. since there does not remain much for structural sharing
09:02CookedGryphonMorgawr: fair enough, you could copy the implementation though
09:04Morgawrclgv: the thing is, I have a hashmap that contains all filenames and I want to append a different extension at the end of said filenames (to distinguish between .mp3 and .ogg sounds depending on the browser)
09:06clgvMorgawr: (defn update-map-values [m f & args] (persistent! (reduce-kv (fn [r, k, v] (assoc! r k (apply f v args))) (transient {}) m)))
09:06clgvMorgawr: you might also add the key to the function invocation
09:06Morgawroh wait
09:07MorgawrI found a much easier way
09:07Morgawrhttp://stackoverflow.com/questions/1676891/mapping-a-function-on-the-values-of-a-map-in-clojure this seems pretty good
09:07Morgawrand it works :)
09:07clgvMorgawr: yes that works. the reduce-kv is the faster approach in Clojure - dont know about ClojureScript
09:09MorgawrI don't really need speed at the moment though, it's a very simple function. Thanks either way :)
09:11LiaoPengyuHello?
09:11clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline LiaoPengyu
09:11LiaoPengyujavadoc
09:11LiaoPengyuToUpperCase
09:51xeqiRaynes: ping; what kind of info do you scrape off clojars for lazybot?
09:57no7hingis there a fast way to add a virtual host to ring/jetty?
09:57weavejesterno7hing: A virtual host is just dispatching off the Host header
09:58weavejesterIn Compojure, you can write: (context "http://subdomain.example.com/&quot; [] ...)
09:59weavejesterAt least in theory...
09:59no7hing@weavejester i didn't get them to show up in the app, but haven't gone for those context's though
09:59weavejesterActually, it would probably be better to write:
09:59weavejester(ANY "http://subdomain.example.com/&quot; [] (routes …))
09:59weavejesterI know that one works
09:59weavejesterNot sure about the context
09:59no7hingwill try that, thanks
10:00weavejesterBut you can always dispatch off the (get-in request [:headers "host"]) anyway
10:00no7hingi understood them to be a way to bundle up handlers;
10:00no7hingbut that's just e
10:00no7hingme
10:00no7hingwas thinking too complicated. again.
10:00weavejesterThe context macro is a way to add a common prefix to a set of routes.
10:01no7hingwhat i thought
10:01no7hingbut couldn't express
10:08mefestoany know if the docs for weavejester/{hiccup,compojure} currently in a transition? Seems like the links are broken and no css
10:09mefestohttp://weavejester.github.io/hiccup
10:09weavejestermefesto: Looks like github.io domain shift broke the redirect
10:10weavejesterhttp://weavejester.github.io/hiccup/
10:10weavejesterIf you add an ending / it works
10:10mefestoweavejester: ahh thank you
10:10weavejesterNot sure how to fix that for a static site...
10:11weavejesterI guess I should alert github to the issue. "/foo" should redirect to "/foo/"
10:12winkyeah
10:13Anderkenttechnomancy: https://github.com/technomancy/leiningen/blob/master/src/leiningen/pom.clj#L234
10:13Anderkent(if (seq extra-src) (add-test-sources)) ? :(
10:13mefestoweavejester: it loads the index page correctly but the resources within the page are relative (js/blah.js) whereas (/hiccup/js/blah.js) would fix it
10:14weavejestermefesto: Yes, but that would require the docs to know where they are being deployed to.
10:14mefestomaybe i shouldn't say `fix it` but work-around it
10:14mefestoweavejester: ah i see
10:15weavejesterIdeally the docs should work as local files as well
10:15weavejesterWhich means relative links
10:15mefestoyeah definitely wouldn't want to sacrifice that.
10:16mefestoknowing to put a slash at the end is enough for me :)
10:19kastermaI just run into some confusing (for me) behaviour of equality. See https://gist.github.com/kasterma/5489015. It seems declared but unset symbols are treated specially for =.
10:20kastermaIs it that, or am I missing something in the behaviour of '?
10:22clgvkasterma: thats symbol versus variable value
10:23kastermaCould you explain a little more?
10:23clgvkasterma: those list constructions are not the same: (def x 42) (list x) => (42), '(x) => (x)
10:25kasterma(= (list |) dd) => true
10:25kastermaAhh, but why did it work with a keyword?
10:25clgvkeywords evaluate to themselves
10:26kastermaSo in the equality test the content of the list is evaluated, and evaluating | doesn't work?
10:27clgvkasterma: in that expression you construct a list with a single element which is the value that is bound to |
10:27kastermaWhich does not exist.
10:28clgvkasterma: | is unbound and thus returns an instance of clojure.lang.Var$Unbound which is an implementation detail
10:29kastermaclgv: thx, for the help.
10:30mefestowhen using lein-ring and lein-cljsbuild is a typical workflow for generating a standalone jar something like the following or is there another way? lein cljsbuild prod && lein ring uberjar
10:32mefestoideally, i'd like to only have to issue `lein ring uberjar` and have cljs build with all the optimizations for production
10:35clgvkasterma: a simple rule to remember: only use '(1 2 3 4 5) to construct list of constants
10:35ucbwhen I eval this I get :default, where am I going wrong? (condp <= 1 0xff "yes" 0xffff "no" :default)
10:36clgv,(<= 1 0xffff)
10:36clojurebottrue
10:37kastermaclgv: thx
10:38ucb,(<= 1 0xff)
10:38clojurebottrue
10:38clgv&(condp >= 1 0xff "yes" 0xffff "no" :default)
10:38lazybot⇒ "yes"
10:38akells`Is a [B not a bytearray? I'm trying to call .length on something that is a [B and its telling me 'no matching field found: length for [B'
10:38clgvthe application of arguments is the other way round in condp
10:39clgvquote: " & & & & & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & & & & \\"
10:39clgvoops
10:39nDuffakells`: there's an alength function
10:39clgvquote: "For each clause, (pred test-expr expr) is evaluated."
10:39nDuffakells`: ...Java exposing it as a field is syntactic sugar.
10:39ucbclgv: ooh, nice, thanks
10:39ucbclgv: totally misread that
10:40akells`nDuff: that seems to be working. is this the length, in bytes?
10:40akells`thank you very much, by the way
10:40clgvucb: I would have guessed for (pred expr test-expr) as well
10:40nDuffakells`: number of array elements, so for a byte array, yes.
10:40ucb*nod*
10:40akells`much appreciated!
11:26akells`Is this going to actually concatenate these two byte arrays? Or is my repl misleading me a little bit by saying it returns one? (byte-array (concat (.getBytes "edf") (.getBytes "abc")))
11:33xeqi(let [x 3 _ (println x) y (+ 1 2) _ (println y)] y)
11:33xeqi&(let [x 3 _ (println x) y (+ 1 2) _ (println y)] y)
11:33lazybot⇒ 3 3 3
11:33gfredericks(let [a (b), :do (things), c (d)] ...)
11:33gfredericksxeqi: yeah, I use that for debugging. feels to awkward to use for real code
11:58dnolenibdknox: congrats on the latest release!
11:59ibdknoxdnolen: thanks :)
12:10seangroveibdknox: Yes, it seemed very well received on hn, great job
12:10n_bI'll second that!
12:10n_bIt's helped get a few of my friends into Clojure :)
12:43saolsenthat js integration is great, does it work that well for clojurescript?
13:00dnolensaolsen: LT is written entirely in ClojureScript as far as I know and I believe ibdknox uses LT to dev LT, so I imagine it works OK. Would like to see more docs on that tho.
13:04ibdknoxsaolsen: dnolen: because of the way cljs works, you'd have to do some weird things to get the same level of eval. For one, it requires replacing the source of a file, which means you'd have to completely recompile on every eval :/
13:05ibdknoxthat being said, LT gets around this because of the BOT architecture - everything is late bound
13:09dnolenibdknox: hmm, why do you need to re-compile the whole file if you just want to change a single def?
13:09ibdknoxdnolen: because I need the complete output of bootstrap.js or whatever you call the cat'd source
13:10dnolenstuartsierra: can we do another CLJS at some point? It's been a while. Main changes would be Clojure 1.5.0 dependency and data.json 0.2.2
13:10stuartsierrawill do
13:10stuartsierramay need updating since Sonatype Nexus change — I'll look into it
13:11dnolenibdknox: oh this is for dev'ing LT directly, I guess less a problem if you're using LT to dev your own CLJS stuff?
13:11dnolenstuartsierra: 1.5.1 I meant
13:11stuartsierraok
13:11ibdknoxdnolen: nope, this is for the VM patching for any CLJS. You can always do normal eval, which is actually more than enough in most cases for CLJS
13:12ibdknoxdnolen: but to do the same things I was showing in the cube video, I have to replace the original source file with a new one and they have to be relatively similar - so I would need the new result of compilation to swap it out with
13:21dnolenibdknox: hmm make some sense ... is there some way you see to make that process smoother?
13:22winkhm, anyone ever tried to put json into mysql via korma? looks like an encoding problem, but it's weird
13:22saolsenI've been working on a cljs game and that level of interaction with a threejs canvas would be the greatest thing ever
13:40ibdknoxsaolsen: depending on how you write your game, you may not need that stuff
13:41ibdknoxdnolen: I haven't though through it too far yet. There may be something clever to do.
13:54akells`clojure.java.io/copy should be able to handle any byte array, correct?
13:56amalloyakells`: i doubt it
13:57amalloywell, i guess it does. it implicitly creates a Reader from it. okay
13:57amalloyer...an InputStream
13:57akells`I must be doing something else wrong. It works fine with a byte array from an image file
13:57akells`but it doesn't seem to be working quite the same with a byte array from a text/html file
13:58akells`well, its actually a byte array that is a concat of two other byte arrays. but it works fine for the concat that uses an image file's byte array, but not for the concat that uses a text/html file's byte array
13:59amalloywell that's obviously a red herring. the jvm doesn't remember where arrays came from
14:00akells`I just wanted to make sure clojure.java.io/copy should work in any case. sounds like I've got an issue somewhere else. this was helpful, thanks amalloy
14:01_francis_I'm looking at this code https://www.refheap.com/paste/14081 and wondering why you would put a type in a function metadata - thoughts anyone?
14:05arrdem_francis_: one day god willing we will have optional typing able to take advantage of that data
14:05_francis_arrdem: thanks
14:06arrdem_francis_: actually no. in this case you are type-hinting the function.
14:06_francis_arrdem: I thought that type hints go in the arg list?
14:07arrdem_francis_: you can put them there too.
14:07arrdem_francis_: I'm not clear on the details, but I understand that it type-specializes the generated code. Used for performance and for Java interop.
14:09_francis_arrdem: Are you certain that types in the metadata will be used for type-hinting? In this case the fn will return that type, but can accept several different types.
14:09arrdem_francis_: that's why I say I'm not sure. I'
14:10arrdemve seen argument metadata used to clamp down the function dispatch time, but I'm not sure what effect typing the return value has.
14:11_francis_Could you supply an example?
14:12sveduboisIn CLJS, how can I set some value inside a "doto".
14:12sveduboisFor example, I have this:
14:12svedubois(set! (.-color sphere) "red")
14:12sveduboisAnd I would like to have something like this:
14:12svedubois(doto (sphere.)
14:12svedubois (.-color "red"))
14:13dnolen_francis_: the compiler will use that information, it makes interop less tedious
14:14dnolen_francis_: for example if you locally bind the result of invoking that function in let, that type hint will be propagated by the compiler
14:14_francis_dnolen: Awesome.
14:14arrdemdnolen: thanks for the save :p, didn't know (let) could use type hinting
14:15arrdem_francis_: I can't find it ATM but I believe that the community matrix library is the last place I saw hinting in the wild.
14:16dnolenarrdem: most of binding forms really as they generally macro expand to let
14:16matkohi #clojure, I was wondering, in a multi-threaded environment, is it a bad thing to have many threads lying around that do nothing? For example, 5000 threads that mostly sleep but wake up now and then to update something? Or does this incur little cost?
14:16dnolennow that I think about it, I think all?
14:17technomancymatko: IIRC the primary cost there is creating and destroying threads; I think once they're around they're supposed to be cheap. but you might want to look into a thread pool anyway to avoid re-inventing the wheel
14:17arrdemdnolen: everything but def should macroexpand to a let at the end of the day
14:17matkotechnomancy: futures already use a threadpool right?
14:17matkoI was thinking of using futures for this
14:17n_bfutures use the agent thread pool I believe
14:17matkohm.. is that bad?
14:17matkoI'd assume that means the send-off pool
14:18n_bThat's my understanding
14:18technomancymatko: it just means you don't have a lot of control over it
14:18technomancymay or may not be a problem in practice
14:18matkook, so startup is costly, but a sleeping thread is not a bad thing
14:18matkothank you :)
14:18technomancywell, not on a decently-sized linux system
14:19matkowhat about windows?
14:19n_bmatko: I just did a pretty large threaded importer, and ended up using threadpools because I had tens of thousands of threads bein created when I just used futures
14:19technomancymatko: no idea about windows or mac
14:19matkook
14:19n_bbut it was a memory consumption issue due to my workload
14:19matkoI'll have to test
14:19technomancyvirtualized linux also might not be so hot
14:19technomancyyou'll have to test anyway; don't trust random advice on IRC =)
14:19matkohahah, that's advice I will trust
14:19stuartsierraFutures use the Agent send-off thread pool.
14:19n_bBenchmark both ways, and remember IFn implements Runnable so you can always (.new (Thread. #(some_fn))
14:20matkowoah, I forgot about that
14:20matkothanks for reminding
14:20stuartsierraIn Clojure 1.5 you can configure the thread pools, e.g. set bounds.
14:20n_bmatko: It makes using Executors much easier :)
14:20matkodoes clojure come with libraries for thread pools?
14:21n_bmatko: Outside the basic concurrency constructs, not to my knowledge. Using Java interop was very easy IME
14:21stuartsierramatko: java.util.concurrent
14:22n_bThough IRC did much to help fill the gaps in my knowledge of it
14:22matkostuartsierra: that's not clojure :) but sure that works
14:22stuartsierraClojure generally makes little effort to hide details of its host platform.
14:22antares_matko: agents use a thread pool and can be (ab)used very similarly to executes in j.u.c.
14:23matkoj.u.c.?
14:23technomancyclojurebot: j.u.c?
14:23clojurebotTitim gan éirí ort.
14:23matko.... scary
14:23technomancyclojurebot: java.util.concurrent?
14:23clojurebotjava.util.concurrent is "When I find myself in times of trouble / Prof. Doug Lea comes to me / Coding lines of wisdom / j.u.c."
14:24matkooh doh
14:24nDuffmatko: RH has been pretty explicit about building Clojure's concurrency primitives to supplement, not replace, java.util.concurrent.
14:24matkocool, so I guess I'll prototype using futures. If it turns out to be problematic, I'll switch to a thread pool. either way should work fine for my purposes
14:24tcrayfordman do I love that j.u.c. thing. That's cscotta or somebody like that originally?
14:24technomancytcrayford: tnm
14:26nDuffmatko: If a future isn't the right thing for the job, don't be shy about going straight to j.u.c. Clojure functions implement both Runnable and Callable; there's nothing at all difficult about using them with the Java APIs.
14:27tcrayfordtechnomancy: oh, of course. I'm sad that dude deleted all his tweets, he was the best
14:27technomancywhat; he did?!
14:27matkohm. I should have a good look at that library anyway. Guess I'll do so now
14:27technomancyweird
14:27tcrayfordyeah :(((
14:27technomancywell it's immortalized in clojurebot now
14:31matkooh, I guess the thing I actually want is a scheduled thread pool. good thing I looked
14:47xorolais clojure strongly typed? i think so.
14:47technomancyxorola: yes
14:49SegFaultAXxorola: Java is strongly typed, yes.
15:01ToBeReplacedhow can i extend the Closeable interface to an existing type i don't own? extend-type yells b/c Closeable is an interface, not protocol
15:03ToBeReplacedfor personal use, of course... i want to take a jzmq context which has a .term destructor that matches libzmq and make it usable from clojure with with-open
15:04xeqiyou can't directly. One option is (proxy Closeable ...) and decorate the object
15:04gfrederickshmm
15:04gfrederickspromises can't act like futures by throwing exceptions on deref can they :/
15:04xeqihmm, I think I want reify there
15:04xeqiinstead of proxy
15:05xeqican never remember which until I try
15:05gfredericksoh nevermind I can combine futures and promises in a magical mystery way
15:05ToBeReplacedyeah reify would work, it would also muck with the type which might make reflections not happy, but i suppose that makes sense
15:05ToBeReplacedthanks
15:25svedubois_I have a vector (def v ["a" "b" "c"])
15:25svedubois_And I would like to create a classname for each element in the vector in only one line.
15:25svedubois_Is it possible, how?
15:25svedubois_(def a (classname.))
15:26SegFaultAXsvedubois_: What do you mean create a classname? Why does it have to be one line?
15:27svedubois_One global variable for each element in the vector
15:28svedubois_With the vector ["a" "b" "c" ... ], create (def a (classname.)), def b ..., def c ...
15:29SegFaultAXsvedubois_: Why do you want to do this?
15:31amalloyyeah, that is not a thing you want to do
15:33matko(map #(eval `(def ~(symbol %))) v)
15:34gdev,(map class [0.07 "james" :bond])
15:34clojurebot(java.lang.Double java.lang.String clojure.lang.Keyword)
15:40svedubois_ClojureScript can list all files in a given directory?
15:41gfredericksprobably in whatever manner you would normally do that in javascript
15:41gfrederickswhich is "no" in a traditional browser setting
16:17arrdemcan I add hooks to a lein command? so "ring server" triggers "lessc" in my specific case.
16:25technomancyarrdem: :prep-tasks ["lessc"] will cause lessc to happen before any code runs inside a project
16:25arrdemtechnomancy: thanks
16:25technomancylessc needs to be fast if there's no work to do, because it'll trigger on every repl, complie, test, etc
16:26arrdemit's pretty fast atm since it doesn't seem to be building my CSS files -_-
16:26technomancyfast is good
16:26arrdemsilent failure is bad tho
16:28winkhmm. (clojure.java.io/copy (clojure.java.io/input-stream "http://...x.png&quot;) (clojure.java.io "/path/to/foo")) copies one image and not another. reproducably. any ideas? :)
16:29wink*add /output-stream ofc where needed
16:42gdevmy eyes, they bleed, warning: java code https://www.refheap.com/paste/af945a051690ee85ec1d018cf
16:43Raynesgdev: This is beautiful code.
16:43RaynesI strive to write this kind of code in Clojure.
16:44arrdemRaynes: not sure if sarcasm
16:44Raynesarrdem: Sarcasm.
16:44arrdemgud
16:44iwohey, does anyone know of an example on how to create a vector of keys that is compatible with get-in/assoc-in/update-in FROM a map?
16:44mthvedtclojure is not type-safe and enterprise-ready, it cannot make code that beautiful
16:44RaynesI think amalloy wrote something to do that.
16:45amalloydoesn't ring a bell, sorry
16:45iwoso i have a nested map structure - i'm trying to decide how I could navigate this map to create all valid keys for get-in
16:45Raynesamalloy: You wrote a function to get all possible keyseqs from a map.
16:45Raynesamalloy: I know you did because we discussed the implementation.
16:45RaynesDon't screw with me, bro.
16:45amalloyi write a lot of functions. i don't remember this one
16:46gdevL.A. GUI with an Oakland back end
16:48amalloyit's not hard to write, though
16:48amalloyhttps://www.refheap.com/paste/5823c0e842a3948b579c42cc5
16:49amalloymodulo your decision about whether (:b) is a valid answer as well
16:49Raynesamalloy: I'm greping every piece of code you ever wrote until I find the one you wrote in the first place.
16:51amalloyit actually comes out a lot nicer if you're willing to count (:b) as a keyseq: https://www.refheap.com/paste/5885807c958f35ab9b80976c1
16:51RaynesI can't remember the bloody project.
16:51RaynesJiraph? Telemetry? BAH.
16:51RaynesThis is going to haunt me.
16:53arrdemRaynes: you were right, noir -> compojure wasn't that bad at all.
16:56Raynesarrdem: Whoa, you just now did it?
16:56arrdemRaynes: yeah I just got the user facing parts of my site ported in the last two hours
16:56ppppauli want to output a JSON stream from my ring endpoint (using cheshire, and can't really figure out how to get an input-stream form it's generate-stream fn
16:56ppppaulany help
16:57ppppaul:)
16:57gfredericksppppaul: oh there was something for this
16:58arrdemRaynes: once I got about 15 github documentation pages open it was dead easy
16:58Raynesarrdem: Worth it!
16:58arrdemppppaul: someone hacked this live here a few months ago....
16:58gfredericksppppaul: first find ring.util.io/piped-input-stream
16:58ppppaulgfredericks, i found some issues on cheshire and ring about this, but i'm looking for a hacked up solution now :)
16:59ppppauli have the piped-input-stream src open...
16:59gfredericksthen make your body (piped-input-stream (fn [out] (->> out (OutputStreamWriter.) (BufferedWriter.) (json/generate-stream data))))
16:59ppppauli know i'm going to use it, and i know where to use it, but the cheshire stuff is what i'm tripping over
16:59ppppaulgfredericks, woooooo thanks so much :D
17:06ppppaulthis is now a part of my liberator fork
17:06ppppaulwoot
17:07ppppaulnever has seeing a data dump from datomic felt so good
17:08ppppaulfeel like watermelon
17:09gfredericks:)
17:09gfredericksI should pass on credit to whoever gave me that snippet in the first place
17:09gfredericksI have no idea who that was
17:09gfredericks(inc anonymous)
17:09lazybot⇒ 1
17:09arrdem(inc clojure) ;; since gfredrics is passing
17:09lazybot⇒ 11
17:10gdevyay, this works, but it seems hacky and amateurish which is a good description of my coding style so not surprising https://www.refheap.com/paste/cbb89e7032d2418dc20d66c84
17:11gdevgfredericks:) I'm still working on that database thing you helped me with; doseq on the update statement meant my update to database call was 1 to 1
17:12gfredericksgdev: how do you do updates without that being the case?
17:12gfredericksI've often wanted that
17:12gdevgfredericks:) I'll let you know when I figure it out =)
17:12gfredericksha
17:13gdevhaving the data pre-staged was half the battle
17:15gfredericksppppaul: ha I started that issue
17:15ppppaul:)
17:16gfrederickssomebody, I think weavejester, pointed out at some point that the ring spec might need some amending to handle cases like this
17:17gfredericksnot basic json, but any kind of streaming that involves an open resource
17:18astevea coworker is trying to pull in a clojure project and is getting checksum errors on com/google/guava; he is using leiningen 2.1.x and we tried remove ~/.m2
17:19asteve26 days ago the developers for guava claimed they pushed a corrected checksum and that it would propagate over the next few hours
17:19asteveany ideas?
17:21stuartsierradnolen: FYI, ClojureScript release build will need some changes to accommodate new Sonatype Nexus version.
17:21stuartsierraI'm burnt out now but I'll try to get to it this week.
17:29astevethis is the exact problem a coworker was having earlier today http://stackoverflow.com/questions/15818219/failed-retrieving-guava-libs-from-maven
17:29astevewe tried lein clean and we tried removing ~/.m2 entirely
17:30asteveis there a way to download the dep manually?
17:30arrdemasteve: your best bet is probably gonna be to force lein to load without checks...
17:30arrdemasteve: not sure how to do that tho.
17:31technomancyasteve: you can always build from source
17:31technomancymvn install or whatever
17:31technomancyturning off checksum checks is pretty sketchy
17:31arrdemoooh yeah
17:31technomancywould strongly not recommend leaving checksum checks off
17:31gdevgfredericks:) sorry, I didn't mean ratio of database calls to update statement, im still trying to figure out how to interpret this oracle database trace file
17:31technomancymaybe turn it off once, download the dep, and turn it back on
17:31technomancyasteve: sometimes bad checksums get stuck on a specific mirror
17:32technomancyso only users from certain geographic locations see them
17:32asteveah
17:32technomancyanyway you should definitely continue to communicate with the maintainers
17:32asteveok
17:32technomancyuntil it's resolved upstream all you have are workarounds
17:38iwohey, is there a neat way to do 'cons if not nil' in clojure?
17:38arrdem,(cons 1 nil)
17:38clojurebot(1)
17:38iwobasically: (if x (cons x l) l)
17:39arrdemoh identity over list?
17:39iwoi suppose i could do: (keep identity (cons x l))
17:39arrdem,(doc keep_
17:39clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:39iwobut that's even less neat :)
17:39arrdem,(doc keep)
17:39clojurebot"([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects."
17:40arrdemno that's neater, it's just not gonna do what you want.
17:40iwo?
17:41iwothis would work: (keep identity (cons x l))
17:41iwoi.e. cons regardless, but use keep identity to remove x if it was nil
17:42iwowhat i'd really like is (if x (cons x l) l)
17:42iwobut in a single fn from clojure core :)
17:42technomancyiwo: useful's "fix" function might do that
17:42technomancynothing in core though
17:42amalloyiwo: (keep identity (cons x l)) doesn't do what you want at all
17:42amalloyit will remove all the nils that were already in the list
17:43sw2wolf,(doc identity)
17:43clojurebot"([x]); Returns its argument."
17:43iwoamalloy: not a problem for me, the list contains no nils
17:43arrdemamalloy: thanks, I didn't think it would behave but I wasn't sure what it _would_ do :p
17:44iwotechnomancy: do you mean flatland/useful?
17:44technomancyiwo: yeah, but amalloy would know for sure
17:44amalloyfix can kinda do it, but it's awkward: (fix l x (partial cons x)) would work most of the time, or (fix l (not (nil? x)) (partial cons x)) to be careful
17:45amalloyi don't think i'd use fix for this
17:45technomancyyeah, it's an awkward request =)
17:45amalloy(concat (keep identity [x]) l)?
17:45amalloybut that's much harder than the simple (if x (cons x l) l)
17:46amalloyi think test-> in 1.5 does a decent job of it, doesn't it?
17:47amalloy(test-> l x (->> (cons x))) probably works
17:47amalloy,(doc test->)
17:47clojurebotGabh mo leithscéal?
17:53iwoi guess clojurebot doesn't speak 1.5
17:54iwo(if x (cons x l) l) it is :)
17:57mthvedtis there a way to make a private defrecord, say Foo, and not have it expose ->Foo
17:58gfredericksmthvedt: you could muck with the var if you really wanted to
17:59amalloymthvedt: this sounds like a great opportunity to use a hashmap instead of a record
17:59gfrederickshaha
17:59gfredericksamalloy the hashmap salesman
18:00amalloymy hashmaps provide genuine, FDA-certified constant-time lookup time, won't you try one?
18:01gfrederickswould "unused arguments" be a good kibit rule?
18:01gdevamalloy:) are they organic?
18:01arrdemamalloy: but can you optimize them out to structs at runtime?
18:01amalloyi was aiming more for the 1950s "door-to-door salesman" archetype, not the 2000s-era organic stuff
18:01tcrayfordamalloy: I only use grass-fed, home grown vegan kosher paeleo primal hashmaps, you got any of those?
18:02mthvedtamalloy: can your hash maps implement protocols? :P
18:02gdevtcrayford:) lol at vegan paeleo
18:02amalloyuse multimethods! technomancy is probably willing to put on an evangelism act to match my salesmanship, telling you how protocols are the devil
18:03tcrayfordtrue story, I know a dude who's on something like that. Asking him "what he eats" leads to a pretty short list
18:03technomancybe free of their tyranny
18:03PudgePacketHi, I'm having some trivial problems importing jara .jars for a clojure project. I'm not sure where to keep the .jar, and how the import should refer to it, I'm used to C++ style of using a filename!
18:03mthvedtthey are not my protocols
18:03amalloytechnomancy: i'm afraid to google "jack chick tract"
18:03tcrayfordtechnomancy: I use a protocol for this core abstraction (of data storage) in my app. Please be mad
18:03Glenjaminamalloy: i can't seem to find test->, did you mean cond-> ?
18:03technomancytcrayford: there is still hope for you
18:03amalloy~repeatability
18:03clojurebotrepeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability
18:03tcrayfordhow do I teach clojurebot shit?
18:03tcrayford~amalloy
18:04clojurebotamalloy is the spotlight illuminating my dumb mistakes
18:04arrdemloooool
18:04amalloyGlenjamin: i probably do. i didn't pay attention to the renaming thing
18:04gdev~nDuff
18:04clojurebotPlease don't use pastebin.com: there are lots of annoying animated ads. Instead, try http://refheap.com, an ad-free pastebin written in Clojure.
18:04arrdemPudgePacket: amalloy is telling you to import your jars to maven and then make them lein deps
18:04arrdemPudgePacket: as of lein 2 lein no longer supports local non-maven jars
18:05Glenjamin,(doc cond->)
18:05clojurebot"([expr & clauses]); Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression is true. Note that, unlike cond branching, cond-> threading does not short circuit after the first true test expression."
18:05PudgePacketarrdem, can i just use maven commands in lein? I only have leiningen
18:05arrdemclojurebot: remember arrdem is about 85% corect
18:05clojurebot'Sea, mhuise.
18:05tcrayfordtechnomancy: also this app has a "util" namespace where I rewrote "keys" and "values" to be sane, also wrote get so it throws an exception if the key isn't there. Be more mad.
18:05technomancytcrayford: non-nilling get is great
18:05arrdemPudgePacket: don't think so. you'll need maven to manipulate ~/.m2 in any reasonable way.
18:05technomancybut "util" is sad times
18:06tcrayfordtechnomancy: I should just open up clojure.core right?
18:06technomancytotes
18:06djwonkI am using `bz2-reader` from http://www.paullegato.com/blog/reading-bzip2-files-clojure/ but I'm having a problem with it: https://gist.github.com/bluemont/8e8b717a732446fc9a8e#file-core-clj-L61
18:06tcrayfordrealtalk, I wish nil didn't exist. Clojure doesn't technically need it except for interop
18:07Glenjaminwhat is a good way to deal with "util" aka random bucket of functions i wish were in core?
18:07Glenjaminalso, what's so bad about Protocols?
18:08arrdemit's clojurebot: forget <phrase>, right?
18:09tcrayfordclojurebot: forget forget
18:09clojurebotIt's greek to me.
18:12PudgePacketarrdem, I've downloaded and got maven working, do i just perform a similar task to running a lein operation ? navigate to project directory then run the command?
18:15arrdemPudgePacket: http://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/
18:19PudgePacketarrdem, it says there is no project object model in the directory, im running from the project directory, do i need to create a POM somehow?
18:20Glenjaminxeqi: am i missing something, or does kerodon not handle select elements?
18:20SegFaultAXPudgePacket: Probably a good idea to read a tutorial on Maven.
18:21PudgePacketSegFaultAx, i'm just trying to use a local .jar file in my clojure code, this seems a pretty ridiculous amount of fiddling to get something so trivial working :/
18:24technomancytcrayford: "except for interop" is kind of a really big thing though =(
18:24technomancybut I would love a nil-free clojure
18:25tcrayfordofc ;). In a modern dynamically typed lang, with Maybe supplied by the lang, there's no need for nil (in my book)
18:26Glenjaminis Maybe actually an improvement over nil?
18:27Glenjamindoesn't it just move the nil along to some point where you need a value?
18:29tcrayfordit's different
18:29tcrayfordMaybe as a return type says "this quite possibly will return nothing"
18:29tcrayfordusually you have to dig in non-existent docs or read the code to find out if something can return nil
18:30mthvedtwhat's the point of maybe without type checking and/or pattern matching
18:30Glenjamin^^ this
18:30tcrayfordif you look at a function, and what you get out of it is a nil, then you know you have to handle the nil case
18:31tcrayfordwheras if you look at a function, often you don't know if there is a nil case, then fail to handle it, then your program blows up in weird and wonderful ways
18:31technomancyit just forces awareness, right?
18:31tcrayfordwithout pattern matching/monads/type checking, yeah
18:31mthvedtso, the point of maybe is to replace java annotations
18:31mthvedtgot it
18:33Glenjaminbut where do you write the Maybe return type in a dynamic language?
18:34technomancydocstring
18:34technomancythe point is, you can't not handle maybe
18:34tcrayfordalso, you'd see it when you called the function at the repl
18:35Glenjaminright, you have to unpack it
18:35Glenjamini see
18:35technomancylike a reference type
18:37SegFaultAX"The point of maybe is to replace Java annotations" wut.
18:38hiredmanif you fail to handle nil you aren't using mapcat enough
18:41mthvedtsegfaultax: sarcasm
18:41amalloy(def easy-version-of-technomancy's-annoying-Maybe-fn (comp fromJust technomancy's-annoying-Maybe-fn)) ;; now i don't have to handle maybe anymore!
18:42Anderkentamalloy: fromJust throws on Nothing, surely
18:42Anderkentit wouldnt return nil
18:43amalloyAnderkent: of course, that's the joke. you're back to exceptions, just like you wanted
18:43amalloynot you specifically, of course
18:45Glenjaminxeqi: going to see if i can get dropdown support into kerodon, the enlive stuff is a bit black-magicky to me though - will send a PR if i get something reasonable
18:46technomancyI imagine haskell users look upon nil with the same disdain exception users look upon languages that use numeric error codes as return values
18:47AnderkentSounds reasonable to me - I think nils are the source of more than half of the bugs i introduce
18:48AnderkentOh, you forgot to initialize your map values to sets? Here, let me give you a nil so that you can conj onto it and break the code mysteriously 20 calls later :)
18:49Glenjaminisn't that basically what happens if you use Maybe with do notation in haskell?
18:50Glenjaminthe Monad composition just shuffles the Nothing along?
18:50Anderkentsure, but that's not what my problem is
18:50Anderkentthe problem is that conj eats the nil happily
18:50Anderkentand gives you back a list :)
18:50SegFaultAXGlenjamin: That's the whole /point/ of Maybe.
18:50SegFaultAXAnderkent: nil is the empty list.
18:51Glenjaminis there a conj-set ?
18:51SegFaultAXconj-set?
18:51AnderkentI know, that's why this problem exists? If conj threw up on nil, I'd get errors at the failure point. But it doesn't, so I only get errors in some random other place that expects a set but sees a list
18:51Glenjamina conj that always gives you a set :p
18:52SegFaultAXAnderkent: conj is fine. You should be correctly checking for errors in your data.
18:53AnderkentI should have a map type that throws on non-existing keys, instead of silently pretending there was a nil in it
18:54Glenjaminor better yet, a map type that gives you empty sets on new keys
18:54Anderkentwell not quite, because it's rare you'd want an empty set for every key
18:54Anderkentit's like
18:54Glenjaminin this case
18:55Glenjaminsomething like python's defaultdict, unsure if that fits the clojure model really
18:55dnolenAnd even tho the MLs got rid of null, ya still got the empty list to produce show stopping runtime errors - http://stackoverflow.com/questions/4883169/why-im-getting-exception-prelude-head-empty-list
18:55Anderkentyou have some state, you store it as (def my-state (ref {:id-ste #{} :some-other-map {}})) and then somewhere else you have (update-in my-state [:id-set] conj new-id)
18:56dnolenc'est la vie
18:56Anderkentlike what kind of idiom would prevent this from blowing up?
18:56Anderkentnever conj in update-in?
18:57SegFaultAXAnderkent: Is it exceptional for the key to not be present?
18:57hiredman,(doc fnil)
18:57clojurebot"([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."
18:57brehautdnolen: something something dependant types and total functions something *handwaves* solves that problem just fine
18:58AnderkentSegFaultAX: yes, the key is only not present because of the typo in original declaration
18:58dnolenbrehaut: ;)
18:58Glenjaminoh, i see
18:59Glenjaminif all you're worried about is typos, you're probably ok
19:00AnderkentI don't think "don't make typos" is a solution
19:01Glenjaminwrite some tests to express behaviour, you'll catch them soon enough
19:01Glenjaminor take a typing class, i don't class typos as one of the major problems in software development
19:08AnderkentThat was uncalled for. Whatever, I'm probably more likely to use something like (defn sget [map key] (when-not (contains? map key) (throw ...)) (map key)). I can imagine at least 2 ways in which even full test coverage wouldn't catch a similar update-in conj issue, but since it seems you never make mistakes I won't bother
19:10SegFaultAXGlenjamin: Humans are prone to typing errors. Some non-trivial percentage of programs are types by humans. Therefore some non-trivial percentage of programs are prone to typing errors. To categorically exclude typing errors as a source of bugs in software is utterly short-sighted.
19:10Glenjaminsorry, that came across as snarky, wasn't intended that way
19:11Glenjaminif you're concerned that typos will be a major source of bugs, then you probably want a statically typed language?
19:11SegFaultAXGlenjamin: Humans are the source of bugs.
19:12Glenjaminwhich is why we write automated tests, and abstractions :)
19:12SegFaultAXGlenjamin: Automated tests can only capture at most a certain subset of all possible errors. Likewise with static typing. There is no silver bullet.
19:13Glenjaminagreed
19:14Glenjamini'm not claming i never make typos or introduce bugs
19:14Glenjamini'm claiming that I don't introduce enough bugs from typos to change my entire approach to development to attempt to avoid them
19:15Glenjamini feel like my tone isn't transferring very well though :(
19:17brehautactually, you dont need static typing to catch typoes; clojure eliminates a large number of typo causing errors by requiring all symbols to be defined before they are reference lexically
19:17SegFaultAXOr at least declared.
19:17brehautobviously whenever strings and keywords etc enter the mix, you reintroduce the potential for that type of typo
19:18brehautyeah sorry
19:18SegFaultAXAs is the case in lots of languages that have forward decls.
19:18SegFaultAX(Dynamic or otherwise)
19:18brehaut(yup
19:19tieTYT2is there a function/library that takes a POJO and converts it into a clojure data structure?
19:19SegFaultAXOn a related tangent, I've never really understood the justification for variable hoisting in JS.
19:19brehaut(clojure,set/subset? static-types static-analysis)
19:19SegFaultAXtieTYT2: Records are POJOs
19:19tcrayforddnolen: re the head of an empty list case, that's been a long complain of mine for haskell. Head should return a Maybe.
19:20brehautalso the bean function
19:20tieTYT2SegFaultAX: my java pojo already exists. Is that an issue?
19:20tieTYT2ooh bean function
19:20SegFaultAXtieTYT2: Oh then you'll probably have to write a converter for it.
19:20SegFaultAXpojo->map or something.
19:20tieTYT2SegFaultAX: well it looks like bean would work?
19:20brehauttieTYT: it creates a proxy thoguh, not a persistent structure
19:20tieTYT2am I wrong?
19:20tieTYT2aw
19:21tieTYT2it says it's read-only
19:22SegFaultAXPlus the bean function is probably a lot more expensive than it's worth if you're converting a lot of these objects.
19:23SegFaultAXI don't really know anything about how HotSpot may or may not optimize lots of reflective calls.
19:23tieTYT2k, i'll write my own converter
19:25tieTYT2here's what I'm trying to do. I've got a list of this POJO. For shitty reasons, its equals() impl is worthless. I need to find instances in the list that are the same based off of specific fields and only keep the instance with the earliest date. Then I need to take the ones that are the same based on a DIFFERENT set of fields, copy the data (except for a primary key field) over to the
19:25tieTYT2instance with a primary key... etc.
19:26tieTYT2to me this sounds like a functional problem and it'd be easier to do in clojure. This is a javaee app and the class is an entity
19:27Glenjaminyou might be as well just breaking into small functions for each step like you would in clojure, but staying on the java side
19:28tieTYT2Glenjamin: it's really hard to do that without a useful equals(). The collections have to be mutated along the way
19:28tieTYT2and it's hard to figure out what's going on
19:28Glenjaminare the fields public?
19:28tieTYT2no, but you can get them through getters
19:28hiredman(->> objs (group-by identity-function) vals (map (partial sort-by date-of)) (map first) (group-by second identity) vals (map (partial apply merger)))
19:28hiredmanthat should be second-identity
19:29Glenjaminjust have your service class define it's own domain specific equals() function
19:29tieTYT2hiredman: yeah that's a shitload of code in java IMO
19:29hiredmanand there is no need to make maps
19:30Glenjaminthat certainly looks better than my idea :)
19:30tieTYT2hiredman: are you advocating what Glenjamin's suggesting with your comment?
19:31hiredmanI dunno, I have Glenjamin on ignore
19:31Glenjamin:(
19:31tieTYT2sounds like a no
19:34tieTYT2hiredman: why'd you mention the maps thing?
19:34tieTYT2did you mean no need for a converter?
19:35hiredmanyes
19:35tieTYT2ah, cool
19:35tieTYT2i'll try it out, thanks
19:37Glenjamini take it all back, i just got a mysterious null pointer error from deep in the stack :(
19:40amalloycheck for typos
19:41Glenjaminheh, forgot to save a file :(
19:42RaynesI read "heh, forgot to save a life :("
19:43tieTYT2is this out of date? The second one looks like what I want to do
19:43tieTYT2http://stackoverflow.com/questions/2181774/calling-clojure-from-java
19:43tieTYT2it says: No need to call RT.init() anymore
19:43tieTYT2but it only works if I do
19:44djwonkMy bzip2 problem was that I needed to use the second constructor form. Groan: http://www.paullegato.com/blog/reading-bzip2-files-clojure/
19:44djwonkWho knew that bzip2 files could be concatenated anyways?
19:45tieTYT2gives me this: java.lang.ExceptionInInitializerError at clojure.lang.Compiler.<clinit>(Compiler.java:47)
19:45djwonkMaking the default be false, which breaks stuff when you don't expect it, is crazytown.
20:22gdev,(#(* %)#_(if youre happy and you know it print a one)(*))
20:22clojurebot1
20:22ToxicFrogMY BRAIN
20:22gdevyour braine on drugs
20:24tomojholy crap, pst takes a depth
20:26tomojnow I can stop lein-swanking instead of jacking-in just to be able to see .printStackTrace