#clojure logs

2014-05-28

00:26thecontrariananybody here use om?
00:27thecontrariani'm having some trouble with react's synthetic events and core.async
00:28thecontrarianas in when i send the event through the channel it seems what i get out the other side has all its fields nulled out
00:33tolstoyI've been using Om lately. That's pretty strange.
00:33akhudekthecontrarian: I’ve seen that, never tracked it down. I just ended up extracting stuff before hand.
00:33thecontrarianlooked it up. apparently its a react thing
00:34thecontrarianreact reuses its event objects for performance
00:34thecontrarianprobably has a pool somewhere
00:34akhudekmakes sense
00:34tolstoyOh! Right. I've seen that, too.
00:34tolstoyI ended up using goog stuff.
00:34ddellacostathecontrarian: I've encountered similar things and find it's better to get the fields from the event at the point the event happens, and send those explicitly into the channel
00:35thecontrarianso theres probably some runtime business that recycles the events after the event handler finishes
00:35ddellacostathecontrarian: presumably you don't need everything
00:35thecontrarianyeah, i'm just gonna write an extract func that makes a hash-map out of what i need
00:36ddellacostathecontrarian: yes, and since your message is being sent asynchronously that event object has been cleaned out by the time you receive the message, most likely
00:36thecontrariani tried into {} just for grins but it errored saying that [Object object] wasnt ISeqable
00:38thecontrariani wish i could get the list of topics that have been sub'd from a pub
00:38thecontrarianthat would help me out alot
00:39ddellacostathecontrarian: you could write some wrapper that records them when a channel is subbed
00:39thecontrarianbut without manageing one myself theres no way. the atom that the pub uses is closured in and unreachable
00:40thecontrarianyeah i could but that would mean rewriting some of the sub methods
00:41thecontrarianspecifically sub, unsub, and unsub-all
00:42thecontrariani guess i could do that, but its just as transparent as i would like
00:42thecontrarianjust not, i mean
00:43thecontrarianit just irks me that the data is right there and already being managed, i just cant get at it
00:43thecontrariani guess i could just rip out the pub method
00:43thecontrarianthats something
00:43thecontrarianhmmm
00:45arrdemso what's with Clojure's inline function support?
00:45arrdem(dec so)
00:45lazybot⇒ -23
00:45clojurebotexcusez-moi
00:47arrdem,(doc definline)
00:47clojurebot"([name & decl]); Experimental - like defmacro, except defines a named function whose body is the expansion, calls to which may be expanded inline as if it were a macro. Cannot be used with variadic (&) args."
00:50hellofunkarrdem that looks rather interesting
00:51arrdemhellofunk: I suppose... also experimental and something I'm probably not going to support.
00:54hellofunkthecontrarian ddellacosta I'm not sure this is what you were talking about (quite new to Om myself) but just read this: Cursors are only consistent during the application render phase - that is inside the life cycle methods. Callbacks on events handlers and core.async loops are not really a part of the Om/React render loop. Thus you are not allowed to use cursors outside of the render phase as this is almost certainly a concurrency bug!
00:54ddellacostahellofunk: no, this was more an issue with the life cycle of React events
00:55thecontrarianyeah
00:55hellofunkok, it's not quite clear to me yet where Om ends and React begins
00:56ddellacostahellofunk: well, all the event handlers you use inside of Om are pseudo-events managed by React.
00:56ddellacostahellofunk: er, handlers managing pseudo-events I should say
00:56hellofunkby event handler, you mean thinks like onClick events?
00:56thecontrarianyeah
00:57FrozenlockThere's also Reagent, if Om is too confusing
00:57tolstoyhellofunk :onClick (fn [e] (put! some-chan e)) ;; e turns into a null
00:57thecontrarianbut only those that you assign through the props of a component like the div
00:57thecontrarianlol, whats the difference?
00:58FrozenlockI find Reagent more clojure-y
00:58thecontrariangenuine question, i have been trying to figure out
00:58thecontrarianwhat do you mean?
00:58FrozenlockYou make a component just like you would a function, without reify and stuff.
00:58thecontrarianword
00:58thecontrarianwhat about performance?
00:59FrozenlockAlso, using multiple atoms is pretty much the norm. (Even single component atoms)
00:59hellofunkI think Om's claim to fame (and arguably the key reason a lot of non-Clojure people are looking at ClojureScript more seriously) is the remarkable bencharks it has shown -- up to triple the speeed of React by itself
00:59Frozenlockhttp://holmsand.github.io/reagent/news/reagent-is-async.html
01:00Frozenlockhellofunk: I think Om's claim to fame is dnolen :-p
01:00hellofunkin fact, it is getting so well-known, that even non-developers are chanting its name. i was at a yoga class recently, and everyone was just sitting down saying its name over and over again
01:00FrozenlockReagent also uses hiccup like syntax, like you would with Om+sablono
01:01thecontrariandnolen is definitely a big part of its appeal
01:01FrozenlockAnd with that (which should work also with Om), you can synchronize all undos for all atoms :-p https://github.com/Frozenlock/historian
01:02thecontrarianFrozenlock that is really cool
01:03FrozenlockThis might also interest you https://github.com/alandipert/storage-atom
01:04thecontrarianit does, but not as much
01:04FrozenlockAwwww
01:04thecontrarianits just that its not as directly useful at the moment
01:04thecontrarianstill really coo
01:04thecontrariancool*
01:05thecontrariani like the cross tab update feature, thats a nice addition
01:06FrozenlockIt is! It's a nice abstraction because you only have to deal with your atoms.
01:07Jaoodis it really to bad to use react directly?
01:07FrozenlockAnd if you are using React (om/reagent/other...), everything is automatically updated.
01:09tolstoyIs the difference that Reagent doesn't have the split between app state and component state?
01:11FrozenlockI'm not sure I understand what you are talking about.
01:11FrozenlockWait, I'm sure I don't.
01:11tolstoyIn Om, a component has its own state which is not connected to the app-state.
01:12tolstoyI guess I'm just saying the same sentence over again. ;)
01:12FrozenlockAh yes, there isn't such a distinction in Reagent (as far as I know).
01:13FrozenlockBut then again you can create an atom for a single component if you want.
01:13tolstoyWhen I first used Om, I just stored ALL state in app-state (including form stuff).
01:13tolstoyRight!
01:13tolstoyI can see the appeal of that.
01:14Frozenlockhttp://holmsand.github.io/reagent/ bunch of examples
01:16thecontrariani sort of like the whole store all your state in app-state idea
01:17thecontrariani mean, yes, it can get sort of unweildy sometimes, but its the only real way i can figure to do true trickle-down views
01:17tolstoyIt's clean. Just have all your components put events in a shared queue and process them all in one place.
01:17thecontrarianexactly
01:17tolstoyHowever, it's not great for "re-usable" components.
01:17thecontrariani disagree.
01:18FrozenlockEverything in the same atom works well 'most of the time'
01:18thecontrarianeach seperate component only sees a portion of the state, so theoretically the main state is a bunch of little states in a tree like form
01:19FrozenlockIf you want to use storage-atom, you are screwed, because serializing everything can take a while.
01:19tolstoyBy re-usable, I mean third-party. (But I don't know, I don't really care about re-usable because I'm just an app writer, not a lib writer.)
01:19thecontrariani'm actually in the process of writing a lib, or framework i guess.
01:19Frozenlockthecontrarian: could you make a variable number of tabset in Om? (genuine question, I really don't know)
01:19tolstoythecontrarian: I think the idea is, though, that some components have local state of no importance to the app itself. Implementation details.
01:20Frozenlockthecontrarian: See this example https://hvac.io/vigilia/v/5371147be4b0222b740851a2?tab=%3Adevices&bc%5B%5D=%3Aa10122..0.7..0.2..4.1 (click on the button 'split screen' at the bottom right)
01:21FrozenlockI made sure that each tabset has its own atom, meaning I can spawn as many as I want.
01:21thecontrariantolstoy yeah, more that the internal state is something that can be recalculated based on the cursor data
01:21thecontrariantolstoy but yeah, implementation details
01:21blur3dHey, I’m trying to insert a row into a postgres table that has a UUID type column, using jdbc library, and I get the following error “java.util.UUID cannot be cast to clojure.lang.Named”. I can’t seem to work out how to give it what it wants
01:22tolstoythecontrarian: Like this thing: https://github.com/arosequist/om-autocomplete.
01:22thecontrarianFrozenlock holy shit this is nice
01:22Frozenlockthecontrarian: The tabset part, or the whole? (thanks either way!) :-D
01:22thecontrarianthe whole thing
01:23thecontrarianwhat do you mean by tabsets?
01:23FrozenlockControllers - timeseries - Analytics ---> 1 tabset (multiple tabs)
01:24FrozenlockIf you click on the button at the bottom right, it will create a second set of those tabs for you.
01:24thecontrarianand they are supposed to be of identical data?
01:24blur3dDoes anyone have any experience with the postgres uuid type?
01:25FrozenlockYes, but you can keep one tabset on 'Controllers', while the other is on 'Timeseries'.
01:25Frozenlock(if you have a kickass big screen)
01:25thecontrarianyeah, you can totally do that with om
01:26FrozenlockWhat would be your approach, if everything is stored in the same atom?
01:26FrozenlockStore a vector?
01:26ddellacostablur3d: you probably need to create a custom Postgres object
01:26ddellacostablur3d: hold on, looking for appropriate javadoc
01:27blur3dddellacosta: ok, thanks
01:27thecontrarianyou'd just have the data that they are rendering from be in one part of the atom and then just have an array of screen keywords or whatever. you store the currently viewing tab for each tabset screen thing and have a sort of internal route based off of that
01:27blur3dI found https://github.com/impossibl/pgjdbc-ng which I might be able to switch to instead
01:27ddellacostablur3d: yeah, I think you'll just need to create one of these: http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/util/PGobject.html
01:28thecontrarianthat make sense?
01:28blur3dddellacosta: ok, i’ll take a look. Thanks
01:28FrozenlockYes, that would have been my 'naive' approach without knowing too much about Om internals. Thanks!
01:28ddellacostablur3d: you could, but it really should just be as simple as (doto (PGobject.) (.setType <whatever the uuid type is>) (.setValue <your uuid>))
01:28thecontrarianthats my naive approach as well
01:29FrozenlockWell hopefully not so naive, if you use Om ;-)
01:29ddellacostablur3d: assuming you are using clojure.java.jdbc
01:29Frozenlock(dec so)
01:29lazybot⇒ -24
01:29blur3dddellacosta: yep, I am.
01:30hellofunkYou guys using cljs in a browser, when writing a function, you wish to quickly evaluate and test it, how do you work? With regular Clojure, it's easy to compile just the one form you are working on and then test at REPL.
01:30thecontrarianwell thats just kinda the way i would do it using plain react
01:30ddellacostahellofunk: either austin/piggieback (https://github.com/cemerick/austin) or lein cljsbuild auto
01:31Frozenlockhellofunk: If it's just a clojure function, I would test it in a repl. If it touches the Dom, I compile and reload my browser. If it's a complicated mess, I start a browser-repl
01:31ddellacostahellofunk: the former gets you a repl but is a bit more complicated. The latter just rebuilds your cljs when you update it, and is quite fast at this point
01:32hellofunkWell I am using lein cljsbuild auto, but to actually try out a function that is not yet wired up to anything on a web page, I'd enjoy not having to do a bunch of console log tests
01:32thecontrarianlighttable
01:32thecontrarianits got a whole instarepl thing
01:32thecontrarianits pretty nice
01:32hellofunki am also trying lighttable a bit too, but i keep coming back to emacs due to some annoying glitches in its editor
01:32Frozenlockemacs powaaaaa
01:33thecontrariani was never an emacs user so this seems fine to me
01:33hellofunki really want to like lighttable. but it's just not as stable as emacs.
01:34thecontrarianhellofunk yes, it is not as stable as the 45 year old editor
01:34thecontrarian;P
01:36tolstoyI'd give LightTable a more serious try, too (I tossed in some kickstarter $), but I do other things in Emacs as well: org-mode, markdown, etc, etc.
01:37Frozenlocktolstoy: ERC?
01:37tolstoySometimes.
01:37p_ltolstoy: at least they learned how to have less annoying library deps in recent versions
01:37tolstoyMagit is pretty nice.
01:39tolstoyThe mailing list had good things to say about: https://github.com/tomjakubowski/weasel/
01:40Frozenlocko_O
01:40FrozenlockThis looks amazing
01:40FrozenlockI wouldn't need to start a ring server just for my browser repl
01:42tolstoyI've never been able to get a cljs repl working. Well, once, a long time ago.
01:42tolstoyI always get so far, and it locks up.
01:42thecontrarianthis looks pretty neat
01:43thecontrarianid love someone to host a tiny little site that just asks you for the websocket address
01:44thecontrarianFrozenlock how did you implement the multiple tabsets using reagent?
01:47Frozenlockthecontrarian: Turns out it was a bad example... I only use a single atom for the tabs. (each tabset an element in a vector)
01:48thecontrarianword
01:48Frozenlockhttps://www.refheap.com/86006
01:48tolstoyHeh. required weasel.repl in my cljs file, get a "no such namespace". Ah, the luck.
01:50thecontrarianFrozenlock so you just have an atom that has the tab data and that just generates a tabset from it?
01:52FrozenlockAh! I knew I something was amiss.
01:52FrozenlockIt's an atom of atoms :-p
01:52Frozenlock(def tabsets-atom (r/atom [(r/atom (or (get-valid-url-tab) :devices))]))
01:54tolstoyIt worked!
01:54hellofunkso much great practical info getting disseminated in here today
01:55Frozenlock#clojure has always great info. It's the official Clojure documentation! <---- lie
01:56arrdemFrozenlock: even if we aren't we're better docs than the official ones...
01:56arrdemclojurebot is arguably a full documentation engine in and of itself..
01:56arrdemtack on lazybot and all the major library devs that lurk in here... this is doc and stupid question heaven.
01:56TEttinger&help source
01:56lazybotjava.lang.RuntimeException: Unable to resolve symbol: help in this context
01:56TEttingerhm
01:57l1x,(re-pattern "\bword\b")
01:57Frozenlockarrdem: I don't know how someone can become good at Clojure without spending time here.
01:57clojurebot#"word"
01:57l1x,(re-pattern "\bwo.d\b")
01:57clojurebot#"wo.d"
01:57TEttingerhm
01:57TEttinger,#"\bword\b"
01:57clojurebot#"\bword\b"
01:57TEttingerI think \b is treated differently in the string
01:58l1xi want to generate a regexp from a string
01:58TEttinger,(re-pattern "\\bword\\b")
01:58clojurebot#"\bword\b"
01:58l1xohh
01:58l1xthis is what i am looking for
01:58l1xthanks
01:58TEttingerno prob
01:58FrozenlockThat escape
01:58TEttingerregexps are always fun
01:58FrozenlockAt least it's not an Emacs regexp escape
01:58arrdemFrozenlock: I think it's an open question unfortuantely
01:58Frozenlock\\\\\\\\\\\\\\\\\\\\\\b
01:59arrdemalso I just did a readme update and am open to comments https://github.com/arrdem/oxcart
01:59arrdemFrozenlock: such escape wow very confuse what does mach much mistery
02:00TEttinger##(re-seq (re-pattern "\\b\\w+\\b") "The quick brown fox jumps over the lazy dog.")
02:00lazybot⇒ ("The" "quick" "brown" "fox" "jumps" "over" "the" "lazy" "dog")
02:00Frozenlockarrdem: I know nothing of compilation stuff, can't help you with that :-(
02:00arrdemFrozenlock: I'll take feature requests and readability comments too :P
02:00TEttingerso that shows that to use other regex escapes they need the double backslash too
02:16hellofunkWhen changes are made to the app state atom in Om, what is necessary for them to update on the page? I have a bunch of components setup and built in functions passed to om/root, and I can log the changes in state fine, but the on-page state never changes. where should I look?
02:18tolstoyIs the app state an atom (atom {....})
02:18hellofunkYes, I can log it by deferencing it
02:18hellofunkand it shows my updates
02:19tolstoyShould work. Maybe a swallowed exception somewhere in there?
02:20tolstoyI've had issues when a component didn't return (om/component ...) or (reify om/IRender ..) or something. But I think the new version warns against that.
02:20hellofunkno exceptions showing in the chrome console. i'm basically following dnolen's example here: https://github.com/swannodette/om/wiki/Basic-Tutorial
02:20tolstoyI get swallowed exceptions in core.async stuff.
02:22ddellacostahellofunk: use transact! or update! to update the app data
02:22ddellacostahellofunk: are you doing that?
02:22hellofunkif anyone can spare a minute of eyes, here it is: https://www.refheap.com/86007
02:22hellofunkddellacosta I am, just exactly as nolen's example shows
02:22ddellacostahellofunk: okay, looks like you are
02:25hellofunkweird, my println @app shows the correct new state changes, but the page never updates.
02:25ddellacostahellofunk: neither deleting nor adding works? Do you get any errors whatsoever?
02:25hellofunkddellacosta the deleting works fine.
02:25ddellacostahellofunk: oh
02:25hellofunkddellacosta no errors with either deleting or adding
02:25ddellacostahellofunk: you are updating at :contacts in your transact! inside of add-composer
02:26ddellacostahellofunk: I guess you probably want :composers there
02:26hellofunkahh!
02:26hellofunkddellacosta thanks, the extra eyes helped
02:27ddellacostahellofunk: yep, extra eyes is key
02:28hellofunkso i guess the idea is that these Om components have independent state as well as access to a global app state, and each has hooks into the lifecycle of their rendering, and each also can own other components with the same powers. Is that the general idea here?
02:37locks5:49 AM <hellofunk> ok, it's not quite clear to me yet where Om ends and React begins
02:37locksuse React and you'll know ;P
02:44thecontrarianhellofunk seriously tho, use react
02:45thecontrariani played around with om, then did some basic stuff with just react, then went back to om and everything made ALOT more sense
02:45FrozenlockUsing react? Directly? As in JS stuff?
02:45thecontrarianyes
02:45Frozenlockyuck
02:45thecontrarian:/
02:45thecontrarianwell at the very least read up on how it works
02:45thecontrarianit would really do you good just to do some mock stuff
02:46thecontrarianor at least look at others mock stuff
02:47FrozenlockI don't really see what there is to learn except the few 'component-did-mount' 'component-will-mount'...
02:47FrozenlockOh, and knowing it doesn't fully support SVG.
02:47Frozenlock*rage*
02:47thecontrarianlol
02:47thecontrariansvg sucks, imo
02:47thecontrarianavoid it where you can
02:48Frozenlocko_O
02:48thecontrarianthis is coming from a guy who made an app starting all svg, then some svg, then no svg, and it just got better each time
02:48thecontrariancss3 transforms
02:49thecontrarianof course, there are some nice things that svg can do
02:49thecontrarianbut its slow
02:49FrozenlockHow do you let your user 'save as' with css3 transforms?
02:49thecontrarianwhich makes me rage
02:49thecontrarianwha?
02:49Frozenlocksave as png, svg, jpg...
02:49thecontrarianoooooh
02:49FrozenlockYou know, outside the browser :-p
02:50thecontrarianwell arent there render html to png libs?
02:50thecontrarian<- ignorance
02:50thecontrarianyou do have a point tho
02:50thecontrarianthat is one place where svg is kind of nice
02:50thecontrarianbut thats an edge case
02:51Frozenlockur... I'd say it depends on your users. Getting out of the browser to send an email or include a graph in a report is not really an edge case I'd say :-/
02:52FrozenlockI'd say twice even
02:52thecontrarianyeah but arent you talking about editing the svg in browser then saving it?>
02:52FrozenlockI'd say.
02:53thecontrarianalso i just found this https://developer.mozilla.org/en-US/docs/Web/HTML/Canvas/Drawing_DOM_objects_into_a_canvas
02:55thecontrarianok so maybe not an edge case, but for stuff like complex ui and animations and stuff, i prefer to use html and css3 when i can
02:55thecontrarianbut i concede that there are things that you cant really do with css and html that you can with svg
02:56Frozenlockhttp://d3js.org/ Do THAT in html :-p
02:57locksthecontrarian: +1 on using react itself
02:57FrozenlockBut the web is doomed anyway. Mobile is destroying everthing. Soon websites will be in font 72pts with a single button that says 'click me'
02:58thecontrarianFrozenlock, actually thats what i was talking about, with the d3 thing
02:59thecontrarianthecontrarian.github.io/Abacus
02:59thecontrarianuses d3 for animations, but everything you see is html
02:59FrozenlockWow, I like that side menu
02:59thecontrarianlol
03:00FrozenlockWell, on a mobile. On a 27inches it sucks :-p
03:00thecontrarianreally? it should be the other way arround
03:00thecontrarianand it was designed for ipa
03:00thecontrarianipad
03:00Frozenlockhmm let me test that
03:01thecontrarianbut its the stuff you drag out from the side menu that is important
03:01thecontrarianfollow the instructions
03:01thecontrarianor dont, w/e
03:02FrozenlockOh God
03:02Frozenlockcase sensitive
03:02FrozenlockI hate you :-p
03:03Frozenlockthecontrarian: is this written in cljs?
03:04thecontrarianno
03:04thecontrarianjust regular js
03:04thecontrarianit was before i really got into clj
03:06FrozenlockOh, I just now realized you could drag boxes out of the menu
03:07thecontrarianSIGH
03:07thecontrariandid you read the instructions?
03:08FrozenlockI thought you said to not follow them ...
03:08Frozenlock"follow the instructions... or don't"
03:08thecontrarianthat was me saying 'its shit'
03:08thecontrarianbut yes, if you play around with it, you should read the instructions
03:09p_l... did *anyone* ever document how gen-class deals with overloaded methods when extending classes?
03:17michal2Hi. Is it possible to return jsonp by luminus ? I would like to write my angular apps with clojure (now python). And it would be cool to have jsonp as a return from controller.
03:29ddellacostam_m: presumably this would let you do it: https://github.com/qerub/ring-middleware-jsonp
06:03noncomso i tried out emacs live and now trying out prelude. aside from the fact that it had many warnings and errors during the initial initialization (but worked at the end), the first inconvenience that i am to notice is that there is no in-place advices for M-x commands, only if I press TAB
06:04noncomis thre a way to enable it, as it is in live?
06:07whilohi
06:07whilois there a reason why https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/reader.cljs#L547
06:08whiloand *default-data-reader-fn* are not declared ^:dynamic?
06:14noncomwhilo: heh, strange, they are earmuffed atoms .. :)
06:15whilononcom: right, and i get warnings when rebinding them, although it works
06:15noncommaybe there is a reason, but i think it is a mistake since even the compiler would warn you to not use earmuffed names for not maken them dynamic
06:15noncomwhilo: you may try asking again later in today when people who are more into cljs will be present here..
06:16whilook
06:18trap_exitare lazy sequences considered as seqable?
06:18trap_exit, (for [i (range 10)] i)
06:18clojurebot(0 1 2 3 4 ...)
06:18trap_exit, (seq? (for [i (range 10)] i))
06:18clojurebottrue
06:18noncomwell, likely...
06:19noncomsequable is something that can be turned into a sequence, and lazy seqs definitely are
06:25ddellacostawhilo: there are no vars in CLJS
06:25ddellacostaearmuffs are just a convention, there is no special handling of them in the compiler as far as I know
06:26whiloddellacosta: the problem is that the reader has these atoms in there and i cannot get a "clean" reader without rebinding these vars
06:27ddellacostawhilo: Is swap!-ing them like normal atoms causing you trouble?
06:28whiloddellacosta: then i will reset the reader state for the whole runtime, possibly interfering with other users. clojure.edn allows to pass in tagged-reader-fns and the default-reader-fn as arguments, which imo is a lot better
06:30whilotools.reader might solve this problem in a similar way, if it becomes the default reader for cljs and clj
06:30ddellacostawhilo: you need to use this I suppose, but I'm not sure you're going to find a way around it: https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/reader.cljs#L567-L572
06:30ddellacostawhilo: but as I said, you don't have vars in CLJS so I'm not sure how else you'd handle it
06:30whiloddellacosta: right, this is basically manipulating the atom
06:31whiloit will probably cause problems, because i want to read all tagged-literals as a map value through the default fn, disregarding custom tagged readers
06:32whiloddellacosta: but rebinding the default fn seems to work through the binding form atm
06:33whiloddellacosta: how does binding work then on cljs?
06:33whiloi mean the (binding [foo/bar 42] ...) form
06:34ddellacostawhilo: not sure, I'm a bit confused by that myself, reading through the code now
06:35ddellacostawhilo: ah, it's wrapping with-redefs, that's what I suspected
06:36whiloddellacosta: this is what i am doing: https://github.com/ghubber/hasch/blob/master/src/cljs/hasch/platform.cljs#L14
06:36whiloddellacosta: uh, redef is ugly, isn't it?
06:36Bronsawhilo: if I'm not mistaken cljs.reader comes from a time where clojurescript didn't support dynamic vars yet
06:37ddellacostaBronsa: does it now? I didn't realize that had changed
06:37Bronsaddellacosta: since a couple of years :)
06:37whiloBronsa: ok. so for now they could be declared ^:dynamic
06:37whilo?
06:37ddellacostaBronsa: jeez am I confused. Obviously ignore what I said whilo!
06:39Bronsawhilo: I suppose so
06:44noncomBronsa: so is it a mistake that these vars are not dynamic or is it ok?
06:45noncomoh yu've already answered
06:45noncomsry
06:45ddellacostawhilo: interesting related conversation from a few years back: https://groups.google.com/forum/#!topic/clojure/6cmnkHmHBNw
06:50whiloddellacosta: thx, i am getting something to eat
06:51ddellacostawhilo: cheers, enjoy. :-)
07:00owl-v-lol this guy wanted jvm-free >> http://danielkvasnicka.tumblr.com/post/54741297421/racket-on-raspberry-pi-the-importance-of-being-jitted
07:01lintomashi, are data structures java objects at the point where the reader finishes parsing them?
07:04Bronsalintomas: yes
07:04Bronsa,(class (read-string "[]"))
07:04clojurebotclojure.lang.PersistentVector
07:10lintomasBronsa, thanks. So in the moment the compiler starts treating the data structures, it sees them as the objects of java, true?
07:12owl-v-omg javascriptV8 is actually quite good in this test >> http://benchmarksgame.alioth.debian.org/u64/benchmark.php?test=all&amp;lang=v8&amp;lang2=sbcl&amp;data=u64
07:12owl-v-much less code :-)
07:12Bronsalintomas: I'm not sure what you mean by that, but both the compiler and the reader output clojure.lang.Persistent* instances
07:19gfrederickslintomas: clojure objects are also java objects -- there's not a sharp distinction
07:20lintomasBronsa, I don't the main idea here, I suppose. User inputs so called reader forms ( [], (), {}, "string") which we consider data-structures. But for reader they just strings. Then there spits data structures. But in what forms, in java object or some internal clojure syntax representation for those data structures?
07:21lintomasBronsa, I don't the main idea here, I suppose. User inputs so called reader forms ( [], (), {}, "string") which we consider data-structures. But for reader they just strings. Then the reader spits data structures. But in what forms, in java object or some internal clojure syntax representation for those data structures?
07:22Bronsalintomas: the reader creates concrete instances of the data structures, yes
07:22lintomasBronsa and gfredericks , I don't the main idea here, I suppose. User inputs so called reader forms ( [], (), {}, "string") which we consider data-structures. But for reader they just strings. Then the reader spits data structures. But in what forms, in java object or some internal clojure syntax representation for those data structures? How can see the exact form of those concrete instances of data structure, their representation form?
07:22Bronsalintomas: what you get as output from read/read-string is effectively what the reader produces.
07:24gfredericks,(map type (read-string "( [], (), {}, \"string\")"))
07:24clojurebot(clojure.lang.PersistentVector clojure.lang.PersistentList$EmptyList clojure.lang.PersistentArrayMap java.lang.String)
07:25gfrederickshuh. the difference beteeen Vector and List$EmptyList there is curious
07:30Bronsagfredericks: not really. all empty lists are List$EmptyLists
07:36lintomasBronsa, wow...then i don't understand anything. What the reader produces is what compiler sees and processes. The (read-string "[]") returns []. So what does compiler do with []? Does it parse it again, understand it is an vector, create a java object array ...??? Sorry for being so noob
07:37Glenjamin,(eval (read-string "[]"))
07:37clojurebot[]
07:37noncom,(type (eval (read-string "[]")))
07:37clojurebotclojure.lang.PersistentVector
07:37noncom,(type "[]")
07:37clojurebotjava.lang.String
07:37noncomjust the magic of toString() :)
07:37Glenjamin,(= '[] (read-string "[]"))
07:37clojurebottrue
07:37Bronsalintomas: yeah, the compiler takes the output of the reader and dispatches over the class, for PersistentVector it creates a new vector evaluating the elements of the vector returned by the reader
07:38Glenjaminread-string isn't returning a vector, it's returning the tokens []
07:38Glenjamini think
07:38Glenjaminmaybe not
07:38BronsaGlenjamin: not true
07:38Glenjamini have confused myself now
07:38Glenjaminisn't it just an expression until it gets evalled?
07:39lintomasBronsa, ty. u're great person :D
07:39Glenjaminoh, right - because it's a literal its already a vector
07:40Glenjamin,(= '[] (read-string "(vector)"))
07:40clojurebotfalse
07:40Glenjamin,(= '[] (eval (read-string "(vector)")))
07:40clojurebottrue
07:40Glenjaminplease disregard my earlier statement about what read-string returns
07:41lintomasThen the reader is useful in which ways. One would be: it expands reader-macros. Other: u can type text in repl or read text from file. Or is there something important reader exist for?
07:41lintomasThen the reader is useful in which ways? One would be: it expands reader-macros. Other: u can type text in repl or read text from file. Or is there something else important reader exist for?
07:50sandbagsam i getting it right that a particular method can only be defined by one (the first) Protocol?
07:57szymanowskiHi, how can i do something like this? (defrecord A []) (extend-type A clojure.lang.Named (getName [this] "A"))
07:58szymanowskiIt work inline but not with extend-type
07:58szymanowskis*
07:58Bronsaszymanowski: yeah, you cannot use extend with interfaces, only protocols
07:58szymanowskiis there a way to do?
07:58Bronsano
07:58szymanowskiok
07:59szymanowskithank you
07:59Bronsayou can only do it inline if it's an interface
08:00m_mI am searching simple web framework for clojure with ORM, MVC. I would like to use clojure only to receiving data from database, sessions etc. Rest of the job is for angular. Any clues?
08:01gfredericksBronsa: but why are not all empty vectors Vector$EmptyVector?
08:02Bronsagfredericks: because there's not $EmptyVector class :D there's no need for it
08:02gfredericksBronsa: why? that's the discrepancy I was originally pointing out
08:03Bronsagfredericks: implementation details, an empty list cannot be implemented as a PersistentList/Cons, an empty vector however can be represented as a PV just fine
08:03gfredericksBronsa: okay that makes more sense
08:04gfredericks(inc Bronsa)
08:04lazybot⇒ 20
08:06gfrederickslintomas: I think you've been noodling at the concept of homoiconicity this whole time: http://en.wikipedia.org/wiki/Homoiconicity
08:07gfrederickslintomas: the two biggest reasons why homoiconicity is useful in lisp is because it makes macros easy and paredit possible
08:45ayiahi! is it possible to import specific java static methods in clojure? I don't want to write each time MyClass at (MyClass/myStaticMethod ...)...
08:46Bronsaayia: the only way AFAIK is wrapping them in a function
08:47ayiaBronsa: big thanks bro! I will...
08:48peterdonMaybe http://richhickey.github.io/clojure-contrib/import-static-api.html
08:48Bronsaclojure-contrib is dead
08:48peterdonah
08:51noncomBronsa: what if, in a case like this one, I will use the machinery from the contrib lib? will it be considered deprecated?
08:52Bronsanoncom: nobody is going to stop you from copying code from clojure-contrib if you need it, but being deprecated means that it's not guaranteed to still works
08:52bbloomamalloy_: can be either low or hight bits, but yeah, i think you're right. low bits are much more common these days
08:53Bronsas/to/it
09:22clgvever seen that one: "CompilerException java.lang.VerifyError: Unable to pop operand off an empty stack" ?
09:26noncomclgv: not recalling.. wow you seem be hunting comiler bugs all over the place :)
09:28clgvnoncom: not intentionally
09:28noncomclgv: maybe you're born a natural compiler-bug-hunter
09:29noncomthe ability you know, a trait so to say
09:29noncomand have a great mission
09:30clgvyeah born a "fuzzier" ;)
09:30clgvit has something to do with primitive functions, but I never encountered that weird error before
09:42clgvThere is a minimal example of that weird bug: https://www.refheap.com/86018
09:42clgvSeems as if the :tag for the array causes problems
10:11clgvaccording to the source HostExpr.tagToClass should work for doubles though ... :(
10:17mskoudI have a structure like this : [({:auth true :b 5} {:c 4}) ({:auth false :b 6} {:c 5}) ({:b 7} {:auth true :c 6})]
10:17mskoud and would like to return all list with :auth true. How do i do that?
10:19gfredericks(filter #(some (comp true? :auth) %) my-lists)
10:19gfredericks,(def my-lists [({:auth true :b 5} {:c 4}) ({:auth false :b 6} {:c 5}) ({:b 7} {:auth true :c 6})])
10:19clojurebot#'sandbox/my-lists
10:19gfredericks,(def my-lists '[({:auth true :b 5} {:c 4}) ({:auth false :b 6} {:c 5}) ({:b 7} {:auth true :c 6})])
10:19clojurebot#'sandbox/my-lists
10:19gfredericks,(filter #(some (comp true? :auth) %) my-lists)
10:19clojurebot(({:auth true, :b 5} {:c 4}) ({:b 7} {:auth true, :c 6}))
10:19mskoudThanks!
10:20llasramclojurebot: what I tell you two times is my-lits
10:20clojurebotIn Ordnung
10:20llasramOops. Oh well
10:23hyPiRionclojurebot: what I tell you two times?
10:23clojurebotwhat I tell you two times is my-lits
10:23hyPiRiontehee
10:33gfredericksclojurebot: what I tell you three times is my-vectrs
10:33clojurebotIk begrijp
10:43Bronsa15:17:03 <clgv> ever seen that one: "CompilerException java.lang.VerifyError: Unable to pop operand off an empty stack" ?
10:43Bronsauuuh I want to see that
10:44clgvBronsa: https://www.refheap.com/86018
10:45Bronsaoh, yeah
10:45Bronsaclgv: the correct way to do it is (defn a ^doubles [] ..)
10:45clgvBronsa: huh? tags are always on the symbol and primitive types on the argument vector
10:46clgvor did that change with 1.5/1.6?
10:47Bronsaclgv: tagging the var sym with a primitive return value never made the fn exploit the invokePrim optimization
10:47Bronsayou have to tag the argvec
10:48clgvBronsa: afaik ^doubles does not make a function primitive, mind the "s" at the end. I want to tag that this function returns a double array
10:48Bronsaalso, metadata on the var sym will be evaluated see http://clojure.org/special_forms#Special%20Forms--(def%20symbol%20init?)
10:48TimMcpeterdon: Or https://github.com/baznex/imports
10:49gfredericksso weird to see rhickey arguing on reddit
10:49Bronsaclgv: oh, right. my point still holds anyway
10:49clgvBronsa: hu why?
10:49hyPiRiongfredericks: huh where
10:49llasramgfredericks: ditto
10:49llasram(the "huh where" part)
10:49Bronsabecause metadata is evaluated on the symbol of def, you're not tagging with 'doubles but with the _function_ doubles
10:50Bronsaclgv: so either (defn ^{:tag 'doubles} a [] ..) or (defn a ^doubles [] ..)
10:50clgvBronsa: so ^'doubles is correct?
10:50gfrederickshyPiRion: two years ago: http://www.reddit.com/r/programming/comments/lirke/simple_made_easy_by_rich_hickey_video/
10:50BronsaI guess
10:50llasram*brain explodes* wrt `doubles`
10:50Bronsaclgv: probably it's '^doubles
10:50clgvBronsa: damn someone should clean that syntax up.
10:51Bronsaclgv: nevermind, neither '^ or ^' works.
10:51Bronsaclgv: as a rule of thumb, always prefer tagging the argvec
10:51clgvBronsa: at least some compiler errors would be good if strange stuff is added as tag
10:51llasramActually, I think '^doubles means "quote the next form and attach {:tag doubles} as metadata"
10:52llasram,'^double foo
10:52clojurebotfoo
10:52clgvBronsa: does tagging the argvec work for normal classes?
10:52Bronsaclgv: agreed. I've made it throw an exception in tools.analyzer.jvm
10:52llasramOh, "neither"
10:52hyPiRiongfredericks: heh
10:52clgvBronsa: what happens with different tags on multiple arity implementations?
10:52Bronsaclgv: what you'd expect
10:53Bronsaclgv: tagging the argvec has a shortcoming too though
10:53clgvBronsa: humm how can the compiler infer the return type in case of apply?
10:53gfrederickshyPiRion: there's a long exchange with psnively further down
10:53Bronsathe class is not resolved so if you have (ns a (:import some.class)) (defn x ^class [] ..)
10:53clgvBronsa: it cant right?
10:53Bronsaand (ns b (:use a))
10:53Bronsa(.someMethod (x)) will not works
10:54hyPiRiongfredericks: currently reading it. Interesting, as I've never really heard rhickey's argument on types
10:54Bronsayou have to either tag with the qualified tag or import the class in b too
10:54Bronsaclgv: no it can't
10:54clgv:(
10:54clgvBronsa: that should be on the agenda for the next release...
10:56gfrederickshyPiRion: ditto; the most I've gotten from most clojure community folks is question-begging dismissal
10:59gfredericksI guess snively got the last word there
11:01hyPiRiongfredericks: on the Internet, the last one to bed is the winner
11:07TimMchyPiRion: But the internet spans all time zones... Oh.
11:07TimMcI see.
11:20Glenjaminwow, thats a fun exchange of views
11:38szymanowskiHi, what is the way to redefine assoc method for a record?
11:43cbpMaybe you want to use deftype instead?
11:50szymanowskiyes I'm I will go with deftype
11:51AWizzArdcbp: And? Already tried out the slider?
11:51cbpAWizzArd: I left that aside for a bit. Can you link me? :)
12:00AWizzArdcbp: https://bitbucket.org/athieme/om-widgets
12:02cbpAWizzArd: thanks!
12:21rasmustoI'd like to host some jars on my own server, what's a good place to start?
12:22ohpauleezrasmusto: Like your own maven repo?
12:22ohpauleezor just host them for downloads
12:22rasmustoohpauleez: yeah
12:22ohpauleezhang on, grabbing a link
12:22rasmustoohpauleez: something that I'd be able to point leiningen at
12:22llasramrasmusto: I have only good things to say about Archiva http://archiva.apache.org/index.cgi
12:22ohpauleezrasmusto: http://cemerick.com/2010/08/24/hosting-maven-repos-on-github/
12:23ohpauleezYou can follow that, or use the general idea
12:23rasmustollasram: ohpauleez: thanks :)
12:23ohpauleeznp!
12:23ohpauleeztotally welcome
12:24technomancyrasmusto: the simplest thing is to just serve jars with nginx if they're not going to be changing frequently
12:24cemerickohpauleez, rasmusto: private s3 repos are fundamentally better https://github.com/technomancy/s3-wagon-private
12:25ohpauleezcemerick: rasmusto: That's a good point - recently, I've done that (used s3)
12:26rasmustotechnomancy: at this point, it'll only be at most a few new releases a day
12:27technomancyrasmusto: that's kind of a lot; you probably need `lein deploy` support for that then
12:27technomancyone thing I am curious about but have never looked into is how the scp transport for aether works
12:28technomancybecause theoretically you could use that without a bunch of new infrastructure
12:28technomancynever really looked into it though
12:31technomancyman, if you could just auth with your SSH keypair that would save a lot of headache with gpg
12:31technomancywhy haven't I tried this before
12:31technomancyssh-agent works basically everywhere
12:38rasmustomy "deployment" strategy right now for python stuff is to scp stuff to a server that serves it with httpd
12:39technomancyrasmusto: it should be possible to make `lein deploy` scp stuff to the right place where nginx can serve it up
12:40rasmustotechnomancy: s/nginx/httpd ? It would be nice to not have to modify the server setup
12:40technomancycemerick: does this look reasonable to you? (aether/register-wagon-factory! "scp" (resolve 'org.apache.maven.wagon.providers.ssh.jsch.ScpWagon))
12:40technomancyrasmusto: sure, whatever
12:41rasmustotechnomancy: awesome, I'd love to make this work. I assume I need pomegranate as a dep?
12:42technomancyrasmusto: lein has pomegranate already
12:42rasmustoah, cool.
12:42technomancyregistering the scp wagon with pomegranate seems to have no effect though
12:42technomancyweird
12:47rasmustotechnomancy: is the register-wagon-factory! something you are putting into project.clj somewhere?
12:48technomancyrasmusto: I added it to lein itself, but it's not working
12:48Viestipuuh
12:48rasmustohm, gotcha
12:50Viesticaching with core.cache/core.memoize is turning out to be surprisingly hard, they are almost there but not quite... :/
12:50rasmustoViesti: what specifically are you trying to cache?
12:50Viestithe composing idea with core.cache is neat, I needed TTL with a limit on items
12:51Viestibut then it turns out that TTLCache has a performance issue
12:51ViestiCCACHE-15
12:52Viestitried to fix it, but then turns out that the secondary structure it keeps doesnt keep up with the limit but eats everything until ttl expires
12:52Viestislightly gave up and looked at memcached clients
12:53Viestiran into mcache but it didn't seem to play nice with core.memoize, tried out spyglass and ran into same issue
12:53Viesti"ClassCastException clojure.lang.ArraySeq cannot be cast to java.lang.String"
12:54ViestiI'm caching queries from mongodb
12:54Viestimaybe I'll get there, but thought that this would be easier... :)
12:57Viestithe problem with memcached backend to core.memoize seems to be how arguments are handled: https://github.com/clojure/core.memoize/blob/master/src/main/clojure/clojure/core/memoize.clj#L145
12:58Viestithe "[& args]" turns args into clojure.lang.ArraySeq
12:58Viestiwhich gets passed onto some spyglass function that expects a string :P
12:59Viestisorry everyone, has to air out thoughts...
13:01noncomthat's perfectly fine
13:01rasmustotechnomancy: would it be (register-wagon-factory! "scp" #(org.apache.maven.wagon.providers.ssh.jsch.ScpWagon)) ?
13:02technomancyrasmusto: hah, literally just realized that like thirty seconds ago
13:02rasmustotechnomancy: :)
13:04mi6x3mhey clojure, is there a web browser component for seesaw?
13:04mi6x3mpreferably something based on xulrunner
13:06technomancyrasmusto: this seems to do the trick: https://www.refheap.com/86021
13:08technomancywe could get rid of the manual registering of wagons if we read plexus components.xml from lein
13:08technomancybut that is probably a huge bucket o worms
13:08rasmustotechnomancy: awesome, I'll give that example a shot
13:08rasmustois "dh" a username?
13:09technomancyrasmusto: no, it's just the repo name
13:09technomancyso you'd deploy with `lein deploy dh`
13:09technomancyuse "releases" to make it work with `lein deploy`
13:09rasmustoah, okay. It'll just auth with the current user?
13:09technomancyrasmusto: usernames should go in .ssh/config
13:09rasmustogotcha, thanks
13:10PigDudei wish there were something like epmd for clojure
13:10PigDudeis there?
13:12cbp$google epmd
13:12lazybot[EPMD - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/EPMD
13:12PigDudeepmd is the erlang port manager daemon
13:13technomancyPigDude: running multiple clojure instances on a single machine doesn't really make sense
13:13technomancyPigDude: for that kind of distributed workflows most people use a message broker like rabbitmq or something
13:13PigDudeok, thanks, i was just curious as it seemed a natural extension of the nrepl
13:13technomancyerlang is really good at that kind of thing; you can write application code in clojure and still let erlang handle message passing across a cluster =)
13:14PigDudetrue :)
13:14technomancyif you want to go nuts you could try mashing up erjang and clojure
13:15PigDudetechnomancy: hehe https://github.com/oubiwann/erlang-clojure-node/blob/master/src/clj_controller.erl
13:16technomancyhoo boy =) fun
13:16PigDudei was looking to see if somebody was making clojure ports for erlang
13:17PigDudebut clojure being on jvm, makes more sense to justuse the java api rather than to make a port
13:18PigDuderight now i am not looking to integrate them though, i just find myself only wanting to program in lisps now that i am using clojure professionally
13:19technomancywell there's nothing as nice as otp on the jvm except for maybe with erjang
13:19technomancyit's pretty amazing the level of compatibility he was able to achieve as a solo hacker on that project
13:19technomancyprobably because erlang is a very small language
13:19PigDudewell there's Pulsar and Akka i suppose
13:20technomancyyeah... ehrm.
13:20technomancythey're a step in the right direction, but really nowhere near as nice
13:21PigDudei have no experience with either, but lots w/ otp and i too like it
13:30elchatyhi all
13:30noncomhi!
13:30elchatyin clojure if I have variable x how can I test to see if that variable is ISeq?
13:31mi6x3melchaty: (seq? my-var) ?
13:31gtrakelchaty: no variables :-)
13:31rasmustotechnomancy: I had to use ssh-agent/add /and/ tell `lein deploy serv` my username/password. Will this go away if I just add credentials somewhere?
13:31elchaty(seq? [1 2]) is false
13:31elchatyforget about the variable thing
13:31technomancyrasmusto: the password prompt will go away in 2.4.0
13:31gtrakelchaty: sequential?
13:31elchatyhow to test is somethig is collection or not
13:31elchatyany
13:31clgv,(seqable? [1 2])
13:31clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: seqable? in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:31elchatysequential? let me try that
13:32rasmustotechnomancy: ok, thanks again for your help :)
13:32elchaty(sequential? [1 2]) works!
13:33mi6x3melchaty: see (doc seq?) it does exactly what you want (ISeq test)
13:33mi6x3mor you just wanted a collection test?
13:33elchatyseq? with a vector returns false
13:33elchatysequential? is what I was looking for. Thanks gtrak
13:34clgv&(-> [] class ancestors)
13:34lazybot⇒ #{java.util.Collection clojure.lang.IPersistentStack java.lang.Object clojure.lang.IPersistentCollection clojure.lang.AFn java.lang.Iterable clojure.lang.Reversible clojure.lang.IObj clojure.lang.APersistentVector java.util.concurrent.Callable clojure.lang.Indexed ja... https://www.refheap.com/86023
13:35clgvelchaty: vector does indeed not implement ISeq but Seqable
13:38kwertiiAnyone use Friend-OAuth2? I’m setting it up as per the example code, but it’s redirecting unauthenticated users to “/login” (the default Friend URL) rather than to the 3rd party site. Is this what it’s supposed to do?
13:38cemericktechnomancy: looks sane
13:39elchatyclgv I didn't know that vector didn't implement ISeq
13:39technomancycemerick: my mistake was returning a class instead of a fn that calls the constructor
13:39technomancyworks fine now
13:39technomancycemerick: seems like with all the trouble people have with s3 creds, documenting ssh deploys could save a lot of headache
13:39cemerickoh, factory-fn
13:40cemerickI guess so? I haven't had any stable deployment targets in years.
13:40cemericktechnomancy: what are the troubles?
13:41technomancycemerick: mostly gpg being a pain on macintoshes
13:41Pourletaincemerick
13:41Pourletainwhat is your opinion on people who use 'who' in object position.
13:41PourletainLike "These foolish children have no idea who they are dealing with."
13:41clgvelchaty: now you do :D
13:41technomancythere's just a ton more good tooling around SSH already
13:42cemericktechnomancy: I don't recall having any trouble when I was in Mac-land, but I can imagine it.
13:42cemerickPourletain: My opinion is that anyone asking me that question is trolling. ;-)
13:43cemerickPourletain: I don't have any problem with that example sentence though. Why?
13:45Pourletaincemerick, because it should be "these foolish children have no idea whom they are dealing with."
13:45PourletainIn this case "who" is the object of "with".
13:46cemerickyeah, ok
13:46cemerickWhy, man, why?
13:47llasramI'd argue that pretty much any use of "whom" sounds stilted to the contemporary ear, outside of very formal contexts
13:47gtrakbeing pedantic about english grammar is like polishing a turd.
13:47Pourletaincemerick, because it's an object.
13:47PourletainYou don't say "he they are dealing with" but "him they are dealing with" do you not?
13:47kwertiiLanguage and grammar are living and changing things; “whom” is now archaic and disused
13:47Pourletainllasram, I disagree.
13:47erlisspeak clojure
13:47llasramTo whom are you talking, my good sir? vs Who are you talking to?
13:47erlisnot english
13:47cemerickPourletain: no, I mean, why are/were you asking me?
13:48PourletainUse of who in object position clearly betrays one as an uneducated snail who never went to oxford or something similar.
13:48Pourletaincemerick, I have no idea.
13:48kwertiithe death of “whom” has been well studied by linguists
13:48kwertiieven “respectable” authors now routinely omit “whom”
13:48cemerickPourletain: that's…bizarre?
13:48PourletainYes well, most people are then again cattle who didn't go to Oxford or Cambridge or something else awesome.
13:48llasramDown with "whom"!
13:48Pourletaincemerick, well, yes, I am kind of bizarre.
13:48PourletainNever.
13:48PourletainI shall stand as the last bastion of proper grammar.
13:49Pourletaincemerick, what is your opinion about people who say "I think you're taller than her.' rather than 'taller than she' though.
13:49dbasch(= :who (first bases))
13:49PourletainIt is truly a failing of the school system that I once heard a professional newscaster use the former.
13:50llasramPourletain: You may need a hobby. I suggest Clojure! Well, unless you use professionally
13:50cmiles74I would say a failing of the culture. It is simply not valued.
13:50kwertii“proper” grammar is merely a psychological construct foisted by self-appointed prestige groups to promote their own superiority. Linguists almost universally rejected “prescriptive grammar” many decades ago
13:51llasramkwertii: But without class markers how will he know which people we're better than?
13:51Pourletainkwertii, I don't see how a linguist can reject that because it has nothing to do with linguistics.
13:51llasrams,he,we,
13:51PourletainLinguistics is a descriptive science. This is like saying that psychologists reject the idea of the law.
13:51gtrakpeople still program in PHP, too. But I don't interop with them.
13:51PourletainPsychology studies human behaviour, the law tells people how to behave, both are completely unrelated.
13:51technomancyllasram: that's why we have windows.
13:52kwertiiPourletain: well, there’s a huge body of work in the subfield of sociolinguistics that goes over that question in excruciating detail, if you’re interested
13:52llasramNice
13:52PourletainAlso, the proper spelling is of course præscriptive.
13:52PourletainThe spelling you used is abomination indicative of never been educated in Latin.
13:52PourletainSuch atrocities need to be weeded out of course.
13:53gtrakhttp://www.oxforddictionaries.com/us/definition/american_english/twerk
13:53kwertii“The abuse of grammar is something up with which I will never put!”
13:53rasmustogtrak: it's "twerkm"
13:54cmiles74Pourletain: You're fighting a losing battle on that one. They will not make the US English keyboard larger.
13:54PourletainDead keys are a convenience.
13:54llasramI think Pourletain has transitioned to pure trolling. Maybe started there?
13:54maxmartintransitioned to?
13:54cemerickPourletain: I'm as much of a pedant as anyone else, but I wouldn't think less of someone for not using proper grammar. Anyway, not into OT grammar quizzes in irc. :-)
13:54Pourletaincemerick, pædant*
13:55Pourletainsurely.
13:55maxmartinso glad I'm in this room to catch all the useful discussion about Clojure
13:55PourletainDamn, I am good at this.
13:56technomancyPourletain: either that or people in this channel are really bad at it
13:59arrdemBronsa: ping
13:59Bronsaarrdem: pong
14:00dbaschI’ve been wanring to build an implementation of Shamir’s Secret Sharing Scheme in clojure for a while but my brain is not letting me get started
14:00dbaschwanting
14:01Jaooddbasch: disconnect from the internet ;)
14:01dbaschJaood: but then how can I steal other people’s code? :P
14:02arrdemBronsa: so I just got lambda lifting working, but there's one dirty trick I'm playing I'd like to check with you. I replace lifted functions with a partial that takes the used locals and makes them explicit parameters. To do this I have to analyze the partial in the same environment that I lifted the inline fn out of, which means that I just steal the :env key and reuse that environment exactly. It works, but does that make sense to you?
14:02arrdemEx. (let [x 3] ((fn [y] (+ x y)) 4)) -> (def fn_9001 ([x y] (+ x y)), (let [x] ((partial fn_9001 x) 4))
14:05Bronsaarrdem: yeah, that's what :env is there for
14:05arrdemBronsa: sweet, thanks.
14:11Viestiseems that Immutant has a workaround for use with core.memoize https://github.com/immutant/immutant/blob/1.1.1/modules/cache/src/main/clojure/immutant/cache.clj#L143-L149
14:12Jaooddbasch: so much dependence
14:12Jaood!
14:19jcrossley3Viesti: the comment for that commit might help to clarify what it's doing: https://github.com/immutant/immutant/commit/d1bcbccbe1
14:19jcrossley3it's not really a workaround. it's just storing the delay in ram until it's actually realized.
14:22rasmustotechnomancy: artifact is gpg signed, and scp deployed to a directory that's symlinked into /var/www, love how easy that was
14:23technomancyrasmusto: yay!
14:23rasmustotechnomancy: that's definitely wiki worthy
14:24technomancyrasmusto: rather have it in the official docs
14:25rasmustothat works too :)
14:26amalloyarrdem: i don't understand the value of doing this lifting and replacing with partial
14:27arrdemamalloy: it exposes otherwise closed over functions as top level defs that I can play with, merge and inline without introducing special case code to handle inline lambdas.
14:27arrdemamalloy: no expected performance gain just from doing this, but it's a transformation enabler.
14:33Viestijcrossley3: yep, the first time I looked at the metadata kept by the memoized function, was a little puzzled an kind of dismissed it but now I'm getting the hang of it
14:33samratin this macro, https://www.refheap.com/86025 why does unquoting happen properly with the `filters`?
14:34Viestireally it seems that keys get stored as clojure.lang.ArraySeq instances and values are deferreds
14:34jcrossley3Viesti: yep
14:35jcrossley3the keys correspond to the args passed to the memoized fn
14:35samratdamn, I meant "why does unquoting _not_ happen properly"
14:37Viestiyep so the "rest args" is neat in that case
14:38Viestiusing memcached with core.memoized would be more simplistic, keys would be just strings
14:38Viestibut it's a little weird..
14:38Viestimemoization is more generic thing
14:40l3dxhow can I get the indices [x y] of a 2d vector where the "cell" value matches some predicate? is map-indexed the way to go?
14:40rasmustol3dx: sounds like it
14:41Viestior well, I could have function that takes any number of arguments, does something, and the value would be stored to memcached
14:41dbaschsamrat: why do you say unquoting doesn’t happen properly? do you have an example usage for that macro? what do you expect it to do?
14:42Viestithe thing is to encode the arguments so that memcached is pleased
14:42samratdbasch: when I call it like (test-macro my-filters), I get Don't know how to create ISeq from: clojure.lang.Symbol
14:42dbaschsamrat: what is my-filters?
14:44samratdbasch: just a var. something like (test-macro [{:term "a" :op "foo" :vals "bar"}] works
14:49amalloysamrat: the macro receives a symbol, not the symbol's value
14:49dbaschsamrat: unquote works, it just evaluates filter to the symbol
14:49amalloyor rather, not the value of the var named by the symbol
14:49dbaschfilters
14:49dbasch(eval filters) would do it
14:50amalloydbasch: :(((((
14:50amalloyonly in the most simplistic of circumstances
14:50dbaschamalloy: yeah, not the best way
14:51dbaschwhat is the macro supposed to do anyway?
14:51samratdbasch: its a simplified version of something else
14:51samratdbasch: so that macro itself is pretty useless
14:51gastoveo
14:52samratamalloy dbasch : what would the right way to have this work then?
14:52amalloysamrat: it's impossible to say, since this macro is, as you say, useless. how can you make it work if it doesn't make sense?
14:52amalloyinstead, describe a real problem you're having, and then solutions to that will be helpful
14:52dbaschsamrat: what do you want this code to look like after macro expansion?
14:55samratamalloy dbasch: I'm writing a macro that generates a function that takes a list of filters described in maps, and returns a predicate function that will check for those filters.
14:55dbaschsamrat: why does it need to be a macro?
14:56samratamalloy: I've already written that macro however I cannot call it with symbols bound to filters, but I can use it with just filters
14:56amalloysamrat: that was dbasch, not me. but i agree with him: this should be a function
14:57amalloyyou've already written a macro which "works", except in the cases where you want it to work (ie, with def'd values instead of inline source code) - and it won't work in those cases, because that's what functions are for, not macros
15:02{blake}I am reconfused by this: https://www.refheap.com/86027 (It's an attempt to allow the caller to access a parsed/zipped xml through a series of tags.)
15:03{blake}Aw...crap...
15:04samratamalloy : alright I'm thinking about this. I now have a function that returns a list, which I can `eval` to get the predicate that I want. Is there a better way to get the function itself?
15:05samrator do I need to eval it?
15:06dbaschsamrat: if you have a list of functions you don’t need to eval anything, you can compose them or juxtapose them or whatever you need to do to create the function you want
15:08samratdbasch: no. I am using the `reduce` to avoid having a list of functions. Only one function is returned. Hence, I need the `reduce` to run when `test-macro` is called
15:11amalloy{blake}: are you confused about anything in particular? it's tough to help with "this is some code, i'm confused"
15:12dbaschsamrat: post the refheap
15:13{blake}amalloy, Yeah, it's a structural thing. I'm passing a vector of hashes, then I'm trying to take a vector of hashes out of that to pass recursively, but...I'm not. I think. That printout makes it look like I am. (But I think there's some laziness there, since it also looks like I'm returning the output of my printlns.)
15:14{blake}The result of (by-tags sample :L1 :L2) should be [{:tag :L2 :content [{:data :stuff}]}]
15:15amalloywell, it's close to that; you just have an extra () at the end
15:15samratdbasch: https://www.refheap.com/86028
15:15{blake}amalloy: Eh...no, I think that's just the result of the printlns. If I take the printlns out I get "(())".
15:16amalloyand why is that? the only obvious error, to me, is that you're calling by-tags incorrectly in the recursive case: it wants varargs
15:16amalloyah. well, that's what you get for putting all these printlns in the middle of lazy code :P
15:16amalloyreally, {blake}, i'd say just remove the & from by-tags's signature - it's not doing anyone any favors
15:16{blake}amalloy, That sounds promising. And, yeah, I realize I'm...either too lazy or not lazy enough. I'm not the precise amount of lazy.
15:16amalloythen call (by-tags sample [:L1 :L2])
15:17{blake}amalloy, Oh...have them pass in a vector?
15:17{blake}'k lemme see
15:17gfrederickssamrat: what happens when you write this as a function?
15:19samratgfredericks: I get a list which I can eval to get the function that I want.
15:21llasramsamrat: What if instead of `eval`ing something you just return a closure?
15:21{blake}amalloy, OK, thanks, that worked.
15:21{blake}(inc amalloy)
15:21lazybot⇒ 113
15:23samratllasram: not sure what you mean. But I need some computation done when test-macro is called- the reduce needs to get evaluated.
15:24{blake}(I really thought I =was= doing someone favors with the whole "& tags" thing.)
15:25llasramsamrat: sure, so do something like (defn whatever [filters] (let [fs (map ... filters)] (fn [obj] (every? #(% obj) fs))))
15:25amalloysamrat: you can write it easily enough as a function with the basic outline of https://www.refheap.com/01d532c4d8e897f3a23217243
15:26amalloywhich, not coincidentally, is what llasram just said, but more fleshed out
15:28llasramYou can pump out code waaay faster when the code doesn't even need to parse :-D
15:28gfredericksdownside to stuartsierra/component: wrapping a component is hard.
15:29amalloyllasram: 14 seconds is hardly waaaaay faster. i'll race you any day
15:29llasram:-)
15:32amalloyjust edited the paste with a slightly more performant version, pre-caching the (set vals) version. <3 (fn (let (fn (let ...))))
15:32gfredericksamalloy: time to use the <<- from swiss-arrows
15:33amalloywat
15:33{blake}Can "recur" only be used with loop? And is that the only form of tail recursion in Clojure?
15:34amalloy{blake}: loop or the start of a function
15:34AimHereWell recur recurs either to the enclosing loop, or to the enclosing function
15:34AimHereThere's also trampoline
15:34gfredericksamalloy_: https://github.com/rplevy/swiss-arrows#the-back-arrow
15:34{blake}amalloy_, AimHere: Thanks, that's what I thought, but all the examples I found only used recur with loop.
15:34AimHere,(recur)
15:34gfredericks&(recur)
15:34clojurebotExecution Timed Out
15:35lazybotExecution Timed Out!
15:35gfrederickslazybot is more enthusiastic about timeouts
15:35arrdemgfredericks: why would you use that...
15:35AimHereYou know, of the two, I'd think lazybot would be the least enthusiastic one
15:36samratamalloy_: ok, thanks a lot for the help. I'll take a better look at it in the morning.
15:36gfredericksarrdem: why would you use swearjure?
15:37{blake}Swearjure: Befunge for a new generation...
15:40gfrederickswe need a word like ninja or rockstar but for swearjure programmers
15:40gfredericksan anchor for recruiters to cling to
15:40{blake}H.P. Lovecraft might be a good source for that.
15:42arrdem1% of the elder gods control 90% of the evil!
15:42{blake}Occupy Ryleh!
15:42arrdemhow about we don't I like my sanity where it is thank you...
15:43arrdemwe'll all be cthulu snacks eventually but I'd rather postpone that fate if possible
15:51arohnerare there any other core.async buffer implementations? I'm thinking I want a core.async buffer that uses a circular buffer (i.e. array) rather than a linked list
15:52arohnerbecause I want to take > 1 value off a channel at once
15:53arrdemdoesn't that violate the core async state machine structure? you can take multiple values, but each time you take a value you "block" on the channel to provide a value which is really a callback to the producer structure to emit values AFAIK.
15:54arohnerthough I guess things might work if I put byte[] as 'values' onto the chan
15:54arohnermy goal is to take all values I can w/o blocking
15:55gfrederickshey rhickey is keynoting at lambdajam maybe he will prove once and for all that static types are the devil
15:57arrdemhe's welcome to say that, but a lot of people myself included will disagree.
15:57mskoud,(partition-by #(= % 3) [1 2 3 4 5 6 3 7 8])
15:57clojurebot((1 2) (3) (4 5 6) (3) (7 8))
15:58mskoudbut i really wanted ((1 2) (3 4 5 6) (3 7 8))
16:02{blake}OK, so, now my by-tags digs down and finds the path :L1 :L2 :L3 (etc) but of course it returns the answer nested for each layer (((L3-stuff))). I really just want "L3-stuff".
16:03{blake}flatten?
16:03clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
16:03{blake}heh
16:04gtrakarohner: cljs version uses circular buffers
16:05gtrakhttps://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/buffers.cljs#L23
16:06gfrederickshaha my such-that just blew up after 10 tries and I have no idea which one it was. thank you combinators and your useless stack traces.
16:09gtrakgfredericks: swearjure impressionists.
16:09gfredericksmskoud: might be easiest to just write your own recursive lazy function
16:10gtrakmaybe not extreme enough.
16:14gtrakswearjure radicals.
16:15rasmustoswashbucklers
16:15gtrakomg, pirates!
16:15gtrakninjas, rockstars, pirates.
16:15gtrakobvz
16:17gfredericksgtrak: but still using the word "swashbucklers"?
16:18TEttingercode khans
16:18TEttingerdigital spartans
16:18joelkuipercan't brain today. Say I have two vectors of maps [{:a 1 :b 2} {:a 3 :b 4}] and [{:a2 1 :b2 2} {:a2 3 :b2 4}] and I wish to merge them such that the result will be a new vector [{:a 1 :a2 1 :b 2 :b2 2} {:a 3 :a2 3 :b 4 :b2 4}]
16:18joelkuiperwhat would be the easiest way to do so?
16:18joelkuipermessed up the example, but you get the ide
16:19rasmusto,(map merge [{:a 1 :b 2}] [{:c 3 :d 4])
16:19clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
16:19rasmusto,(map merge [{:a 1 :b 2}] [{:c 3 :d 4}])
16:19clojurebot({:d 4, :c 3, :b 2, :a 1})
16:20joelkuiperdo totally forgot about the & cols on map, thanks rasmusto
16:20rasmustojoelkuiper: np
16:22gfrederickswhy on earth would you throw an ExceptionInfo with an empty map?
16:23rasmustowhom is throwing ExceptionInfo?
16:23hiredmanyou just want to watch the world burn
16:28gfrederickshttps://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/generators.clj#L258-259
16:28gfredericksreiddraper: when I first saw the limit-10 on such-that I thought it was terrible and now that I've run into for the first time I think it's great
16:35reiddrapergfredericks: happy to hear that
16:48whodidthishttp://docs.oracle.com/javase/8/docs/api/java/time/Instant.html#now-- how do i get one of these bad boys in clojure
16:50dbaschwhodidthis: are you running java 8?
16:51whodidthisyes, am just confused how to interop one of them cool instants
16:51dbaschdo you really need nanosecond precision?
16:52whodidthiswell, that or localdatetime, more interested in minus/plus functionality without joda
16:53dbaschwhat’s the confusing part? can’t you treat them like any other java classes?
16:53whodidthisold style date thingie is (java.util.Date.), instant is (. now java.time.Instant) but that doesnt work cause im a bad
16:53dbasch(java.time.Instant/now)
16:53dbaschit’s a static method
16:53whodidthissweet, thanks
17:01technomancywhoa, somehow I missed that 310 made it in
17:02technomancymakes it sting all the more than clojure ships with j.u.Date support by default =(
17:02gfredericks310?
17:02technomancyjsr 310
17:02technomancytemporal units that aren't a disaster
17:03gfredericksdo we need a lib for setting #inst to the new stuff?
17:03technomancyI think it's just a data_readers entry
17:04arrdemgfredericks: you can't write a lib for that unless it crowbars into core..
17:04arrdemonly namespaced reader lits are user accessible.
17:04technomancyrich said he was debating having the default data_readers blow up if 310 wasn't available, but sadly that didn't happen =\
17:06gfrederickstechnomancy: you know I'm starting to wonder if you might have something against java.util.Date.
17:06arrdemBronsa: ping
17:06technomancygfredericks: "why should I change; he's the one that sucks", &c
17:07arrdemBronsa: https://www.refheap.com/86030
17:07gfredericksarrdem: really? I coulda sworn you can do those things as long as you don't tell rich
17:07arrdemgfredericks: here take this crowbar it's dangerous to go alone
17:08Farehow do I use maths functions?
17:09Bronsaarrdem: ouch.
17:09Fare(use 'clojure.math.numeric-tower) => FileNotFoundException Could not locate clojure/math/numeric_tower__init.class or clojure/math/numeric_tower.clj on classpath: clojure.lang.RT.load (RT.java:443)
17:09seancorfieldFare: sounds like you didn't add the dependency to project.clj?
17:09arrdemBronsa: T_T I'm getting started on dealing with letfn and that guy cropped up.
17:09Farewhat project.clj? All I did was M-x cider-jack-in
17:10seancorfieldFare: to use anything other than core Clojure, you need a "project" (created by Leiningen) that lists dependencies
17:11kenrestivoclojurebot: java.util.Date is Michael Bolton
17:11clojurebotOk.
17:11Fareok. What if I'm not using leiningen?
17:11warlockclojurebot: crowbar is when all else fails just alter-var-root!
17:11clojurebotOk.
17:12Bronsaarrdem: looking into it
17:12arrdemBronsa: Thanks. I'm gonna reup on the coffee and take a look myself.
17:12technomancyrich said on an application level it would be OK to make #inst use something else
17:13technomancybut that may have been before the design was finalized
17:13kenrestivoi was amused that in one of rich's projects, instead of fixing a bug in an upstream library and submitting a pull request, he just copy/pasted the function's code into his own project, fixed the bug, and alter-var-root patched it
17:14arrdemCrowbars: even the language designer uses them, why don't you!
17:14seancorfieldFare: what are you using for dependency management then if you're not using Leiningen?
17:14seancorfieldFare: hint: use Leiningen :)
17:15hiredmantechnomancy: well, that is sort of the point of data readers, to disentangle the semantics of serialized data from the actual type in memory
17:15gfredericksarrdem: now that technomancy mentions it I think changing the behavior of the core data readers was completely intended
17:15gfredericks,default-data-readers
17:15technomancyyeah, one would hope you'd be able to reverse the brain damage of the defaults
17:15clojurebot{inst #'clojure.instant/read-instant-date, uuid #'clojure.uuid/default-uuid-reader}
17:16gfredericksarrdem: and I've definitely done this at an app level, e.g. with clj-time/joda
17:16amalloyFare: if you're not using leiningen, use leiningen
17:16technomancydoing it in a library might be mildly sketchy? dunno.
17:16amalloyit's so much better than the alternative
17:16PigDude,(defn update [m ks f] (let [v (select-keys m ks)] (merge m (zipmap (keys v) (map f (vals v)))))) (update {:a "2" :b "3"} [:a :b] #(Integer. %))
17:16clojurebot#'sandbox/update
17:16PigDudeis there something like this in clojure.core?
17:16PigDude,(update {:a "2" :b "3"} [:a :b] #(Integer. %))
17:16clojurebot{:b 3, :a 2}
17:17technomancyPigDude: map-keys and map-vals are conspicuously absent for some reason
17:17PigDudeok, thanks
17:17PigDudeyea, those are better names
17:17arrdemPigDude: there is an open proposal for _a_ update function, but it behaves differently than what you described.
17:17amalloytechnomancy: he actually didn't wriet map-vals, there
17:17gfredericksPigDude: they're conspicuously present in prismatic/plumbing
17:17technomancyamalloy: oh, hrm
17:18technomancyamalloy: overzealous irc pattern matching strikes again
17:18amalloyPigDude: http://dev.clojure.org/jira/browse/CLJ-1251 is why it doesn't yet exist; https://github.com/flatland/useful/blob/develop/src/flatland/useful/map.clj#L127-L134 is an implementation in useful
17:19PigDudeamalloy: is it better to use update-in than to just straight-away recreate the map?
17:19PigDudeamalloy: (using zipmap like mine)
17:21Bronsaarrdem: it's a bug in the collect-closed-overs pass
17:21Fareok.
17:21amalloyPigDude: if you have a large map and you're updating each key in it, building a new map and then merging it is pointlessly expensive, compared to updating the existing one in place
17:22PigDudemakes sense
17:22PigDudemy first one was using reduce like yours but i didn't like how it looked
17:22arrdemBronsa: shall I kick off a ticket for it?
17:22arrdemalso looking into that pass because I just build something very like it...
17:23FareHow do I tell emacs which project to use?
17:23Faredo M-x cider-jack-in while the current directory is under the project?
17:23technomancyFare: yeah, it's based on the current dir
17:24Bronsaarrdem: yeah go on open a ticket
17:25amalloyPigDude: i mean, you can write it differently if you don't like reduce: (into m (for [k ks :let [e (find m k)] :when e] [(key e) (f (val e))]))
17:25amalloybut i don't think that reads better
17:25seancorfieldFare: if you have Leiningen installed, you could say: lein new mathtest - to create a project, then edit project.clj and add [org.clojure/math.numeric-tower "0.0.4"] as a dependency, then edit src/mathtest/core.clj and jack in and you'll be off to the races
17:25stormeis there a way to assign arguments in clojure similar to the ||= operator in ruby?
17:25stormevars*
17:26amalloystorme: there's no way to assign anything ever
17:26amalloybut you can just use (or)
17:27storme(or something-that-might-have-been-defined what-it-will-be-defined-if-it-has-not)?
17:27PigDude,(defn map-keys [m ks f] (reduce (fn [m* k] (if-let [v (k m*)] (assoc m* k (f v)) m*)) m ks))
17:27clojurebot#'sandbox/map-keys
17:27amalloywell, yes, modulo the weirdness of what it means to be "not defined"
17:27PigDude(map-keys {:a 1} [:a :b] -)
17:27PigDude,(map-keys {:a 1} [:a :b] -)
17:27clojurebot{:a -1}
17:27PigDudeamalloy: that was my first one which doesn't pass nils to the fucntion, unlike update-in
17:27PigDudeamalloy: that's also why i use the select-keys view in the first code i showed
17:28amalloyPigDude: well, the one i linked in useful assumes you're passing keys that exist. but if it's important that you be able to "skip" keys that don't exist, the one i pasted in irc a minute ago does that
17:29Fareseancorfield, thanks
17:29amalloyyours has the serious issue that it doesn't work for maps whose values are nil or false
17:29PigDudei was just using it for strnig to integer conversion :P but fair point
17:31PigDudeamalloy: but i just change the if-let to contains? and i'm set
17:31arrdemBronsa: merry christmas. http://dev.clojure.org/jira/browse/TEMJVM-6. let me know if there is anything I can do to help.
17:33PigDude,(defn map-keys [m ks f] (reduce (fn [m* k] (if (contains? m* k) (assoc m* k (f (k m*))) m*)) m ks))
17:33clojurebot#'sandbox/map-keys
17:33PigDude,(map-keys {:a nil :b false :c 4 :d 2} [:a :b :c] (constantly 5))
17:33clojurebot{:c 5, :b 5, :d 2, :a 5}
17:33amalloysure, but now you're looking a key up in the map twice. it's harder than you think to write quality implementations of these basic functions
17:37PigDude,(defn map-keys [m ks f] (reduce (fn [m* k] (let [v (get m* k ::empty)] (if-not (= v ::empty) (assoc m* k (f (k m*))) m*))) m ks))
17:37clojurebot#'sandbox/map-keys
17:37PigDude,(map-keys {:a nil :b false :c 4 :d 2} [:a :b :c] (constantly 5))
17:37clojurebot{:c 5, :b 5, :d 2, :a 5}
17:37PigDudeer i should include a nil key
17:37PigDude,(map-keys {:a nil :b false :c 4 :d 2} [:a :b :c :zzz] (constantly 5))
17:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: map-keys in this context, compiling:(NO_SOURCE_PATH:0:0)>
17:38PigDudewell that romance ended quickly
17:38PigDude,(defn map-keys [m ks f] (reduce (fn [m* k] (let [v (get m* k ::empty)] (if-not (= v ::empty) (assoc m* k (f (k m*))) m*))) m ks))
17:38clojurebot#'sandbox/map-keys
17:38PigDude,(map-keys {:a nil :b false :c 4 :d 2} [:a :b :c :zzz] (constantly 5))
17:38clojurebot{:c 5, :b 5, :d 2, :a 5}
17:39hiredman(doc find)
17:39clojurebot"([map key]); Returns the map entry for key, or nil if key not present."
17:40amalloyhiredman: i already showed an implementation using find. i imagine he wants to do it differently
17:40PigDudethanks hiredman
17:40hiredmananyway, map-keys is gross
17:40hiredmanuse something that isn't a map
17:50Frozenlo`Anyone familiar with nginx and ssl stuff? I have 2 website on the same server. I use clj-http to fetch some data. Doing (client/get "https://my-website-1&quot;) works fine. But (client/get "https://my-website-2&quot;) fails. ---> SSLException hostname in certificate didn't match <my-website-2> != <my-website-1> OR <my-website-1> OR <www.my-website-1>
17:50Frozenlo`I'm a little confused, because browsers don't throw this error :-/
17:54noonianfrozenlock: it sounds like the ssl certificate is only valid for the domains my-website-1 and www.my-website-1
17:55frozenlockSure, but each website has its own certificate
17:56frozenlockI suppose nginx is giving the wrong certificate to clj-http but not to browsers for whatever reason...
17:57Bronsaarrdem: https://github.com/clojure/tools.analyzer/commit/60e271ca7066c59d04d683c7c403045d3e048669
17:59arrdemBronsa: Awesome thanks! Now to update oxcart to use your bindings collection code rather than mine...
18:00Bronsaarrdem: oh well wait. now it compiles but still fails ;-;
18:06frozenlockwell, looks like I'm not alone O_o https://github.com/dakrone/clj-http/issues/202
18:07frozenlockdakrone: Ping! Could it be that clj-http doesn't support SNI (server name indication)?
18:13gfredericksman assembling symbols from other symbols is always a pain
18:13caternit should be a pain, though, because it's a dark thing to do, right?
18:14frozenlockWhy would it be dark?
18:15amalloyit's something you should be careful about, anyway. most of the time you should regard symbols as indivisible, whereas strings are just a seq of chars in a pretty package
18:15gfrederickse.g., if in a def-style macro I want to make a symbol representing the fully-qualified name of the thing being defined
18:15technomancythere's a reason CL calls them "atoms"
18:16gfredericksI have to create a (symbol (name (.getName *ns*)) (name the-def-name))
18:16dakronefrozenlock: pong, I saw the issue you pinged on, I will look at it when I can (traveling now)
18:16amalloygfredericks: (defn symbol* "Like symbol, but not as dumb." [& args] (apply symbol (map name args)))
18:16gfredericksamalloy: uh huh
18:17gfredericksamalloy: apparently my threshold for complaining about a problem is lower than my threshold for using a util library to solve it
18:17frozenlockdakrone: Awww... but I wanted it naow! :-p Perhaps you could point me in the good direction for a pull request? (if you know what the problem is)
18:17bbloomgfredericks: seems to me that the cost of utilizing a util lib is dramatically too high
18:17amalloyyou don't even need a util library. just tattoo that snippet on your wrist so you remember to paste it into every app
18:18bbloomgfredericks: yeah, what amalloy said. copy/paste is a-ok
18:18amalloyanyway, i don't know of any util libraries that actually include symbol*
18:19cbpnot even useful?!
18:20gfrederickstechnomancy: yeah ' FTW
18:20amalloywell, i defined it once as a letfn for a function in useful.experimental
18:20technomancyactually that one especially. just call it useful.whatever/symbol
18:20gfredericksoh right of course
18:20technomancygfredericks: http://p.hagelb.org/get-out.gif
18:20gfredericksbbloom: any speculations for how it could be easier?
18:21technomancygfredericks: I had to remove a bunch of faux-prime marks from leiningen the other day
18:21amalloyi'm gonna define a library named *
18:22amalloythe functions will just be named *, **, ***, ****
18:22bbloomgfredericks: automated copy/paste :-P
18:22bbloomamalloy: what will they do?
18:22frozenlockWait, there's an official usage of '*'?
18:22Bronsaarrdem: ok there was a bug on the tej side too, fixed that. looks like I forgot to test letfn w/ out-of-order deps
18:22amalloybbloom: annoy technomancy
18:22frozenlockI usually append * to a function that shouldn't be considered complete - shoudn't be used directly. Any suggestion? :-/
18:22bbloomamalloy: seems like that belongs in useful
18:23technomancyfrozenlock: that's what I interpret * as meaning, yeah
18:23technomancythat you shouldn't be using it directly
18:23frozenlockah ok
18:23technomancybut it can't be private because it's in macroexpansions
18:23amalloyfrozenlock: that's one common use of *. technomancy thinks it should be the only use, but it's not really a language standard
18:23amalloyesp given functions like list*
18:23arrdemBronsa: cool.
18:23technomancythe other meaning is "I couldn't think of a good name for this" =P
18:23Bronsaarrdem: thanks for the report and sorry for the trouble :/
18:23amalloywhere * just means "kinda like X but i couldn't think of a good name"
18:23bbloomtechnomancy: for that purpose, i use "blah"
18:23arrdemdefn****
18:24cbpsymbol++
18:24amalloyone thing about working witn ninjudd: he could *always* find a name he liked better than foo*. he programmed with a thesaurus in his hand
18:24Bronsahttps://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/jvm/utils.clj#L228-L233 get on my level.
18:24arrdemBronsa: no worries, thanksf or the quick fix
18:24bbloomBronsa: heh, i've done that
18:25technomancyamalloy: https://mobile.twitter.com/topfunky/status/466652171061436416?p=v
18:25bbloomBronsa: actually
18:25bbloomBronsa: that looks silly
18:25amalloyBronsa: there are so many nicer ways to write that (or)
18:26amalloyeg, (#{mn mn* mn** mn***} name)
18:26bbloomBronsa: and you can create that #{...} at once
18:26Bronsaamalloy: yeah, I'm not really sure why I didn't do that
18:27arrdemeh the jit'll probably throw away a set if you use one there and generate exactly that comparison code..
18:27amalloyarrdem: you wish
18:28arrdemamalloy: object elision is osum
18:29arrdemBronsa: heh using your collect-closed-overs makes this way nicer.
18:29amalloyarrdem: i think you actually get more efficient code if you close over the set, probably
18:29amalloyas opposed to writing out four = comparisons
18:30TimMcWhat, an object creation and a hash lookup is faster than four equality checks?
18:31TimMc*three, I guess
18:32amalloyTimMc: you can create the object once and use it many times
18:33amalloy(let [matcher #{...}] (fn [name] (matcher (str name))))
18:33amalloyand then you're only closing over one thing instead of four, so making the object is cheaper; and you only have to pass name once, and...
18:36TimMcBut the hash lookup is faster?
18:36TimMcHmm... I guess JVM string hashes are pretty simple, and these are small strings...
18:38amalloy,(class #{"x" "y"})
18:38clojurebotclojure.lang.PersistentHashSet
18:38TimMcWhen someone says "hash" I think "SHA1" or in general something more involved than a linear combination of the inputs. :-P
18:38amalloyi always forget we don't have array-sets
18:39bbloomamalloy: yup, no array-sets :-/
18:44technomancypoll: would you want `lein release` to run your tests for you before bumping your version number, tagging, deploying, etc? or would you be annoyed at it.
18:45arrdem+1 would want, or would write git hook to provide
18:46technomancyeither way it'd be easy to add
18:46catern+1
18:48shep-homeHi all!
18:48shep-homeAbout how long does it take from me putting my CA in the mail and showing up on the CA list?
18:49shep-homeI've got some commits burning a hole in my pockets!
18:49hiredmantechnomancy: by "either way it'd be easy to add" do you mean it would be asy to remove if you don't want that?
18:50technomancyhiredman: yeah
18:50technomancywell
18:50technomancyyou could provide your own :release-tasks vector
18:50technomancywhich is easy but verbose
19:22kenrestivo,(def -_- 42)
19:22clojurebot#'sandbox/-_-
19:23kenrestivo,-_-
19:23clojurebot42
19:32frozenlockIf I want to result of something sent to a writer, I can use `with-out-str' and *out*. Is this the best way?
19:34kenrestivoi guess, if the function you're trying to capture the result of, doesn't return it directly, but instead wants to poot it to *out* as a side effect
19:35frozenlockIt does, which is kinda weird... Especially considering that similar libraries just return you the data. https://github.com/clojure/data.csv
19:35kenrestivo,(def -_- (symbol ":-)"))
19:35clojurebot#'sandbox/-_-
19:35kenrestivo,-_-
19:35clojurebot:-)
19:35kenrestivoclojure mood improvement
19:37kenrestivohuh, i've used that library before, i don't remmmeber it being that annoying and insisting on *out*. huh. maybe i used it only for reading
19:37dbaschfrozenlock: I see that the functions explicitly ask for a writer in the parameters
19:37frozenlockYes :-(
19:37frozenlockI give it *out*
19:38dbaschis that a problem?
19:38frozenlockI don't know
19:41dbaschfrozenlock: this library is meant to spit out csv files, using a writer is one way to do that
19:41kenrestivothers's probably some plumbing with bufferedwriter or similar that could be done to create a writer you could pass to that function, and then pull the data out of into a string or whatever you like. been a while since i dealt with clojure.java.io though.
19:41amalloydumping an entire csv into one string doesn't seem like a fun time. people make absurdly large csvs
19:42frozenlockhttps://github.com/clojure/data.json is pretty much the same thing, but gives the result back.
19:42dbaschbut if you know you’re creating small csv files in your program, you can dump them into a StringWriter
19:43dbaschnot sure why you would want csv in memory as a string though
19:44dbaschcsv is a least-common-denominator export format
19:45dbaschjson is different because it’s meant to be passed over the wire
19:46frozenlockdbasch: I want to serve it throught liberator. I have some data in vectors form that I want to let the user download as a CSV.
19:48dbaschfrozenlock: are they generated on the fly or are they worth caching?
19:48frozenlockon the fly
19:48amalloyyeah, definitely don't put that into a string
19:49amalloyinstead, create a Writer that pipes to a pipe that ring is reading from, so that the data streams straight from data.csv to the user
19:51amalloyeg, use https://github.com/ring-clojure/ring/blob/bc4ddda43e68cc2117f73306d936555ac870239b/ring-core/src/ring/util/io.clj#L11 and java.io.OutputStreamWriter
19:52frozenlockWill try immediately, thanks
19:55krasHi, I am reading an EDN file into clojure. It gives me an error saying there are duplicate keys. IllegalArgumentException Duplicate key: clojure.lang.PersistentHashMap.createWithCheck (PersistentHashMap.java:67)
19:55krasHow do I find out this duplicate key?
19:55gtraksounds like EDN that was edited manually.
19:56krasI generated the EDN file from a python parsing program
19:56gtrakohhhhh... :-
19:56gtrak)
19:56hiredmanhow are you reading the file?
19:57kras(read-string (slurp "/Users/myself/gate_parser/hod.edn"))
19:57hiredmanthe easiest thing would be to put a check in the in the python program to make sure it doesn't output the same key twice
19:58amalloykras: i mean, when you try to read a map with a duplicate key, the exception message contains the duplicate key
19:58amalloy,'{a 1, a 1}
19:58clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: a>
19:58amalloyso, what is the duplicate key? look for that in the file
19:59hiredmankras: how large is the edn file? if it is small you should be able to read through it(if it is large you shouldn't be using slurp and read-string)
19:59hiredmanamalloy: it helpful prints nil as ""
20:00amalloyoh, no kidding? i was wondering why he didn't seem to have one
20:00amalloy,'{nil nil nil nil}
20:00clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: null>
20:00krasamalloy: it doesn't print the key in my case
20:00amalloyhiredman: looks like null to me
20:00hiredmanhuh
20:00nooniansounds like a bug in the python program to me
20:00amalloy,'{""""""""}
20:00clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: >
20:00noonian,{"" "" "" ""}
20:00clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: >
20:00noonianlol
20:00hiredmanheh
20:01hiredmanI guess " " would match the spacing
20:01krasjava.lang.IllegalArgumentException: Duplicate key:
20:01kras PersistentHashMap.java:67 clojure.lang.PersistentHashMap.createWithCheck
20:01kras RT.java:1462 clojure.lang.RT.map
20:01kras LispReader.java:1094 clojure.lang.LispReader$MapReader.invoke
20:01kras LispReader.java:1148 clojure.lang.LispReader.readDelimitedList
20:02noonianso the python program looks to be outputing a map with two or more keys that are strings of the same length containing nothing but whitespace
20:03noonianhow are you generating the edn in the python code?
20:03krasyeah looks to be the case
20:04krasyeah I open the edn file, I see a lot of "" in there
20:05krasI guess I need to work on my python edn_dump function
20:05krasamalloy: hiredman thanks for the hints
20:06krasnoonian: if you are interested in the python edn_dump, here it is
20:06nooniantry refheap or pastebin instead of pasting multiple lines in irc
20:06noonianhttps://www.refheap.com/
20:06krashttp://pastebin.com/Qz6fPfVT
20:07kraswas going to do that :-)
20:10krashiredman: on the file size, it is a 5MB file, but this is just a testcase
20:10krasmy actual files can run into GB
20:11amalloyyou plan to slurp a many-gig file into a single string, and then read-string it into a single object?
20:11hiredmangonna have a bad time
20:12hiredmaneven if you aren't doing that, gigs of small edn maps in a single file are a bad time
20:13krasfor the application I am building, I need that whole map in the memory
20:13hiredmanhave you considered a database?
20:14krashiredman: never used one so far
20:15nooniani envy you
20:15krasbasically, here is what the application is:
20:15hiredmananyway, we don't know what your requirements are, but slurp+read-string on a multi gb file is going to be slow
20:16krasI parse a verilog file using python and dump an EDN file. The goal is to read the EDN file which has all the sub-module information and build a graph out of it
20:17krasthen use DOT to generate a visaulization of that graph
20:17dbaschkras: you may want to check out neo4j
20:17hiredmanat the very least I would dump pairs in to the file, so each pair can be read one at a time instead of dumping a multi gig map
20:17dbaschit may be overkill though
20:18frozenlockWow. I'm so bad.
20:18frozenlockBehold, my csv! https://www.refheap.com/86033
20:19dbaschcsv is supposed to stand for comma, not crap :P
20:19krasnoonian: I am not a software engineer
20:19frozenlockdbasch: That's YOUR opinion! :-p
20:20dbaschkras: if you can write that code, you definitely can figure out a way to dump those values into a more efficient store
20:20krashiredman: I achieved the same stuff in python, memory is not a very big concern here
20:21krasthis is a process of porting the idea using clojure
20:21hiredmankras: sure, if it works it works
20:21krasmy finished python code looks like sphagetti and hence this exeercsie
20:22dbaschkras: I’m sure there are verilog parsers in Java you could use from Clojure instead of going through edn
20:23krasdbasch: antlr is on my mind
20:23krasbut as a first step I am using this approach
20:23krasbecause antlr has a big learning curve if I am not wrong
20:23noonianlike hiredman said, if it works it works; i'd stick with spit and slurp until it becomes a problem
20:24nooniani'm trying to figure out how many map entries you need for a GB+ file
20:25hiredmanI wonder about the amount of garbage the reader will generate
20:25krasnoonian: to give you an example, an average verilog netlist contains roughly 2.5M submodules
20:26krasso each child modue corresponds to a key in the dictionary
20:27frozenlockamalloy: I get a bunch of garbage out... would you mind telling me if everything looks in order? https://www.refheap.com/86035
20:27hiredmanyou may even have better luck writing values to a local memcached and just passing a list of keys
20:30krashiredman: since the hardware being equal and since it worked in python I am confident that this will work in clojure as well :-)
20:30Jaoodsqlite could be a sane choice too but I hear sqlite java support is not that nice
20:31amalloyfrozenlock: (a) please please include error messages when something goes wrong. it's tiring to use psychic powers. (b) you're passing data.csv an OutputStream, where it wants a Writer. that's why i said you'd need OutputStreamWriter
20:31dbaschJaood: sqlite from java is no different than using any other sql db
20:32Jaooddbasch: I was actually referring to the sqlite java driver
20:32noonianif you're set on using file's i'd try putting each sub module on a line and maping read-string over (line-seq file)
20:32dbaschJaood: I haven’t used it in maybe 5 or 6 years, it was fine back then. Has it gotten worse?
20:37frozenlockamalloy: (a) I did, I pasted it just a few lines higher. I guess I should have pinged you then.
20:37l1xhas anybody used graphs with clojure?
20:38amalloywait, that refheap was generated by your ring server? the code you pasted shouldn't even produce output at all; you should die quite quickly on a classcastexception
20:39hiredmanl1x: what do you mean by that?
20:39frozenlockAnd there I was thinking making progress because at least my server was giving me something.
20:40l1xhiredman: i was wondering how could i have a very simple undirected graph in clojure, i need to be able to get the shortest path between two nodes
20:42hiredmanl1x: https://github.com/aysylu/loom may be a good place to start, it is still maturing but it does have some path finding algorithms
20:44l1xhiredman: thanks!
21:14tufti used loom in a project -- worked well
21:40hellofunkwith cljs and getting DOM elements, it would seem wiser to leverage the built-in goog.dom library rather than the document.getElementById, is that right? or is there an even wiser approach?
21:45beamsoit looks like goog.dom.getElement just calls document.getElementById anyway.
21:45beamsohttp://docs.closure-library.googlecode.com/git/local_closure_goog_dom_dom.js.source.html#line112
21:46beamsoi have no idea what has changed but now my first om page using cljs-ajax is working now.
21:48hellofunkperhaps when working with Om, relying on the #js :ref for assigning and retrieving DOM ids is even better
21:48hellofunkbecause that should wrap everything in React, right?
21:51stormeWould someone be willing to look at my binary search implementation in clojure and critique it for me please?
21:51stormehttps://github.com/vincentstorme/clj-binary-search/blob/master/src/clj_binary_search/core.clj
21:54dbaschstorme: it’s very inefficient to sort the collection just to check that it’s sorted
21:54stormedbasch, What would you recommend?
21:55dbaschstorme: if you must check that it’s sorted, at least do it in linear time
21:57stormedbasch, Ah, so do the checks while it is searching by checking the neighboring elements if they are respectively higher/lower as they should be?
21:57hellofunk,(= [1 2 3 4] [4 3 2 1])
21:57clojurebotfalse
21:57hellofunkIsn't it throwing an exception because sorting negates equality?
21:58hellofunkYou are telling it if they are not equal, then throw an exception.
21:58hellofunkAnd you are making them non equal by comparing the original with the sorted version
21:59stormehellofunk, Thank you, I was assuming ascending sort
21:59hellofunkit probably is ascending sort
21:59hellofunk,(sort [4 3 2 1])
21:59clojurebot(1 2 3 4)
21:59hellofunkascending, right?
21:59stormehellofunk, Yep
22:01dbaschstorme: but more importantly, it defeats the purpose of binary search
22:02dbaschstorme: i.e. if you’re going to check every element, might as well do a linear search
22:02dbaschbinary search assumes your collection is sorted
22:03stormedbasch, So I shouldn't even worry about checking if the collection is sorted?
22:04dbaschif you’re going to be using binary search for millions of queries with the same collection, it may be worth checking the first time depending on your application
22:04beamsothe function str doesn't exist in clojurescript?
22:05seancorfieldbeamso: sure it does...
22:06beamsoit's probably me stuffing something up. my apologies.
22:07seancorfielddrop the code in refheap and show us?
22:08beamsoi think it's more me strugging to construct a anchor link in om.
22:09beamsohttps://www.refheap.com/86037
22:10stormedbasch, Thank you
22:10seancorfieldbeamso: you have an extra set of parens
22:10seancorfieldbeamso: compare with this https://www.refheap.com/86038
22:10stormedbasch, Do you see anything else that you might have concern with/that could be improved?
22:11beamsoseancorfield: i apologise for my stupidity. i think i may need food or coffee on that one.
22:13dbaschstorme: it can be made more idiomatic and probably more efficient too, and also you want to check that you’re doing this on a collection for which counting is free
22:13dbaschstorme: e.g. not a linked list
22:16seancorfieldbeamso: it's easy to accidentally add parens and get a baffling error msg - esp. in clojurescript!
22:23hellofunkI am working on a library, CloError, for clojurescript, that will give you an exact explanation of all errors, but also fix them for you, and with optional config, it will write your program for you. More details closer to launch, circa 2019
23:16LemurIs there a definitive source on operators? They're rather pesky to Google for.
23:17Lemursuch as ->> (which I assume is some form of pipe) and % (which is mod in some languages, args in others)
23:17bbloomLemur: you can always try (doc ...)
23:17bbloom(doc ->>)
23:17clojurebot"([x & forms]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
23:17bbloomworks in your repl
23:17Lemurnifty
23:17LemurSlightly new to this area.
23:17bbloomthere's also http://clojure.org/reader that covers the actual parsed syntax
23:18bbloomthose two things should get you started
23:18bbloomif you don't find anything in either of those, you can ask here
23:18LemurI know Ruby and a good amount of Haskell so shouldn't be too bad.
23:36uvtcLemur, I've always found the [cheatsheet](http://clojure.org/cheatsheet) to be very helpful.
23:37LemurVery nice indeed.