2015-05-20
| 00:19 | credulous | Hello. I am trying to learn emacs and clojure at the same time. This may not be wise. Questions are emerging. |
| 00:21 | credulous | One 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:21 | credulous | Is there a constantly running server, maybe within nRepl, that can reload code on the fly? |
| 00:29 | ballpointcarrot | credulous: have you looked into http-kit? It seems to have a hot reload: http://www.http-kit.org/migration.html#reload |
| 00:30 | ballpointcarrot | or, just do a search for ring.middleware.reload; it may help instead of killing/restarting ring |
| 00:32 | credulous | thanks, ballpointcarrot I'll look into that now |
| 02:56 | [mad] | hi |
| 03:31 | tdammers | any vim-fireplace gurus here? |
| 03:31 | tdammers | I'd like to disable how fireplace changes what vim considers a "word" |
| 03:31 | tdammers | is there an easy way to do that without hacking fireplace.vim itself? |
| 03:49 | oddcully | tdammers: i sometimes stumble over them too (e.g. /), but i have left them alone for now, since most of the time they work |
| 03:49 | oddcully | tdammers: the way i'd try to do that: |
| 03:50 | oddcully | tdammers: add an "after" ftplugin and put your `set keyword-=<thechar?` there |
| 03:52 | oddcully | tdammers: it's actually `set iskeyword-=...` |
| 03:53 | zot | in 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:58 | oddcully | tdammers: works. put `set iskeyword-=/` in your `~/.vim/after/ftplugin/clojure.vim` |
| 04:03 | tdammers | ah cool |
| 04:03 | tdammers | will try |
| 04:04 | tdammers | btw, the reason I don't want to treat / as a kw char is because it makes no sense in file paths and such |
| 04:04 | tdammers | and ofc consistent behavior across all the languages I use |
| 04:11 | tdammers | oddcully: the -=/ thing works, thanks |
| 04:11 | oddcully | yw |
| 04:13 | tdammers | while we're discussing fireplace, I noticed that :Require(!) does not reliably show compilation errors |
| 04:13 | tdammers | it 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:20 | wagjo | I 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:21 | tdammers | I wonder if that's a problem with fireplace or with nrepl |
| 04:55 | okal | Not 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:55 | okal | s/to do/to ask/g |
| 04:59 | Seylerius | Is there a parallel equivalent to mapv? |
| 05:00 | kaiyin | Is there any performance penalty in using https://github.com/Prismatic/schema ? |
| 05:01 | slipset | Seylerius: don't quite know, but https://www.youtube.com/watch?v=BzKjIk0vgzE is a nice video on the subject |
| 05:01 | Seylerius | slipset: Thanks. |
| 05:02 | slipset | Seylerius, you're basically looking at mapv because of side-effects, right? |
| 05:03 | Seylerius | slipset: I'm looking at mapv because get/assoc prefer vectors. |
| 05:03 | slipset | ah, ok. |
| 05:04 | slipset | I've generally used mapv because I'm to lazy to figure out how doseq works |
| 05:04 | pastafari | Seylerius: what about (comp vec pmap) |
| 05:49 | justin_smith | ~pmap |
| 05:49 | clojurebot | pmap is not what you want |
| 05:50 | hyPiRion | hah |
| 05:50 | hyPiRion | claypoole is probably more like what you want |
| 06:36 | justin_smith | gfredericks: this seems up your alley https://plus.google.com/101584889282878921052/posts/Fni6x2TTeaS |
| 07:06 | donbonifacio | my 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:06 | donbonifacio | btw my feeling is that the newrelic agent takes the majority of time |
| 07:07 | Empperi | how about doing stuff lazily after starting your app? |
| 07:07 | donbonifacio | it timeouts _before_ getting to main |
| 07:07 | Empperi | ok, you have something seriously funky going on there |
| 07:08 | donbonifacio | yes, newrelic agent |
| 07:09 | Empperi | anyway, 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:10 | Empperi | you could load those classes lazily within your -main |
| 07:10 | Empperi | so instead of requiring/importing stuff at the ns level do that explicitly inside -main |
| 07:10 | Empperi | and only when it is absolutely necessary |
| 07:11 | donbonifacio | kay, I'll investigate, thanks :) |
| 07:13 | Empperi | hope that helps |
| 08:08 | kaiyin | core.typed has not effect at run time, right? |
| 08:08 | kaiyin | s/not/no |
| 08:33 | ambrosebs | kaiyin: as of today you can hook it into the compilation process, if that's what you mean |
| 08:34 | ambrosebs | kaiyin: there's no type based optimisations yet |
| 08:35 | kaiyin | ambrosebs: so after an annotated func is compiled, it will still report type error when it occurs? |
| 08:36 | ambrosebs | kaiyin: if the current namespace is "typed", yes |
| 08:37 | ambrosebs | try it out here https://github.com/typedclojure/typed-repl |
| 08:43 | kaiyin | ambrosebs: I got stackoverflow error when loading this into repl: https://gist.github.com/kindlychung/2d73bbc2f46ff713535e |
| 08:44 | kaiyin | ambrosebs: version 0.2.92 |
| 08:45 | ambrosebs | don't add a self-recursive check-ns in a namespace |
| 08:45 | gfredericks | justin_smith: the way the numbers grow reminds me of goodstein numbers, which start 2,4,6,(3*2^402653211-2), ... |
| 08:46 | ambrosebs | either do it at the REPL or add ^:core.typed metadata to the namespace with the project.clj nrepl middleware described in that project |
| 08:49 | kaiyin | ambrosebs: doing it in repl gives CompilerException java.lang.RuntimeException: No such namespace: -t |
| 08:51 | kaiyin | ambrosebs: I have to leave for something else, will continue this later, thanks a lot! |
| 08:52 | ambrosebs | kaiyin: thanks for the report though, that's a regression. |
| 08:52 | ambrosebs | should be a better error |
| 09:01 | mrb_bk | Anyone 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:04 | vijaykiran | mrb_bk: generating an uberjar and using a small script to java -jar uberjar.jar should work |
| 09:20 | justin_smith | for extra credit, you can use jsvc by making it implement the daemontools interface |
| 09:20 | justin_smith | (this has uberjar as a pre-requisite) |
| 09:25 | entity | hello, 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:26 | entity | no sure if that makes much sense |
| 09:26 | entity | not* |
| 09:32 | mrb_bk | This looks reasonable https://devcenter.heroku.com/articles/clojure-web-application#putting-it-all-together |
| 09:56 | entity | how do you make a copy of a string? |
| 09:56 | entity | does str make a copy? |
| 09:58 | socksy | strings are immutable |
| 09:58 | patrickgombert | entity: strings are immutable so it wouldn't necesarrily matter if it made a copy or not |
| 09:59 | socksy | (they are just java strings) |
| 09:59 | entity | ah, I dodn't know they were immutable, assumed they're mutable since they're java strings |
| 10:00 | socksy | java strings are immutable :) |
| 10:00 | entity | java.lang.String is immutable? |
| 10:00 | socksy | yes |
| 10:01 | entity | ah, all the methods return new copies |
| 10:01 | entity | right, thanks |
| 10:01 | wasamasa | they are in all the sane languages |
| 10:01 | socksy | wasamasa: that's not fair, you could say that about nearly every data structure ;) |
| 10:01 | wasamasa | ruby and C and elisp are therefore out :> |
| 10:03 | wasamasa | socksy: my point is that strings being mutable is the exception |
| 10:03 | entity | so suppose I wanted to kinda merge two strings together, taking a random character from each string... so (merge "abcd" "xyzw") could return "xbzw" |
| 10:03 | entity | is there a fast way to do this, not making a new string object at each character? |
| 10:05 | entity | or would it be more efficient to have the strings represented as lists/vectors of character in this case |
| 10:08 | socksy | I'd do vectors of chars personally |
| 10:09 | entity | looks like it will be easier to do that |
| 10:09 | socksy | actually, 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:10 | socksy | once you have the map logic hashed out, then look into optimisations, perhaps |
| 10:10 | wasamasa | hum, in clojure (seq "foobar") gives you (\f \o \o \b \a \r), but in clojurescript it's ("f" "o" "o" "b" "a" "r") |
| 10:10 | entity | socksy: thanks for the tips, I'll go with vectors for now |
| 10:14 | mgaare_ | anyone have any luck getting clojure.tools.namespace.repl and cljx to play nice? |
| 10:16 | patrickgombert | wasamasa: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#the-reader |
| 10:16 | patrickgombert | there are no character literals in javascript |
| 10:19 | wasamasa | it 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:20 | CookedGryphon | Hi, I'm loading a runtime dependency with pomegranate. How can I call a contained static method? |
| 10:20 | CookedGryphon | if it was a clojure function, I'd use resolve and the quoted form |
| 10:21 | CookedGryphon | but I get a NPE doing that with a static java method |
| 10:31 | mrb_bk | Anyone got recommendations for simple signal handling? |
| 10:32 | mrb_bk | Need to handle TERM and INT with a ring server |
| 10:32 | gfredericks | mrb_bk: like handling unix signals from the jvm? |
| 10:33 | mrb_bk | gfredericks: Oh hi! Yes |
| 10:33 | gfredericks | I have some stuff somewhere that casually did this |
| 10:33 | mrb_bk | gfredericks: dope, casual is fine |
| 10:33 | gfredericks | please coat this code in disclaimers |
| 10:34 | gfredericks | https://github.com/clojure/test.check/blob/gfredericks/prng-comparison/src/dev/clojure/clojure/test/check/prng_comparison.clj#L6-12 |
| 10:35 | mrb_bk | sun.misc |
| 10:35 | mrb_bk | Is so dope |
| 10:35 | mrb_bk | gfredericks: thanks |
| 10:35 | gfredericks | mrb_bk: np |
| 10:35 | mrb_bk | https://github.com/hyPiRion/beckon looks somewhat reasonable |
| 10:38 | gfredericks | yeah I bet so |
| 10:43 | entity | I'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:44 | entity | although things like 'K' seem to work |
| 10:45 | entity | weird, maybe I jsut can't use it :P |
| 10:45 | entity | oh, it's not :cpp it's cpp |
| 10:45 | kaiyin | hi, ambrosebs. i am back. |
| 10:45 | entity | nevermind then |
| 10:45 | kaiyin | So what's the better version of that error msg? |
| 11:13 | entity | how can I dynamically create a vector of length n? |
| 11:14 | entity | the docs for assoc are confusing |
| 11:14 | Bronsa | entity: start with an empty vector and just keep adding elements to it |
| 11:14 | entity | Bronsa: using assoc? |
| 11:14 | Bronsa | ,(conj [] 1) |
| 11:14 | clojurebot | [1] |
| 11:14 | entity | ah, thanks |
| 11:15 | kaiyin | ambrosebs: I have created a bug report on jira. |
| 11:16 | justin_smith | entity: if you know the exact size vector (or the contents) ahead of time, there is vec |
| 11:16 | justin_smith | ,(vec (repeat 10 nil)) |
| 11:16 | clojurebot | [nil nil nil nil nil ...] |
| 11:17 | Bronsa | justin_smith: it makes little sense to create an "empty" vector of size n in clojure, imho |
| 11:17 | Bronsa | justin_smith: usually that's something you need to do in langs with mutable colls/explicit memory allocation |
| 11:18 | entity | awesome, I can replace 'nil' with a function, I assume? |
| 11:18 | Bronsa | entity: using repeatedly rather then repeat, yes |
| 11:18 | entity | ah okay, cool |
| 11:19 | Bronsa | ,(repeatedly 10 (constantly 3)) |
| 11:19 | clojurebot | (3 3 3 3 3 ...) |
| 11:35 | wombawomba | So 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:35 | justin_smith | wombawomba: by using lein ring you alter your deps |
| 11:36 | wombawomba | justin_smith: any way I can make that alteration ahead of time? |
| 11:36 | justin_smith | Bronsa: it looks like creating a vector all in one go has perf benefits compared to conj https://www.refheap.com/101346 |
| 11:37 | justin_smith | wombawomba: 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:37 | justin_smith | Bronsa: whether those are worth it is an open question, and probably depends on context too... |
| 11:38 | wombawomba | I'm trying to build a docker container that has my app in it, and that runs `lein ring server-headless` |
| 11:38 | justin_smith | wombawomba: make an uberjar instead, and run the uberjar with java |
| 11:38 | wombawomba | ...but running lein ring means it takes forever |
| 11:38 | Bronsa | justin_smith: it sure does, my point is that I don't think it's something one should need to do in clojure |
| 11:39 | justin_smith | Bronsa: OK. |
| 11:39 | sobel | +1 uberjar |
| 11:39 | sobel | works well. |
| 11:39 | wombawomba | justin_smith: I could do that, but I'm doing this for development |
| 11:39 | justin_smith | wombawomba: with an uberjar, your docker no longer needs to contain git, or lein |
| 11:39 | justin_smith | wombawomba: oh |
| 11:39 | wombawomba | so I don't want to have to rebuild my container every time I change the code |
| 11:39 | sobel | i generally can't hear any meaning in the phrase, "but this is for development" |
| 11:39 | sobel | code is code |
| 11:40 | justin_smith | sobel: point being that he wants eg. the reloading behavior you get with lein ring, and to edit his code while the server runs. |
| 11:40 | justin_smith | inside a docker container |
| 11:40 | wombawomba | right |
| 11:41 | sobel | oh so the whole container is a dev instance |
| 11:41 | wombawomba | exactly |
| 11:41 | justin_smith | wombawomba: 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:42 | justin_smith | wombawomba: weavejester might be able to tell you if there's a trick for that, if he was around. |
| 11:42 | wombawomba | hmm |
| 11:42 | arohner | wombawomba: you can probably make it happen using 'lein with-profile |
| 11:43 | wombawomba | I guess I could try to find another way to get the autoreloading running |
| 11:43 | justin_smith | there is the wrap-reload middleware |
| 11:43 | arohner | wombawomba: 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:43 | justin_smith | that plus some embedded ring server (jetty, aleph, http-kit)? should get you what you want |
| 11:44 | justin_smith | arohner: oh, it's that easy? nice. |
| 11:44 | arohner | +1 for reading the source :-) |
| 11:44 | justin_smith | (inc arohner) |
| 11:44 | lazybot | ⇒ 1 |
| 11:44 | entity | can someone please take a look at this code? I can't fihure out what's going on http://pastie.org/10198865#9 |
| 11:44 | wombawomba | arohner: neat :) |
| 11:45 | justin_smith | entity: defn needs a parameter vector |
| 11:45 | justin_smith | entity: so change it to (defn rand-dna [] ... |
| 11:45 | entity | ahh |
| 11:45 | entity | thanks |
| 11:45 | justin_smith | also, that fn rand-gene is a no-op |
| 11:45 | justin_smith | it doesn't get called or returned |
| 11:46 | justin_smith | so it is effectively not there |
| 11:46 | entity | it is called on the line below |
| 11:46 | justin_smith | no, it isn't |
| 11:46 | justin_smith | because there is no binding :) |
| 11:46 | justin_smith | it doesn't exist as far as the next line is concerned |
| 11:46 | justin_smith | you need to use let or letfn |
| 11:47 | entity | oh, I see |
| 11:47 | entity | thanks again :) |
| 12:23 | andyf_ | 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:25 | andyf_ | Lots of common cases could be handled without full eval, of course, so perhaps Cursive just handles the common cases? |
| 12:29 | kaiyin | why does this block indefinitely after msg1? |
| 12:30 | gfredericks | kaiyin is blocking after the first message and so cannot send the second message with the actual code in it |
| 12:31 | kaiyin | sorry, copy/paste stopped working suddenly. https://gist.github.com/kindlychung/3f7c7a82f9dcecc4eb18 why does this hangs indefinitely on msg1? |
| 12:34 | kaiyin | ah, i think timeout is misused here. |
| 12:35 | kaiyin | how can I make it sleep for some time in a go block? |
| 12:37 | gfredericks | I think that would be a misuse of go blocks |
| 12:38 | gfredericks | you probably want to read a message from the timeout channel |
| 12:38 | gfredericks | but I'm not the bestest with core.async so dunno |
| 12:42 | kaiyin | ok |
| 12:52 | edbond | how to access environment by environ.core/env in project.clj? I want to pass database-url to ragtime in project.clj |
| 12:53 | edbond | environ page says I need to add lein-environ to :plugins. What's next? |
| 12:54 | edbond | https://www.refheap.com/101349 |
| 12:58 | justin_smith | you add an :env key (usually under some profile), or alternatively set an environment variable in the shell so that lein will see it |
| 12:58 | justin_smith | typical is :env key for dev config, shell environment for prod |
| 12:59 | justin_smith | edbond: see the second block of source code here https://github.com/weavejester/environ#example-usage |
| 13:00 | justin_smith | that hash-map would go under :profiles |
| 13:00 | edbond | justin_smith, yes, I created profiles.clj |
| 13:00 | justin_smith | OK, then you are done |
| 13:00 | edbond | question is how to access it in :ragtime { :database <here> } |
| 13:00 | justin_smith | (env :ragtime) |
| 13:01 | justin_smith | in your source |
| 13:01 | edbond | that's not my source, it's project.clj, see https://www.refheap.com/101349 part of project.clj |
| 13:02 | justin_smith | right. That sets the data. In your source you use env to access it. |
| 13:02 | justin_smith | but :ragtime has to be under the :env key |
| 13:02 | justin_smith | like in the example I pointed out |
| 13:03 | edbond | I need to access environ.core/env in project.clj, in :plugins |
| 13:04 | edbond | hm, wait |
| 13:05 | edbond | profiles.clj will be merged in project.clj without subkey? |
| 13:05 | justin_smith | oh, I misunderstood, sorry |
| 13:05 | edbond | I mean as is? |
| 13:06 | edbond | or under :profiles key in project.clj? |
| 13:06 | justin_smith | I'd say for a tool like ragtime, it makes more sense to just have profile-specific configs, rather than using indirection via env |
| 13:08 | faveteli1guis | what am i missing here, any ideas? https://gist.github.com/favetelinguis/de0071d7b237a600f310 |
| 13:13 | edbond | faveteli1guis, #(0 > 1) => #(> 0 1) |
| 13:13 | edbond | ,(> 0 1) |
| 13:13 | clojurebot | false |
| 13:13 | edbond | ,(0 > 1) |
| 13:13 | clojurebot | #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:14 | edbond | justin_smith, yes, I still don't get how to access env in project.clj using :plugins [lein-environ] |
| 13:15 | justin_smith | edbond: doing that makes no sense to me, sorry |
| 13:15 | edbond | or 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:16 | edbond | hm, how the to make project.clj environment aware? (if dev [criterium "x.x"]) for example |
| 13:17 | justin_smith | well 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:17 | justin_smith | but maybe I'm missing something here |
| 13:22 | edbond | justin_smith, found in internets this thing: ~(System/getenv "artifactory_username") |
| 13:23 | justin_smith | that would get it out of the environment as set by the shell |
| 13:23 | justin_smith | I don't see how this would help during development, and in production you shouldn't be using project.clj at all |
| 13:24 | edbond | why not? I need to run migrations using ragtime - lein ragtime migrate in production. |
| 13:24 | edbond | For this I will need another database-url, most likely set in env |
| 13:32 | edbond | For this I will need another database-url, most likely set in env |
| 13:47 | kaiyin | could anyone help with this? |
| 13:47 | kaiyin | http://stackoverflow.com/questions/30356859/upper-limit-for-number-of-jobs-in-a-do-block |
| 13:49 | noncom | kaiyin: puts and jobs are different |
| 13:49 | noncom | puts are queued on the channel |
| 13:49 | noncom | (afaik) |
| 13:50 | kaiyin | ok, i see. |
| 13:51 | noncom | kaiyin: or, better, 1 channel allows for no more tahn 1024 putting/taking jobs |
| 13:51 | noncom | you may increase the size or use the buffering window |
| 13:52 | noncom | also, you may have more channels and more go-blocks |
| 13:52 | noncom | the keyword is that 1024 is max on a *single* channel |
| 13:55 | kaiyin | noncom: how do you use a buffering window? |
| 13:56 | noncom | kaiyin: http://clojure.github.io/core.async/ look at sliding-buffer and dropping-buffer |
| 13:58 | noncom | kaiyin: you can also pass a number of max buffer elements to a channel or buffer when creating them] |
| 14:00 | kaiyin | ok |
| 14:03 | harrigan | is there any way to stop seque from holding onto the head of a seq? |
| 14:03 | harrigan | e.g. so that (let [r (seque (range 1e8))] [(first r) (last r)]) will not run out of memory |
| 14:06 | cfleming | noncom: Did you receive my email? Did it help? |
| 14:31 | harrigan | sorry, it's not holding onto head -- some other issue -- (last (seque (range 1e8))) also runs out of memory |
| 14:38 | andyf | cfleming: Does Cursive ever eval Clojure source code for the purposes of analyzing it (I don't mean in a REPL) |
| 14:41 | sritchie | anyone used a project with lein-modules on dokku or heroku? |
| 14:41 | sdegutis | Look. 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:41 | sritchie | ***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:42 | sdegutis | Na'm sa'n? |
| 14:42 | sdegutis | So 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:42 | sdegutis | So how do you solve this? |
| 14:44 | btobolaski | Use the threading macro inside the map? |
| 14:45 | sdegutis | Sorry I don't mean threaded like -> or ->> |
| 14:46 | sdegutis | I 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:48 | andyf | sdegutis: reduce ? |
| 14:48 | sdegutis | Hmm yeah maybe that will work. Seems like a weird way to map, but if it gets the job done... |
| 14:48 | andyf | There's always loop, if you have to, or just prefer the way the code looks |
| 14:49 | Bronsa | andyf: I think cursive only does static analysis -- no eval |
| 14:50 | andyf | Bronsa: 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:50 | infinity777 | Disco 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:51 | andyf | I 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:51 | Bronsa | andyf: lot of work for sure. I believe it also requires custom rules for macros in order to do correct symbol resolution |
| 14:54 | Bronsa | andyf: 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:55 | Bronsa | but I understand cfleming is just one guy and it'd be probably impossible time-wise to do both :P |
| 14:55 | andyf | I'm just idly imagining what a Clojure lint tool would have to look like in order to avoid 'launching the missiles' |
| 14:56 | andyf | I suppose an approach like clojail might help protect you. |
| 14:56 | lvh | Doesn't kibit do a lot of that? |
| 14:56 | lvh | (It does it by parsing the code and doing pattern matching on the sexps; no evaling) |
| 14:57 | Bronsa | andyf: 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:57 | andyf | Yes, but kibitz doesn't catch the kinds of potential mistakes that Eastwood does (which evals) |
| 14:57 | andyf | s/kibitz/kibit/ |
| 14:57 | lvh | sure |
| 14:57 | Bronsa | kibit is significantly less powerful than eastwood |
| 14:57 | lvh | it seems like there's an opportunity for limited evaluation for stuff like "is this actually a fn" |
| 14:57 | lvh | I don't know if that means "clojail" or "implement a handful of behaviors separately" |
| 14:58 | sdegutis | Figured it out. |
| 14:58 | sdegutis | I shouldn't have side-effect-ish functions like this that take and return state. |
| 14:58 | sdegutis | Instead I should be building up descriptions of side effects to run, and then committing them all at once. |
| 14:58 | sdegutis | Because working with data is way easier than working with state. |
| 14:59 | andyf | Preach it, sdegutis. |
| 14:59 | andyf | (I mean that in an encouraging, not sarcastic, way) |
| 14:59 | sdegutis | Plus I'll be able to add another badge to my nerd sash. |
| 14:59 | mlb- | Not trolling, but is there a guide for Java design patterns for Clojure programmers? |
| 15:00 | sobel | mlb-: i can explain why that's not 1:1 |
| 15:01 | mlb- | sobel: I'm not expecting a complete 1:1 mapping of Clojure idioms to Java GoF design patterns ;] |
| 15:02 | andyf | mlb-: Do you mean a book on design patterns in Java, targeted at someone who knows Clojure already, but not Java? |
| 15:02 | sobel | are you looking for a getting-started group? |
| 15:02 | allenj12 | this 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:03 | mlb- | andyf: If such a thing existed, I'd be very interested. |
| 15:04 | andyf | Some Lisp developer, maybe Paul Graham, wrote a summary of some OO design patterns, and how many of them were unnecessary in Common Lisp |
| 15:04 | mlb- | sobel: "Getting-started group"? I think so? |
| 15:04 | sobel | mlb-: are you starting clojure? |
| 15:05 | mlb- | andyf: Ah, no. Other way about. I got my team hooked on Clojure, but $WORK has mandated future development should be in Java |
| 15:05 | andyf | There may be a link to that article on this page: http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures |
| 15:05 | atankanow | mlb-: 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:05 | sobel | i 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:06 | sobel | oh, bummer |
| 15:06 | andyf | Reading that page will be demotivating to anyone tasked with switching from Clojure to Java, I think :) |
| 15:08 | cfleming | andyf Bronsa: That's right, Cursive only does static analysis of the source |
| 15:08 | atankanow | mlb-: 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:08 | mlb- | andyf: I was demotivated when I heard the underlying motivation to move from Clojure to Jave :( |
| 15:09 | cfleming | andyf 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:10 | mlb- | atankanow: Ah, thanks. I found it on Amazon |
| 15:10 | atankanow | mlb-: yw |
| 15:10 | atankanow | mlb-: what was the motivation to move to java? |
| 15:12 | mlb- | atankanow: Concerns over finding qualified candidates and assumptions of salary making them costly to retain. |
| 15:12 | cfleming | andyf 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:12 | andyf | cfleming: Thanks for the info. I am happy to be amazed at your achievements, without reimplementing them :) |
| 15:13 | cfleming | andyf: Hehe - it's definitely been more work than I expected! |
| 15:15 | atankanow | mlb-: ah ... well ... there are lots of expensive bad java devs out there too =) |
| 15:16 | andyf | mlb-: 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:17 | mlb- | Haha, true. Sadly, I've uncovered there's more cargo-culting here than observation of facts :( |
| 15:18 | atankanow | mlb-: i write java at work ... it's not a bad language ... like anything it can be corrupted |
| 15:18 | sobel | i really like my niche here, where i write extensions to a mostly-java code base in Clojure and call into them as needed. |
| 15:18 | sobel | library sized extensions |
| 15:19 | mlb- | atankanow: I fear that only works when your coworkers also have enough discipline to not do things the sloppy way |
| 15:20 | atankanow | nice ... 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:20 | TEttinger | also never throw an exception |
| 15:20 | mlb- | my current escape hatch is to extend the existing Clojure stuff and let "new" projects be Java ;] |
| 15:22 | sritchie | gah, why am I still seeing this WARNING: please set :license in project.clj. |
| 15:22 | sritchie | err |
| 15:22 | sritchie | No credentials found for clojars |
| 15:22 | sritchie | I know they’re in credentials.clj; |
| 15:23 | sritchie | under #”https://clojars.org/repo" |
| 15:23 | sritchie | is there something else I need to do to alias the entry as “clojars” or something? |
| 15:28 | allenj12 | sorry for the repeat, but does anyone have experience with transducers? http://pastebin.com/5tgRccPN |
| 15:29 | atankanow | given a map where the vals are vectors, what is the idiomatic way to sort every val in the map? |
| 15:29 | atankanow | this is what i have: |
| 15:29 | sritchie | anyone using credentials.clj? |
| 15:29 | atankanow | ,(map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1]}) |
| 15:29 | clojurebot | ([:a (1 2 3 4)]) |
| 15:29 | atankanow | ,(map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1] :b [\d \c \b \a}) |
| 15:29 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: }> |
| 15:30 | atankanow | ,(map (fn [[k v]] [k (sort v)]) {:a [4 3 2 1] :b [\d \c \b \a]}) |
| 15:30 | clojurebot | ([:a (1 2 3 4)] [:b (\a \b \c \d)]) |
| 15:31 | allenj12 | atankanow: that looks good, you could use (into [] .. ) if you want the vector back |
| 15:31 | atankanow | right ... 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:32 | tcrawley | sritchie: I use a ~/.lein/credentials.clj.gpg, with: {#"https://clojars.org/.*" {:username "foo" :password "barbell"}} |
| 15:33 | tcrawley | and that works for me |
| 15:33 | sritchie | tcrawley: looks like I had two maps in that file by accident. whoops |
| 15:33 | sritchie | fixed my big issue on OS X by installing GPGTools |
| 15:33 | tcrawley | gpg is the bestest |
| 15:34 | tcrawley | glad you figured it out though |
| 15:35 | TimMc | mlb-: Just tell them you'll switch to writing Java but occasionally pull in Clojure "just as a library". ;-) |
| 15:35 | allenj12 | atankanow: If your using the clojure beta you can use transducers |
| 15:35 | allenj12 | (into {} (map (fn [[k v]] [k (sort v)])) {:a [4 3 2 1]}) |
| 15:35 | TEttinger | atankanow: |
| 15:35 | allenj12 | ,(into {} (map (fn [[k v]] [k (sort v)])) {:a [4 3 2 1]}) |
| 15:35 | TEttinger | (doc sorted-map-by) |
| 15:35 | clojurebot | "([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:35 | clojurebot | {:a (1 2 3 4)} |
| 15:37 | TEttinger | atankanow, what kind of input to what kind of output do you want? |
| 15:38 | sritchie | tcrawley: thanks! |
| 15:38 | atankanow | TEttinger: {:a [4 3 2 1} -> {:a [1 2 3 4]} ... yes ... i could rigth a k/v comparator and used sorted-map-by |
| 15:38 | atankanow | write |
| 15:40 | allenj12 | atankanow: so you want it to be sorted by key aswell? |
| 15:44 | TEttinger | ,(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:44 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 15:45 | TEttinger | ,(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:45 | clojurebot | #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:45 | TEttinger | aww |
| 15:47 | crack_user | why I should put a '@' in front the keyword when it refers a atom? |
| 15:47 | TEttinger | crack_user: @ dereferences it, it gets the current value |
| 15:48 | TEttinger | otherwise you are passing the wrapping atom, which can later change, not its current value |
| 15:48 | crack_user | TEttinger: so atom store others values beyond the current? |
| 15:48 | tcrawley | sritchie: my pleasure! |
| 15:49 | fourq | What 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:50 | puredanger | repl is a macro that takes options as alternating key/value pairs |
| 15:50 | puredanger | I guess I don't know if it's a macro, prob a fn actually |
| 15:50 | TEttinger | ,(let [adam (atom [])] (do (print adam) (print @adam) (swap! adam conj :eve) (print adam) (print @adam))) |
| 15:50 | clojurebot | #object[clojure.lang.Atom 0x2facf711 {:status :ready, :val []}][]#object[clojure.lang.Atom 0x2facf711 {:status :ready, :val [:eve]}][:eve] |
| 15:51 | TEttinger | crack_user, just printing adam isn't very useful, as you can probably tell :) |
| 15:51 | atankanow | as an Adam, I appreciate that reference ... and dereference ... thanks TEttinger! |
| 15:51 | TEttinger | heh |
| 15:52 | fourq | puredanger ty |
| 15:59 | crack_user | TEttinger: thx, I get it |
| 16:20 | Reefersleep | Hey peeps |
| 16:20 | Reefersleep | Anyone use Vim for Clojure development? |
| 16:21 | Reefersleep | I'd like to pick your brain about vim-fireplace and indentation via =G |
| 16:21 | Reefersleep | or = anything |
| 16:25 | oddcully | Reefersleep: i do and = usually leaves my brain alone |
| 16:27 | Reefersleep | Cool oddcully |
| 16:27 | Reefersleep | So you never experience anything weird when using = to indent? |
| 16:28 | kaiyin | Here is the hotdog machine example from Clojure for the brave and true: https://gist.github.com/kindlychung/36ffd585378c69b4895c |
| 16:29 | kaiyin | Using one channel seems quite enough, what's the advantage of using two channels? |
| 16:29 | Reefersleep | I've experience a weird, unnecessary deep level of indentation after a line containing \[, that is, the character "[" |
| 16:29 | Reefersleep | I think the indenting mechanism interprets it as the beginning of a vector |
| 16:29 | Reefersleep | or something like that |
| 16:30 | oddcully | Reefersleep: let me try that... |
| 16:31 | Reefersleep | Cheers :) |
| 16:32 | oddcully | cheers 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:33 | Reefersleep | lemme whip something up |
| 16:41 | Reefersleep | here you go oddcully |
| 16:41 | Reefersleep | http://pastebin.com/dCN5iHwx |
| 16:41 | Reefersleep | That's as it appears when I do gg =G |
| 16:42 | Reefersleep | I've got stuff in my .vimrc of course |
| 16:42 | Reefersleep | let me just try with an empty .vimrc |
| 16:44 | oddcully | i pasted this, paredit added the ] and after cleaning out some whitespace the internet gods gave me, this indents quite correct for me |
| 16:44 | oddcully | the (+ is under (prn |
| 16:48 | Reefersleep | here's with an empty .vimrc |
| 16:48 | Reefersleep | it actually looks fine. Well, not wrong, anyway. |
| 16:48 | Reefersleep | http://pastebin.com/6t7Bxvik |
| 16:49 | sorbo_ | 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:50 | sorbo_ | vector of maps -> map of maps makes sense to me, but I'm not sure how to "update" fields as I zip |
| 16:51 | Reefersleep | I guess I gotta find the culprit in my .vimrc |
| 16:51 | Reefersleep | I don't use paredit |
| 16:51 | Reefersleep | for some reason, the Leader key does not work in my current Vim |
| 16:52 | oddcully | paredit most likely does not fix indenting |
| 16:52 | Reefersleep | and without it paredit doesn't work the way it's supposed to |
| 16:52 | Reefersleep | Well, just to say that I don't use it :) |
| 16:54 | oddcully | i am the first to turn of stupid "autocomplete" stuff in any program... but paredit + i/a motions is really handy |
| 16:54 | gfredericks | sorbo_: you just have the id key and the one other key? |
| 16:54 | sorbo_ | gfredericks: there are other keys, but those don't need to accumulate. they're the same from map to map. |
| 16:55 | gfredericks | sorbo_: okay so those would not be included in the return value? |
| 16:56 | gfredericks | sorbo_: I think this does what you want https://github.com/Prismatic/plumbing/blob/master/src/plumbing/core.cljx#L160-169 |
| 16:56 | Reefersleep | hm, it was not "set filetype indent on" |
| 16:56 | sdegutis | Is there an idiomatic Clojure pattern for this that doesn't use a custom function? |
| 16:57 | sdegutis | I have a list of maps, and I want to get the first one (if any) with a key matching a given value. |
| 16:57 | Reefersleep | oddcully, 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:57 | sorbo_ | gfredericks: this looks promising, I'll give it a go |
| 16:57 | sorbo_ | thanks! |
| 16:57 | sdegutis | Only way I know how to do it is with (first (filter #(= value (:key %)))) |
| 16:58 | sdegutis | Hi I'm new to Clojure, please help? |
| 16:58 | oddcully | Reefersleep: maybe you have just configured it wrong? my leader is the default \ iirc. i have several commands on , as pseudo leader |
| 16:58 | justin_smith | sdegutis: lol |
| 16:58 | oddcully | Reefersleep: at least things like \sh for slamhound work |
| 16:59 | sdegutis | I mean new to writing good Clojure. |
| 16:59 | sdegutis | Sorry for ambiguity. |
| 16:59 | oddcully | Reefersleep: but paredit (for me) needs no leader at all. it just works its magic with (){}[]"" |
| 16:59 | gfredericks | sdegutis: I think that's how most people do it |
| 16:59 | sdegutis | gfredericks: there must be a better way |
| 17:00 | sdegutis | I thought I found one the other day, but I can't remember it. |
| 17:00 | sdegutis | I think it used juxt and set. |
| 17:01 | gfredericks | there's certainly weirder ways to do it |
| 17:01 | sdegutis | Sorry no I am looking for idiotic way. |
| 17:01 | sdegutis | idiomatic |
| 17:01 | justin_smith | (first (filter (comp #{:v} :field) [{:field :a} {:field :b} {:field :v}])) ; something like this? |
| 17:01 | justin_smith | ,(first (filter (comp #{:v} :field) [{:field :a} {:field :b} {:field :v}])) |
| 17:01 | clojurebot | {:field :v} |
| 17:02 | sdegutis | Looks right. |
| 17:02 | sdegutis | How the.. |
| 17:02 | justin_smith | it's classier I guess, but not neccessarily better |
| 17:02 | sdegutis | Why not better? |
| 17:02 | gfredericks | readability |
| 17:02 | sdegutis | I'm trying to idiomatic my Closure code. |
| 17:02 | justin_smith | a simple equality check is more directly what you want, and more efficient than the set lookup I would assume |
| 17:02 | sdegutis | I want repeatability over readability. |
| 17:03 | sdegutis | And generalizationiability. |
| 17:03 | sdegutis | This is more general solution which works for more than just maps and attributes. |
| 17:03 | sdegutis | For example, the function I want to compare right now involves comp, not just a key test. |
| 17:03 | sdegutis | Ima comp a datomic entity attribute to another lazy datomic entity relationship and get *that guys* attribute key. |
| 17:04 | justin_smith | I 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:04 | sdegutis | I always thought it was better form to write more general and functional code and fewer anonymous functions. |
| 17:04 | sdegutis | Since anonymous functions encourage repeating the same algorithm everywhere instead of giving it a name. |
| 17:05 | justin_smith | I'm being a bit glib there |
| 17:05 | sdegutis | Even after reading the definition of glib I don't know what you mean sorry. |
| 17:05 | gfredericks | you could argue that readability is a lot more important than maximizing generality |
| 17:05 | Reefersleep | Whatever I comment out, stuff is not right |
| 17:05 | Reefersleep | I can get rid of the \[ problem, but then other stuff happens |
| 17:06 | sdegutis | (def get-first [things finder value] (first (filter (comp #{value} finder) things))) |
| 17:06 | sdegutis | gfredericks: they're equally important |
| 17:06 | sdegutis | gfredericks: they both have a precedence of 120 |
| 17:06 | gfredericks | okay |
| 17:06 | gfredericks | good to know |
| 17:06 | sdegutis | (if you compile with default flags) |
| 17:06 | justin_smith | sdegutis: if the person is looking for false or nil, that will fail |
| 17:07 | sdegutis | justin_smith: ugh dangit |
| 17:07 | sdegutis | then maybe just = |
| 17:07 | sdegutis | (partial = value) |
| 17:07 | justin_smith | I would use (partial = value) yeah |
| 17:07 | sdegutis | Great. |
| 17:07 | sdegutis | Still feels better than #(= value %) |
| 17:07 | justin_smith | if you had values (partial contains? (set values)) |
| 17:07 | sdegutis | I'm sure it is better, even though I can't fully explain why. |
| 17:08 | justin_smith | ,((partial (contains? (set [:a :b :c]))) :a) |
| 17:08 | clojurebot | #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:08 | justin_smith | ergh |
| 17:08 | justin_smith | ,((partial contains? (set [nil :a :b :c])) nil) |
| 17:08 | clojurebot | true |
| 17:09 | sdegutis | justin_smith: thanks for helping me with this i appreciate the patience |
| 17:09 | sdegutis | and gfredericks thank you for your persistence in helping finding a good solution |
| 17:09 | gfredericks | np |
| 17:10 | sdegutis | attribute 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:10 | sdegutis | maybe function? |
| 17:10 | sdegutis | like "its a function of this thing" |
| 17:11 | gfredericks | key-fn is used a lot in clojure.core |
| 17:11 | gfredericks | ,(doc min-by) |
| 17:11 | clojurebot | Excuse me? |
| 17:12 | gfredericks | &(doc min-by) |
| 17:12 | lazybot | java.lang.RuntimeException: Unable to resolve var: min-by in this context |
| 17:12 | gfredericks | &(doc min-key) |
| 17:12 | lazybot | ⇒ "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is least." |
| 17:12 | sdegutis | but it mightnt be a key, it might be any arbitrary derivation |
| 17:12 | sdegutis | derivation-fn seems more apt |
| 17:12 | sdegutis | amirite |
| 17:12 | Reefersleep | oddcully: some stuff worked in paredit without the leader key |
| 17:12 | gfredericks | sdegutis: the min-key and max-key functions use "key" in a more abstract way |
| 17:12 | gfredericks | that is similar to yours |
| 17:12 | sdegutis | oh |
| 17:12 | sdegutis | ok maybe keyfn |
| 17:12 | sdegutis | why the dash tho? |
| 17:12 | sdegutis | keyfn isnt ambiguous |
| 17:13 | gfredericks | somepeoplelikedashes |
| 17:13 | Reefersleep | oddcully: 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:13 | sdegutis | keyfn is short enough to not be difficult to visually parse |
| 17:13 | gfredericks | okay |
| 17:13 | sdegutis | so-mepe-ople-liked-ashes btw fwiw |
| 17:13 | Reefersleep | oddcully: 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:14 | Reefersleep | oddcully: which caused lag. Which, you can guess, was immensely annoying. Imagine lag for every third w |
| 17:14 | Reefersleep | horrible. |
| 17:15 | oddcully | Reefersleep: brain fade... i actually use the leader there all the time for \W, \w{ and \s etc |
| 17:16 | Reefersleep | oddcully: 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:16 | oddcully | Reefersleep: but i feel the pain. i have configured plugins to my needs because they used some odd leader which cramped my style |
| 17:16 | sdegutis | It workd be. |
| 17:16 | sdegutis | btw |
| 17:16 | Reefersleep | oddcully: And I could not get sane indentation with any of the individual options left out. |
| 17:17 | Reefersleep | oddcully: I've read that this is a common problem with Vim :( |
| 17:17 | oddcully | not with my vim it aint ^_^ |
| 17:17 | Reefersleep | oddcully: Good for you :) |
| 17:18 | oddcully | Reefersleep: i run std gentoo vim 7.4.273 |
| 17:18 | Reefersleep | oddcully: I'll figure the leader out eventually, and I'm looking forward to parediting :) |
| 17:18 | Reefersleep | oddcully: how do you get the version? |
| 17:18 | oddcully | run vim - it's in the middle of the screen |
| 17:18 | Reefersleep | VIM - 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:19 | Reefersleep | (from :version) |
| 17:19 | oddcully | there for sure is some --version too |
| 17:19 | Reefersleep | Hm. I thought it would be compiled by me. Maybe I've accidentally removed a symlink or something |
| 17:20 | oddcully | maybe relevant plugins are: paredit, fireplace, typedclojure, slamhound, eastwood, surround, matchit |
| 17:20 | oddcully | rather excessive list for a try-and-error-run :/ |
| 17:20 | Reefersleep | Of those, I only have fireplace |
| 17:20 | Reefersleep | I could try commenting out pathogen infect |
| 17:22 | Reefersleep | No difference without vim-fireplace |
| 17:22 | oddcully | i have used all my vim foo for today. i have no clue, where i would start to look for such an indenting problem |
| 17:22 | Reefersleep | Well, thanks for spending it on me, oddcully :) |
| 17:22 | oddcully | its hard to believe, that they broke it in those about 15 patches |
| 17:22 | Reefersleep | Huh? |
| 17:23 | oddcully | haha! no i actually helped one today with a oneliner on the right place |
| 17:23 | Reefersleep | Of whom are you talking, and what patches? |
| 17:23 | oddcully | 258 vs 273 |
| 17:23 | Reefersleep | aah |
| 17:23 | Reefersleep | Hm |
| 17:23 | oddcully | i assumed your "included patches" there refers to my patchlevel |
| 17:23 | Reefersleep | Guess so |
| 17:24 | Reefersleep | Well |
| 17:24 | Reefersleep | Do you have any idea who I could ask about this stuff? |
| 17:24 | Reefersleep | A forum or specific peeps? |
| 17:25 | oddcully | do 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:25 | Reefersleep | I guess I could just try a different version |
| 17:26 | oddcully | i meant, if you have an account to some unix box somewhere. opening a .clj file there should give some results |
| 17:26 | Reefersleep | oh, no. :/ |
| 17:26 | Reefersleep | But I could run Linux from a USB I guess |
| 17:26 | Reefersleep | ? |
| 17:26 | Reefersleep | Some Linux. |
| 17:27 | oddcully | na no hastle |
| 17:29 | sandbags | is it possible to redefine count for a record type? |
| 17:30 | gfredericks | don't think so |
| 17:30 | gfredericks | kind 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:31 | sandbags | gfredericks: yeah, my record is essentially a list + some housekeeping info |
| 17:31 | sandbags | so i wanted it to act like a list in some contexts |
| 17:31 | gfredericks | it's probably cleaner to just explicitly convert it when necessary |
| 17:32 | sandbags | gfredericks: yeah, i was hoping to avoid having to create type specific functions for common ops |
| 17:32 | sandbags | but you could be right |
| 17:32 | gfredericks | metadata 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:32 | sandbags | gfredericks: i thought about that, but it didn't feel right |
| 17:33 | gfredericks | making a record have a different count is a lot less right :) |
| 17:33 | sandbags | okay, i guess i give up the yak shave and get on with solving my problems |
| 17:33 | sandbags | gfredericks: i'm not sure about that but i'll take your word for it |
| 17:35 | gfredericks | sandbags: magical data structures can confuse the hell out of people that don't know what you're doing |
| 17:35 | sandbags | gfredericks: and thanks for the info |
| 17:36 | sandbags | gfredericks: i do agree although i think context is important in making that judgement |
| 17:36 | gfredericks | I 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:36 | sandbags | i suppose i could deftype if i really care enough |
| 17:38 | amalloy | !lm . abyss.exit x=turn |
| 17:38 | amalloy | oops |
| 17:39 | Reefersleep | oddcully: Thanks a lot for your help :) |
| 17:39 | gfredericks | amalloy: seems like a weird password to me but who am I to judge |
| 17:39 | gfredericks | I wouldn't have guessed it so I guess it's a good one |
| 17:40 | amalloy | /msg nickserv identify amalloy<3gfredericks4ever |
| 17:40 | oddcully | BUSTED! |
| 17:40 | Reefersleep | oddcully: I'm heading off. hope I'll figure it out eventually. Starting to consider checking out Emacs with Evil mode or maybe Spacemacs |
| 17:40 | oddcully | Reefersleep: yw, good luck, like any state ridden blob this is sometimes hard... |
| 17:41 | Reefersleep | Aye |
| 17:41 | Reefersleep | Thanks :) |
| 17:41 | gfredericks | amalloy: ha |
| 17:53 | danielcompton | Does 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:57 | arohner_ | 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:58 | arohner_ | aha, looks like I need :unauthenticated-handler |
| 18:01 | TimMc | Anyone 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:01 | TimMc | Thinking of writing one, don't want to waste effort. |
| 18:02 | justin_smith | TimMc: well, you could use read + data.diff I guess |
| 18:02 | kaiyin | ,(get (iterate inc 1) 14) |
| 18:02 | clojurebot | nil |
| 18:02 | TimMc | justin_smith: This would be slightly more than that since I have to resolve the deps, and add a little around profiles. |
| 18:02 | justin_smith | kaiyin: vectors are associative, lazy-seqs are not |
| 18:02 | kaiyin | ok |
| 18:03 | justin_smith | kaiyin: but nth would work |
| 18:03 | justin_smith | ,(nth (iterate inc 1) 14) |
| 18:03 | clojurebot | 15 |
| 18:03 | kaiyin | ah, cool. |
| 18:03 | justin_smith | the difference is that get guarantees constant time |
| 18:03 | kaiyin | i see. |
| 18:03 | justin_smith | but there is no constant time way to get the nth item of a lazy-seq |
| 18:04 | kaiyin | sure, you might have to realize stuff. |
| 18:05 | TimMc | justin_smith: What's data.diff? |
| 18:06 | justin_smith | ,(require 'clojure.data) |
| 18:06 | clojurebot | nil |
| 18:06 | justin_smith | ,(dir clojure.data) |
| 18:06 | clojurebot | Diff\nEqualityPartition\ndiff\ndiff-similar\nequality-partition\n |
| 18:06 | justin_smith | ,(doc clojure.data/diff) |
| 18:06 | clojurebot | "([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:06 | TimMc | Man, how long has this been around? |
| 18:06 | TimMc | ,(-> clojure.data/diff var meta) |
| 18:06 | clojurebot | {: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:06 | TimMc | ,(-> clojure.data/diff var meta :added) |
| 18:06 | clojurebot | "1.3" |
| 18:06 | justin_smith | ,(clojure.data/diff {:a 0 :b [1 2]} {:a 0 :b [1 2 3]}) |
| 18:06 | clojurebot | (nil {:b [nil nil 3]} {:b [1 2], :a 0}) |
| 18:06 | TimMc | WTF, I need to go spelunking again. |
| 18:07 | justin_smith | heh :) |
| 18:09 | justin_smith | anyway, I could see data.diff being helpful in comparing two project maps |
| 18:10 | justin_smith | even if it has to be after some normalization |
| 18:11 | TimMc | For now my use-case is "what dependencies changed between these two git commits". |
| 18:12 | TimMc | I'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:12 | justin_smith | get project files -> extract :dependencies -> put in sets -> set/difference ? |
| 18:12 | TimMc | more or less |
| 18:12 | justin_smith | ahh, that's a cool idea |
| 18:12 | TimMc | Not a huge amount of work, obviously. |
| 18:13 | justin_smith | it would be useful to do it with recursive dependencies |
| 18:13 | TimMc | exactly |
| 18:13 | TimMc | "Oh, clj-http updated its version of Apache HTTP client? Fascinating." |
| 18:14 | m1dnight_ | why dont I ever have any good ideas like that! :p |
| 18:15 | justin_smith | or "this one dep I added has 1,000 deps of questionable quality?" |
| 18:15 | oddcully | quit slacking around in irc! ;P |
| 18:16 | oddcully | and print it out in a git bisect |
| 18:16 | TimMc | m1dnight_: Becuase you haven't had the pleasure of dependency hell recently? |
| 18:18 | m1dnight_ | just today i was bragging about how lein is so fantastic with deps! |
| 18:18 | m1dnight_ | is there a plugin to detect unused deps? i think i could manage that |
| 18:18 | m1dnight_ | i had deps hell today with cabal too though (haskell) |
| 18:19 | oddcully | there ya go! this is a good idea |
| 18:20 | justin_smith | m1dnight_: I think eastwood can find unused required namespaces |
| 18:20 | justin_smith | that would maybe be a start |
| 18:20 | wasamasa | argh, why does C-c C-c in figwheel's repl just abort the process |
| 18:21 | justin_smith | wasamasa: within what interface? |
| 18:21 | wasamasa | justin_smith: I'm using it from the shell |
| 18:21 | wasamasa | "Exit: Control+C or :cljs/quit" |
| 18:21 | oddcully | justin_smith: eastwood left me in the eastern woods while trying out clara rules |
| 18:22 | wasamasa | I'd expect it to happen on C-d |
| 18:22 | justin_smith | wasamasa: C-c is kill, C-d is end-of-input |
| 18:22 | oddcully | is there a way around to have import the defrecords (for their class-iness)? |
| 18:22 | amalloy | wasamasa: i think i submitted a patch with that feature added, a long time ago |
| 18:23 | amalloy | to cljs, not figwheel or whatever |
| 18:24 | justin_smith | wasamasa: note that if you have anything typed in but have not hit return, C-d does nothing |
| 18:24 | wasamasa | justin_smith: of course, just like in everything else on linux |
| 18:24 | justin_smith | right, so why would C-c do anything different? |
| 18:24 | wasamasa | where C-c aborts the current computation and C-d ends the process |
| 18:25 | justin_smith | aborting the current computation is not a standard behavior |
| 18:25 | justin_smith | and C-d is eof, and that is not always ending the process |
| 18:25 | amalloy | justin_smith: a lot of repl-ish tools do that with C-c though |
| 18:25 | wasamasa | it is, type in something in a shell prompt, hit C-c and watch the next one coming in |
| 18:26 | wasamasa | so, you can use a C-c C-d chord to quit pretty much any shell |
| 18:34 | justin_smith | hmm, I always thought of C-c as "kill the program in the foreground", but I guess that's less widespread than I thought |
| 19:06 | gfredericks | does anybody have non-trivial test.check test suites and would like to help me test the performance of the new RNG code? |
| 21:01 | creese | What does this mean? java.lang.ClassCastException: clojure.test$test_vars$fn__7209 cannot be cast to clojure.lang.Atom |
| 21:01 | justin_smith | creese: inside test-vars, an anonymous function is created. Somebody is trying to deref it |
| 21:02 | justin_smith | or maybe swap! on it |
| 21:02 | creese | there is a swap! |
| 21:02 | creese | (defn stubbed-publish! |
| 21:02 | creese | [_ message] |
| 21:02 | creese | (swap! stubbed-queue conj message)) |
| 21:02 | creese | What's wrong with this? |
| 21:02 | justin_smith | what is stubbed-queue ? |
| 21:03 | creese | atom set to nil |
| 21:03 | creese | (def stubbed-queue |
| 21:03 | creese | (atom nil)) |
| 21:03 | justin_smith | if that's the case, then that isn't your issue |
| 21:03 | justin_smith | do you have a stack trace to go with that error? |
| 21:03 | creese | yeah |
| 21:03 | justin_smith | if you can share it on refheap.com or gist or something that would help |
| 21:04 | justin_smith | don't paste the whole thing here though |
| 21:04 | creese | https://gist.github.com/creese/18e701ecfd36bc0c80d4 |
| 21:04 | creese | I would never do |
| 21:04 | justin_smith | so persister-test has something called init |
| 21:04 | justin_smith | and it calls reset! on a function |
| 21:05 | justin_smith | that's the issue here |
| 21:05 | creese | (defn reset-queue! |
| 21:05 | creese | [] |
| 21:05 | creese | (reset! stubbed-queue [])) |
| 21:06 | creese | stubbed-queue is an atom |
| 21:06 | justin_smith | is that called in init? |
| 21:06 | justin_smith | because init is the one doing it |
| 21:06 | creese | (defn init |
| 21:06 | creese | [] |
| 21:06 | creese | (reset! system {:db-spec nil :out-queue {:event nil}})) |
| 21:06 | justin_smith | I bet system isn't an atom |
| 21:06 | justin_smith | I bet it's a function |
| 21:06 | creese | (def system |
| 21:06 | creese | (atom nil)) |
| 21:06 | justin_smith | that's what the stack trace is saying at least |
| 21:07 | justin_smith | trying adding (print (type system)) to the definition of init |
| 21:07 | creese | how do you get that from the stack trace? (not doubting… just...) |
| 21:08 | justin_smith | the stack trace tells you which functions were called |
| 21:08 | justin_smith | the innermost at the top |
| 21:09 | justin_smith | so from your stack trace, line 17, we see that persister-test is called by the test setup |
| 21:09 | justin_smith | err, I mean something called init inside persister-test |
| 21:09 | justin_smith | and that calls reset |
| 21:09 | justin_smith | *reset! |
| 21:10 | justin_smith | and the next thing, we get an fn that cannot be cast to atom |
| 21:10 | justin_smith | so it has to be in init that the problem is happening (or at least the symptom) |
| 21:11 | creese | there must be another "system" that is taking precedence |
| 21:11 | justin_smith | yeah, could be a scope problem |
| 21:11 | creese | main has one |
| 21:12 | creese | but it's an atom there too |
| 21:12 | justin_smith | stack traces may be confusing, but in my experience they don't lie |
| 21:14 | creese | where do you get L17? |
| 21:14 | justin_smith | the gist has line numbers |
| 21:14 | TimMc | justin_smith: Or you may not have the whole thing, such as with pst. |
| 21:14 | TimMc | which drops part of the chain sometimes :-( |
| 21:14 | justin_smith | TimMc: fair enough, but this looks like the real deal |
| 21:15 | creese | justin_smith: oh, I thought you mean L17 of the code |
| 21:16 | justin_smith | sorry, I should have been more explicit |
| 21:16 | justin_smith | line 17 in that stack trace, moving up, is the part that is running your code |
| 21:18 | creese | I change the name to "system2" and it still does it. |
| 21:21 | justin_smith | did you try adding the print to show the type? |
| 21:21 | creese | yeah, no |
| 21:22 | creese | wrong file |
| 21:22 | creese | persister != processor |
| 21:23 | justin_smith | oh, so you had an error in persister and were trying to fix it in processor |
| 21:23 | creese | yeah :( |
| 21:48 | gfredericks | hello |
| 22:14 | madan | I 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:21 | justin_smith | madan: have you looked at http://swannodette.github.io/todomvc/labs/architecture-examples/om/ and https://github.com/omcljs/om/wiki/Basic-Tutorial ? |