#clojure logs

2015-01-04

00:08chenglou(count (range)) works fine in cljs but explodes in clojure?
00:08chenglou(clojure 1.6.0)
00:09amalloywhat makes you think that, chenglou?
00:09chengloujust tried it
00:10chenglouin cljs it gives me MAX_NUMBER
00:10andyfSounds like Clojure's behavior is closer to what is documented behavior there.
00:10andyfassuming you got infinite loop?
00:10chenglouyeah
00:13chenglouI kinda find it convenient to be able to to (count (drop 100 infinite-seq))
00:13chenglouis that a bad pattern?
00:13rhg135yes
00:14rhg135imnsho
00:14andyfWhy do you find it convenient to count sequences that are not supposed to end?
00:14rhg135^
00:14chengloubecause I don't know whether it's an infinite seq or not when it's passed to me
00:15chenglouand I'd like to do make sure its size is bigger than x, then do something with it
00:16andyfThen maybe try (count (take (inc x) sequence)) and see if it is bigger than x?
00:17chenglouthat works, thanks
00:18rhg135chenglou, relying on what seems like a bug is just bad
00:18andyfThat and creating infinite loops in your code
00:19chengloudidn't know it was a bug actually, now I know. But it seemed kinda intuitive for me that size doesn't have to rely on the fact that you're evaluating your seq
00:19rhg135well, should infinte sequences have a count besides infinity?
00:20chenglouno you're right, but that's what I expected to get
00:20chenglouinfinity, which is MAX_NUMBER here
00:20andyfMost sequences require evaluating them to count them.
00:20rhg135actually it might be a bonafide bug that it returns max_number
00:21rhg135oh im not familiar with js's semantics
00:21chenglouandyf: eh derp, right lol. Alright thanks
00:53amalloyandyf: btw, instead of (>= n (count (take n xs))), instead write (nthnext xs (dec n))
00:54amalloymaybe an off-by-one error in there somewhere, but that's the general idea
04:14didasoftwhat is the usage of mapcat?
04:15luxbockdidasoft: it's the same as (apply concat (map f coll(s)))
04:20amalloydidasoft: see http://stackoverflow.com/a/5236194/625403 for one example usage
04:24didasoftthanks for the example
05:43hellofunkwith Cursive, I'm trying to open an existing project. it says to select an SDK but there are none listed. the Getting Started docs don't mention installing an SDK. how to proceed?
05:48justin_smithhellofunk: by SDK I think hey just mean the jvm installation
05:48expezhellofunk: just install the java 8 sdk using your system's package manager
05:49hellofunkexpez: what is my system's package manager? you mean just download the java installer for OSX?
05:49hellofunkit is worth noting that i already have java of course since i've been using clojure for a while with emacs
05:50expezhellofunk: then you just need to figure out how to point cursive to your existing java installation, installing another one probably won't help
05:51hellofunkexpez: ok, so anyone know where this installation would be located on OS x?
05:51mi6x3m-altany experts on autodoc around? how can I put a link to another function?
05:52mi6x3m-altlike See: (boofoo) ?
05:52expezhellofunk: http://stackoverflow.com/questions/18144660/what-is-path-of-jdk-on-mac tl;dr /usb/libexec/java_home seems likely
05:52expezs/usb/usr/
05:54maaclDoes anyone know of a implementation of zip/next that is breadth first instead of depth first?
05:54hellofunkexpez: thanks.. of course on OS X by default the usr/ dir is not viewable to GUI file browsers in apps like Cursive.
05:55luxbockmaacl: https://gist.github.com/luxbock/4a4cafdcf2522ede6575
05:56expezhellofunk: Cursive is based on intellij so you might have some luck finding out how they solve that. It's likely an equivalent problem. Perhaps just setting the $JAVA_HOME variable is enough for all I know.
05:57maaclluxbock: Yeah, found that one :-) but I am looking for a implementation of zip/next so I can swap back and forth btw depth first and breadth first in my algorithm.
05:57justin_smithhiding something like /usr/ from a file system browser is so weird
05:58maaclluxbock: And thanks for putting it out there, it helped me solve the problem I was having, now I am trying to make it more flexible.
06:07amalloymaacl: i'm not 100% sure, but i don't think a breadth-first zipper makes sense
06:07amalloywith depth-first you're traversing each edge exactly twice, once down and once up. breadth-first you're bouncing all over the tree
06:15maaclamalloy: Well, that would explain why it is not out there, wnd why I cannot wrap my head around how to do it.
06:16amalloyyou can of course traverse a tree in breadth-first order, which is not too hard, but zippers need to do more than that
06:20maaclamalloy: Yeah, I also found your SO answer whic shows it nicely.
06:20amalloyoh?
06:21maaclhttp://stackoverflow.com/a/11426326/53943
06:23maaclamalloy: I assume there is just one amalloy? http://stackoverflow.com/a/11426326/53943
06:23amalloyah, for traversing it. i was pretty sure i didn't have one about doing it with zippers
06:28maaclamalloy: right.
06:35hellofunkupon installing the latest Cider, when i compile a project that previously worked fine, i get this error, any ideas? error in process filter: Symbol's value as variable is void: clojure--prettify-symbols-alist
06:36hellofunkactually the error happens not upon compilation but upon starting the nRepl server
06:36justin_smithhellofunk: that's an elisp error. I think it means you need a newer clojure-mode
06:36justin_smithhellofunk: I have never upgraded cider without seeing problems like that, it is a very unstable abi
06:37justin_smithalso, if you didn't already, be sure to clear out your .elc files too, because those can be compiled against older versions leading to weird errors
06:37hellofunkok, let me try a few things
06:37hellofunkthanks
06:38hellofunkjustin_smith: how do i quickly remove all .elc files that in all dirs in my .emacs.d?
06:39justin_smithhellofunk: you can start with "find . -name *.elc"
06:39justin_smithlikely they will be in a small predictable set of places
06:40hellofunkand clojure-mode should be manually uninstalled then re-installed via packages, it is not something covered by the cider installation itself?
06:41justin_smithhellofunk: I'm not certain. It could be your clojure-mode was updated, but cached elc caused your issue, or it could be that your clojure-mode is out of date.
06:43hellofunkjustin_smith: does emacs require a restart after doing all this?
06:43justin_smithabsolutely, yes
06:44hellofunkok, see ya later
06:47hellofunkok, progress. i can start a repl now. but i get this error: WARNING: CIDER's version (0.8.2) does not match cider-nrepl's version (not installed)
06:47hellofunkso i guess cider also does not manage the cider-nrepl installation?
06:47hellofunki need to uninstall and re-install cider-nrepl?
06:47justin_smithno, that has to be manually updated
06:47justin_smithit's not as much "installing" as asking for the right version in your .lein/profiles.clj
06:48hellofunkand for this emacs ignoramus, should i go to list-packages, delete it from there, and then install again or should i just do a m-x package-install on top of it for cider-nrepl?
06:48justin_smithno, cider-nrepl is a clojure plugin
06:48justin_smith*dep
06:48justin_smithit is not an emacs thing, it just contains things emacs needs
06:49justin_smithso you specify it in your .lein/profiles.clj
06:49hellofunkthere is no profiles.clj in my .lein dir
06:49justin_smiththen you need to make one
06:50hellofunkok, how did i live so long with it, interesting
06:50justin_smithif you never needed universally available deps, it probably never came up
06:51justin_smithquoting the README from cider-nrepl "A minimal profiles.clj for CIDER would be: {:user {:plugins [[cider/cider-nrepl "0.8.2"]]}}"
06:53hellofunkok, so i just create that file, restart repl, trying now
06:54hellofunki must admit the most frustrating aspect to working in Clojure (everythign else is quite nice) is that it mostly requires developers to also be IDE engineers
06:54justin_smithnone of the other IDEs are as bad as cider
06:55hellofunkyou mean light table, cursive, etc
06:55justin_smithI actually gave up on it, I use emacs because I have used emacs for over a decade, but I just run a repl via inferior lisp and fuck the rest of it because it's too much hassle
06:55justin_smithlight table, night code, cursive, fireplace.vim, etc.
06:56hellofunkglad to know it bothers other also. i upgraded because it is supposed to have much improved cljs support
06:56justin_smithcider is the only one that is that much of a mess
06:58hellofunkwow now i'm getting the odd behavior of when i press enter, the line does not auto indent like it used to (when in a clojure form)
06:58justin_smiththere will be a config variable to control that, name probably starts with "clojure-electric..."
06:59hellofunkgreat, so all my configs were reset or something when i upgraded cider?
06:59hellofunkbecause this issue didn't used to be there
06:59justin_smithit probably started using slightly different config variable names for some stuff
06:59justin_smithbecause as mentioned prior, their abi is very unstable
06:59justin_smiththey rename stuff a lot
06:59hellofunki am about to ditch emacs for good right this second.
07:00justin_smithemacs is great, most stuff in the emacs ecosystem is not developed that recklessly
07:00hellofunki would still use emacs for shell, irc, org mode, etc. but editing clojure in emacs is starting to be a time suck
07:19kungihellofunk: what would you use instead for clojure development?
07:21hellofunkkungi: trying Cursive as we speak
07:21hellofunkkungi: it's getting quite popular
07:22kungihellofunk: I heard about it and tried it for a very short time. Then I went back to emacs.
07:22hellofunkTim Baldridge and David Nolen both seem to like it, that's enough for me to give it a serious look
07:23mi6x3m-altI am with CCW
07:23kungihellofunk: I read there is a symbol-renaming refactoring in Cursive have you tried that?
07:24hellofunkkungi: there are quite a lot of refactoring tools built-in and they are increasing in number all the time. but it has other features that are compelling too.
07:31hellofunkjustin_smith: and now i also get this odd message every now in then at my cider repl: nREPL: No response handler with id nil found [2 times]
07:33justin_smithweird
08:24jonathanjis there a more idiomatic way of writing:
08:24jonathanj(defn explode [t]
08:24jonathanj (let [mimes (:mimes t [(:mime t)])]
08:24jonathanj (map (partial assoc (dissoc t :mimes) :mime) mimes)))
08:25KristienI'm having a bit of a pickle with core.async.
08:26KristienIs there a general guideline of when some publishing service should take a channel or create and return one?
08:27KristienI think taking one is more flexible.
08:27KristienEsp. wrt buffering
08:41TimMcjonathanj: Example input/output?
08:47jonathanjTimMc: {:name "Python", :mimes ["text/x-python" "text/x-python-script"]} => ({:name "Python", :mime "text/x-python"} {:name "Python", :mime "text/x-python-script"})
08:56TimMcjonathanj: What other invariants hold? Could there be both :mimes and :mime?
09:02hellofunkwhere does the lein executable typically reside on OS X?
09:03hellofunkis it the same as the lein "script" in /bin ?
09:04scottjhellofunk: likely
09:08jonathanjTimMc: yes, there might be, hence the default value for (:mimes ..)
09:11sovahi everyone
09:12hellofunksova: and hello to you, good tidings and a merry happy new years
09:13sovahellofunk: thank you kind friend, happy new year to you as well (=
09:14sovain learning Ring (ring-clojure/ring), could someone please explain to me how something like (defn app [{:keys [uri]}] {:body (format "you requested %s" uri)}) ... handles/works with the arguments passed to app? the args portion [{:keys [uri]}] is somewhat opaque to me.
09:14hellofunksova: are you familiar with clojure destructuring? is your question a syntax question or a Ring api question?
09:15sovai am a novice, it is a syntax question
09:15hellofunkok, that is destructing, a mini-language of sorts building into clojure to allow you to pull out values from maps and vectors that are passed as args
09:15hellofunkin this case, the uri binding is to the value of the :uri key in the map passed to the app fn
09:16hellofunksova: do a search for clojure destructing and you will get many articles on the syntgax
09:16hellofunksyntax
09:17sovaAhhh. so something like [{:keys [uri scheme query-string]}] would map the corresponding key names to the arguments uri scheme and qs?
09:17weavejes_sova: Here's the official docs on destructuring: http://clojure.org/special_forms#binding-forms
09:17sovayes, i shall, thank you very much (=
09:17sovaoh awesome, you're the best
09:17TimMcjonathanj: cooking, afk
09:32KristienIn (cond x ..., y ...) is it possible to access x and y in ...?
09:33AimHereYou mean the cond analogue of if-let?
09:34KristienYeah.
09:35AimHereDon't think such a thing exists, but it would be a fun little exercise to write a cond-let macro that expands to nested if-lets
09:40mearnshspoilers: https://github.com/clojure/clojure-contrib/blob/b8d2743d3a89e13fc9deb2844ca2167b34aaa9b6/src/main/clojure/clojure/contrib/cond.clj#L18
09:40visofhi guys
09:41sovahey visof, welcome
09:41visof,(re-find #"\(.*\)" "Hello world (x y z)")
09:41clojurebot"(x y z)"
09:42visofwhat is the best way to get results from any string contain substring in this format (word1 word2 word3), i want to get word1, word2 and word3 in local var
09:42visofand the rest of the string to another var
09:43visofi can do this with split and replace methods, but i'm asking if there are better ways to do this
09:43visofi can get the rest of the string using this:
09:44visof,(clojure.string/split (re-find #"\(.*\)" "Hello world (x y z)") #" ")
09:44clojurebot["(x" "y" "z)"]
09:44visof,(clojure.string/split "Hello world (x y z)" #" ")
09:44clojurebot["Hello" "world" "(x" "y" "z)"]
09:44visof,(clojure.string/split "Hello world(x y z)" #" ")
09:44clojurebot["Hello" "world(x" "y" "z)"]
09:45visof,(clojure.string/split "Hello world (x y z)" #"\(.*\)")
09:45clojurebot["Hello world "]
09:46visofis there a better ways to do this ?
09:46KristienAimHere: https://gist.github.com/rightfold/0c49f29105a8d67b93ee
09:50daGrevishello, lispers. how should I call channels (ones from core.async)? {noun}-chan or {verb}-chan? I'm trying to understand how to use them and probs naming would shed some light on it.
09:51daGrevisI have connections-chan now and it actually puts on data listener on that connection when it sees one
09:54mearnshvisof: not claiming this is better, but here's an idea at least https://www.refheap.com/95715
09:54mearnsh(oops unnecessary nested let)
10:11KristienAimHere: never mind
10:11TimMcjonathanj: But a map wouldn't have both :mimes and :mime on it, right? Anyway, nothing comes to mind other than possibly using a for expression instead of a map.
10:19KristienAimHere: never mind the never minding; it's correct :P
10:20sovahehe sounds very zen "nevermind the minding"
10:23Kristiennever mind the gap
10:24KristienNice, now I can access groups from the first matched regex.
10:25sveriHi, what is the return value of a go block?
10:26nuwanda_a channel
10:26sverinuwanda_: even if I did not create one explicitely?
10:27KristienReturns a channel which will receive the result of the body when completed
10:27KristienRTFM :)
10:27sverithe first time I read that in this channel -.-
10:29sverinuwanda_: thank you
10:36expezBronsa: you around?
10:39arkhis there an efficient way to conj the items of a vector onto another vector?
10:40arkhit seems like it grows in time linearly to the number of items being conj'ed
10:41Kristienarkh: I can't imagine concat not being the most efficient way to concatenate two vectors.
10:41KristienOh wait it returns a lazy seq.
10:42arkhthat'd be ok if didn't have O(n) speed
10:43Kristienalso Vim sometimes segfaults iff I work on clojure code aargh
10:43arkhI have vectors I'd like to grow up to N items; maybe what I should do is pre-allocate a vector of size N and then assoc items as I go?
10:44arkhKristien: are you using vim-fireplace?
10:44expezthat would also be O(n), no?
10:44Kristienarkh: nope
10:45arkhexpez: what I have is a loop that starts with a vector of 1 thing, then I want to put another item at the head of the vector, which in total is O(n!) ?
10:46KristienIn Scala you have VectorBuilder which is similar to StringBuilder. Doesn't Clojure have something similar?
10:46arkheach step is linear
10:47arkhKristien: it's not part of clojure.core if there is
10:48mi6x3mwhat do you guys use for testing
10:48mi6x3mwhat can you recommend?
10:48rweiran army of qa people
10:48mi6x3mclojure.test looks good enough to me
10:48expezmi6x3m: clojure.test is good enough
10:48mi6x3mrweir: good call
10:48nuwanda_arkh: wouldn't that be a good use case for transients?
10:51arkhnuwanda_: transients wouldn't help with the time to concatenate/push/etc., unfortunately. What they would do is not retain the intermediate data structures ... I think.
10:53arkhoh neat - there's clojure.rrb-vector which allows concatenation of two vectors in logarithmic time https://github.com/clojure/core.rrb-vector
10:55arkhI still think pre-allocation will be fastest though for my narrow use case
11:16patrkrishi folks! how do people here write functions that can both return a desired value but also an error if some condition is not met? do you throw an exception on error, or do you mostly do something like Go, where multiple values can be returned (the desired value and potentially an error)? maybe a third approach?
11:17hellofunkpatrkris: all of the above, depending on case
11:17hellofunkpersonally i return maps with multiple values all the time
11:17hellofunkone of which is often :error key
11:17arkhpatrkris: in simpler cases, returning nil in the case of some error conditions is commonly done
11:17nuwanda_yeah, I usually return something like [:error something] or [:ok something]
11:20patrkrisokay, thanks. by the way, how do you "return" from functions early, when some error occurs? in imperative languages, you can just return as soon as possible, but I seem to get myself into a let of nested ifs in Clojure
11:21patrkris*a lot of
11:21nuwanda_well, usually functions shouldn't be doing a ton of actions, some of which can create an error, those should be smaller functions (sorry if that seems condescending, I know this can't always be helped)
11:23sveripatrkris: catching execptions is part of the answer
11:24sveripatrkris: as it breaks the flow and returns the last statement of (catch)
11:29patrkrissveri: I thought about exceptions, but somehow it just doesn't feel right as an error reporting mechanism. or maybe I've just gained a distaste for exceptions... :)
11:29patrkrisI mean if the error condition is not exception, it doesn't feel right
11:30patrkriswell, thanks for your answers. later.
11:35hellofunkpatrkris the cond macro lets you return without doing other things
11:45hellofunki'm noticing for the first time that when i save a clj file, it is automatically recompiling any changes without me having to manually do so. is this is a new lein feature? i upgraded to 2.5 earlier
11:46hellofunkor is it something inside chestnut doing this, as i'm using its template for the first time
11:46andyfI am almost certain it is not lein by itself doing that.
11:46hellofunkandyf only ask because lein does this for cljs and wondered if it had somehow added clj to this
11:47andyfThe description of chestnut includes "instant reloading" (I've not used chestnut), so that seems more likely where that feature is implemented.
11:48bolivierre
11:48andyfI frequently use lein 2.5.0 with Clojure/JVM only projects, and there is no auto-reloading on file saves.
11:49hellofunkandyf ahh that's probably it. i've upgraded my whole dev workflow and tools this weekend so don't almost know what is causing a new feature
11:49hellofunks/almost/always
11:56l3dxwhat am I doing wrong? Referred var fressian-cljs.fns/lookup does not exist at line 1 file:/home/thomas/.m2/repository/net/unit8/fressian-cljs/0.1.0/fressian-cljs-0.1.0.jar!/fressian_cljs/reader.cljs
12:00muhukl3dx: can you paste (pastebin, dpaste etc) your code
12:00andyfYeah, a link to a file on your local file system doesn't help us much.
12:02l3dxI was hoping someone had seen that particular error before. I tried googleing it without any luck. the file referred to is deep inside some transient dependency
12:02l3dxbut hang on and I`ll paste some code
12:03l3dxhttps://gist.github.com/tskardal/4c149a1d8a5050b76a06
12:04muhukl3dx: that's odd, this code doesn't refer lookup or fressian.
12:04muhukl3dx: paste the traceback please.
12:07l3dxthe gist is updated
12:14muhukl3dx: weird. Unless I'm missing something... See here's the import https://github.com/kawasima/fressian-cljs/blob/master/src/cljs/fressian_cljs/reader.cljs
12:14muhukl3dx: and there's no lookup in https://github.com/kawasima/fressian-cljs/blob/master/src/cljs/fressian_cljs/fns.cljs
12:15l3dxmuhuk: thanks for looking into it. I'll take some steps back and try to figure out what introduced the problem
12:15l3dxgit stash takes me to a working state at least
12:17muhukl3dx: I think there's a bug in freesian-cljs
12:17muhukl3dx: not in your code.
12:17muhukl3dx: (I might be wrong of course)
12:25dnolen_chenglou: that's definitely a bug in Range, works by accident
12:26dnolen_chenglou: and that won't be truly for many infinite lazy seqs - Range can be bounded so there's some bad arithmetic that makes that work
12:26Glenjamindnolen_: do you know if there's any active work on CinC for clojurescript going on? I'd be keep to pitch in, but I have no idea where to start
12:28andyfGlenjamin: There are the tools.analyzer and tools.analyzer.js libraries. I haven't used tools.analyzer.js yet, but have tested tools.analyzer and tools.analyzer.jvm via my use of them from Eastwood.
12:30andyfIf by CinC you mean "ClojureScript-in-ClojureScript" then I don't know what might be happening in that area.
12:30Glenjamini did, yeah
12:30Glenjaminpresumably there's some crossover
12:32andyfwell, other than that most of tools.analyzer and tools.analyzer.js are likely to be valid ClojureScript code.
12:32dnolen_Glenjamin: https://github.com/clojure/clojurescript/wiki/Bootstrapping-the-Compiler
12:32dnolen_Glenjamin: got sick of answering this so I made a page :)
12:33dnolen_Glenjamin: there's not much left to do
12:34Glenjaminoo, neat
12:37Glenjaminwould a portable tools.reader need to be a fork, or some extension to the existing one that makes it work on cljs + clj ?
12:40Bronsadnolen_: "Native macroexpander - currently we rely on Clojure's" huh? doesn't cljs implement its own macroexpand-1?
12:40dnolen_Glenjamin: needs discussion with Bronsa, whether tools.reader.js is desirable
12:41BronsaGlenjamin: dnolen_ I don't have time to port t.reader to cljs myself but if anybody wants to contribute, I'd rather keep the cljs version along the clj one, a la core.async
12:42Glenjamini can certainly have a go, i do quite a lot of node so the port itself should be easy enough
12:42Glenjamini don't have any exp with making a project run on clj+cljs though
12:43Bronsadnolen_: or did you mean the syntax-quote auto-qualifying thing?
12:43dnolen_Bronsa: oops right, removed that - yes auto-qualitfying
12:43dnolen_Bronsa: though that's handleable by the reader now
12:44Bronsayeah
12:44dnolen_Glenjamin: so even less to do, tools.reader & parameterized source
12:44dnolen_Bronsa: ok k, cool that we can keep cljs stuff in same source tree
12:45Bronsadnolen_: eventually with feature expressions I'd rather have it merged -- most of the platform specific bits in t.reader are just for performance
12:45dnolen_Bronsa: yep
12:50Bronsathere might be some hooks to add to tools.reader to support cljs auto-qualification as I don't want to have t.reader depend on cljs
12:50Bronsa(that could also be problematic for circular deps)
12:56Glenjaminany pointers for starting a tools.reader port? I'm not really sure how to start running under node
12:59dnolen_Glenjamin: Glenjamin you can start by being able to read strings, then worry about reading from urls/disk etc.
13:00jonathanjTimMc: what about the (assoc (dissoc m :key) :new-key value) pattern? seems like there might be somet other way of spelling that
13:01Glenjamindnolen_: it's more the mechanics of getting some code running i'm not clear on
13:01Glenjaminwould the idea be to have cljs namespaces which have the same interfaces as their jvm counterparts?
13:04dnolen_Glenjamin: sorry don't have time to answer these questions - also they are easily answered if you look at portable Clojure libraries
13:04Glenjaminok, cheers
13:04dnolen_Glenjamin: see core.match
13:04Glenjamini'll have a read through
13:05Glenjaminright, this makes sense - should be enough to get started
13:05Glenjaminthanks for the pointers
13:17dnolen_running CLJS REPLs w/o 3rd party runners https://github.com/clojure/clojurescript/wiki/Running-REPLs
13:26dnolen_Bronsa: hrm btw what does the reader return for Ctrl-D? Trying to figure out how to support exit in ClojureScript REPLs on Ctrl-D, I'm assuming this will be read by tools.reader
13:33dnolen_Bronsa: hrm, I suppose we should just read in directly and only invoke the reader when we think we have a form same as clojure.main's REPL ...
13:34justin_smithdnolen_: wouldn't Ctrl-D in a terminal not be a character you handle, but rather a signal you handle?
13:35dnolen_justin_smith: yeah that's what I'm thinking same as the Clojure REPL
13:36Bronsadnolen_: handling Ctrl-D is not really the job of t.reader
13:36dnolen_Bronsa: yep figures as much, was just thrown by the default behavior of CLJS REPLs just to read directly from reader
13:36dnolen_Bronsa: not behavior that I wrote
13:42KristienMy Clojure code works! I'm a heroine.
13:45mpenetcore.async question: is there a way to know if a put! on a channel is queued or not, no matter the channel under the hood (it's user supplied in my case)
13:45mpenetseems not, but I might be wrong
13:46justin_smithmpenet: even if you controlled the channel, the only way to know the ocntents is to remove them
13:46justin_smith*contents
13:47rlbKristien, arkh: another option is to just accumulate the strings, and then (apply str coll).
13:47mpenetI hoped I could avoid this, but well...
13:48Kristienrlb: another option for what?
13:48lasergoatmpenet: you have a callback for when it does go onto the channel
13:48rlbwrt stringbuilder, etc.
13:48KristienAbout the vector concatenation?
13:49justin_smithrlb: they weren't talking about building a string, just using StringBuilder as an analogy
13:49rlbjustin_smith: oh... nevermind
13:50justin_smithfor efficient concatenation, you want a datatype that supports that, either lazy-seq or rrb-trees or finger trees I think?
13:50mpenetlasergoat: I know, but this is not good enough in my case, I need to know when it's queued. I need this to handle backpressure. So if put is queued, suspend reads and resume after put succeeds, hopefully without suspending everytime I try to read first, even tho this could be considered
13:50l3dxmuhuk: I think you're right. Seems to be a problem with the library chord. I get the same error when doing a 'lein cljsbuild once' in its example project
13:51justin_smithmpenet: shouldn't parking behavior with channel put automatically cover this?
13:51mpenetI guess I ll have to dig into the java code I am hooking into and see the implications
13:51l3dxor, maybe not actually with chord, but in my case it was the addition of that library that caused it
13:52mpenetjustin_smith: it's a bounded queue under the hood, so not good enough
13:52the-kennydnolen_: Sorry for tweeting - are you aware that - when waiting for a browser to connect - there's no way to cancel? :cljs/quit (as mentioned) obviously doesn't work, as the repl isn't started yet, and Ctrl-c brings everything into some broken state which is neither a cljs nor a clojure repl
13:52justin_smithmpenet: it will still park if it is waiting on room
13:52the-kenny(I can't even stop the process anymore - I have to kill it)
13:53lasergoatmpenet: i guess i'd ask why you're using put! at all
13:53mpenetjustin_smith: on a go block yes, but it's again a queue under the hood, after 1024 parks it starts loosing data if am not wrong
13:53lasergoatinstead of >! or >!!
13:53justin_smithmpenet: you get to decide whether it's a blocking or dropping queue, blocking is the default
13:53the-kenny(I'm starting a browser-repl from an existing lein-repl. Cider is completely broken, but that's another topic)
13:54mpenetjustin_smith: yeah but fixed/global nb of threads with go blocks, potentially starved easily
13:55justin_smithlasergoat: yeah, good point, shouldhe should use one of those
13:55mpenetjustin_smith: I want to avoid using them in this case
13:55justin_smithparking does not consume a thread from the pool
13:57lasergoatmpenet: >! in a go block = do a put!, monitor the callback, when lands in the queue, resume where you were. it's all done by rewriting your code to use callbacks, so it's not burning threads.
13:57justin_smith(inc lasergoat)
13:57lazybot⇒ 1
13:58lasergoatmpenet: basically, what you're trying to do is exactly what go blocks are designed to do for you
14:06lasergoati have a ring question. i have my server behind an ssl-unwrapping proxy, so all my ring server sees is the http request, plus an X-Forwarded-Proto header. I want to make the redirects generated by ring go to the https address. How should I handle that?
14:07lasergoatfor example, i could ignore it and have the proxy do a second redirect. But ideally, I'd like to have a piece of middleware say "hey, this redirect should be to the https version of this url"
14:07justin_smith{:status 30[x] :body "https://example.com"} as your response
14:08lasergoatright, so i have to know my absolute url
14:08lasergoatwhich is unfortunate
14:08justin_smithit will be in the incoming request
14:09mpenetlasergoat: not really, it doesn't solve anything in this particular case (at least not to the question I asked), using a go block with a "callback" after the action or checking the callback on put! is (nearly) the same, it doesn't let me know before hand if I can try to put in the channel. I have to do some book-keeping myself, which is fine
14:09lasergoatjustin_smith: true enough. i guess i just need a piece of middleware that makes absolutizes the request and then subs in https
14:09lasergoatjustin_smith: ok, thanks, i'll do that
14:10justin_smithmpenet: in a go block, using >! why would you need to do any callback or checking at all?
14:10lasergoatmpenet: what do you want to happen if you can't put! on the channel?
14:10justin_smiththe go block will park, and let go of its thread, until the data is written to the channel
14:11mpenetsuspend reads on a socket, via an ext api
14:12justin_smith(go (suspend-reads) (>! c d) (resume-reads))
14:13justin_smithyou don't need callbacks in core.async
14:13mpenetI don't want to suspend on every inputs... I only want to suspend when parking occurs
14:14AeroNotixWhich is the latest version of CIDER that isn't going to make me crazy?
14:14mpenetanyway, as I said, I can do it without using only core.async api, thx for the suggestions
14:14justin_smithAeroNotix: Mu
14:14AeroNotixI'm on 0.8.0-snapshot apparently.
14:15hellofunkAeroNotix: my experiences with a Cider upgrade today made me sit down and spend the rest of the day on Cursive instead
14:15AeroNotixhellofunk: put your .emacs.d in VCS, install latest => check it out => decide to keep?
14:15AeroNotixnot a whole-day thing :)
14:17justin_smithAeroNotix: so you are putting compiled files into version control?
14:17AeroNotixjustin_smith: just the .el files
14:17mpenetjustin_smith: btw using (suspend) (put! c x (fn [] (resume))) would be the same, without requiring all the magic of go blocks, but again this is not what I was looking for
14:18justin_smithAeroNotix: elc files can fuck your shit up if they aren't in sync, and the package code generates them
14:18AeroNotixjustin_smith: yes, which is why I never use elc files if I can help it.
14:20the-kennyFor the record: There's `load-prefer-newer' in emacs24 which should get rid of most mess caused by outdated elc files
14:21AeroNotixthe-kenny: or just, y'know, don't use elc files at all.
14:21AeroNotixif you're a serious emacs user and you're not using emacs --daemon, you're doinitwrong
14:23Jaooduntil it freezs and crashes
14:23AeroNotixsystemctl --user restart emacs
14:23AeroNotixdone :)
14:23the-kenny(systemd debate incoming)
14:23AeroNotixyou can easily do the same with other init systems
14:24the-kennyI know, I'm just joking
14:24AeroNotixmy point was that using emacs --daemon really is the way to go
14:24JaoodAeroNotix: does that sends a HUP?
14:24justin_smiththe-kenny: proposed: systemd is the cider of init systems
14:24AeroNotixjustin_smith: denied
14:24the-kennyjustin_smith: I actually enjoy systemd. But I don't have that much contact with it by using NixOS.
14:24AeroNotixJaood: no, the way I've got it set up it just kills the pid
14:28dnolen_the-kenny: hrm, probably need to listen for kill even booting - someone should submit a patch for that - too many other things in my own queue
14:29dnolen_the-kenny: there's going to be quite a bit of REPL churn for a couple of week, things have been subpar for far too long as most of the changes are bringing all official CLJS REPLs into parity with Clojure's REPL
14:29the-kennydnolen_: yup, I'm aware of that. And I agree it's the right direction. I really like the startup time
14:30dnolen_the-kenny: http://dev.clojure.org/jira/browse/CLJS-961
14:31dnolen_the-kenny: the same, it's funny how 30 second startup time causes people to not use it
14:32the-kennyI am happily using weasel right now - I just connect two sessions via cider and have one running a clojure and one a clojurescript repl. Weasel has some quirks though
14:34lasergoatjustin_smith: better answer to my proxy question turned out to be using this: https://ring-clojure.github.io/ring-headers/ring.middleware.proxy-headers.html, which is a middleware that uses the address the proxy adds to the headers, and makes it so when i absolutize the url it just incorporates https automatically
14:34dnolen_the-kenny: yeah, the recent changes should hopefully help eliminate those - Weasel is very simple
14:34dnolen_the-kenny: in fact people should examine the Node.js REPL and submit a PR to Weasel, mfikes may already be working on that?
14:34the-kennyI think there's an WIP fork, yeah
14:35lasergoatmy biggest issue with weasel is that it can only do one session at a time
14:35the-kennyhu?
14:35lasergoator so it seemed, anyway
14:36lasergoati got some pretty weird behavior connecting more than one JS environment to it
14:37justin_smithlasergoat: cool, I did not know about that particular middleware
14:40lasergoatjustin_smith: took me a bit to realize the proxy's job was to tag the request appropriately and the server's job to use that info. until i understood that i didn't know to look for it
14:41dnolen_lasergoat: that only really makes sense if all the connecting sessions represent the same build - the analysis environment needs to match
14:42the-kennydnolen_: for my understanding: A running REPL will continuously check the 'current' analysis environment, right? E.g. Changing a file, reloading the browser, then evaluating stuff in the repl will work fine, right?
14:43dnolen_the-kenny: that's right, REPL can now always match the state of the build efficiently
14:43dnolen_the-kenny: the whole point of analysis caching
14:43dnolen_keeping everything in sync always
14:43the-kennyPerfect :)
14:44the-kennyNow we just need a way to read the current :output-dir from profile.clj instead of hardcoding it ;) (which isn't pretty hard, I know)
14:44dnolen_the-kenny: this is the reason Node.js REPL can boot in <1s on my work machine
14:44the-kennyohhhh I need to try that
14:44dnolen_it doesn't actually do anything except read some EDN
14:44the-kennyI just tried the browser-repl
14:44lasergoatdnolen_: my particular use case is a browser extension that has a "background" and "content" script. right now, i launch separate repls run weasel on a different port on each
14:46lasergoatdnolen_: i guess the right thing for me to do is have one build and just a thin JS wrapper that calls into different externs in the same CLJS build
14:47lasergoatdnolen_: if I did that, maybe i could get multiple connections to work
14:47dnolen_lasergoat: or just write your own tiny bit of code that launches two weasel REPLs
14:47dnolen_people need to start looking out how all this stuff actually works :)
14:47dnolen_https://github.com/clojure/clojurescript/wiki/Running-REPLs
14:47gfixlerFailed to download https://leiningen.s3.amazonaws.com/downloads/leiningen-2.3.4-standalone.jar
14:48muhukl3dx: good luck. I'd take a closer look at those 2 files in fressian-cljs first and file a bug report there.
14:48gfixler403 forbidden - anyone know what this is about?
14:48lasergoatdnolen_: yeah, i didn't realize that would work
14:48muhukl3dx: perhaps also create a minimal module to reproduce the issue.
14:49the-kennygfixler: 2.3.4 is quite old - it might be that the jar isn't hosted on aws anymore (given that new jars are hosted on github)
14:50gfixlerthe-kenny: where is that version specified?
14:50gfixlerI just grabbed the lein script from the lein site, ran it, and tried lein repl
14:51the-kennyhttps://github.com/technomancy/leiningen/releases
14:51l3dxmuhuk: I'm completely unfamiliar with that lib. I only use it as a transient dependency. However, I've reported an issue at the library I'm actually using. The example project there doesn't compile either
14:51the-kennygfixler: That's a bit strange. The current lein script definitely fetches 2.5.0
14:52gfixlermaybe I just need to delete my .lein folder
14:52gfixlerI upgraded recently, this is my first attempt to fire up lein again
14:52the-kennyalso check $PATH
14:52the-kennymight be you have a system installed lein somewhere which overrides the downloaded
14:53gfixlerstrange - my ~/.lein folder only has self-installs/leiningen-2.5.0-standalone.jar in it
14:54the-kennythat really sounds like it's using a lein installed by your package manager or something
14:54gfixlerhow strange - I don't recall setting up lein or clojure since reinstalling my OS a few weeks ago
14:55gfixleraah, I think I see
14:55gfixlerit's my .dotfiles, which are versioned
14:56gfixleryeah, that was it - I had an old lein in ~/.dotfiles/scripts - unversioned, but I dumped scripts back in there from a thumbdrive
14:57gfixlermoved it, and now lein repl works
14:57gfixlerthanks, the-kenny!
14:57the-kennyyou're welcome
14:57gfixlerfor posterity, I found that out with `whereis lein` => ~/.dotfiles/scripts/lein
15:00justin_smithgfixler: funny - "whereis lein" returns nothing of interested for me, but "which lein" shows its location
15:00gfixlerjustin_smith: hmmm, different distros, perhaps?
15:02justin_smithgfixler: "BUGS ... whereis has a hard-coded path, so may not always find what you are looking for"
15:02justin_smith(debian based system)
15:02gfixlerjustin_smith: same
15:03gfixlerwhich lein => /home/gfixler/scripts/lein; whereis lein => lein: /home/gfixler/.dotfiles/scripts/lein
15:04gfixlerlooks like whereis follows the scripts directory symlink
15:15augustlanything built-in to get the ex-info out of an exception where the actual IExceptionInfo exception is in the causedBy chain?
15:17andyfaugustl: Not in core that I?m aware of
15:17augustltime to find a way to create a lazy seq out of the chain then :)
15:18andyf(take-while identity (iterate some-fn exc)) might work
15:21augustljust (iterate #(.getCause e) e) could work too?
15:21augustlor will it fail when it gets the first null cause?
15:24andyfaugustl: Try and see :) If so, the take-while identity can help
15:25augustlah, right, that's what that's for
15:27mi6x3mClojure, how come 'lein test' is not counting executed tests when they are executed on another thread
15:28augustl(defn get-caused-exceptions-chain [^Exception e] (if (nil? e) nil (cons e (lazy-seq (get-caused-exceptions-chain (.getCause e)))))) works
15:28augustlthe chain is typically not that long though so making it lazy is a bit silly
15:30andyfmi6x3m: Just a guess: the counts are maintained in some dynamic var that gets its own value in other threads?
15:31irctcQUESTION: CODE: (def men (db [man 'Bob][man 'John])) ---> How can I add a new value to db? tried merge and "->". Its a syntax question. Please help me.
15:31mi6x3mandyf: very possible
15:31mi6x3mthis ain't good though
15:34andyfLook at function clojure.test/test-ns, which does a binding on dynamic var *report-counters*. That may be the root cause.
15:35andyfThere might be a way to pass that on to other threads using bound-fn
15:36hellofunkhow can you select a block of code and auto-indent all the lines appropriately, in Cursive?
15:37mi6x3mandyf: yes found report-counters also
15:38mi6x3mandyf: can you suggest some way of influencing that?
15:40andyfmi6x3m: How are you creating mutliple threads in your test suite?
15:41justin_smithirctc: what does that db call return?
15:43irctcjustin_smith: says it is a PersistentArrayMap :(
15:43mi6x3mandyf: I am running tests on the AWT event dispatching thread
15:43mi6x3mbecause I have to
15:44justin_smithirctc: OK, than try (conj men [man 'Tod])
15:44justin_smithirctc: or (assoc men man 'Todd)
15:46andyfmi6x3m: I haven't done that before, but if you can somehow pass a function to that AWT thread for execution using bound-fn, such a function should have the same dynamic vars bound as the thread where bound-fn is called.
15:56mi6x3mandyf: didn't quite get that :) but anyhow, this should be somewhat easier
15:58augustlI get an error with :source-paths and :java-source-paths. Seems my clojure code is complied first so I get a "java.lang.ClassNotFoundException" because it doesn't seem to have compile the java code when it tries to compile the clojure code
15:58augustlI'm trying to implement my own custom exception class
15:59mearnshaugustl: try adding it to :aot in your profile.clj
15:59augustlmearnsh: it being the java class?
16:00mi6x3mandyf: I might as well just define a macro deftest-awt which executes the test through invoke-now
16:00mearnshaugustl: the namespace
16:01augustlmearnsh: hmm, that didn't help
16:01mearnshlein compile
16:01augustlmearnsh: same problem
16:02augustlhmm, code that refres to my java class is referred to in a clojure ns with (:gen-class)
16:02augustlperhaps that's the problem
16:03mearnshis the java class the exception you're extending?
16:05augustlmearnsh: yep
16:06mearnsh:gen-class is fine
16:07mearnshyou could try calling compile on the ns
16:08augustleven "lein javac" failed with that error
16:31muhukShould I just use hash-map here? Or does it make sense to try making a map literal? {~@(mapcat #(vector (keyword %) %) params)}
16:31muhukIt fails saying map literal must have even number of args.
16:31justin_smithI wouldn't even call that a literal
16:31justin_smithsince the whole thing is generated
16:32justin_smithapply hash-map, or use into
16:32justin_smithor, I should say - it has none of the advantages of using a literal
16:32andyfPretty sure that ~@ cannot be used that way to make maps.
16:32justin_smithso why hold on to the annoying part
16:34muhukyeah, I'll just use hash-map
16:35justin_smith&`{~@[:a 0] ~@[:b 1]} ;; there is *this* sort of monstrosity
16:35lazybot⇒ {:b 1, :a 0}
16:35justin_smithbut that's messed up
16:35andyfSave that for the International Obfuscated Clojure Code Contest
16:35justin_smithyeah, seriously
16:36justin_smithalso it only works if you have an even number of ~@[...] blocks in the {}
16:37justin_smith&`{~@[:a 0 :b] ~@[1 :c 2]} ;; wow, I found a way to make it even worse
16:37lazybot⇒ {:c 2, :b 1, :a 0}
16:38hellofunkjustin_smith: lol
16:44TimMcandyf: You just need to add a ~@[] to balance things out as necessary.
16:44andyfFor the IOCCC, yes :)
16:44TimMc&`{~@(range 4) ~@[]}
16:44lazybot⇒ {0 1, 2 3}
16:44justin_smithoh, good point
16:44TimMc(inc hyPiRion) ;; for that one
16:44lazybot⇒ 59
16:45justin_smithwe should name ~@[] "sperm whale"
17:07hyPiRionThat's how to implement hash-map in swearjure
17:07hyPiRion(def hash-map #([`{~@%& ~@()}](+)))
17:10zophyis somebody going to ban hyPiRion ?
17:10justin_smith? why would they?
17:11zophyi think he's a radical
17:11hyPiRionburn the witch with the crazy non-alphanumeric solutions
17:21hellofunkhyPiRion: what is the point of the (+)
17:24hyPiRionhellofunk: ##({:foo :bar}) isn't legal because you cannot call a map with itself
17:24lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap
17:24hyPiRionso ##([{:foo :bar}](+)) is just a way of getting around that, so we can return the map itself
17:24lazybot⇒ {:foo :bar}
17:24justin_smith&(#([{:a 0}] 0))
17:24lazybot⇒ {:a 0}
17:25justin_smith(slightly less obfuscated)
17:25hyPiRionand (+) is 0 so it'll return the first argument to the list [...]
17:25hellofunkah, ok. cryptic.
17:25ddimahyPiRion: thanks, inspired me to dig up your post, trying to find out how that works ;)
17:25hellofunkreminds me of swearjure
17:29justin_smithbecause it is
17:30ddimahyPiRion: haven't encountered that yet, but it almost begs for some platform like bash/perl/vimgolf ;)
17:43TimMc~swearjure
17:43clojurebotthere is no do
17:44TimMc...
17:44TimMc~swearjure
17:44clojurebotthere is no do
17:44TimMcI... see.
17:44TimMchellofunk: http://www.hypirion.com/musings/swearjure
18:17irctcany namespace and symbols guru please PM me )
18:17mi6x3mdoes anyone know of a larger library using midje?
18:17Bronsairctc: please ask your question in channel if you want an answer
18:18hyPiRionddima: yeah, it does. There is http://maurits.wordpress.com/2014/12/29/the-international-obfuscated-clojure-coding-contest/ though, hoping it will get some traction
18:18ddimathanks :)
18:18irctci have a foo symbol as function and macro parameter all over my code. i need to replace it with "foo" (a variable). how can i do it?
18:19irctci mean i need this symbol to be able to change it's name dynamicaly
18:19irctcall combinations of name(symbol(resolve(whatever are tryied
18:20irctcif clojure is a dynamic language than how can i?
18:20AeroNotixirctc: show example code
18:20dweavewhy do u need to do this
18:22irctc(db-rel likes x y)
18:22irctc(def facts
18:22irctc(db-fact likes 'Bob 'Mary)
18:22irctc(db-fact likes 'John 'Lucy))
18:23irctcit's a core.logic library. i need this likes to be "likes" (dynamicaly changable variable, not hardcoded)
18:23AeroNotixirctc: use a paste service, like refheap
18:24AeroNotixnow show the macro db-fact
18:24AeroNotix,doc resolve
18:24clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0:0)>
18:24AeroNotixffs
18:24irctchttps://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/pldb.clj#L79
18:24AeroNotixoh right, it's not your code. Well, the macro author needs to do that
18:24justin_smithAeroNotix: db-fact is from core.logic, it is a macro that expands to a def form
18:24AeroNotixyou can't do it from your code
18:25AeroNotixbecause macros
18:25justin_smithAeroNotix: he can, it just requires using yet another macro
18:25AeroNotixjustin_smith: yeah?
18:25AeroNotixoh right yeah if you want to wrap db-fact
18:25AeroNotixbut, blegh
18:25justin_smithjust the same way core.logic used db-fact to wrap def, yeah
18:25justin_smithyeah, it sucks
18:25irctccan anybody provide a working code? i tryied everything
18:26trptcolinthat link doesn't look like a macro to me
18:26trptcolindb-rel looks like one
18:26AeroNotixah you're right
18:26irctcguys it's all about namespace is'nt it? just need to make clojure to treat "likes" = likes
18:27justin_smithtrptcolin: yeah, you're right- I was communicating with irctc about this early and failed to notice this was a different function this time
18:27AeroNotixirctc: what exactly is the error you're getting (remember use a paste service)
18:27AeroNotixAlso, no-one is just going to drop working code into your lap.
18:27irctcit's sad because it's a syntax question
18:28AeroNotixNot by the way you've phrased the question, no.
18:28AeroNotixHence me asking for example code and error output
18:28irctcin any dynamic language including javascript or php you can access anything by value
18:28AeroNotixSo we can see what is really going on, sans your diagnosis
18:28AeroNotixsigh
18:28Bronsairctc: what you're saying doesn't make much sense
18:28AeroNotixwhatever
18:29irctci mean is there any way in closure to create something with name as a string variable and then call it by this name all over the code?
18:29trptcolinin general, if you need something dynamic, don't use a macro. db-rel is a macro and acts on the *code* that's given to it to def that thing. you cannot change that first argument to db-rel at runtime.
18:29irctc*in clojure
18:30AeroNotixirctc: Probably there's a way to do that. But that's probably not the solution to the problem you're trying to solve.
18:30trptcolinas i think bbloom would say, sure: just use eval.
18:30AeroNotixlol, yeah. Just use eval.
18:30AeroNotixThe worse code out there, the better. More work for me.
18:32dweaveirctc maybe give a small example in js or something of what you are trying to do
18:32dweavesounds like no one knows what ur asking
18:33AeroNotixExactly.
18:33dweaveis he looking for dynamic scope or something?
18:33AeroNotixirctc is just assuming the same solution as they'd use in inferior languages.
18:33AeroNotixdweave: don't start with dynamic scope just yet :)
18:33dweaveok
18:33irctca dynamic scope yes )
18:34AeroNotixsigh
18:34AeroNotixdweave: see
18:34dweavedamnit
18:34dweavesorry
18:34irctcsomething like var xxx='myname'; and then call window[xxx]
18:34ticking_no I think he's asking for variable resolve by sting
18:34dweavewomp
18:34clojurebotIt's greek to me.
18:35irctci mean i have a symbol. but i need it not to be hardcoded but dynamic
18:35dweaveirctc that pattern is one of JS’s biggest problems
18:35dweaveprobably don’t want to reproduce that
18:36irctcok. what if i have an array of billion of string. and i want to call (db-rel onevalue x y)
18:36dweavewhat is dynamic about xxx=‘mayname’
18:36irctci must copypaste billion strings?
18:36AeroNotixwhat
18:36trptcolinyou don't want one billion vars to be def'ed
18:36dweaveumm please don’t
18:36AeroNotixirctc: do you want a map?
18:37dweaveAeroNotix yeah sounds like map
18:37ticking_I think the main confusion comes from namespaces vs maps vs js objects
18:37ticking_yeah
18:37irctci want to call (db-rel with changeable, not a hardcoded parameter
18:37AeroNotix(def some-map {"likes" var-of-some-db})
18:37trptcolinyou'll have wrap it in a macro, like justin_smith said. macros are contagious like that.
18:37AeroNotix(db-rel (some-map "likes") 'Bill 'Ted)
18:38AeroNotixdb-rel isn't a macro, so the above should work.
18:38trptcolinhttps://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/pldb.clj#L48
18:38ticking_irctc: db-rel from core.logic?
18:38irctcticking_ yes
18:38justin_smithAeroNotix: db-rel is a macro, db-fact isn't
18:38AeroNotixjustin_smith: right, I was confused here.
18:39AeroNotixirctc: use another macro, then in that, use resolve and expand to the original db-rel call.
18:39ticking_irctc: db-rel defines a db relation, is that really what you want to do or do you want do define elements of the relations?
18:39ticking_AeroNotix: he will create billions of vars then because db-rel is just a wrapper around def
18:40AeroNotixnie moj cyrk, nie moj malpy
18:40irctcticking_ i want to define elements relations but i don't want this relation name to be hardcoded (likes) but to be dynamic ("likes")
18:44AeroNotixirctc: how many different relation names do you want to use?
18:45dweaveis pldb in memory?
18:48justin_smithdweave: yeah - and you think that the pldb namespace would at least have one docstring to that effect
18:48justin_smithlow hanging fruit as a contribution I guess
18:48dweaveyeah
18:49dweaveoh wells
18:49ticking_I acrually find irctc's problem interesting, because I don't see immediately how to solve it
18:49ticking_it boils down to: make a def based on a string instead of symbol
18:50AeroNotixticking_: easy, wrap a macro, call symbol on the string.
18:50AeroNotixIf you want the string under a var, resolve it first.
18:52irctcthis macro is not an only placed where it is called
18:52irctca universal solution is required so clojure can know what symbol is wanted
18:52AeroNotixhttps://gist.github.com/AeroNotix/9b12798577d437cc4937
18:52AeroNotixfor the simplest cae
18:52AeroNotixcase
18:53ticking_AeroNotix: no you need a vanilla def
18:53ticking_(def (sm "foo") 1)
18:53ticking_irctc: I'd really check out a datomic database if you have the time
18:53AeroNotixticking_: why do you need a vanilla def?
18:54ticking_AeroNotix: irctc wants to use it on core.logic db-rel and that is already a macro wrapping a def
18:54AeroNotixticking_: you need another macro above db-rel
18:54justin_smithticking_: not really applicable here, but you can use intern for that
18:54irctcis there any way to just refer to a value by dynamic name not carrying where it is used in macro, functions or whatever? :-(
18:54justin_smith&(intern *ns* (symbol "foo") 42)
18:54lazybotjava.lang.SecurityException: You tripped the alarm! intern is bad!
18:55justin_smith,(intern *ns* (symbol "foo") 42)
18:55clojurebot#'sandbox/foo
18:55justin_smith,foo
18:55clojurebot42
18:55AeroNotixirctc: ticking_ https://gist.github.com/AeroNotix/f04ca13a2df8aa30c176
18:55ticking_what irctc wants is to use core.logic as a solver in his/her app and then let the user define additional relations
18:56AeroNotixticking_: so eval, then
18:56AeroNotix:)
18:57irctcwhen i use eval then there are namespace problems
18:57AeroNotix(I was kidding with eval)
18:57irctcon other defs inside eval
18:57AeroNotixirctc: are the relations known at compile time?
18:58irctcAeroNotix they aren't :(
18:58irctcAeroNotix i need to make those relation names dynamic
18:58ticking__sorry what did I miss?
18:58AeroNotixticking_ https://gist.github.com/AeroNotix/f04ca13a2df8aa30c176
18:58AeroNotixI sent you that
19:01AeroNotixjustin_smith: looking at db-rel, couldn't it create kname at runtime? https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/pldb.clj#L67
19:01ticking__AeroNotix: wow, this is really confusing, I'm struggling to get what happens at compile time and what at runtime
19:02AeroNotixticking__: enjoy
19:02justin_smithAeroNotix: like, hypothetically, if you rewrote it to do so? yeah probably
19:03AeroNotixhaha
19:03AeroNotixIt's 1am, I'm not explaining things correctly.
19:03ticking__irctc: how much logic solving do you actually need?
19:03irctcticking__ tones of
19:03BronsaAeroNotix: where are you from? we're in the same time zone
19:03justin_smithAeroNotix: as it is, of course, the kname is calculated when the macro is expanded and that's that
19:03irctcticking__ other libs are not an option
19:03ticking__irctc: why not?
19:04AeroNotixBronsa: .pl
19:04ticking__Bronsa, AeroNotix: me too
19:04ticking__Bronsa AeroNotix: ger currently in spain :D
19:04BronsaAeroNotix: italy here
19:04irctcticking__ i prefer to use a top rated solutions
19:05ticking__irctc: lol wat
19:06ticking__irctc: your solution is not "top rate" when 4 experienced clojure people strugle to wrap their head around the way want to abuse the library :P
19:06irctcticking__ LOL))))
19:06AeroNotixI think I'd either hack something with eval or not use this macro at all. You can extract the essence of what db-rel is doing into a runtime function
19:07ticking__irctc: and Datomic/Datascript _are_ "top rate" especially datomic
19:07ticking__irctc: Datomic is the project rich hickey build with clojure
19:07ticking__irctc: you won't get more top than that
19:08ticking__irctc: so how much time constraint do you have, do you write an open source project, if not, what is your budget? and how much logic programming do you actually need
19:08AeroNotixthe real questions^
19:09irctci am just learning clojure and logic programming for now
19:09ticking__AeroNotix: I'm still confused, the resolve _should_ happen at runtime since the let is runtime, but the ~ should happen at compile time right?
19:09ticking__irctc: so no client project?
19:10irctcjust tryied to change a single line in example hello wolrd and now see it is impossible )
19:10justin_smithticking__ the let in db-rel happens when the macro is expanded, not at runtime
19:10ticking__irctc: not impossible just hard
19:10AeroNotixticking__: the resolve happens at macro expansion time, though
19:11ticking__justin_smith AeroNotix: really?, but couldn't the let contain arbitrary code? or would the resolve fail then? or would it fire-missiles! at compile time and just use the value of that?
19:12ticking__irctc: there is a reason this is hard, you are misusing the library
19:12justin_smithticking__: arbitrary code that gets run when the form is created via macro-expansion, and does not get run again when the actual args are visible
19:13ticking__justin_smith: so how would the compiler react if I turned the let into a fn?
19:13ticking__throw an error because resolve doesn't work?
19:13irctcticking__ you mean i can't use dynamic names of relations (only hardcoded) in a #1 world among-all-languages logic library (according to github stars)?
19:14ticking__irctc: you can't do the same in prolog
19:14justin_smithirctc: you can, and it will be ugly, because it was not designed to work that way
19:14ticking__which is a #1 logic language among all languages according to world leading experts
19:14AeroNotixticking__: the let thing was a troll.. sorry about that :S
19:14ticking__(inc justin_smith)
19:14lazybot⇒ 164
19:14AeroNotixI was messing with peeps
19:16ticking__AeroNotix: throws a null pointer when used also
19:16AeroNotixticking__: yes :)
19:16AeroNotixthe example looks like it works because of the names used
19:16justin_smithirctc: with datomic you can create schema relations or add facts in any order you like, and there is little macro usage, it all uses vanilla data structures.
19:16ticking__AeroNotix: you almost broke my head in two
19:17AeroNotixticking__: haha, sorry
19:17ticking__AeroNotix: Any idea if this can actually work without eval?
19:17ticking__AeroNotix: no right? because it would require a macro-expansion step at runtime which can only happen at compile time a.k.a eval
19:17AeroNotixticking__: right
19:18irctcticking__ justin_smith datomic seems to be a better option... i was wrong
19:18AeroNotixyou can do some level of expansion at runtime, to get vars. Which is sometimes as-good-as
19:20justin_smithyou could hypothetically use intern instead of def in a redefinition of index-for-query that is a function rather than a macro. The tricky part I guess would be making sure things didn't break things by not having the metadata that def adds to the var. That and the ugly fact that you would be basically copy-paste rewriting the original function.
19:20justin_smithwait
19:20justin_smiths/index-for-query/db-rel
19:21irctcguys thanks for your help, it really made me understand that core.logic or prolog are not maid for in-memory-dynamic-things, only pre-coded
19:21ticking__irctc: yeah, logic programming is not really database stugg
19:21ticking__irctc: but having said that
19:22irctcticking__ i'll go with datomic
19:22ticking__irctc: the reason db-rel doesn't work for you that well is because it was written with that static context in ming
19:22ticking__mind
19:22irctcticking__ i will need to store data statically somewhere anyway
19:22ticking__I vaguely think and guess that you could do what you want to do by doing the following
19:24ticking__irctc: ah no sorry discovered that what I tried to do causes weird stuff to happen sorry :(
19:27ticking__irctc: yeah core.logic pldb is really tailored towards programmer level stuff, they even use the namespace and variable name and pass it around
19:28ticking__irctc: but tbh the pldb is something people don't use that much with core.logic it is really great at solving logic problems but not good as a database, so go with datomic and you'll enjoy it :D
19:28arrdemticking__: it's not a bad poor man's datomic :P
19:29ticking__arrdem: unless you want to dynamically expand the database as we've seen in the last hour :P
19:33irctcok, my next question: how to treat Datomic like a Visual Foxpro database using WindowsXP build-in VBScript shell?
19:34irctc(a joke)
19:34ticking__urgggggh
19:34ticking__what is visual foxpro
19:34arrdemI was really worried there for a minute
19:34arrdemnot gonna lie
19:34ticking__yeah me too
19:35justin_smithhand was hovering over the /ignore button, not gonna lie
19:35arrdemlol
19:35irctc))
19:35ticking__my eyebrows basically formed a solid monobrow and they are normaly rather apart
19:35arrdemthe disapproval is strong with this chan
19:35ticking__(inc arrdem)
19:35lazybot⇒ 41
19:36arrdemokay so who thinks that reader discard is a feature worth preserving in a new lisp
19:37ticking__arrdem: I think discarding the reader is a worthy feature
19:37arrdemticking__: groan
19:37ticking__:P
19:38ticking__I still think that pretification should be done by the editor :P
19:39ticking__but aside, with all these new clojure like languages popping up I wonder if there shouldn't be a clojure.kernel
19:39arrdemcljs.core isn't half bad
19:40ticking__arrdem yeah but to have a basic set of functions or protocols and datastructures that the implementor has to provide to get a full albeit slow clojure.core
19:40TimMcarrdem: #_ ?
19:40ticking__arrdem: like core.matrix does
19:41ticking__arrdem: you only have to provide like 10 functions to get a working core.matrix implementation, because it will fallback to slow default implementaitons, but if you want to make it fast you can provide hundreds of detailed special purpose implementations
19:41ticking__clojure needs that too
19:42ticking__shen, while its creator is a maniac, has like 25 base functions that are really required to make it work which is really really nice
19:43arrdemyeah shen is really elegant just because of that
19:43arrdemnot my cup of tea, but really really nice.
19:44justin_smithticking__: yeah I think there is something like that for scheme - default impls of the fundamental stuff that you can find
19:44ticking__yeah so why not for clojure
19:44ticking__nice thing would be, as long as you only use things that depend on .kernel, you'd be really really portable
19:44arrdemwell for one thing we don't have a spec..
19:45ticking__arrdem: create one?
19:45ticking__arrdem: treat current .core as spec?
19:45arrdemticking__: wouldn't be a spec for Clojure. Clojure is defined by Rich.
19:46ticking__arrdem: yeah treat .core as spec, and reimplement the things needed on top of the .kernel stuff
19:46ticking__which can have a spec since it is as of now not done by rich :D
19:47ticking__common clojure lol
19:48arrdemticking__: I've caught a fair bit of flack for raising that idea :P
19:49justin_smithwe could have the cchs (pronounced sea cheese) - the common clojure hyper spec
19:50ticking__yes please
20:13zophyhi
20:14ticking__zophy: ho
20:16irctc_what should I do if I want to do a sequence operations where the function depends on neighboring values? For example, if I want to partition a collection into parts where it is increasing/decreasing?
20:18crash_epreduce
20:19irctc_crash_ep: how would that work?
20:20crash_epThe function you pass to reduce takes two parameters, an accumulator and the next element in the source collection. Your accumulator would be some data structure that stores the partitions, as well as whatever state you need in order to determine which partition the next element should be added to (or perhaps it should just be held in the state).
20:21justin_smith[#clojure]&(map #(map first %) (partition-by #(apply > %) (partition 2 1 [1 2 3 2 1 2 3 2 1 2 3 4 5 4 3])))
20:21justin_smitherr
20:21justin_smith &(map #(map first %) (partition-by #(apply > %) (partition 2 1 [1 2 3 2 1 2 3 2 1 2 3 4 5 4 3])))
20:21justin_smith:P client issues
20:21justin_smith&(map #(map first %) (partition-by #(apply > %) (partition 2 1 [1 2 3 2 1 2 3 2 1 2 3 4 5 4 3])))
20:21lazybot⇒ ((1 2) (3 2) (1 2) (3 2) (1 2 3 4) (5 4))
20:21crash_epjustin_smith: nice
20:23irctc_justin_smith: crash_ep thanks to both of you!
20:23irctc_justin_smith: also thanks for helping me with my messed up quad tree earleir
20:23justin_smithreduce likely will get a clearer / better performing result, but I just wanted to see if I could do it with partition
20:23justin_smithheh, np
20:23ticking__we still need a partition-at
20:25craigglennieLooking at clojure-toolbox.com I see 6 SQL DB migration libraries. Anyone got recommendations? I’m building a web-app (not sure on the framework, yet) if that helps.
20:30craigglennieHmm, looks like Luminus defaults to using Ragtime for migrations. Maybe I should just try that.
21:13mercwithamouthso after upgrading to yosemite..i've had to repair a few things. when i attempt to run a nrepl i get an error zsh command could not find lein....
21:14mercwithamouthi don't see how that's possible when it's included in my path. i have no issue doing 'lein new blah' under a zsh shell...
21:14mercwithamouthusing emacs/cider...
21:20stavroshello
21:20ticking__hi
21:21stavrosi am trying a tutorial, and my results are checked by running "lein midje". is there a way to have it output the inputs? right now it only gives me the failed result
22:14mercwithamouthdoes anyone here use light table?
22:19arrdemI've tried it a few times, but didn't find it compelling for vanilla clojure
22:19arrdemfor ClojureScript it's definitely easier to get up and going
22:19mercwithamouthfine... why is it if i'm calling a simple method that takes 1 argument and prints it...i get the value returned yet in light table it only returns nil
22:21bwreillymercwithamouth: it is going to be printing to console. I tend to run a tab with console (control-space, start typing console I think)
22:25mercwithamouthbwreilly: ahh i see
22:26mercwithamouthok...good enough. giving light table a second try.
23:35AWizzArdcore.async + transducers: why the 1 in `(chan 1 (map mouse-loc->vec))`? https://github.com/cognitect/async-webinar/blob/master/src/webinar/core.cljs#L133
23:37AWizzArdAn event gets written into the channel when the mouse moves. There will be one single message in the chan, namely the mousemove event.
23:38AWizzArdmouse-loc->vec extracts the coordinates into a vector. Why does the channel need that extra space for a second object before writing to the chan blocks?