#clojure logs

2015-05-20

00:19credulousHello. I am trying to learn emacs and clojure at the same time. This may not be wise. Questions are emerging.
00:21credulousOne question I currently have: how do people conveniently run a web server within emacs? I have been running lein ring server from within an emacs terminal, but startup times are long.
00:21credulousIs there a constantly running server, maybe within nRepl, that can reload code on the fly?
00:29ballpointcarrotcredulous: have you looked into http-kit? It seems to have a hot reload: http://www.http-kit.org/migration.html#reload
00:30ballpointcarrotor, just do a search for ring.middleware.reload; it may help instead of killing/restarting ring
00:32credulousthanks, ballpointcarrot I'll look into that now
02:56[mad]hi
03:31tdammersany vim-fireplace gurus here?
03:31tdammersI'd like to disable how fireplace changes what vim considers a "word"
03:31tdammersis there an easy way to do that without hacking fireplace.vim itself?
03:49oddcullytdammers: i sometimes stumble over them too (e.g. /), but i have left them alone for now, since most of the time they work
03:49oddcullytdammers: the way i'd try to do that:
03:50oddcullytdammers: add an "after" ftplugin and put your `set keyword-=<thechar?` there
03:52oddcullytdammers: it's actually `set iskeyword-=...`
03:53zotin cider, if I have a stacktrace that points to query.cljc, and I have 2 files (in different subtrees/namespaces) named query.cljc, it often goes to the wrong file when I press enter. any clues on how to give it enough information to go to the right file?
03:58oddcullytdammers: works. put `set iskeyword-=/` in your `~/.vim/after/ftplugin/clojure.vim`
04:03tdammersah cool
04:03tdammerswill try
04:04tdammersbtw, the reason I don't want to treat / as a kw char is because it makes no sense in file paths and such
04:04tdammersand ofc consistent behavior across all the languages I use
04:11tdammersoddcully: the -=/ thing works, thanks
04:11oddcullyyw
04:13tdammerswhile we're discussing fireplace, I noticed that :Require(!) does not reliably show compilation errors
04:13tdammersit says that it reloads, and everything seems to be working, and then when I restart the entire thing, it fails to compile because there's a syntax error somewhere
04:20wagjoI have stateless cloud instances and I'm looking for some approach to pass configuration to them upon start. Any best practices for that? Was thinking about storing it in s3 object, or using zookeeper but the latter may be an overkill
04:21tdammersI wonder if that's a problem with fireplace or with nrepl
04:55okalNot sure if this is the right place to do this, but is it possible to use inline dependencies, so as to have auto reloading in leiningen when you change a file in a 3rd party lib?
04:55okals/to do/to ask/g
04:59SeyleriusIs there a parallel equivalent to mapv?
05:00kaiyinIs there any performance penalty in using https://github.com/Prismatic/schema ?
05:01slipsetSeylerius: don't quite know, but https://www.youtube.com/watch?v=BzKjIk0vgzE is a nice video on the subject
05:01Seyleriusslipset: Thanks.
05:02slipsetSeylerius, you're basically looking at mapv because of side-effects, right?
05:03Seyleriusslipset: I'm looking at mapv because get/assoc prefer vectors.
05:03slipsetah, ok.
05:04slipsetI've generally used mapv because I'm to lazy to figure out how doseq works
05:04pastafariSeylerius: what about (comp vec pmap)
05:49justin_smith~pmap
05:49clojurebotpmap is not what you want
05:50hyPiRionhah
05:50hyPiRionclaypoole is probably more like what you want
06:36justin_smithgfredericks: this seems up your alley https://plus.google.com/101584889282878921052/posts/Fni6x2TTeaS
07:06donbonifaciomy app on heroku keeps taking more than 60s to boot and heroku kills it. I have it precompiled. Is there anything I can do to speed things up?
07:06donbonifaciobtw my feeling is that the newrelic agent takes the majority of time
07:07Empperihow about doing stuff lazily after starting your app?
07:07donbonifacioit timeouts _before_ getting to main
07:07Empperiok, you have something seriously funky going on there
07:08donbonifacioyes, newrelic agent
07:09Empperianyway, if it dies before getting to main then most likely your library stuff is doing a lot of work in static constructors in java
07:10Empperiyou could load those classes lazily within your -main
07:10Empperiso instead of requiring/importing stuff at the ns level do that explicitly inside -main
07:10Empperiand only when it is absolutely necessary
07:11donbonifaciokay, I'll investigate, thanks :)
07:13Empperihope that helps
08:08kaiyincore.typed has not effect at run time, right?
08:08kaiyins/not/no
08:33ambrosebskaiyin: as of today you can hook it into the compilation process, if that's what you mean
08:34ambrosebskaiyin: there's no type based optimisations yet
08:35kaiyinambrosebs: so after an annotated func is compiled, it will still report type error when it occurs?
08:36ambrosebskaiyin: if the current namespace is "typed", yes
08:37ambrosebstry it out here https://github.com/typedclojure/typed-repl
08:43kaiyinambrosebs: I got stackoverflow error when loading this into repl: https://gist.github.com/kindlychung/2d73bbc2f46ff713535e
08:44kaiyinambrosebs: version 0.2.92
08:45ambrosebsdon't add a self-recursive check-ns in a namespace
08:45gfredericksjustin_smith: the way the numbers grow reminds me of goodstein numbers, which start 2,4,6,(3*2^402653211-2), ...
08:46ambrosebseither do it at the REPL or add ^:core.typed metadata to the namespace with the project.clj nrepl middleware described in that project
08:49kaiyinambrosebs: doing it in repl gives CompilerException java.lang.RuntimeException: No such namespace: -t
08:51kaiyinambrosebs: I have to leave for something else, will continue this later, thanks a lot!
08:52ambrosebskaiyin: thanks for the report though, that's a regression.
08:52ambrosebsshould be a better error
09:01mrb_bkAnyone got recommendations for a good read on packaging/deploying simple Clojure web apps? I have a little 3 route ring JSON API that I want to launch as an executable
09:04vijaykiranmrb_bk: generating an uberjar and using a small script to java -jar uberjar.jar should work
09:20justin_smithfor extra credit, you can use jsvc by making it implement the daemontools interface
09:20justin_smith(this has uberjar as a pre-requisite)
09:25entityhello, I'm thinking about developing a genetic algo. in Clojure and I need some kind of a fast data structure to hold the genetic information, which would look something like (up down right right ...); i.e. listing actions to take in certain situations
09:26entityno sure if that makes much sense
09:26entitynot*
09:32mrb_bkThis looks reasonable https://devcenter.heroku.com/articles/clojure-web-application#putting-it-all-together
09:56entityhow do you make a copy of a string?
09:56entitydoes str make a copy?
09:58socksystrings are immutable
09:58patrickgombertentity: strings are immutable so it wouldn't necesarrily matter if it made a copy or not
09:59socksy(they are just java strings)
09:59entityah, I dodn't know they were immutable, assumed they're mutable since they're java strings
10:00socksyjava strings are immutable :)
10:00entityjava.lang.String is immutable?
10:00socksyyes
10:01entityah, all the methods return new copies
10:01entityright, thanks
10:01wasamasathey are in all the sane languages
10:01socksywasamasa: that's not fair, you could say that about nearly every data structure ;)
10:01wasamasaruby and C and elisp are therefore out :>
10:03wasamasasocksy: my point is that strings being mutable is the exception
10:03entityso suppose I wanted to kinda merge two strings together, taking a random character from each string... so (merge "abcd" "xyzw") could return "xbzw"
10:03entityis there a fast way to do this, not making a new string object at each character?
10:05entityor would it be more efficient to have the strings represented as lists/vectors of character in this case
10:08socksyI'd do vectors of chars personally
10:09entitylooks like it will be easier to do that
10:09socksyactually, I wouldn't care about performance at all until it was slow enough to warrant rewriting it, so I'd probably do any old collection with single char strings
10:10socksyonce you have the map logic hashed out, then look into optimisations, perhaps
10:10wasamasahum, in clojure (seq "foobar") gives you (\f \o \o \b \a \r), but in clojurescript it's ("f" "o" "o" "b" "a" "r")
10:10entitysocksy: thanks for the tips, I'll go with vectors for now
10:14mgaare_anyone have any luck getting clojure.tools.namespace.repl and cljx to play nice?
10:16patrickgombertwasamasa: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#the-reader
10:16patrickgombertthere are no character literals in javascript
10:19wasamasait totally makes sense, I've just learned that using seq on a string gives me something else than substrings and was surprised about clojurescript behaving differently
10:20CookedGryphonHi, I'm loading a runtime dependency with pomegranate. How can I call a contained static method?
10:20CookedGryphonif it was a clojure function, I'd use resolve and the quoted form
10:21CookedGryphonbut I get a NPE doing that with a static java method
10:31mrb_bkAnyone got recommendations for simple signal handling?
10:32mrb_bkNeed to handle TERM and INT with a ring server
10:32gfredericksmrb_bk: like handling unix signals from the jvm?
10:33mrb_bkgfredericks: Oh hi! Yes
10:33gfredericksI have some stuff somewhere that casually did this
10:33mrb_bkgfredericks: dope, casual is fine
10:33gfredericksplease coat this code in disclaimers
10:34gfrederickshttps://github.com/clojure/test.check/blob/gfredericks/prng-comparison/src/dev/clojure/clojure/test/check/prng_comparison.clj#L6-12
10:35mrb_bksun.misc
10:35mrb_bkIs so dope
10:35mrb_bkgfredericks: thanks
10:35gfredericksmrb_bk: np
10:35mrb_bkhttps://github.com/hyPiRion/beckon looks somewhat reasonable
10:38gfredericksyeah I bet so
10:43entityI'm trying to use fireplace with vim... I can see fireplace in :scriptnames, but commands like :Connect or :cpp fail, saying they're not an editor command
10:44entityalthough things like 'K' seem to work
10:45entityweird, maybe I jsut can't use it :P
10:45entityoh, it's not :cpp it's cpp
10:45kaiyinhi, ambrosebs. i am back.
10:45entitynevermind then
10:45kaiyinSo what's the better version of that error msg?
11:13entityhow can I dynamically create a vector of length n?
11:14entitythe docs for assoc are confusing
11:14Bronsaentity: start with an empty vector and just keep adding elements to it
11:14entityBronsa: using assoc?
11:14Bronsa,(conj [] 1)
11:14clojurebot[1]
11:14entityah, thanks
11:15kaiyinambrosebs: I have created a bug report on jira.
11:16justin_smithentity: if you know the exact size vector (or the contents) ahead of time, there is vec
11:16justin_smith,(vec (repeat 10 nil))
11:16clojurebot[nil nil nil nil nil ...]
11:17Bronsajustin_smith: it makes little sense to create an "empty" vector of size n in clojure, imho
11:17Bronsajustin_smith: usually that's something you need to do in langs with mutable colls/explicit memory allocation
11:18entityawesome, I can replace 'nil' with a function, I assume?
11:18Bronsaentity: using repeatedly rather then repeat, yes
11:18entityah okay, cool
11:19Bronsa,(repeatedly 10 (constantly 3))
11:19clojurebot(3 3 3 3 3 ...)
11:35wombawombaSo running `lein deps` doesn't seem to download all my dependencies; when I run `lein ring server`, a bunch of extra dependencies are downloaded. Is there any way to get around this?
11:35justin_smithwombawomba: by using lein ring you alter your deps
11:36wombawombajustin_smith: any way I can make that alteration ahead of time?
11:36justin_smithBronsa: it looks like creating a vector all in one go has perf benefits compared to conj https://www.refheap.com/101346
11:37justin_smithwombawomba: not that I know of. I hope this isn't a concern because you want to use lein ring in production. Don't do that.
11:37justin_smithBronsa: whether those are worth it is an open question, and probably depends on context too...
11:38wombawombaI'm trying to build a docker container that has my app in it, and that runs `lein ring server-headless`
11:38justin_smithwombawomba: make an uberjar instead, and run the uberjar with java
11:38wombawomba...but running lein ring means it takes forever
11:38Bronsajustin_smith: it sure does, my point is that I don't think it's something one should need to do in clojure
11:39justin_smithBronsa: OK.
11:39sobel+1 uberjar
11:39sobelworks well.
11:39wombawombajustin_smith: I could do that, but I'm doing this for development
11:39justin_smithwombawomba: with an uberjar, your docker no longer needs to contain git, or lein
11:39justin_smithwombawomba: oh
11:39wombawombaso I don't want to have to rebuild my container every time I change the code
11:39sobeli generally can't hear any meaning in the phrase, "but this is for development"
11:39sobelcode is code
11:40justin_smithsobel: point being that he wants eg. the reloading behavior you get with lein ring, and to edit his code while the server runs.
11:40justin_smithinside a docker container
11:40wombawombaright
11:41sobeloh so the whole container is a dev instance
11:41wombawombaexactly
11:41justin_smithwombawomba: part of what lein-ring does is that it adds deps to be resolved. I'm not sure if there is a simple way to add those deps manually.
11:42justin_smithwombawomba: weavejester might be able to tell you if there's a trick for that, if he was around.
11:42wombawombahmm
11:42arohnerwombawomba: you can probably make it happen using 'lein with-profile
11:43wombawombaI guess I could try to find another way to get the autoreloading running
11:43justin_smiththere is the wrap-reload middleware
11:43arohnerwombawomba: ah, no, lein ring just adds a dep on '[ring-server/ring-server "0.4.0']. If you add that to your deps, it will probably be downloaded
11:43justin_smiththat plus some embedded ring server (jetty, aleph, http-kit)? should get you what you want
11:44justin_smitharohner: oh, it's that easy? nice.
11:44arohner+1 for reading the source :-)
11:44justin_smith(inc arohner)
11:44lazybot⇒ 1
11:44entitycan someone please take a look at this code? I can't fihure out what's going on http://pastie.org/10198865#9
11:44wombawombaarohner: neat :)
11:45justin_smithentity: defn needs a parameter vector
11:45justin_smithentity: so change it to (defn rand-dna [] ...
11:45entityahh
11:45entitythanks
11:45justin_smithalso, that fn rand-gene is a no-op
11:45justin_smithit doesn't get called or returned
11:46justin_smithso it is effectively not there
11:46entityit is called on the line below
11:46justin_smithno, it isn't
11:46justin_smithbecause there is no binding :)
11:46justin_smithit doesn't exist as far as the next line is concerned
11:46justin_smithyou need to use let or letfn
11:47entityoh, I see
11:47entitythanks again :)
12:23andyf_cfleming: Bronsa: I was reminded of Eastwood's WARNING in its documentation about how it will 'launch the missiles' if require or use on your namespaces would also do that. I am guessing that whatever static analysis Cursive does would *not* launch the missiles on similar source files? Sounds tricky to get good knowledge of what symbols mean without full eval.
12:25andyf_Lots of common cases could be handled without full eval, of course, so perhaps Cursive just handles the common cases?
12:29kaiyinwhy does this block indefinitely after msg1?
12:30gfrederickskaiyin is blocking after the first message and so cannot send the second message with the actual code in it
12:31kaiyinsorry, copy/paste stopped working suddenly. https://gist.github.com/kindlychung/3f7c7a82f9dcecc4eb18 why does this hangs indefinitely on msg1?
12:34kaiyinah, i think timeout is misused here.
12:35kaiyinhow can I make it sleep for some time in a go block?
12:37gfredericksI think that would be a misuse of go blocks
12:38gfredericksyou probably want to read a message from the timeout channel
12:38gfredericksbut I'm not the bestest with core.async so dunno
12:42kaiyinok
12:52edbondhow to access environment by environ.core/env in project.clj? I want to pass database-url to ragtime in project.clj
12:53edbondenviron page says I need to add lein-environ to :plugins. What's next?
12:54edbondhttps://www.refheap.com/101349
12:58justin_smithyou add an :env key (usually under some profile), or alternatively set an environment variable in the shell so that lein will see it
12:58justin_smithtypical is :env key for dev config, shell environment for prod
12:59justin_smithedbond: see the second block of source code here https://github.com/weavejester/environ#example-usage
13:00justin_smiththat hash-map would go under :profiles
13:00edbondjustin_smith, yes, I created profiles.clj
13:00justin_smithOK, then you are done
13:00edbondquestion is how to access it in :ragtime { :database <here> }
13:00justin_smith(env :ragtime)
13:01justin_smithin your source
13:01edbondthat's not my source, it's project.clj, see https://www.refheap.com/101349 part of project.clj
13:02justin_smithright. That sets the data. In your source you use env to access it.
13:02justin_smithbut :ragtime has to be under the :env key
13:02justin_smithlike in the example I pointed out
13:03edbondI need to access environ.core/env in project.clj, in :plugins
13:04edbondhm, wait
13:05edbondprofiles.clj will be merged in project.clj without subkey?
13:05justin_smithoh, I misunderstood, sorry
13:05edbondI mean as is?
13:06edbondor under :profiles key in project.clj?
13:06justin_smithI'd say for a tool like ragtime, it makes more sense to just have profile-specific configs, rather than using indirection via env
13:08faveteli1guiswhat am i missing here, any ideas? https://gist.github.com/favetelinguis/de0071d7b237a600f310
13:13edbondfaveteli1guis, #(0 > 1) => #(> 0 1)
13:13edbond,(> 0 1)
13:13clojurebotfalse
13:13edbond,(0 > 1)
13:13clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval49 invoke "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval49 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler eval "Compiler.java" 6792]\n [clojure.lang.Compiler eval "Compiler.java" 6755]\n [c...
13:14edbondjustin_smith, yes, I still don't get how to access env in project.clj using :plugins [lein-environ]
13:15justin_smithedbond: doing that makes no sense to me, sorry
13:15edbondor I don't understand correct "If you want to be able to draw settings from the Leiningen project map, you'll also need the following plugin"
13:16edbondhm, how the to make project.clj environment aware? (if dev [criterium "x.x"]) for example
13:17justin_smithwell this is what profiles are supposed to be for, and I really don't see what environ does that would improv it in any way
13:17justin_smithbut maybe I'm missing something here
13:22edbondjustin_smith, found in internets this thing: ~(System/getenv "artifactory_username")
13:23justin_smiththat would get it out of the environment as set by the shell
13:23justin_smithI don't see how this would help during development, and in production you shouldn't be using project.clj at all
13:24edbondwhy not? I need to run migrations using ragtime - lein ragtime migrate in production.
13:24edbondFor this I will need another database-url, most likely set in env
13:32edbondFor this I will need another database-url, most likely set in env
13:47kaiyincould anyone help with this?
13:47kaiyinhttp://stackoverflow.com/questions/30356859/upper-limit-for-number-of-jobs-in-a-do-block
13:49noncomkaiyin: puts and jobs are different
13:49noncomputs are queued on the channel
13:49noncom(afaik)
13:50kaiyinok, i see.
13:51noncomkaiyin: or, better, 1 channel allows for no more tahn 1024 putting/taking jobs
13:51noncomyou may increase the size or use the buffering window
13:52noncomalso, you may have more channels and more go-blocks
13:52noncomthe keyword is that 1024 is max on a *single* channel
13:55kaiyinnoncom: how do you use a buffering window?
13:56noncomkaiyin: http://clojure.github.io/core.async/ look at sliding-buffer and dropping-buffer
13:58noncomkaiyin: you can also pass a number of max buffer elements to a channel or buffer when creating them]
14:00kaiyinok
14:03harriganis there any way to stop seque from holding onto the head of a seq?
14:03harrigane.g. so that (let [r (seque (range 1e8))] [(first r) (last r)]) will not run out of memory
14:06cflemingnoncom: Did you receive my email? Did it help?
14:31harrigansorry, it's not holding onto head -- some other issue -- (last (seque (range 1e8))) also runs out of memory
14:38andyfcfleming: Does Cursive ever eval Clojure source code for the purposes of analyzing it (I don't mean in a REPL)
14:41sritchieanyone used a project with lein-modules on dokku or heroku?
14:41sdegutisLook. You have a function create-widget which takes [state, number] and returns [state, widget], alright? And you have a seq of numbers, so you want to create a seq of widgets. Normally you could use map, right? But look, you need to thread the returned state from one call into the next call.
14:41sritchie***ing the bed in a big way: java.io.IOException: Cannot run program "lein" (in directory "/tmp/build/queue"): error=2, No such file or directory
14:42sdegutisNa'm sa'n?
14:42sdegutisSo I thought to myself, surely this sounds like a job for some kind of monad. But I don't know Haskell, and this is Clojure.
14:42sdegutisSo how do you solve this?
14:44btobolaskiUse the threading macro inside the map?
14:45sdegutisSorry I don't mean threaded like -> or ->>
14:46sdegutisI mean, the state returned from one call to create-widget needs to be passed into the next call of create-widget as the first parameter.
14:48andyfsdegutis: reduce ?
14:48sdegutisHmm yeah maybe that will work. Seems like a weird way to map, but if it gets the job done...
14:48andyfThere's always loop, if you have to, or just prefer the way the code looks
14:49Bronsaandyf: I think cursive only does static analysis -- no eval
14:50andyfBronsa: Makes sense, if so. Sounds like a lot of work to write, with weird corner cases it won't quite do, unless I'm missing something.
14:50infinity777Disco Melee is hiring clojure developers. We are a fun team that is growing rapidly. Help us shape the future of gaming! https://docs.google.com/document/d/1GvnrSCUbYgbY9XdFs_DUx-0QZG2bIYT8Mbr0zdpTeew/edit?usp=sharing
14:51andyfI think it is the right way to go for a commercial tool. Not criticizing, just thinking about the approach and what it can do.
14:51Bronsaandyf: lot of work for sure. I believe it also requires custom rules for macros in order to do correct symbol resolution
14:54Bronsaandyf: I only partially agree -- no eval is definitely better than eval for an IDE but since it's so common to have live repls, runtime code might be available anyway. could have the best of both worlds combining static analysis with slime-like runtime introspection
14:55Bronsabut I understand cfleming is just one guy and it'd be probably impossible time-wise to do both :P
14:55andyfI'm just idly imagining what a Clojure lint tool would have to look like in order to avoid 'launching the missiles'
14:56andyfI suppose an approach like clojail might help protect you.
14:56lvhDoesn't kibit do a lot of that?
14:56lvh(It does it by parsing the code and doing pattern matching on the sexps; no evaling)
14:57Bronsaandyf: while worth it for a code editor, I don't think it'd be worth for a linter. would require too much config for the user
14:57andyfYes, but kibitz doesn't catch the kinds of potential mistakes that Eastwood does (which evals)
14:57andyfs/kibitz/kibit/
14:57lvhsure
14:57Bronsakibit is significantly less powerful than eastwood
14:57lvhit seems like there's an opportunity for limited evaluation for stuff like "is this actually a fn"
14:57lvhI don't know if that means "clojail" or "implement a handful of behaviors separately"
14:58sdegutisFigured it out.
14:58sdegutisI shouldn't have side-effect-ish functions like this that take and return state.
14:58sdegutisInstead I should be building up descriptions of side effects to run, and then committing them all at once.
14:58sdegutisBecause working with data is way easier than working with state.
14:59andyfPreach it, sdegutis.
14:59andyf(I mean that in an encouraging, not sarcastic, way)
14:59sdegutisPlus I'll be able to add another badge to my nerd sash.
14:59mlb-Not trolling, but is there a guide for Java design patterns for Clojure programmers?
15:00sobelmlb-: i can explain why that's not 1:1
15:01mlb-sobel: I'm not expecting a complete 1:1 mapping of Clojure idioms to Java GoF design patterns ;]
15:02andyfmlb-: Do you mean a book on design patterns in Java, targeted at someone who knows Clojure already, but not Java?
15:02sobelare you looking for a getting-started group?
15:02allenj12this might be a litttle too big of an example but is it possible to make this use a transducer instead of reduce? http://pastebin.com/5tgRccPN
15:03mlb-andyf: If such a thing existed, I'd be very interested.
15:04andyfSome Lisp developer, maybe Paul Graham, wrote a summary of some OO design patterns, and how many of them were unnecessary in Common Lisp
15:04mlb-sobel: "Getting-started group"? I think so?
15:04sobelmlb-: are you starting clojure?
15:05mlb-andyf: Ah, no. Other way about. I got my team hooked on Clojure, but $WORK has mandated future development should be in Java
15:05andyfThere may be a link to that article on this page: http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures
15:05atankanowmlb-: you may want to look up some of Venkat Subramaniam's java books or if you just want Java best practices read Effective Java
15:05sobeli can point you at some items to look at if you are trying to solve a specific case, otherwise... start doing stuff, ask specific questions. you will be amazed how fast just using clojure will cause you to need answers to specific questions :)
15:06sobeloh, bummer
15:06andyfReading that page will be demotivating to anyone tasked with switching from Clojure to Java, I think :)
15:08cflemingandyf Bronsa: That's right, Cursive only does static analysis of the source
15:08atankanowmlb-: Venkat has a nice Functional Pogramming in java book ... it's better than starting with lots of value objects as I learned when i started
15:08mlb-andyf: I was demotivated when I heard the underlying motivation to move from Clojure to Jave :(
15:09cflemingandyf Bronsa: It is indeed very tricky and it does also require custom rules for macros (currently only provided by me, but that will change)
15:10mlb-atankanow: Ah, thanks. I found it on Amazon
15:10atankanowmlb-: yw
15:10atankanowmlb-: what was the motivation to move to java?
15:12mlb-atankanow: Concerns over finding qualified candidates and assumptions of salary making them costly to retain.
15:12cflemingandyf Bronsa: The main limitation is the macro issue - once that's dealt with, it allows some very powerful functionality. For example, I'm currently doing type inference for Java interop, so completion etc will (hopefully) work as well as Java
15:12andyfcfleming: Thanks for the info. I am happy to be amazed at your achievements, without reimplementing them :)
15:13cflemingandyf: Hehe - it's definitely been more work than I expected!
15:15atankanowmlb-: ah ... well ... there are lots of expensive bad java devs out there too =)
15:16andyfmlb-: Might not be possible to convince your management otherwise, but I noticed that Alex Miller at Clojure/West had everyone in the room hiring Clojure developers raise their hands, and then put them down. Then everyone looking for work writing Clojure raise their hands. He commented that they should all be talking to each other :)
15:17mlb-Haha, true. Sadly, I've uncovered there's more cargo-culting here than observation of facts :(
15:18atankanowmlb-: i write java at work ... it's not a bad language ... like anything it can be corrupted
15:18sobeli really like my niche here, where i write extensions to a mostly-java code base in Clojure and call into them as needed.
15:18sobellibrary sized extensions
15:19mlb-atankanow: I fear that only works when your coworkers also have enough discipline to not do things the sloppy way
15:20atankanownice ... that is cool ... I asked Neal Ford of thoughtworks once how I can get clojure into my java-based work projects, his response was to simply use AOT compilation and put the jars out ... no one will be the wiser
15:20TEttingeralso never throw an exception
15:20mlb-my current escape hatch is to extend the existing Clojure stuff and let "new" projects be Java ;]
15:22sritchiegah, why am I still seeing this WARNING: please set :license in project.clj.
15:22sritchieerr
15:22sritchieNo credentials found for clojars
15:22sritchieI know they’re in credentials.clj;
15:23sritchieunder #”https://clojars.org/repo&quot;
15:23sritchieis there something else I need to do to alias the entry as “clojars” or something?
15:28allenj12sorry for the repeat, but does anyone have experience with transducers? http://pastebin.com/5tgRccPN
15:29atankanowgiven a map where the vals are vectors, what is the idiomatic way to sort every val in the map?
15:29atankanowthis is what i have:
15:29sritchieanyone using credentials.clj?
15:29atankanow,(map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1]})
15:29clojurebot([:a (1 2 3 4)])
15:29atankanow,(map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1] :b [\d \c \b \a})
15:29clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: }>
15:30atankanow,(map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1] :b [\d \c \b \a]})
15:30clojurebot([:a (1 2 3 4)] [:b (\a \b \c \d)])
15:31allenj12atankanow: that looks good, you could use (into [] .. ) if you want the vector back
15:31atankanowright ... the point was actually to sort the map by keys and vals, so i just put the output of that map (into (sorted-map) ...)
15:32tcrawleysritchie: I use a ~/.lein/credentials.clj.gpg, with: {#"https://clojars.org/.*&quot; {:username "foo" :password "barbell"}}
15:33tcrawleyand that works for me
15:33sritchietcrawley: looks like I had two maps in that file by accident. whoops
15:33sritchiefixed my big issue on OS X by installing GPGTools
15:33tcrawleygpg is the bestest
15:34tcrawleyglad you figured it out though
15:35TimMcmlb-: Just tell them you'll switch to writing Java but occasionally pull in Clojure "just as a library". ;-)
15:35allenj12atankanow: If your using the clojure beta you can use transducers
15:35allenj12(into {} (map (fn [[k v]] [k (sort v)])) {:a [4 3 2 1]})
15:35TEttingeratankanow:
15:35allenj12,(into {} (map (fn [[k v]] [k (sort v)])) {:a [4 3 2 1]})
15:35TEttinger(doc sorted-map-by)
15:35clojurebot"([comparator & keyvals]); keyval => key val Returns a new sorted map with supplied mappings, using the supplied comparator. If any keys are equal, they are handled as if by repeated uses of assoc."
15:35clojurebot{:a (1 2 3 4)}
15:37TEttingeratankanow, what kind of input to what kind of output do you want?
15:38sritchietcrawley: thanks!
15:38atankanowTEttinger: {:a [4 3 2 1} -> {:a [1 2 3 4]} ... yes ... i could rigth a k/v comparator and used sorted-map-by
15:38atankanowwrite
15:40allenj12atankanow: so you want it to be sorted by key aswell?
15:44TEttinger,(into (sorted-map-by (fn [[k1 v1][k2 v2]] (compare v1 v2)) (map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1] :b [\d \c \a \b]} ))
15:44clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:45TEttinger,(into (sorted-map-by (fn [[k1 v1][k2 v2]] (compare v1 v2))) (map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1] :b [\d \c \a \b]} ))
15:45clojurebot#error {\n :cause "nth not supported on this type: Keyword"\n :via\n [{:type java.lang.UnsupportedOperationException\n :message "nth not supported on this type: Keyword"\n :at [clojure.lang.RT nthFrom "RT.java" 933]}]\n :trace\n [[clojure.lang.RT nthFrom "RT.java" 933]\n [clojure.lang.RT nth "RT.java" 883]\n [sandbox$eval47$fn__50 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.AFunction compare...
15:45TEttingeraww
15:47crack_userwhy I should put a '@' in front the keyword when it refers a atom?
15:47TEttingercrack_user: @ dereferences it, it gets the current value
15:48TEttingerotherwise you are passing the wrapping atom, which can later change, not its current value
15:48crack_userTEttinger: so atom store others values beyond the current?
15:48tcrawleysritchie: my pleasure!
15:49fourqWhat kind of lists do lines 2 and 3 evaluate to? (They just look like floating keywords) https://gist.github.com/anonymous/6f3059ea59a5713f08e5#file-clj-L2-L3
15:50puredangerrepl is a macro that takes options as alternating key/value pairs
15:50puredangerI guess I don't know if it's a macro, prob a fn actually
15:50TEttinger,(let [adam (atom [])] (do (print adam) (print @adam) (swap! adam conj :eve) (print adam) (print @adam)))
15:50clojurebot#object[clojure.lang.Atom 0x2facf711 {:status :ready, :val []}][]#object[clojure.lang.Atom 0x2facf711 {:status :ready, :val [:eve]}][:eve]
15:51TEttingercrack_user, just printing adam isn't very useful, as you can probably tell :)
15:51atankanowas an Adam, I appreciate that reference ... and dereference ... thanks TEttinger!
15:51TEttingerheh
15:52fourqpuredanger ty
15:59crack_userTEttinger: thx, I get it
16:20ReefersleepHey peeps
16:20ReefersleepAnyone use Vim for Clojure development?
16:21ReefersleepI'd like to pick your brain about vim-fireplace and indentation via =G
16:21Reefersleepor = anything
16:25oddcullyReefersleep: i do and = usually leaves my brain alone
16:27ReefersleepCool oddcully
16:27ReefersleepSo you never experience anything weird when using = to indent?
16:28kaiyinHere is the hotdog machine example from Clojure for the brave and true: https://gist.github.com/kindlychung/36ffd585378c69b4895c
16:29kaiyinUsing one channel seems quite enough, what's the advantage of using two channels?
16:29ReefersleepI've experience a weird, unnecessary deep level of indentation after a line containing \[, that is, the character "["
16:29ReefersleepI think the indenting mechanism interprets it as the beginning of a vector
16:29Reefersleepor something like that
16:30oddcullyReefersleep: let me try that...
16:31ReefersleepCheers :)
16:32oddcullycheers in deed. need a beer. well could you provide some snippet via pastebin/gist/refheap/... ? my naïve attempt don't break (e.g. (str "asdf" \[ "adsf"))
16:33Reefersleeplemme whip something up
16:41Reefersleephere you go oddcully
16:41Reefersleephttp://pastebin.com/dCN5iHwx
16:41ReefersleepThat's as it appears when I do gg =G
16:42ReefersleepI've got stuff in my .vimrc of course
16:42Reefersleeplet me just try with an empty .vimrc
16:44oddcullyi pasted this, paredit added the ] and after cleaning out some whitespace the internet gods gave me, this indents quite correct for me
16:44oddcullythe (+ is under (prn
16:48Reefersleephere's with an empty .vimrc
16:48Reefersleepit actually looks fine. Well, not wrong, anyway.
16:48Reefersleephttp://pastebin.com/6t7Bxvik
16:49sorbo_I'm trying to "roll up" a vector of maps into a map of maps. Anyone done something like this? Gist here: https://gist.github.com/anonymous/05428c95465d590400be
16:50sorbo_vector of maps -> map of maps makes sense to me, but I'm not sure how to "update" fields as I zip
16:51ReefersleepI guess I gotta find the culprit in my .vimrc
16:51ReefersleepI don't use paredit
16:51Reefersleepfor some reason, the Leader key does not work in my current Vim
16:52oddcullyparedit most likely does not fix indenting
16:52Reefersleepand without it paredit doesn't work the way it's supposed to
16:52ReefersleepWell, just to say that I don't use it :)
16:54oddcullyi am the first to turn of stupid "autocomplete" stuff in any program... but paredit + i/a motions is really handy
16:54gfrederickssorbo_: you just have the id key and the one other key?
16:54sorbo_gfredericks: there are other keys, but those don't need to accumulate. they're the same from map to map.
16:55gfrederickssorbo_: okay so those would not be included in the return value?
16:56gfrederickssorbo_: I think this does what you want https://github.com/Prismatic/plumbing/blob/master/src/plumbing/core.cljx#L160-169
16:56Reefersleephm, it was not "set filetype indent on"
16:56sdegutisIs there an idiomatic Clojure pattern for this that doesn't use a custom function?
16:57sdegutisI have a list of maps, and I want to get the first one (if any) with a key matching a given value.
16:57Reefersleepoddcully, I'm sure it's neat (paredit), and I'd love to give it a go - I think I need to recompile Vim or something to fix the Leader key first, though
16:57sorbo_gfredericks: this looks promising, I'll give it a go
16:57sorbo_thanks!
16:57sdegutisOnly way I know how to do it is with (first (filter #(= value (:key %))))
16:58sdegutisHi I'm new to Clojure, please help?
16:58oddcullyReefersleep: maybe you have just configured it wrong? my leader is the default \ iirc. i have several commands on , as pseudo leader
16:58justin_smithsdegutis: lol
16:58oddcullyReefersleep: at least things like \sh for slamhound work
16:59sdegutisI mean new to writing good Clojure.
16:59sdegutisSorry for ambiguity.
16:59oddcullyReefersleep: but paredit (for me) needs no leader at all. it just works its magic with (){}[]""
16:59gfrederickssdegutis: I think that's how most people do it
16:59sdegutisgfredericks: there must be a better way
17:00sdegutisI thought I found one the other day, but I can't remember it.
17:00sdegutisI think it used juxt and set.
17:01gfredericksthere's certainly weirder ways to do it
17:01sdegutisSorry no I am looking for idiotic way.
17:01sdegutisidiomatic
17:01justin_smith(first (filter (comp #{:v} :field) [{:field :a} {:field :b} {:field :v}])) ; something like this?
17:01justin_smith,(first (filter (comp #{:v} :field) [{:field :a} {:field :b} {:field :v}]))
17:01clojurebot{:field :v}
17:02sdegutisLooks right.
17:02sdegutisHow the..
17:02justin_smithit's classier I guess, but not neccessarily better
17:02sdegutisWhy not better?
17:02gfredericksreadability
17:02sdegutisI'm trying to idiomatic my Closure code.
17:02justin_smitha simple equality check is more directly what you want, and more efficient than the set lookup I would assume
17:02sdegutisI want repeatability over readability.
17:03sdegutisAnd generalizationiability.
17:03sdegutisThis is more general solution which works for more than just maps and attributes.
17:03sdegutisFor example, the function I want to compare right now involves comp, not just a key test.
17:03sdegutisIma comp a datomic entity attribute to another lazy datomic entity relationship and get *that guys* attribute key.
17:04justin_smithI think the main thing it has going for it is it makes the reader thing "gee whiz, I bet the person who wrote that is a functional programmer"
17:04sdegutisI always thought it was better form to write more general and functional code and fewer anonymous functions.
17:04sdegutisSince anonymous functions encourage repeating the same algorithm everywhere instead of giving it a name.
17:05justin_smithI'm being a bit glib there
17:05sdegutisEven after reading the definition of glib I don't know what you mean sorry.
17:05gfredericksyou could argue that readability is a lot more important than maximizing generality
17:05ReefersleepWhatever I comment out, stuff is not right
17:05ReefersleepI can get rid of the \[ problem, but then other stuff happens
17:06sdegutis(def get-first [things finder value] (first (filter (comp #{value} finder) things)))
17:06sdegutisgfredericks: they're equally important
17:06sdegutisgfredericks: they both have a precedence of 120
17:06gfredericksokay
17:06gfredericksgood to know
17:06sdegutis(if you compile with default flags)
17:06justin_smithsdegutis: if the person is looking for false or nil, that will fail
17:07sdegutisjustin_smith: ugh dangit
17:07sdegutisthen maybe just =
17:07sdegutis(partial = value)
17:07justin_smithI would use (partial = value) yeah
17:07sdegutisGreat.
17:07sdegutisStill feels better than #(= value %)
17:07justin_smithif you had values (partial contains? (set values))
17:07sdegutisI'm sure it is better, even though I can't fully explain why.
17:08justin_smith,((partial (contains? (set [:a :b :c]))) :a)
17:08clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/contains?"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/contains?"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval49 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang....
17:08justin_smithergh
17:08justin_smith,((partial contains? (set [nil :a :b :c])) nil)
17:08clojurebottrue
17:09sdegutisjustin_smith: thanks for helping me with this i appreciate the patience
17:09sdegutisand gfredericks thank you for your persistence in helping finding a good solution
17:09gfredericksnp
17:10sdegutisattribute is too specific to objects, whats a better word for a function that can be operated on a value to turn it into another value somehow
17:10sdegutismaybe function?
17:10sdegutislike "its a function of this thing"
17:11gfrederickskey-fn is used a lot in clojure.core
17:11gfredericks,(doc min-by)
17:11clojurebotExcuse me?
17:12gfredericks&(doc min-by)
17:12lazybotjava.lang.RuntimeException: Unable to resolve var: min-by in this context
17:12gfredericks&(doc min-key)
17:12lazybot⇒ "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is least."
17:12sdegutisbut it mightnt be a key, it might be any arbitrary derivation
17:12sdegutisderivation-fn seems more apt
17:12sdegutisamirite
17:12Reefersleepoddcully: some stuff worked in paredit without the leader key
17:12gfrederickssdegutis: the min-key and max-key functions use "key" in a more abstract way
17:12gfredericksthat is similar to yours
17:12sdegutisoh
17:12sdegutisok maybe keyfn
17:12sdegutiswhy the dash tho?
17:12sdegutiskeyfn isnt ambiguous
17:13gfrederickssomepeoplelikedashes
17:13Reefersleepoddcully: it was kind of weird, though. According to the documentation, stuff that was supposed to be preceded with the leader key just worked without
17:13sdegutiskeyfn is short enough to not be difficult to visually parse
17:13gfredericksokay
17:13sdegutisso-mepe-ople-liked-ashes btw fwiw
17:13Reefersleepoddcully: and this caused a problem whenever I passed over function names from clojure core (I think), because it would try to look up the documentation (I think)
17:14Reefersleepoddcully: which caused lag. Which, you can guess, was immensely annoying. Imagine lag for every third w
17:14Reefersleephorrible.
17:15oddcullyReefersleep: brain fade... i actually use the leader there all the time for \W, \w{ and \s etc
17:16Reefersleepoddcully: Anyhow, I looked through my .vimrc with /indent and commented out any line I found, one by one, and tried to indent afterwards with each individual change.
17:16oddcullyReefersleep: but i feel the pain. i have configured plugins to my needs because they used some odd leader which cramped my style
17:16sdegutisIt workd be.
17:16sdegutisbtw
17:16Reefersleepoddcully: And I could not get sane indentation with any of the individual options left out.
17:17Reefersleepoddcully: I've read that this is a common problem with Vim :(
17:17oddcullynot with my vim it aint ^_^
17:17Reefersleepoddcully: Good for you :)
17:18oddcullyReefersleep: i run std gentoo vim 7.4.273
17:18Reefersleepoddcully: I'll figure the leader out eventually, and I'm looking forward to parediting :)
17:18Reefersleepoddcully: how do you get the version?
17:18oddcullyrun vim - it's in the middle of the screen
17:18ReefersleepVIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 22 2014 11:08:18) MacOS X (unix) version Included patches: 1-258 Compiled by buildbot@tenseven-slave.macports.org Huge version without GUI. Features included (+) or not (-):
17:19Reefersleep(from :version)
17:19oddcullythere for sure is some --version too
17:19ReefersleepHm. I thought it would be compiled by me. Maybe I've accidentally removed a symlink or something
17:20oddcullymaybe relevant plugins are: paredit, fireplace, typedclojure, slamhound, eastwood, surround, matchit
17:20oddcullyrather excessive list for a try-and-error-run :/
17:20ReefersleepOf those, I only have fireplace
17:20ReefersleepI could try commenting out pathogen infect
17:22ReefersleepNo difference without vim-fireplace
17:22oddcullyi have used all my vim foo for today. i have no clue, where i would start to look for such an indenting problem
17:22ReefersleepWell, thanks for spending it on me, oddcully :)
17:22oddcullyits hard to believe, that they broke it in those about 15 patches
17:22ReefersleepHuh?
17:23oddcullyhaha! no i actually helped one today with a oneliner on the right place
17:23ReefersleepOf whom are you talking, and what patches?
17:23oddcully258 vs 273
17:23Reefersleepaah
17:23ReefersleepHm
17:23oddcullyi assumed your "included patches" there refers to my patchlevel
17:23ReefersleepGuess so
17:24ReefersleepWell
17:24ReefersleepDo you have any idea who I could ask about this stuff?
17:24ReefersleepA forum or specific peeps?
17:25oddcullydo you have some account in the world, where you could test at least another version? if nothing else, i'd try to report a bug
17:25ReefersleepI guess I could just try a different version
17:26oddcullyi meant, if you have an account to some unix box somewhere. opening a .clj file there should give some results
17:26Reefersleepoh, no. :/
17:26ReefersleepBut I could run Linux from a USB I guess
17:26Reefersleep?
17:26ReefersleepSome Linux.
17:27oddcullyna no hastle
17:29sandbagsis it possible to redefine count for a record type?
17:30gfredericksdon't think so
17:30gfrederickskind of the point of defrecord is to be map-like in all the mappy ways. deftype is the lower-level thing that lets you make whatever alien thing you want
17:31sandbagsgfredericks: yeah, my record is essentially a list + some housekeeping info
17:31sandbagsso i wanted it to act like a list in some contexts
17:31gfredericksit's probably cleaner to just explicitly convert it when necessary
17:32sandbagsgfredericks: yeah, i was hoping to avoid having to create type specific functions for common ops
17:32sandbagsbut you could be right
17:32gfredericksmetadata can be an okay way to sneak housekeeping info along for the ride if you're passing things through code you don't control
17:32sandbagsgfredericks: i thought about that, but it didn't feel right
17:33gfredericksmaking a record have a different count is a lot less right :)
17:33sandbagsokay, i guess i give up the yak shave and get on with solving my problems
17:33sandbagsgfredericks: i'm not sure about that but i'll take your word for it
17:35gfrederickssandbags: magical data structures can confuse the hell out of people that don't know what you're doing
17:35sandbagsgfredericks: and thanks for the info
17:36sandbagsgfredericks: i do agree although i think context is important in making that judgement
17:36gfredericksI once spent hours debugging only to find out that clj-http or ring or something was using a magical case-insensitive map for http headers
17:36sandbagsi suppose i could deftype if i really care enough
17:38amalloy!lm . abyss.exit x=turn
17:38amalloyoops
17:39Reefersleepoddcully: Thanks a lot for your help :)
17:39gfredericksamalloy: seems like a weird password to me but who am I to judge
17:39gfredericksI wouldn't have guessed it so I guess it's a good one
17:40amalloy/msg nickserv identify amalloy<3gfredericks4ever
17:40oddcullyBUSTED!
17:40Reefersleepoddcully: I'm heading off. hope I'll figure it out eventually. Starting to consider checking out Emacs with Evil mode or maybe Spacemacs
17:40oddcullyReefersleep: yw, good luck, like any state ridden blob this is sometimes hard...
17:41ReefersleepAye
17:41ReefersleepThanks :)
17:41gfredericksamalloy: ha
17:53danielcomptonDoes anyone have a guide for porting clojure libraries to cljc libraries? I'm fine with writing the reader conditionals, but I'm getting stuck with how to build the ClojureScript part of it
17:57arohner_with friend, is there a way to make unauthorized requests return 40x rather than 302 to "/login"? I've found :login-failure-handler, but that only handles POST to /login, not unauthorized requests to e.g. /api/foo
17:58arohner_aha, looks like I need :unauthenticated-handler
18:01TimMcAnyone know of a lein plugin that will diff two versions of a project file? Perhaps just looking at what resolved dependencies differ between them?
18:01TimMcThinking of writing one, don't want to waste effort.
18:02justin_smithTimMc: well, you could use read + data.diff I guess
18:02kaiyin,(get (iterate inc 1) 14)
18:02clojurebotnil
18:02TimMcjustin_smith: This would be slightly more than that since I have to resolve the deps, and add a little around profiles.
18:02justin_smithkaiyin: vectors are associative, lazy-seqs are not
18:02kaiyinok
18:03justin_smithkaiyin: but nth would work
18:03justin_smith,(nth (iterate inc 1) 14)
18:03clojurebot15
18:03kaiyinah, cool.
18:03justin_smiththe difference is that get guarantees constant time
18:03kaiyini see.
18:03justin_smithbut there is no constant time way to get the nth item of a lazy-seq
18:04kaiyinsure, you might have to realize stuff.
18:05TimMcjustin_smith: What's data.diff?
18:06justin_smith,(require 'clojure.data)
18:06clojurebotnil
18:06justin_smith,(dir clojure.data)
18:06clojurebotDiff\nEqualityPartition\ndiff\ndiff-similar\nequality-partition\n
18:06justin_smith,(doc clojure.data/diff)
18:06clojurebot"([a b]); Recursively compares a and b, returning a tuple of [things-only-in-a things-only-in-b things-in-both]. Comparison rules: * For equal a and b, return [nil nil a]. * Maps are subdiffed where keys match and values differ. * Sets are never subdiffed. * All sequential things are treated as associative collections by their indexes, with results returned as vectors. * Everything else (including...
18:06TimMcMan, how long has this been around?
18:06TimMc,(-> clojure.data/diff var meta)
18:06clojurebot{:arglists ([a b]), :doc "Recursively compares a and b, returning a tuple of\n [things-only-in-a things-only-in-b things-in-both].\n Comparison rules:\n\n * For equal a and b, return [nil nil a].\n * Maps are subdiffed where keys match and values differ.\n * Sets are never subdiffed.\n * All sequential things are treated as associative collections\n by their indexes, with results returned...
18:06TimMc,(-> clojure.data/diff var meta :added)
18:06clojurebot"1.3"
18:06justin_smith,(clojure.data/diff {:a 0 :b [1 2]} {:a 0 :b [1 2 3]})
18:06clojurebot(nil {:b [nil nil 3]} {:b [1 2], :a 0})
18:06TimMcWTF, I need to go spelunking again.
18:07justin_smithheh :)
18:09justin_smithanyway, I could see data.diff being helpful in comparing two project maps
18:10justin_smitheven if it has to be after some normalization
18:11TimMcFor now my use-case is "what dependencies changed between these two git commits".
18:12TimMcI'd like to eventually have this be integrated into a build agent so that Github pull requests can be annotated with a dep diff.
18:12justin_smithget project files -> extract :dependencies -> put in sets -> set/difference ?
18:12TimMcmore or less
18:12justin_smithahh, that's a cool idea
18:12TimMcNot a huge amount of work, obviously.
18:13justin_smithit would be useful to do it with recursive dependencies
18:13TimMcexactly
18:13TimMc"Oh, clj-http updated its version of Apache HTTP client? Fascinating."
18:14m1dnight_why dont I ever have any good ideas like that! :p
18:15justin_smithor "this one dep I added has 1,000 deps of questionable quality?"
18:15oddcullyquit slacking around in irc! ;P
18:16oddcullyand print it out in a git bisect
18:16TimMcm1dnight_: Becuase you haven't had the pleasure of dependency hell recently?
18:18m1dnight_just today i was bragging about how lein is so fantastic with deps!
18:18m1dnight_is there a plugin to detect unused deps? i think i could manage that
18:18m1dnight_i had deps hell today with cabal too though (haskell)
18:19oddcullythere ya go! this is a good idea
18:20justin_smithm1dnight_: I think eastwood can find unused required namespaces
18:20justin_smiththat would maybe be a start
18:20wasamasaargh, why does C-c C-c in figwheel's repl just abort the process
18:21justin_smithwasamasa: within what interface?
18:21wasamasajustin_smith: I'm using it from the shell
18:21wasamasa"Exit: Control+C or :cljs/quit"
18:21oddcullyjustin_smith: eastwood left me in the eastern woods while trying out clara rules
18:22wasamasaI'd expect it to happen on C-d
18:22justin_smithwasamasa: C-c is kill, C-d is end-of-input
18:22oddcullyis there a way around to have import the defrecords (for their class-iness)?
18:22amalloywasamasa: i think i submitted a patch with that feature added, a long time ago
18:23amalloyto cljs, not figwheel or whatever
18:24justin_smithwasamasa: note that if you have anything typed in but have not hit return, C-d does nothing
18:24wasamasajustin_smith: of course, just like in everything else on linux
18:24justin_smithright, so why would C-c do anything different?
18:24wasamasawhere C-c aborts the current computation and C-d ends the process
18:25justin_smithaborting the current computation is not a standard behavior
18:25justin_smithand C-d is eof, and that is not always ending the process
18:25amalloyjustin_smith: a lot of repl-ish tools do that with C-c though
18:25wasamasait is, type in something in a shell prompt, hit C-c and watch the next one coming in
18:26wasamasaso, you can use a C-c C-d chord to quit pretty much any shell
18:34justin_smithhmm, I always thought of C-c as "kill the program in the foreground", but I guess that's less widespread than I thought
19:06gfredericksdoes anybody have non-trivial test.check test suites and would like to help me test the performance of the new RNG code?
21:01creeseWhat does this mean? java.lang.ClassCastException: clojure.test$test_vars$fn__7209 cannot be cast to clojure.lang.Atom
21:01justin_smithcreese: inside test-vars, an anonymous function is created. Somebody is trying to deref it
21:02justin_smithor maybe swap! on it
21:02creesethere is a swap!
21:02creese(defn stubbed-publish!
21:02creese [_ message]
21:02creese (swap! stubbed-queue conj message))
21:02creeseWhat's wrong with this?
21:02justin_smithwhat is stubbed-queue ?
21:03creeseatom set to nil
21:03creese(def stubbed-queue
21:03creese (atom nil))
21:03justin_smithif that's the case, then that isn't your issue
21:03justin_smithdo you have a stack trace to go with that error?
21:03creeseyeah
21:03justin_smithif you can share it on refheap.com or gist or something that would help
21:04justin_smithdon't paste the whole thing here though
21:04creesehttps://gist.github.com/creese/18e701ecfd36bc0c80d4
21:04creeseI would never do
21:04justin_smithso persister-test has something called init
21:04justin_smithand it calls reset! on a function
21:05justin_smiththat's the issue here
21:05creese(defn reset-queue!
21:05creese []
21:05creese (reset! stubbed-queue []))
21:06creesestubbed-queue is an atom
21:06justin_smithis that called in init?
21:06justin_smithbecause init is the one doing it
21:06creese(defn init
21:06creese []
21:06creese (reset! system {:db-spec nil :out-queue {:event nil}}))
21:06justin_smithI bet system isn't an atom
21:06justin_smithI bet it's a function
21:06creese(def system
21:06creese (atom nil))
21:06justin_smiththat's what the stack trace is saying at least
21:07justin_smithtrying adding (print (type system)) to the definition of init
21:07creesehow do you get that from the stack trace? (not doubting… just...)
21:08justin_smiththe stack trace tells you which functions were called
21:08justin_smiththe innermost at the top
21:09justin_smithso from your stack trace, line 17, we see that persister-test is called by the test setup
21:09justin_smitherr, I mean something called init inside persister-test
21:09justin_smithand that calls reset
21:09justin_smith*reset!
21:10justin_smithand the next thing, we get an fn that cannot be cast to atom
21:10justin_smithso it has to be in init that the problem is happening (or at least the symptom)
21:11creesethere must be another "system" that is taking precedence
21:11justin_smithyeah, could be a scope problem
21:11creesemain has one
21:12creesebut it's an atom there too
21:12justin_smithstack traces may be confusing, but in my experience they don't lie
21:14creesewhere do you get L17?
21:14justin_smiththe gist has line numbers
21:14TimMcjustin_smith: Or you may not have the whole thing, such as with pst.
21:14TimMcwhich drops part of the chain sometimes :-(
21:14justin_smithTimMc: fair enough, but this looks like the real deal
21:15creesejustin_smith: oh, I thought you mean L17 of the code
21:16justin_smithsorry, I should have been more explicit
21:16justin_smithline 17 in that stack trace, moving up, is the part that is running your code
21:18creeseI change the name to "system2" and it still does it.
21:21justin_smithdid you try adding the print to show the type?
21:21creeseyeah, no
21:22creesewrong file
21:22creesepersister != processor
21:23justin_smithoh, so you had an error in persister and were trying to fix it in processor
21:23creeseyeah :(
21:48gfrederickshello
22:14madanI want to try out Om for React Native application, but couldn't find any DETAILED discussions happening - just a couple of very short videos in youtube and supporting git repo. Can someone share me any good material?
22:21justin_smithmadan: have you looked at http://swannodette.github.io/todomvc/labs/architecture-examples/om/ and https://github.com/omcljs/om/wiki/Basic-Tutorial ?