#clojure logs

2014-07-28

01:22sm0keis some port for reducers http://clojure.org/reducers available for 1.4?
01:57kelseygii have this function: (def reply-or-manual-rt?
01:57kelseygi (some-fn #(.startsWith % "@")
01:57kelseygi #(.startsWith % "\"@")
01:57kelseygi #(.startsWith % "“@")
01:57kelseygi #(.startsWith % "RT")
01:57kelseygi #(.startsWith % "MT")))
01:58kelseygii'd like to store those strings in a vector and dynamically create that function but i'm getting stuck
02:05TEttinger,(defn reply-or-manual-rt? [s] (map (partial .startsWith s) ["@" "\"@" "“@" "RT" "MT"])
02:05clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
02:05TEttinger,(defn reply-or-manual-rt? [s] (map (partial .startsWith s) ["@" "\"@" "“@" "RT" "MT"]))
02:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: .startsWith in this context, compiling:(NO_SOURCE_PATH:0:0)>
02:06TEttinger,(defn reply-or-manual-rt? [s] (map (partial (memfn startsWith s)) ["@" "\"@" "“@" "RT" "MT"]))
02:06clojurebot#'sandbox/reply-or-manual-rt?
02:06TEttinger,(reply-or-manual-rt? "whee")
02:06clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/reply-or-manual-rt?/fn--92>
02:10TEttingerkelseygi, I'm a bit unsure what some-fn should do
02:10TEttingeris it supposed to call all these .startsWith fns?
02:11kelseygii think it could have been or
02:11kelseygieither way i was getting tripped up with the order of arguments using partial
02:11kelseygithat's a much simpler way to write it, thanks
02:12TEttingerso reply-or-manual-rt? should be a function that just checks if an arg starts with certain prefixes?
02:12kelseygiyeah
02:13TEttinger,(defn reply-or-manual-rt? [s] (reduce #(.startsWith s %) ["@" "\"@" "“@" "RT" "MT"]))
02:13clojurebot#'sandbox/reply-or-manual-rt?
02:13TEttinger,(reply-or-manual-rt? "whee")
02:13clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: sandbox/reply-or-manual-rt?/fn--142>
02:17TEttinger,(defn reply-or-manual-rt? [s] (reduce #(if (.startsWith %1 %2) (reduced false) s) s ["@" "\"@" "“@" "RT" "MT"]))
02:17clojurebot#'sandbox/reply-or-manual-rt?
02:17TEttinger,(reply-or-manual-rt? "whee")
02:17clojurebot"whee"
02:17TEttinger,(reply-or-manual-rt? "\"whee")
02:17clojurebot"\"whee"
02:17TEttinger,(reply-or-manual-rt? "\"@whee")
02:17clojurebotfalse
02:18TEttingerkelseygi, you can tweak that so it returns true if the reduce is non-falsy
02:18kelseygiok, that makes sense
02:18kelseygii was really stuck on map--thanks TEttinger!
02:18TEttingeryeah, I tried a lot of things -- it was a hard task! no prob, thanks for the challenge!
02:21kelseygireduced is interesting to learn about
02:21TEttingerI
02:21TEttingerI've actually never used it before, but I've seen it in eval here all the time
02:22TEttingerit was introduced a while after I started learning clojure
02:43gws,(def reply-or-manual-rt-2? (apply some-fn (map #(partial (fn [p s] (.startsWith s p)) %) ["@" "\"@" "“@" "RT" "MT"])))
02:44clojurebot#'sandbox/reply-or-manual-rt-2?
02:44gws,(reply-or-manual-rt-2? "test")
02:44clojurebotnil
02:44gws,(reply-or-manual-rt-2? "@test")
02:44clojurebottrue
02:44gwskelseygi: alternate implementation using some-fn just for fun
02:45kelseygisome-fn would be useful to pass in a collection of strings to test, right?
02:45kelseygi,(reply-or-manual-rt-2? ["test","@test","RT test"])
02:45clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: startsWith for class clojure.lang.PersistentVector>
02:45kelseygihrm or not
02:45TEttingerwait some-fn is a real fn not a placeholder?
02:46TEttinger,(doc some-fn)
02:46clojurebot"([p] [p1 p2] [p1 p2 p3] [p1 p2 p3 & ps]); Takes a set of predicates and returns a function f that returns the first logical true value returned by one of its composing predicates against any of its arguments, else it returns logical false. Note that f is short-circuiting in that it will stop execution on the first argument that triggers a logical true result against the original predicates."
02:46gwsnah in that case what i did was build up a set of predicate fns (it's like your original list of #(.startsWith % "@") and so on)
02:46gwsand that can be run directly against the candidate string
02:48gwsso basically.. map over your list of prefixes, creating partial fns which each look something like #(.startsWith % "@") for each of those elements. once you've got that, you apply that mapping of fns to some-fn, which will try them in order
03:51kitallishas anyone used https://github.com/ckuttruff/clj-sql-up and deployed to heroku?
03:53kitallisI'm trying to run the migrations using heroku run, but it complains about "Could not locate cemerick/pomegranate__init.class" – but it works fine on dev. Curiously, I also don't see pomegranate as a dep in the project.
04:04SagiCZ.
04:05SagiCZ.
04:10SagiCZ.
04:25__daniel__.
04:25SagiCZ__daniel__: top of the morning to ya
04:26__daniel__top of the morning to you
04:56Kototamai'm having trouble with sql korma generating a query with my table as "metadata" when the name is metadata (without quotes)
04:56Kototamaeven the sql korma tests themselves use double quotes for table names
04:56Kototamahttps://github.com/korma/Korma/blob/master/test/korma/test/integration/per_query_database.clj#L18
04:56Kototamaany idea how to disable this behavior?
05:12Glenjaminyou need to tell it which type of database you're using
05:12Glenjaminso it knows how to quote
05:14KototamaGlenjamin: my connection specificies the h2 database, do I need to do something extra for korma?
05:15Glenjaminif you're using korma's (h2) function, then it should be correctly quoting for h2
06:42piranhaI feel like my brain is still not woken up. I have a list of items like [{:id 5}, {:id 3}, etc]. Any ideas how do I find an index if I have :id of an element?
06:47vijaykiran&(.indexOf [ {:id 1} {:id 3} {:id 5}] {:id 5})
06:47lazybot⇒ 2
06:47vijaykiranpiranha: does that work ?
06:50__daniel__vijaykiran: wouldn't work if there were more keys, which i would guess there are
06:52clgv,
06:52clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
06:53pyrtsaSomething like (defn index-where [f xs] (first (keep-indexed #(if (f %2) %1) xs))) (index-where #(= (:id %) 5) [...])
06:54vijaykiran__daniel__: yeah, but I assumed "find an index" means there's no duplication
06:54piranhavijaykiran: not really, there are more keys
06:55piranhavijaykiran: well, there is no duplication, but there are more keys
06:55vijaykiran &(.indexOf [ {:id 1} {:id 5} {:id 3} {:id 5}] {:id 5}) < will only give the first index of
06:56vijaykiran &(.indexOf [ {:id 1} {:id 5} {:id 3} {:id 5}] {:id 5})
06:56vijaykiran&(.indexOf [ {:id 1} {:id 5} {:id 3} {:id 5}] {:id 5})
06:56lazybot⇒ 1
06:56pyrtsapiranha: Got the above? ^
06:57piranhapyrtsa: yeah that looks good!
06:57piranhathanks!
06:59pyrtsapiranha: No problem. Just watch out, it often turns out in the end you're better with not dealing with indices but by e.g. searching the tail where the first item matches or something more general like that.
07:00pyrtsa...Which would be just (drop-while (complement f) xs).
07:00piranhapyrtsa: well, in my case I display them from this vector and I need to display next/previous, and ids are unique, so I guess should be more or less ok :)
07:00piranhahaha, drop-while isn't bad
07:00piranhahm :)
07:00pyrtsa:)
07:01pyrtsaThe problem with indices is they often go out of sync and fail silently.
07:25ro_sti need help debugging "Can't define method not in interfaces: get_file_name"
07:25ro_stworks on one machine, but not another. same .lein/profiles.clj, same lein deps :tree output
07:25ro_stsame project.clj
07:25ro_stanyone encountered this?
07:26xsynenvironment variables?
07:27ro_stthanks xsyn. hadn't thought of that. validating...
07:45xsynweird
07:52TimMcro_st: I'd chalk it up to either crap left behind in ./target/*/classes or /m2/repository
07:52TimMcTry lein clean in both places.
07:52TimMcAnd are you depending on SNAPSHOT versions of anything?
07:52ro_stcan you lein clean in m2/repository ?!
07:53TimMcOh! No, that's not what I meant.
07:53__daniel__[
07:53TimMclein clean at the project root on both computers. :-)
07:53ro_styes. there are several snapshots, all clojurescript-only though
07:53ro_stok, so lein clean on the working computer could break things on the working computer :-)
07:54ro_stok. clearing out ./target entirely made no difference
07:55TimMcThen you might have different SNAPSHOT artifacts for something.
07:55TEttingerlein deps
07:55TimMcTEttinger: All dependencies are up to date.
07:55TEttingerthen I'm going to bed
07:55ro_st-grin-
07:57Glenjaminsame jvm version?
07:58ro_stsame jvm version
07:58ro_stidentical lein deps :tree output
07:58ro_stonly google results talk about core.typed which we aren't using at all
08:00TimMcro_st: Move .m2/repository out of the way on both machines and try again. (Put it back later; it's a pain to redownload everything...)
08:01ro_styup. broken machine is doing it first.
08:01ro_stif it still fails, then i'll do the same on the working one
08:01SagiCZ&(println "what")
08:01lazybot⇒ what nil
08:01SagiCZ,(println "what")
08:01clojurebotwhat\n
08:05ro_stTimMc: ok. a fresh m2 didn't fix it. now running the same test on the working machine. (?!)
08:14ro_stTimMc: ok. now the working machine is also broken
08:14ro_stthat means some sort of dependency tangle in the project, right?
08:42hyPiRionro_st: usually, yes.
08:43ro_sti'm no closer to a resolution. i'm utterly baffled
08:43hyPiRionro_st: and this worked fine previously?
08:43ro_styes. now that i've moved my .m2/repository aside and made a new one, it's also broken
08:44ro_stCaused by: java.lang.IllegalArgumentException: Can't define method not in interfaces: get_file_name, compiling:(clojure/tools/reader/reader_types.clj:107:1)
08:45ro_stmy deps tree: https://www.refheap.com/88641. there are no warnings about ranges or overides being printed along with this tree
08:47hyPiRionro_st: yes... this sounds like a record/type issue.
08:47ro_sta lein check fails before it can start compiling any namespaces. i can't get a repl up at all to poke at things
08:49hyPiRionro_st: lein downgrade 2.4.0 and check if it works
08:50hyPiRionI know there were some AOT issues appearing going from 2.4.0 → 2.4.x
08:50ro_sttrying that
08:50ro_stno, that appears to make no differene
08:52hyPiRioneven after lein clean?
08:52ro_styep
08:52hyPiRionyou can try to force tools.reader to 0.8.4 to see if that helps
08:52hyPiRionadd [org.clojure/tools.reader "0.8.4"] into the dependency list
08:54ro_stno, that didn't help either
08:54ro_stlooking at the source, i bottom out at a defprotocol for IndexedReader
08:54boxeddoes anyone know the correct way to get the clojure version in leiningen plugins? I have clojure 1.2.0 in my project.clj but when my plugin is run I get 1.5.1
08:54ro_stis it that it can't find the proto or is it that it doesn't have a valid object to which the proto has been extended?
08:55hyPiRionro_st: do you extend it? It may be that you attempt to use get_file_name instead of get-file-name
08:55hyPiRionBut I would expect that get-file-name is munged and that the error necessarily isn't there
08:56ro_stno, i'm definitely not invoking tools.reader directly
08:56ro_stthe stacktrace goes via cljs.analyzer in clojurescript
08:56hyPiRionOk, let me take a look at the dep tree again
08:57ro_sti'm updating the refheap with the latest tree and the full strace
08:58ro_sthttps://www.refheap.com/88641
09:01boxednm.. the answer seems to be to use leiningen.core.eval/eval-in-project
09:04hyPiRionro_st: My guess is that there's some AOT issue going on
09:04hyPiRionat least there's something with protocols/records extending protocols.
09:05ro_stso it's a name munging issue? _ where it should be -?
09:06ro_stReflection warning, clojure/tools/reader/reader_types.clj:34:1 - call to method get_file_name on clojure.tools.reader.reader_types.IndexingReader can't be resolved (no such method).
09:06ro_sti disabled my dev time user.clj and was able to get this warning as well
09:07gfredericksboxed: yeah the nature of plugins is that they run in the leiningen process
09:08gfredericksboxed: what does your plugin do?
09:08boxedconverts README.md into a midje style test file
09:08boxedthe problem I have now is that I need to make it delete that test file if we’re running on a clojure version midje doesn’t support
09:08Bronsaro_st: I haven't followed the convo but get-file-name has been in tools.reader since 0.7.8
09:09gfredericksboxed: why would someone use your plugin if they're using a clojure version midje does not support?
09:09ro_stBronsa: something is causing it to want get_file_name instead
09:10boxedgfredericks: they’re running tests on multiple versions of clojure, and they are ok with only testing the examples againsts the latest
09:10ro_sti don't know enough about AOT or protocols and types to know why
09:10boxedwell…. againsts 1.4+
09:11Bronsaro_st: that's how it gets munged, the error is not about that
09:12ro_stok. i have a barebones lein project with the same behaviour
09:13boxedwell shit, eval-in-project always returns nil, that’s a bit blech
09:15SagiCZhey guys, what do you do in case you are developing an api for example, you define a function which takes 2 parameters, you presume that one of them is a simple string and the other one is a map with some special keys.. you are expecting those. How do you force the users of your API to send the correct parameters to the function? Check it with asserts or "pre:" ?
09:15thengeUse prismatic schema or something similar
09:15Bronsaro_st: I'm sorry I really don't know much about leiningen to help, but that error suggests some of your deps is pulling an AOT compiled tools.reader version prior to 0.7.8
09:16ro_stthanks bronsa
09:17SagiCZ,(map "string-is-not-a-function" {:a 0 :b 1 :c 2})
09:17clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
09:17boxedSagiCZ: as for the map, just destructuring it is probably ok, otherwise maybe look at core.typed?
09:18boxedI’m just guessing though :P
09:18SagiCZthis is how clojure does it.. and i dont like it.. it should say: "The first parameter should be a function"
09:18augustlSagiCZ: according to clojure.core, nothing, your problem, fail run-time, etc ;)
09:18SagiCZaugustl: yeah.. i see that.. but it could lead to some hard-to-find bugs
09:19stuartsierraThe problem is that this kind of type-checking has a significant runtime performance cost.
09:19SagiCZstuartsierra: does it really though..
09:19stuartsierraRich has accepted patches that improve error messages, but only if they don't effect performance.
09:19stuartsierra*affect
09:19SagiCZstuartsierra: uh-huh
09:20ro_stBronsa: yes. i deleted 0.7.3 and 0.7.5 from m2/repositories and a lein deps redownloaded them
09:20augustlthat's what you get for not doing it compile time :)
09:20hyPiRionSagiCZ: linters, type checkers might help you
09:20boxedSagiCZ: I agree with you. At least we should have a debug mode that has errors that can be used
09:20Bronsaro_st: if this can help, the last version of tools.reader that was AOT compiled shoule be around 0.7.3
09:20ro_sthow would i find out which dependencies are pulling them in?
09:20Glenjaminthe build profiles thing in clojure 1.7 might open the door to better error messages in the debug build
09:21SagiCZlet me restate the question.. lets say i expect the user to pass a map with keyword ":a" but he passes a map without it. what is the idiomatic way to deal with this in clojure?
09:21stuartsierraYes, I'm hoping for that as well.
09:21hyPiRionboxed: I agree fully with this. But it's time consuming to keep both clojure versions (normal vs debug) up to date
09:21hyPiRionat least naively, but of course possible to optimise that overhead
09:21ro_sthyPiRion: how would i determine which of my deps are pulling in the older tools.reader jars?
09:22boxedhyPiRion: could be something like asserts that are removed in some non-debug mode
09:22ro_sthyPiRion: same tree as before. i deleted 0.7.* from m2, did a lein deps, and it redownloaded 0.7.3 and 0.7.5. if i can find out which deps are doing this, then i can exclude and it should work
09:23TimMcro_st: You ahve consistency between your two machines. My work here is done.
09:23ro_stTimMc: thank you. your advice was very helpful :-)
09:24hyPiRionro_st: Hrm. Can you dump out `lein deps :plugin-tree`? There may be some interference there somehow
09:24augustlisn't there a way to disable pre/post when you compile jars for production?
09:24ro_stzero output for that
09:26hyPiRionro_st: oh, riiight. you know that [org.clojure/tools.reader "0.8.4"] dependency I asked you to add in? Could you move that to the very top of the dependency list?
09:27hyPiRionIt's too much magic for me to handle.
09:28ro_stit's at the very top now, no change.
09:29ro_stif it only downloads .pom, that means it isn't actually using that code right?
09:29hyPiRionright
09:29ro_sti only have 0.8.* jars in m2
09:30hyPiRionHrm, I would guess there's a problem if you have a dependency depending on an AOT-compiled version?
09:30ro_stnow i only have 0.8.5 jar in m2. still no dice.
09:31ro_sthow would i check for that?
09:31hyPiRionI don't know, unfortunately.
09:32stuartsierra`lein deps :tree`
09:32hyPiRionstuartsierra: https://www.refheap.com/88641 – doesn't show which version they depend on
09:33hyPiRionunfortunately, hrm.
09:33hyPiRionro_st: actually, could you file an issue for this on the Leiningen issue tracker? Because I guess we want to find out of this as well.
09:34ro_stsure, i will do
09:34hyPiRionthanks, much appreciated
09:35stuartsierraOh, you want to know every version that appears in the dependency tree?
09:35ro_styes please :-)
09:36stuartsierraOK, `lein deps :tree` only shows you the resolved deps the app is going to use.
09:36ro_ststuartsierra: the core issue: "Reflection warning, clojure/tools/reader/reader_types.clj:34:1 - call to method get_file_name on clojure.tools.reader.reader_types.IndexingReader can't be resolved (no such method)."
09:36hyPiRionI guess, if you want to figure out if some dependency depends on an old AOT-compiled version of the library.
09:37stuartsierraTry `lein pom` then `mvn dependency:tree -Dverbose`
09:37ro_stwe now think that one of my deps' deps is requiring an AOT compiled reader older than 0.7.8. it fetches 0.7.3 and 0.7.5 poms when i do a fresh deps with an empty m2
09:38ro_stthanks. trying that now. hopefully i can spot which libs want the older readers so i can exclude
09:42stuartsierraYou can also make a global :exclusions in your project.clj
09:43ro_stok. i found (org.clojure:tools.reader:jar:0.7.5:compile - omitted for conflict with 0.8.5)
09:43ro_stadding an exclusion to that dep made no difference, however
09:45ro_stthe full mvn output is now also on https://www.refheap.com/88641
09:46ro_stif lein deps :tree only shows a modern tools. reader, doesn't that mean that's the only one that'll load into memory?
09:46ro_stif so, why then do i get the stacktrace in the middle of the refheap?
09:47gfredericksbbloom: ha I just had a minor unexpected issue with comparing floats
09:53gfredericksand I'm pretty sure it's because of serailization roudntrip issues (with a db)
09:55jcromartieParedit command of the day: when inside a string, M-S splits it just like a sexp!
09:56jcromartiethat's meta-S not shift
09:56jcromartieor Super or whatever S is on the left side of an Emacs keybinding
09:59ro_stand M-J splits it
09:59__daniel__and in paredit.vim?
10:02ro_sthyPiRion: fixed it
10:02ro_sti have a fork of another project that uses an old t.r. i had updated the t.r in my fork but had not `lein install`ed it
10:03raj91Hello, does someone have the power to add a 1.6 tag to https://github.com/clojure/clojure ?
10:03ro_stso deps reports the right t.r version but check uses the one from m2 which is the older t.r
10:03raj91I'd like to properly hyperlink to some source code there.
10:03ro_straj91: probably stuartsierra does
10:03raj91Meaning that I'd like a branch name to use; currently I can use d6baf6e1 which is a little ugly
10:04arrdemno 1.6 tag? that's weird...
10:04ro_stthe reason is because i had that fork in checkouts
10:04arrdemraj91: there's a 1.6 tag
10:04arrdemraj91: https://github.com/clojure/clojure/releases/tag/clojure-1.6.0
10:05raj91arrdem raj91 my fault, I was searching the branches
10:05raj91should there be a 1.6.X branch?
10:05hyPiRionro_st: oh, nice
10:05stuartsierraThere will only be a 1.6.X branch if we have a need for a 1.6.X release.
10:05raj91sorry for the false alarm
10:05arrdemthere's no official branching standard specifying how Rich and co structure 1.6.X/1.7 devel.
10:05hyPiRionro_st: hard to find such errors though
10:06ro_sthyPiRion: i made a new proj and copied all the deps and removed them one by one until it worked :-(
10:06ro_stjust glad it's fixed.
10:06ro_stthanks for your assistance!
10:08hyPiRionyw
10:08TimMcCheckouts + local-only installs? Yuck.
10:31GenaraLsLm
11:40gfredericksthere's a lein plugin for running standalone clojure scripts somewhere amirite?
11:41gfredericksin particular supporting some sort of dependency declaration at the top of the file
11:42technomancygfredericks: you could include direct calls to pomegranate
11:42arrdemgfredericks: lein-oneoff showed up recently..
11:43awwaiidgfredericks: I recently had good luck with lein-exec
11:44gfrederickslein-oneoff looks good, since it explicitly supports the deps
11:45gfrederickstechnomancy: arrdem: awwaiid: thanks
11:45arrdemI need to look at how lein-oneoff is built..
11:45arrdemit's a little weird to me that it's built on a #_ prefix
11:46gfredericksyeah I just checked that
11:46gfredericksthey delete any initial #"\s*#_" before reading
11:46arrdemslurps, drops to chars, reads a form with lispreader?
11:46arrdemyeah
11:46arrdem*two
11:48awwaiidgfredericks: the issue with lein-exec can be in the #!/usr/bin/env portability. On my system I was able to cheat with "#!lein exec" and avoid adding a special "lein-exec" to my path
11:49gfredericksawwaiid: yeah I don't mind having to use lein to execute the file; I'm just trying to avoid the whole project filesystem
11:50awwaiidYeah. Especially with [insert whatever is the most modern equivalent of nail-gun] you might actually be able to use it as a scripting language :)
11:53arohnergfredericks: there's lein jarbin
11:55gfredericksarohner: interesting but not obviously related?
11:55arohnerah, read things out of order
11:55arohnerif you want a single file, yeah oneoff looks like a better fit
12:15arrdemjohn2x: ping
12:26seangrov`technomancy: I can open your eyes--take you wonder by wonder over, sideways and under on a magic carpet ride.
12:26technomancyseangrov`: <3
12:26technomancybest way to start your week
12:27seangrov`My repl feels so pleasant and nice now
12:31bbloomyour repl will feel even more warm and fuzzy with https://github.com/greglook/whidbey
12:31arrdembbloom: does that behave wit cider?
12:32arrdem*with
12:32bbloomarrdem: no idea, i use vim
12:32arrdemo
12:32bbloomarrdem: but it seems to behave fine there
12:32seangrov`bbloom: Doesn't look like it's using fipp
12:33technomancyoh yeah, the guy who made this demoed it at seajure a while back
12:33seangrov`Looks nice though
12:33technomancylooks like he got it working more smoothly now
12:33bbloomseangrov`: it is using fipp via pudget
12:34seangrov`Very nice, didn't recognize pudget
12:34bbloomer pudget
12:34bbloomseesh
12:34bbloompuget*
12:34bbloommade the same typo twice
12:35bbloomanyway, puget nicely sorts maps and such, but sadly has to lose some performance promises to do that :-/ but still, it's fast enough for interactive work
12:35bbloomone of these days i might try to modify puget to support a mode where it gives up on sorting for collections over a certain size
12:56bordatouecould anyone using gloss framework tell if how to skip bytes while decoding ; for example if want to read only third byte how do I skip byte 1 & 2
13:00seangrov`bbloom: Yeah, my concern would be accidentally hosing my repl in emacs because of it
13:00bbloomseangrov`: it's worked flawlessly for me for months with vim-fireplace
13:01seangrov`bbloom: Emacs struggles with large text in nrepl/cider buffers, biggest source of emacs crashes for me
13:01bbloom:-/
13:01tbaldrid_+1 I hate working in emacs for that reason
13:01tbaldrid_didn't seem to be an issue until the cider switch
13:02tbaldridgenot sure what changed when that update happened.
13:02technomancyI'm still on 0.5.0 which is pretty stable
13:03bbloomtbaldridge: btw, i read the mu-karen paper & implemented it. the implementation has always made sense to me, it's the way you use it that feels weird.... the "fact" based workflow of prolog just makes more sense to me vs the "relation" workflow of kanren... but i'm still exploring
13:03tbaldridgebbloom: yeah, it started making a bit more sense to me when I rewrote it using lazy seqs instead of monads.
13:04bbloomtbaldridge: ah the good ol' list monad. really, the only one you *strictly* need :-P
13:04bbloomso much easier to debug too b/c you can *see* how it works
13:04bbloomi did my mukanren impl in mathematica so that i could see inside to the thunks
13:04tbaldridgenice
13:06tbaldridgethat being said, I think datalog has a more common use case: querying sets of data.
13:07tbaldridgeClojure could really use a light-weight, cross-platform Datalog.
13:07mdrogalis+1
13:07mdrogalisTo some extent, didn't DataScript accomplish that?
13:07tbaldridgemdrogalis: to some extent, although last I looked, their query language wasn't exactly fast
13:08mdrogalistbaldridge: Ah, I didn't dig into it.
13:52i-blisif I ((juxt keys vals) m), is there any guarantee that keys and vals will be in order?
13:52i-blisor should I better opt for a safer (apply map vector m)?
13:53mthvedti-blis: probably yes, but map has no ordering guarantees
13:53joegallokeys and vals are in the same order, yes
13:53bbloomkeys & vals are documented to match seq
13:53bbloom(doc keys)
13:53clojurebot"([map]); Returns a sequence of the map's keys, in the same order as (seq map)."
13:53bbloom(doc vals)
13:53clojurebot"([map]); Returns a sequence of the map's values, in the same order as (seq map)."
13:53mthvedtbbloom: that's interesting i didn't know that
13:53mthvedtthat is stronger than java.lang.map
13:54i-blisoh, thanks
13:54bbloombut the map seq itself already returns vector-like key entries
13:54bbloom,(seq {:x 1 :y 2})
13:54clojurebot([:y 2] [:x 1])
13:54bbloom,(map vec {:x 1 :y 2}) ; for true vectors
13:54clojurebot([:y 2] [:x 1])
13:54stuartsierraIn general, anything returning a sequence will return a consistent order for the same input.
13:54i-blisyep, thsi is why i did not seq before the map
13:58i-blisthanks :)
14:04ahoenigmann15
14:04amalloyoh nice, bbloom, i didn't realize that had finally gotten documented
14:04amalloyas of this february, apparently
14:05ahoenigmannI need a environment for clojure
14:06justin_smithahoenigmann: what kind of environment?
14:06ahoenigmannwell I know emacs
14:07ahoenigmannso I need to know what tools to go setup for a clojure development environment?
14:07justin_smiththan you are in luck, integration with emacs is pretty good
14:07justin_smithyou should definitely be using lein
14:07justin_smithand then, you should find a recent stable version of cider
14:07arrdempshaw stable
14:07justin_smithI think cider also needs a clj plugin lib to be in your ~/.lein/profiles.clj
14:08justin_smitharrdem: I'm not trying to destroy this person's sanity
14:08arrdemjustin_smith: he used emacs before clojure. I argue I'm not destroying anything.
14:10justin_smithahoenigmann: anyway, there is lein (definitely use) and cider (depends on how brave you are / how willing you are to fiddle with broken things, how recent a version of that to use)
14:12arrdemcider is usable... if your definition of usable means you do daily system snapshots before and after a package upgrade in case today's top of tree is horked.
14:12arrdemafter several months of cider usage there've only been one or two days when it was totally horked and I had to roll back
14:12technomancyif you want something stable you can stick with nrepl.el
14:13arrdemor join Bronsa in the slime users club
14:13amalloyi will become a cider contributor just to sneak an rm -rf into arrdem's emacs
14:13technomancythe one upside of the gratuitous rename shuffle: nrepl.el isn't gonna break
14:14llasramMan, #clojure has gotten cantankerous
14:14llasramWell, or maybe just curmudgeonly
14:15amalloysounds like someone has a case of the mondays!
14:15llasramhah
14:16cminusWhat library are folks using for async http that plays nice with core.async?
14:16justin_smithyeah, I still use nrepl, one of these days I will find and switch to a stable cider version (if such a thing is available)
14:17llasramI've been on 0.5.0 (from marmalade) for a while, and its been totally fine
14:17arrdemupsides of using cider: in addition to amalloy's attempts at sabotage, you get cool new features like M-x cider-grimoire :P
14:18technomancyarrdem: which totally shouldn't be hard-coded into cider =
14:18technomancy=\
14:19arrdemtechnomancy: meh... I can see an argument that cider-grimoire or cider-clojuredocs should be packages rather than making cider monolithic
14:19technomancyarrdem: especially with cider's stability track record
14:20technomancyif you want a new grimoire feature, do you really want to spin the Wheel of Batsov to risk upgrading the whole lib?
14:20bridgethillyerIs there a canonical reference for how to get setup for Clojure development with emacs?
14:20justin_smithtechnomancy: that sounds like a really scary game show
14:20bridgethillyerThat is a rhetorical question I just asked.
14:20technomancybridgethillyer: the one on clojure-doc.org was good last I checked
14:20justin_smithtechnomancy: it's time for... WHEEL! OF! BATSOV!
14:20arrdemtechnomancy: I woke up to find the wheel had spun itself and landed on "new cool feature" rather than "rm -rf --no-preserve-root /"
14:21bridgethillyerEmacs for Clojure Development: http://clojure-doc.org/articles/tutorials/emacs.html
14:22martinklepschare there any great starting templates for Clojure+Clojurescript apps?
14:22martinklepschI know Luminus but I assume there might be others
14:28bridgethillyermartinklepsch: what do you mean by template? project template? or tutorial? or libraries? or?
14:28martinklepschbridgethillyer: project template
14:28martinklepschthis looks neat as well, super minimal: https://github.com/konrad-garus/cljs-kickoff
14:31bridgethillyerHow about mies or cljs-webapp? I have no idea myself. I have not used any of them.
14:31ahoenigmannhmm
14:32ahoenigmanndoes cider have paredit?
14:33martinklepschahoenigmann: nope
14:33ahoenigmannoh cider is just the repl
14:33martinklepschahoenigmann: nrepl integration, yes
14:33technomancyyou can turn paredit on for cider
14:33technomancyit's just a minor-mode
14:42ahoenigmannwhats best online resource for learning clojure?
14:43technomancythis IRC channel
14:43ahoenigmann:)
14:43ahoenigmannmy first project tail/parse a log file
14:44nullptrahoenigmann: there are many answers to that question, here is one: http://aphyr.com/posts/301-clojure-from-the-ground-up-welcome
14:47bridgethillyerI really like aphyr’s Clojure from the Ground Up
14:47ahoenigmannthanks
14:47amalloyi'll let him know, bridgethillyer
14:47bridgethillyerBut I also really like nonrecursive’s Clojure for the Brave and True http://www.braveclojure.com/
14:48bridgethillyer:) Oh, he knows how I feel about it.
14:49bridgethillyerAnd, goes without saying, 4clojure is the best for practicing basic Clojure skills
14:50pbalduinobridgethillyer: agreed
14:50pbalduinohi there. I have a doubt about gen-class. I'm using inside lein repl and nothing happens.
14:50hiredman,(doc gen-class)
14:50clojurebot"([& options]); When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. When not compiling, does nothing. The gen-class construct contains no implementation, as the implementation will be dynamically sought by the generated class i...
14:50hiredman"When not compiling, does nothing.
14:50hiredman"
14:50hiredmanthat should really say "when not aot compiling" but whatever
14:51pbalduino"When not compiling, does nothing."
14:51pbalduinohiredman: and how could I enable "aot compiling" inside repl? I'm following these: https://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html
14:51justin_smithhiredman: yeah, I was gonna say "wait, isn't every clojure form compled?". When aot makes it much more clear
14:51justin_smithpbalduino: aot inside a repl is not a thing
14:52pbalduinoouch
14:53hiredmanclojure at one time had something like gen-class that would let you generate classes whenever like that, but there are all kinds of classloader/visibility issues with that
14:53pbalduinojustin_smith: I'm trying to explain java interop using the REPL, and gen-class is the next step. so to work I would need to create a project and compile calling the app?
14:54pbalduinohiredman: so (gen-class) is deprecated nowadays?
14:54hiredmanhow is gen-class the next step?
14:54justin_smithpbalduino: not sure - I haven't tried gen class outside of fully aot compiled projects, because I only need the aot-only features when java needs to access my stuff
14:54hiredmanpbalduino: it isn't deprecated, it just isn't used much
14:54technomancyjustin_smith: it's technically possible, just a bad idea
14:54rhg135proxy if you're extending
14:54rhg135idk
14:55rhg135java does have a framework for thi s i believe
14:55justin_smithpbalduino: maybe I can express that more clearly: if you need the things that gen-class provides, that likely means java is using your .class files, which probably means aot at product packaging time
14:56justin_smiths/product/project
14:56justin_smithin my experience at least
14:56pbalduinojustin_smith: in my tiny experience, I think so
14:59rhg135doesn't deftype generate a class at runtime?
15:00justin_smithrhg135: yes, but there are things gen-class does that deftype cannot
15:01llasramYes. And it's actually possible to wire up the same dynamic class loader plumbing to gen-class. I actually wrote a tiny library which does that: https://github.com/llasram/shady
15:01llasramThe fact that clojure.core didn't bother is another reason to consider it semi-deprecated/largely-unused
15:02rhg135justin_smith, i know i meant like llasram did
15:02rhg135hacking it into gen-class
15:05Raynestbaldridge: arrdem requested your presence for unknown reasons, hence the invite.
15:06goochello, anyone free to answer a quick clojure question?
15:06llasram~anyone
15:06clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
15:06mi6x3m-althey clojure, do you respect 80 chars boundary?
15:07goocWhy are clojure programmers such pussies compared to python programmers?
15:07llasramWow. It must be the trolling hour
15:07mi6x3m-altGo go go
15:07rhg135hmm smells troll-like
15:11schmeecan a multimethod dispatch based on a string passed to it?
15:11schmeeI want to use something like that to handle user input
15:11rhg135yes
15:11rhg135on anything really
15:12schmeeI've been experimenting in the REPL but I can't figure out the correct way to write it
15:12amalloy(defmulti handle-input [command & opts] command) (defmethod handle-input "quit" [& args] (System/exit 0)) (handle-input "quit" "now")
15:12mi6x3m-altschmee: what?
15:13rhg135(defmulti on-hi (fn [s] (= "hi" s)))
15:13pbalduinothank you
15:13rhg135amalloy, i forgot it could dispath on strings lol
15:14cbpI have an emacs thingy that paints text red when it goes over 80 columns but I sometimes ignore it
15:14cbpIt might be whitespace.el or something
15:14schmeeamalloy: when I type (defmulti handle-input [command & opts] command) in the REPL I get "Exception The syntax for defmulti has changed. Example: (defmulti name dispatch-fn :default dispatch-value)"
15:14amalloyrhg135: that defmulti example you gave is like super-awful, it's not a multimethod at all, but an if statement in a big floofy dress
15:15amalloyoh, ugh. it's (defmulti handle-input (fn [command & opts] command))
15:15cbp(defmethod foo [s] (cond (= s "hi") ..)) ; eheheh
15:15rhg135amontalenti, i haven't written clo‌jure in months
15:15rhg135amalloy,
15:16rhg135darn tab
15:16amalloyrhg135: it's the fanciest name anyone's called me in months
15:16cbpI can never remember the correct syntax the first time
15:16rhg135i'm practically shaking from clojure withdrawl by now
15:17schmeeamalloy: (handle-input "quit" "now") <-- is the `now` in here necessary?
15:17amalloytry it and see
15:19schmeeAny idea why this won't work? (defmulti tester (fn [command] command)) (defmethod tester "quit" [_] (println "quitting!")) (tester "quit")
15:20rhg135idk
15:20amalloyit would work fine, except multimethods have this awful "feature" where if you try to change the dispatch function of an existing multifn nothing happens
15:20rhg135also use identity as a dispatch fn
15:21amalloyyou have to def the multifn as nil in between, or reload your repl or whatever
15:21cbpuse (def tester nil) before modifying and recompiling a multimethod
15:21jeremyheileramalloy: are you implying that is desired? i've always felt that was a short coming
15:21schmeeamalloy: haha wow, that is indeed aweful
15:22amalloyjeremyheiler: it's on purpose for sure. the alternative is not very nice either
15:22schmeeamalloy: REPL restart did the trick, thanks a lot for the help!
15:22schmeerhg135: like so? (defmulti tester identity
15:22schmee)
15:22jeremyheileramalloy: the alternative being a set-dispatch-fn fn?
15:23rhg135schmee, yup
15:23jeremyheilertherefore making it mutable
15:23amalloysuppose i have a defmulti using some dispatch function in ns A, and defmethods for it in B and C. if i redefine the dispatch function in A without reloading namespaces B and C, what happens?
15:23rhg135more readable imo
15:23schmeerhg135: absolutely, thanks!
15:23amalloydo those methods get thrown away? attached to the new method even though the new dispatch function would dispatch to them differently?
15:24rhg135amalloy, i'd think it'd get nasty in mutability-land but agree it's surprising
15:24amalloyobviously the existing behavior is awful, but there are no obviously non-awful behaviors available
15:25jeremyheileramalloy: i see. makes sense
15:25rhg135imagine, you require namespace D edits dispatch fn
15:25jeremyheilerin general, i think it works to use a function defined with defn so you can independently reload it.
15:26rhg135FBBOOM,, none of your defmethods work right
15:26schmeeman, I have this feeling that once I get used to Clojure, programming in any other language is going to suck
15:26rhg135schmee, ain't it the truth
15:27rhg135although bitemyapp enjoys haskell
15:27ahoenigmannI setup a new project with lein following: http://clojure-doc.org/articles/tutorials/emacs.html#using-the-repl
15:27ahoenigmannNow when I run test with C-c ,
15:28ahoenigmannI get:
15:28ahoenigmannclojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: clojure.test.mode
15:30hugodIs there a pattern for providing/consuming plugin components in clojurescript? ie, I want to add library X to my dependencies, and be able to discover some function/object that X provides.
15:33hugodI wonder if I could do the plugin discovery in clojure, and expose this via a macro to clojurescript.
15:48gfrederickscomparing two doubles of unknown scale is tricky
15:49the_banksyhey
15:50amalloygfredericks: (defn compare-doubles [a b] :probably-different)
15:50lpvbare top level defs realized on application start
15:50gfredericksamalloy: aaaahh
15:50lpvbe.g. when is a def'd object created
15:50gfredericksI need to detect that 0.0903293108114148 and 0.09032931081141483 are mostly the same
15:50the_banksyI wonder if anybody could let me know whether it's possible to do a 'let' over the various definitions of an overloaded function?
15:51gfredericksthe_banksy: you can let around a defn
15:51gfredericksthe_banksy: the other style is more defns as helpers
15:52amalloygfredericks: (defn similar-doubles? [a b] (< 5 (levenshtein (str a) (str b))))
15:52gfredericksamalloy: omg
15:52the_banksygfredericks: ah I see, thanks
15:52jeremyheiler(defn compare-doubles [a b] (rand-nth [1 -1]))
15:52justin_smithgfredericks: there is also java.lang.Math/ulp
15:53gfredericks,(def x1 0.0903293108114148)
15:53clojurebot#'sandbox/x1
15:53gfredericks,(def x2 0.09032931081141483)
15:53clojurebot#'sandbox/x2
15:53gfredericks,[(Math/ulp x1) (Math/ulp x2)]
15:53clojurebot[1.3877787807814457E-17 1.3877787807814457E-17]
15:53rhg135amalloy, dafuq?
15:53gfredericks,(= (Math/ulp x1) (Math/ulp x2))
15:53clojurebottrue
15:54halogenandtoastCan anyone explain to me why nothing gets printed here? https://gist.github.com/halogenandtoast/1a4cfe9691429f1b0836
15:54halogenandtoastoh wait I might have an idea. idk why I’m trying to map print.
15:54justin_smithgfredericks: ulp can also be used to calculate the range of effectively identical values around a given value (and that is its intended usage)
15:54gfredericks,(let [ulp (Math/ulp x1)] (< (Math/abs (- x1 x2)) ulp))
15:54clojurebotfalse
15:54nkozohalogenandtoast: map returns a lazy-sequence
15:54gfredericks,(let [ulp (Math/ulp x1)] (< (Math/abs (- x1 x2)) (* 2 ulp)))
15:54clojurebotfalse
15:54gfredericks,(let [ulp (Math/ulp x1)] (< (Math/abs (- x1 x2)) (* 4 ulp)))
15:54clojurebottrue
15:55halogenandtoastnkozo: can you not map on a lazy sequence.
15:55nkozohalogenandtoast: try doing (doall (map print-card deck))
15:55schmeewhat's the best way to avoid repetition here? (f1 x) (f2 x) (f3 x)
15:55halogenandtoastI tried mapv still nothing
15:55gfredericksjustin_smith: cool, thanks
15:55gfredericksschmee: juxt
15:55schmeenow I'm using ((juxt f1 f2 f3) x)
15:55halogenandtoastnkozo: OOOH
15:55halogenandtoastYep derp.
15:55hiredmanamalloy: you would want to augment levenshtein distance with some notion of significance
15:55halogenandtoastDidn’t even try it, but I understand now.
15:55nkozohalogenandtoast: doall enforces "realizing" the lazy-seq returned by map
15:55justin_smithgfredericks: no matter what your desired equivalent range, if you want it scaled based on your input, ulp is a good starting point I think
15:56schmeegfredericks: nice, just wanted to check if there was a more idiomatic way
15:56amalloyhiredman: i was hoping nobody would treat my suggestion as having any signifigance at all
15:57justin_smithis that a rimshot I hear in the distance?
15:59halogenandtoastnkozo: would this be more idiomatic? (doseq [card deck] (print-card card))
16:01nkozohalogenandtoast: I think yes
16:01amalloyhalogenandtoast: print-card's implementation doesn't look right at all either. (5 some-vector) is not going to work
16:01halogenandtoastamalloy: yeah fixed it with (println (str (values (card 0)) (suits (card 1))))
16:03amalloyi kinda like (apply str (map get [values suits] card))
16:03halogenandtoastamalloy: that is neat, I don’t use apply enough.
16:13schmeehow do I expand a macro without actually running it?
16:13teslanickWithout running the expanded result?
16:14vermamacroexpand/macroexpand-1/macroexpand-all
16:24sveriHi, I have a vec with maps: [{:foo "f" :bar "baz"}{:foo "f2" :bar "baz2"} ...] and I know the key and value of one map :foo "f", what is the idiomatic way to get the whole map from that vec: {:foo "f" :bar "baz"}?
16:25seangrovebbloom: Had this linked to me on twitter, think you might be interested as well http://lambda-the-ultimate.org/node/5001
16:28justin_smithsveri: (first (filter (comp #(= "f" %) :foo) maps))
16:29sverijustin_smith: thank you, thats similar to what I came up with, I was wondering if there is a shorter way :D
16:33AimHere,(some #(when (= (:foo %) "f") %) [{:a 3} {:foo "g"} {:foo "f" :bar "z"} {:x 1}])
16:33clojurebot{:bar "z", :foo "f"}
16:34arrdemlpvb: no, top level defs are realized when the containing namespace is loaded
16:34AimHeresome (...) looks like better style to me than (first (filter ...)) but there's not much difference in size
16:34gfredericksholy crap these doubles have gotten quite different
16:34gfredericksI gotta multiply the ulp by 32
16:35technomancydouble your refreshment
16:35lpvbarrdem: does that include when it is required by another namespace?
16:37gfrederickss/32/64/
16:38arrdemlpvb: yes, require is a wrapper over load, as is use.
16:39sveriAimHere: thaank you :-)
16:39lpvbso it will just get loaded at application start anyway because eventually require in the main namespace will load the def
16:39lpvbarrdem: right?
16:41arrdemlpvb: at application start, Clojure will load only your entry namespace. In evaluating its (ns) form, it will generate (require) statements which will cause the loading and compilation of other namespace recursively until everything is loaded at which point the rest of the entry namespace will begin to evaluate.
16:42arrdemlpvb: does that make sense?
16:42lpvbsounds like what I just asked o.o
16:42gfredericksanybody know if the transit repos accept PRs?
16:42arrdemlpvb: mod the detail that ns is imperative not declarative.
16:43arrdemgfredericks: they don't appear to... bbloom tried to give dnolen a PR a while back and was turned down.
16:43technomancygfredericks: your a funny guy
16:43lpvbso I guess if I don't want a def to run something at start I should turn it into defn
16:43arrdemlpvb: defn is a macro that reduces to (def .. (fn))
16:43gfrederickstechnomancy: I wasn't sure about the scope of opinions about PRs
16:43arrdemlpvb: using defs for load time side-effects is a no-no
16:44gfrederickstransit-clj has a significant typo in the docstring
16:44lpvbwell I didn't want the side effects and I think it's affecting my application
16:44mi6x3m-alttechnomancy: any combo of run and repl?
16:44lpvbbecause right now I have a bunch of swing components and I think they're being created before my application can configure them
16:45arrdemif you're using defs, then yes they will be created at load time
16:45technomancymi6x3m-alt: what
16:45justin_smithlpvb: make an init function that creates any java class instances
16:45justin_smithlpvb: don't def to them directly
16:45mi6x3m-alttechnomancy: lein run+repl, something that launches the program and runs a repl
16:45gfredericksI'm gonna just try it
16:45lpvbjustin_smith: are you implying to do it indirectly?
16:46justin_smithlpvb: by wrapping class instantiation in an init funciton, you can decide when it happens
16:46lpvbjustin_smith: (def my-frame (init JFrame. args))
16:46technomancymi6x3m-alt: probably best to embed an nrepl server in your -main method
16:46gfredericksany bets about how it gets handled? https://github.com/cognitect/transit-clj/pull/13
16:46justin_smith(def my-frame (atom nil)) (defn init [] (reset! my-frame (init JFrame. args)))
16:47justin_smithlpvb: you want to be able to control when that class is instantiated
16:47lpvbokay
16:47lpvbjustin_smith: another unrelated question, is using reset! safe, even though it doesnt compare the previous value?
16:48mi6x3m-alttechnomancy: thanks :)
16:48technomancymi6x3m-alt: you could make a profile that puts an :injections entry that runs a namespace too and repl in that
16:48justin_smithlpvb: you could use swap! and either return the old value (if not nil) or create a new value - it depends if your initialization is thread safe / guaranteed to only be invoked once
16:49gfrederickswelp that answers that
16:49lpvbjustin_smith: so reset! isn't safe for mutating the atom repeatedly?
16:49technomancygfredericks: we don't "accept" PRs
16:49akhudekhas anyone dealt with permgen leaks? I’m seeing a lot of “Loaded sun.reflect.GeneratedConstructorAccessor121 from __JVM_DefineClass__ “ that never seem to be unloaded. Trying to figure out where to lay the blame here. Could proxy cause these?
16:49gfredericksthey made the change and now alex gets the internet points for it :)
16:49justin_smithlpvb: the pattern I generally use is have an init function in any ns that needs a singleton class instance, and then call the init functions once in my top level ns, (in its one time init function)
16:49gfrederickstechnomancy: this is an exciting new win-win way of engaging the community
16:50justin_smithlpvb: the atom / reset! is an implementation detail, it's not really the core thing here. The important thing is to have an init function that binds any singleton class instance your namespaces use, and to ideally have just one place where that is called
16:51justin_smithlpvb: and you can bind that to a def or a reference type inside a def or whatever makes sense in your code, at runtime
16:51lpvbjustin_smith: yeah I understand the init thing, I'm just confused by reset! separately idk if it's safe to use or not
16:51lpvbin other purposes
16:52akhudekhmm, maybe it was visualvm
16:52gfredericksdoes this mean they don't accept changes at all or do they have a jira somewhere
16:52schmeeis it possible to write a macro so that instead of (with-open [socket (Socket. "localhost" 8888)]
16:52schmee (connect socket user)
16:52schmee) I can write (with-socket (connect socket user))?
16:52schmeegah sorry for multiline
16:53justin_smithlpvb: I only use reset! if I know I won't care about a previous value. In this example it was easier to use reset! but likely you would want a swap! that checks for an old binding and just returns that if you have any suspicion init would be called one too many times
16:53gfredericksoh I see it's in the README
16:54gfredericks"Because transit is incorporated into products and client projects, we prefer to do development internally and are not accepting pull requests or patches."
16:54gfredericksseems fair I guess
16:55gfredericksmight be the kind of situation where a community fork could do okay if needed
16:56lpvbwhy isn't there a function for atoms called set! that regards the current val? seems like indirection to try to mutate an atom with functions only
16:56halogenandtoastIf anyone is interested, here’s a program that deals out 4 poker hands and then prints what the highest hand value they have is (royal flush, straight, etc.): https://gist.github.com/halogenandtoast/1a4cfe9691429f1b0836
16:56halogenandtoastfeedback welcome of course :p
16:56cbplpvb: reset!
16:56lpvbyea but I get the feeling it's unsafe?
16:56cbplpvb: if by regards you mean disregards
16:57gfrederickslpvb: the point is that if you're using reset! from multiple threads it's inherently racey; but if your particular use doesn't care about that then it's fine
16:57lpvbor actually maybe a better question is what's the point of compare-and-set!, what purpose would comparing serve
16:58gfrederickslpvb: what if you were using an atom for a counter
16:58gfredericks,(def request-count (atom 0))
16:58clojurebot#'sandbox/request-count
16:58gfredericks,(swap! request-count inc)
16:58clojurebot1
16:58gfredericks^ you wouldn't want to use reset! for that if there was any concurrent use
16:58cbplpvb: to be thread-safe
16:59gfredericksand (reset! request-count (inc @request-count)) is harder to write anyhow
16:59gfredericksso the "indirection" can often be more straightforward
16:59cbpor uh atomic rather
17:00lpvblet's say the atom represents a random number
17:00lpvb,(def random-num (atom 4))
17:00clojurebot#'sandbox/random-num
17:00arrdemgfredericks: I don't think that's an atomic transaction... which (swap! inc) would be
17:00lpvb,(compare-and-set! @random-num 8)
17:00clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/compare-and-set!>
17:00amalloyjustin_smith: (comp #(= % "f") :foo) is kinda weird - either (comp #{"f"} :foo) or #(= "f" (:foo %)) would make more sense
17:00lpvb,(compare-and-set! @random-num 4 8)
17:00clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.Atom>
17:00lpvberm
17:00gfredericksarrdem: yes that was my point?
17:00lpvb,(compare-and-set! random-num 4 8)
17:00clojurebottrue
17:01lpvbsorry about that
17:01arrdemgfredericks: sorry missed that bit.
17:01lpvbwhy not a function ,(defn set! [atomic new-val] (compare-and-set! atomic @atomic newval))
17:02gfrederickslpvb: if the successive values of a reference are independent of the previous values, then the update function isn't very useful, but there's also limited use for that due to the raceiness
17:02gfrederickslpvb: what's the advantage of that over reset?
17:02lpvbI don't know, compare-and-set! does a compare and reset! doesn't
17:03lpvbbut I fail to see beyond that
17:03gfredericksall that compare does is slow you down
17:03gfredericksno wait
17:03gfredericksI guess it fails to set the value sometimes
17:03gfrederickswhich is a strange thing to want
17:03gfredericks(defn set! "fails if somebody else updates the atom at just the right instant" ...)
17:04lpvboh
17:05lpvbgfredericks: then atoms to me seem like not something you use to replace mutable state, it's purity in disguise
17:06lpvbbecause the current value of the atom is continually fed through a linear chain of functions
17:06lpvbto set the new val of the atom
17:06gfrederickslpvb: it's definitely mutation...but the big idea is having a singular reference to immutable values
17:06amalloywell yeah. that's the point. it's mutable state but without the part where everything explodes if two threads race
17:06gfredericksrather than having a large structure that can have different parts mutated individually
17:07gfrederickslike a generic collection or a classic OO bean thing
17:07lpvbamalloy: well then I've been using it for the wrong purpose :(
17:09gfrederickswhat purpose?
17:10lpvba bunch of reset!'s everywhere trying to use it like a global mutable variable
17:13halogenandtoastIs there any way to make this look more sane? (= 2 (count (filter #(= 2 (count %)) (partition-by first (sort-by first hand)))))
17:14gfrederickslpvb: well it works okay like that if that's what you need; the question is if you actually need that ;-)
17:14gfredericksI think when clojure programmers want a global mutable variable, they use atoms
17:15amalloyhalogenandtoast: you're trying to detect two pair?
17:15halogenandtoastamalloy: yes
17:16amalloy(= [1 2 2] (sort (vals (frequencies (map first hand))))) maybe?
17:17halogenandtoastinteresting… not sure if that is better, but it’s neat to see another solution using frequencies.
17:18halogenandtoastIt’s at least less verbose.
17:21gfredericks(->> hand (map first) frequencies vals sort (= [1 2 2]))
17:24halogenandtoastgfredericks: I’m thinking maybe I should write some function composition instead of the thread-last macro.
17:24amalloygfredericks: blech. it's arguably easier to read as like... (= [1 2 2] (->> (frequencies (map first hand)) (vals) (sort)))), but the fully arrowed version is no fun at all
17:25halogenandtoastI use (partition-by first (sort-by first hand)) in a couple of places so it seems like a good opportunity for composition.
17:25gfredericksamalloy: it's = at the end of arrows that you hate?
17:32amalloygfredericks: no, i just like the important/interesting stuff at the beginning, where it's easy to see, and the boring stuff at the end so you can gloss over it while reading
17:32amalloyhere, we're looking at the frequencies of the first cards, and we want them to be 1 2 2. sorting and calling vals are just details
17:33halogenandtoastamalloy: I kept the original but extracted methods. Now looks like: (= 2 (count (groups-of-size 2 hand)))
17:33amalloy(whereas comparing to [1 2 2], calling frequencies, and mapping first over the hand are all *not* details, but the key point of what we're doing)
17:35gfredericksamalloy: INTERESTING
17:36amalloygfredericks: to me the real value of ->/->> is not reducing nesting, which is pretty boring, but letting you reorder things in an articulate way
17:37hlshipI agree, threading macros make it easy to see the flow
17:37hlshipmuch easier than parsing deeply nested function calls
17:37technomancythey *can* make it easier to see the flow
17:37amalloyhlship: you are saying the opposite of what i just said. which is fine, i guess, but you said "i agree"
17:37technomancyif they're not used indiscriminately
17:38nullptrthreading macros are all fun and games until you need a parallel trystero furcula
17:38hlshipthe flow which is explicit and convinient for the reader is not the flow that is readable for the programmer
17:38hlshipnot for me, anyway
17:44turbofailhm. i actually kind of like having the important stuff at the end
17:44turbofailusually when reading i just assume the stuff at the top is just preliminary setup
17:46turbofailalso if you want to get really silly, you could do (-> (map first hand) frequencies vals frequencies (get 2 0) (= 2))
17:48halogenandtoastI’d like to avoid silly :p
17:49hyPiRionpsh
17:49hyPiRionsilly is what this stuff is for
17:49hyPiRion(-> (map first hand) sort (partition 2 1) (filter (partial apply =)) distinct count (= 2))
17:51hyPiRionThis also returns true if you have three of the same card as well, but I'd argue you technically have two pairs if you have a full house.
17:52halogenandtoasthyPiRion: You could argue you have 3 pairs with a full house as well
17:52halogenandtoast1,1,1,2,2 = (1,1),1,2,2 | 1,(1,1),2,2 | 1,1,1,(2,2)
17:52hyPiRionhalogenandtoast: Sure. And with four cards
17:53amalloyhyPiRion: also you got your silly arrowing wrong: (filter coll f) doesn't work well
17:53hyPiRionamalloy: yeah, I meant ->>
18:09halogenandtoastIs there a thread-first like version of cond with a binding, that may seem strange but I’l lookinf for something like (condx hand royal-flush? “royal flush” staight-flush? “straight flush” etc…)
18:09halogenandtoast*looking.
18:11halogenandtoastOh an advanced condp would work
18:12hyPiRionyeah, condp surprise me with that functionality.
18:12halogenandtoast(condp #(%1 %2) hand …) seems like it would work
18:12danielcomptonIs there a way to name the Clojure applications that show up in Jvisual VM? At the moment they're only distinguished by their PID
18:13amalloyhalogenandtoast: you can also do it like (first (for [[test name] [[royal-flush? "royal flush"] ...] :when (test hand)] name))
18:15amalloycondp is fine here, and probably better, but the pattern of looping over a seq of tests is a useful one to keep in mind
18:16hiredman(but for is not a loop)
18:20amalloyhiredman: funnily enough, neither first nor for is a loop, but using them both together is a lot like looping
18:23halogenandtoastamalloy: Interesting, not sure if I entirely understand it (I’ve found I often don’t understand things in the functional world until I need that solution for the first time, and then it clicks).
18:23halogenandtoastoh nvm I get it now.
18:23halogenandtoastThe bindings threw me off
18:24halogenandtoastamalloy: Does that handle a default case?
18:25halogenandtoastI guess something like [(fn [hand] true) “High card”]
18:25hiredmanamalloy: magic
18:26amalloyhalogenandtoast: right indeed. or use (constantly true). or use (or (first (for ...)) "High card")
18:26halogenandtoastamalloy: oh neet, hadn’t seen constantly yet.
18:27halogenandtoast*neat
18:41johnwalkerhow do you handle edn's tagged literals in clojurescript?
18:42johnwalkeri get errors like "Could not find tag parser"
18:54ahoenigmannHi, I have emacs, cider, lein setup src compiled, and when running tests with C-c C-, I get:
18:54ahoenigmannCompilerException: java.lang.ClassNotFoundException: clojure.test.mode
18:55ahoenigmannin cider-error buffer
18:56johnwalkerahoenigmann: i get that sometimes too
18:56johnwalkerahoenigmann: have you tried restarting cider?
18:56ahoenigmannhow do i do that?
18:56johnwalkerM-x cider-restart
18:56justin_smithlast I heard clojure-test-mode was outdated anyway
18:56johnwalkerit's different
18:57johnwalkeri don't know what the deal is ._.
18:57technomancyjustin_smith: it's undesirable, but its replacement isn't polished.
18:57technomancyslash finished
18:58johnwalkeris cider test using clojure test mode?
18:58johnwalkerno thats not it
18:59ahoenigmannthat worked, but before I ran test i compiled each source and test file
18:59johnwalkerahh, i dont think you need to do each pair
18:59ahoenigmannhow do you do all instead of each?
19:01johnwalkerhave you tried evaluating just one source file
19:01johnwalkerand then doing cider test?
19:01johnwalkerit could just be that the first namespace hasn't been evaluated
19:02johnwalker(speculation)
19:09ahoenigmannhmm I’ll try that next time i restart
19:38danielcomptonWhat's a guy got to do to get a new version of Clojure.java.jmx released? Last release was in Feb 2012
19:39TEttingerdanielcompton: a guy could got to release a new version to clojars
19:40danielcomptonTEttinger: fork it and publish under my own clojars account?
19:40arrdemwhen all else fails fork...
19:41TEttingerif the existing dev isn't working on it, you could maybe get him/her to transfer ownership to your fork
19:41TEttingerI dunno how that works
19:42arrdemAFAIK taking over contrib projects with inactive maintainers is an open question
19:44danielcomptonarrdem: how do you know if a project is contrib or core?
19:45arrdemdanielcompton: if it's in org.clojure/clojure it's in core and it's probably frozen for eternity
19:45arrdemdanielcompton: I can't add anything more useful than checking the source unfortunately.
19:46danielcomptonarrdem: thought that might have been the case.
19:46danielcomptonarrdem: Frozen but not the good one
19:47arrdemheh
19:47technomancyclojurebot: let it go. let it goooooooooooo.
19:47clojurebotGabh mo leithscéal?
19:48danielcomptonarrdem: think I'll vendor the bug fixed function for now and cry myself to sleep tonight
19:49TEttingerlet?
19:49clojurebotlet is creating a local binding in your lexical scope
19:50arrdemidk why yall like this ice wielder... http://imgur.com/SFyQ18g
20:28johnwalkerwow sente is really confusing me
20:28johnwalkerhas anyone used it with tagged edn?
20:29johnwalkerit appears to have zero tests, so it wouldn't surprise me if it were broken for tags
21:00TEttingerthis was posted in #scala , thought it should be mentioned here http://blog.ontoillogical.com/blog/2014/07/28/how-to-take-over-any-java-developer/
21:03technomancydiscussion in lein issue tracker https://github.com/technomancy/leiningen/issues/1604
21:03hiredmanit was sort of a center piece of technomancy's conj talk 2 years ago
21:06hiredman(was two? maybe 1.5)
21:06johnwalkeris there an easy way to strip the tags out of edn?
21:06johnwalkeri'm trying to isolate a bug
21:08TEttingerthe easiest way would be having a copy of clojure's repos on maven central on clojars, no?
21:09taliosrun a local nexus
21:09technomancyyeah, you have to run your own nexus
21:09talioswhich is a wise idea anyway.
21:10technomancydepends on the context
21:10technomancyit's a terrible idea to make it impossible for freelance OSS devs to responsibly develop clojure without setting up a remote server somewhere
21:11talioswell true. but for a company who wants to like, release artifacts to use in multiple projects - they _need_ some repo server somwhere.
21:11technomancynot really true
21:11technomancyyou can use S3 if you don't want to run a server
21:12taliosthats still something serving a "repo" tho.
21:12taliosbut yes
21:12technomancydepends how pedantic you want to be I guess =)
21:13taliosI think I've been podcasting with burngreg to much, the pedantry is wearing off :)
21:16OlegYchisn't sonatype repo mirroring central?
21:23taliosnope - given central feeds from oss.sonatype that would circular.
21:28taliosone work around for the SSL issue would be including SHA1 hashes for each dep to check against. I know buck does that, but there's no way in Maven to (currently) do that. And its quite anal, and prone to breaking if you use version ranges - unless a plugin/mojo used a separate SHA1 verification service (via https ) to build a local index
21:58arrdemor you could just use Namecoin or some equivalent scheme for solving the public key distribution and verification problem then just digitally sign all artifacts rendering this moot... see technomancy's comment on the HN thread about why lein enforces signatures.
21:59taliosdo you have a link to the HN thread?
21:59arrdemhttps://news.ycombinator.com/item?id=8099713
21:59taliosgot it :)
21:59arrdemlolfrontpage
21:59taliostop story :)
21:59arrdemtech is the third comment :P
22:01taliosyep - oss.sonatype.org requires all artifacts to be gpg signed already before syncing. but thats more about who uploaded the artifact, and tracing that.
22:01taliosdoesn't prevent someone uploading infected artifacts which are -also- signed.
22:02taliosbut would go to prevent man in the middles
22:02taliosI should raise this on this weeks Maven Dev Hangout.
22:03taliosthey do have one major problem that clojars doesn't tho. clojars is a tiny tiny repository. central is.... a behemoth. old artifacts remain without signage, and with security holes.
22:04arrdemtalios: ur blag iz down
22:04taliospoop - is twitter still refering to talios.com? try http://www.theoryinpractice.net/
22:04arrdemtalios: your github still links there too
22:04taliosI should put a redirect
22:04taliosdoh
22:04arrdemalso welcome to my bbdb of Clojure users
22:06taliosto be honest I've not actually touched real clojure code in a long time. starting again, mostly since I forked clojure and put an OSGi'ified version in central.
22:08arrdemwhat does having a bundled version of core buy you?
22:08arrdemthe ability to inject a REPL with good JVM interop/introspection?
22:09justin_smitharrdem: I would assume the desire to have OSGi compatible classloader control
22:09taliosmore its an core with OSGi exports, and a support library for looking up/registering services. I just adopted the long abandoned project and brought it up to date with 1.6
22:10taliosI need to find some time to blog about it.
22:10arrdemthis is way more heavyweight Java architecture than I've worked with before so I'll just nod my head...
22:11taliosideally you'd just have a super lite clojure app, but our core main system is all OSGi, and replacing the whole thing would be.... difficult.
22:11justin_smithtalios: so is it true that via OSGi you could have separate classloaders with separate (otherwise conflicting) versions of classes?
22:11taliosyep
22:12taliosmy bundle embeds all the clojure libs, and nothing outside of it can see those classes, they might even have their own version.
22:12justin_smithso you could have a standing naked jvm+clojure left running, and then via some utility have it load the deps in your project.clj for short startup time...
22:13justin_smithtalios: so what would you use this invisible set of clojure libs for?
22:14taliosthey're invisible to the "outside world", not to the bundle using them. so, theres an http service from OSGi that I can hook into to register a servlet, using clojure and clojure libs, but no one else can see any of that.
22:14taliosgives isolation.
22:14taliosimproved release cadence, modularity.
22:14justin_smithahh
22:14justin_smithright
22:15justin_smithso within one jvm running OSGi, you could have multiple clojure projects running, potentially each having their own version of clojure
22:17taliosin theory yes.
22:18taliosI probably wouldn't go that route just for that tho.
22:19justin_smithyeah, seems like a good way to find jvm / osgi bugs
22:19justin_smithand you could just have a vm per project for better isolation
22:53jeremyheiler,{}
22:53clojurebot{}
22:53jeremyheiler,(let [a {}])
22:53clojurebotnil
22:53jeremyheiler,(def a {})
22:53clojurebot#'sandbox/a
22:53jeremyheiler,a
22:53clojurebot{}
22:57literater(-> 1 + + +) = 1, but (apply -> [1 + + +]) is a compilerexception. any way to do what i want? (thread a list of functions?)
22:58gws,((comp + + +) 1)
22:58clojurebot1
22:58gwslike that?
22:59literater,((apply comp [+ + +]) 1)
22:59clojurebot1
22:59literateryes, exactly! thanks (:
22:59clojurebotNo entiendo
22:59gwsyeah!
23:00jeremyheileri have this huge map of clojure data, and when i try to def it with out quoting it, i get this compiler error... what causes this?
23:00jeremyheilerCompilerException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentHashMap
23:00gwsliterater: hard to see in those examples because the fns are the same, but comp applies the fns right-to-left
23:00gws,(doc comp)
23:00clojurebot"([] [f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
23:05gws,(def fail ({:foo "bar"}))
23:05clojurebot#<CompilerException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentHashMap, compiling:(NO_SOURCE_FILE:0:0)>
23:05gwsjeremyheiler: could you be doing something like that? ^
23:05jeremyheilerah, yes, that is likely.
23:06jeremyheilerthe message seems a bit misleading
23:06jeremyheilerbut i get it
23:06TEttingerjeremyheiler, also very large collections can't be constructed as primitives by the JVM
23:07TEttingerI generated this from a spreadsheet and it won't load, or at least won't AOT compile: https://dl.dropboxusercontent.com/u/11914692/weapons-map-too-large.clj
23:07jeremyheileras primitives?
23:07jeremyheilerwhat do you mean
23:07TEttingererr, literals
23:07TEttingersorry
23:07jeremyheilerthanks gws
23:07TEttingeras in with {}
23:08TEttingerthat same map was successfully compiled with...
23:08TEttingerhttps://dl.dropboxusercontent.com/u/11914692/weapons-map.clj
23:08jeremyheilerTEttinger: ah, haha. do you know the max ?
23:09TEttingerinstead of one def with about 7200 items, I did 100 defs with 72 items, then one more def that defined a hashmap of each of the previous defs to a key
23:09justin_smithTEttinger: I am glad yoyo is a key in that map
23:09TEttingeryes.
23:09gwsjeremyheiler: np. i wasn't aware of the large collection limitation either.. The More You Know (tm)
23:11justin_smithTEttinger: http://www.vikingsword.com/vb/attachment.php?attachmentid=264&amp;stc=1
23:12arrdemI mean... it's not large collections it's large literals
23:12TEttingerwhat is that, justin_smith??
23:12lazybotTEttinger: Uh, no. Why would you even ask?
23:12justin_smithTEttinger: a yoyo for hunting with (from the phillipines)
23:12jeremyheilerarrdem: right. so im guessing it's the number of method paramers that is the limitation?
23:12jeremyheilermethid/constructor
23:13TEttingergws, yeah, the final collection was actually larger than the first one. the issue was not params but the size of the JVM instruction
23:13gwsinteresting. thanks
23:14TEttingeryou know how in Java you declare hashmaps element-by-element? myHash.put("key", "value"); or whatever?
23:14TEttingerin clojure it tries to put the whole literal as one statement in the assembled code
23:15arrdemwhich likely blows either single method size or locals count limitations.
23:15TEttingerI had 100 params in one literal with bwtween 70 and 90 literals in each of those, and it encountered a hard limit
23:15TEttingerit works in the repl though
23:15TEttinger(IIRC, this was a while ago)
23:15hiredmanit won't work in the repl with more complex expressions
23:16hiredmanthe repl takes some short cuts in some places that avoids generated bytecode
23:16hiredmanbut any path that results in generating bytecode that ends up having to the embed the literal map in the generated bytecode
23:22hiredmanwhen/if clj-701 is fixed it should be possible to split large literal construction across multiple methods easily, at which point we'll be limited by any class file size limits or method count limits instead of method size limits
23:22technomancywell it sounds like something side-effecty
23:22technomancyso let's go with when
23:22hiredmanof course if you just stick you large literal in a file and read it using the reader instead of trying to send it through the compiler it will work fine already
23:23hiredmanwhich is really what you should be doing anyway
23:23hiredmantechnomancy: hwa
23:24hiredman^- the above fact is why no one who fiddles with the compiler cares much and it is unlikely to be fixed anytime soon
23:25technomancyit was a joke
23:25arrdemcould probably fix it right quick in TEJVM if one so cared, just change -emit-const, but why
23:29talios*yay* SSL will come to central - http://maven-dev.markmail.org/thread/2gtqlgfi4uh6m6wy
23:30taliosor more - come to maven./
23:30taliosand also central
23:30technomancytalios: great news; thanks!
23:31TEttingergreat talios!
23:32taliosI never actually considered that SSL wasn't cheap/free until rather recently.
23:32taliosalso, you needed a physical IP for the host as well to bind to from memory
23:33taliosoh how the interweb has changed
23:33technomancytalios: that's been mitigated in the past few years
23:33technomancyhttps://en.wikipedia.org/wiki/Server_Name_Indication
23:35taliostechnomancy - yes. as Brian mentioned in that email, the CDN situation back in 2012 was quite different tho. and large infrastructure projects take awhile to change
23:36technomancydefinitely; it's a much bigger job, and I don't envy them
23:36taliostho I would have thought something like that should have been upgradable
23:46taliostechnomancy - and now I get pointed to http://docs.codehaus.org/display/MAVEN/Repository+Security - design ideas for improving repository security, but sadly the prototype code didn't go anywhere at the time. Now we have life back in Maven hopefully this may see more movement.