#clojure logs

2013-02-01

00:06rlI'm working on how to make a HTML form from a database model. The idea is to define the database model via macros, allowing the user to lables and description which can be be used for the html form. Would it be considered bad to do use a macro to automatically define functions for saving/loading/and persisting these models?
00:06rlsorry, mean saving, loading, and then displaying
00:07rlthinking a head, I know in Java with JDO you can use annotations to have a function be called for each specific model type before or after saving and loading
00:08rlusing macros I can define functions to do this without having to do run-time to see if a pre or post save/load function should be called for each model
00:09TimMcI'm not entirely clear on what you're asking, but I haven't heard anything yet that precludes using functions instead of macros.
00:14rlTimMc: the idea is do something like
00:14rl(define-model book ({:name author :description 'Author of book'} {:name published-data :description 'Published Date'}))
00:14rlthen a function such as (save-book book) can be defined, where it does all the necessary checking and sanitation if required
00:15technomancyrl: that would involve looking up what function to call at runtime based on user input; not a very good idea
00:17rltechnomancy: how so? i thought by using macros i can avoid this lookup issue
00:17technomancyrl: macros happen at compile time
00:17technomancyyou don't have user input at compile time
00:18rlyes, their is no need for user input at compile time here
00:18rlsave-book would be a defined function by the macro which can be used at run time
00:18technomancyyou don't need a macro for that
00:21TimMcrl: define-model would produce (defn save-book ...) and (defn load-book ...)?
00:21rlTimMc: yes, and (display-book) would be a html string such as a form
00:21rland (process-book) would parse the input data for a form
00:22TimMcWhy not (save-model :book ...) and (load-model :book ...) etc.?
00:23TimMcThen (def models {:book [{:name ... :description ...} ...]})
00:29rltinmc: thinking a head, mabey their comes a time I need to add a field. instead of having to check each field needs to have a default field added, using amcros i can create a function to mark this part of the run process, reducing the overhead of loading entities
00:29nonubyive got 2 arrays ['a','b','c'] and [1,2,3], I want to merge into a map { 'a': 1, 'b': 2, 'c': 3}, which clojure core function should I be looking at?
00:30technomancynonuby: zipmap
00:30nonubyperfect!
00:31rltinmc: erm, mean to say i can create a function to fill in the blanks for missing attributes if necessary.
00:31rlif i did this during run time, i would have to keep checking every attribute of every model if their is a default value to be loaded, which would be costly
00:32technomancyI think you would be surprised about what is actually costly
00:32technomancyI/O overhead will always dominate.
00:32rlbut if your modifying 1,000 entities, why even have the overhead you know?
00:33technomancybecause maintainability is more important than a few extra microseconds?
00:38rltechnomancy: is it really that unmaintainable in your opinion? if so, why? im new to clojure and trying to understand best pracitices
00:39technomancymacros are much more unpredictable than functions
00:40technomancyif I see someone using macros, I start looking for the reason behind it, and I assume there's something tricky going on
00:40technomancyif I see a function call, it's easy to tell at a glance what it does
00:42technomancymacros allow you to invent entirely new syntactic constructs, which is overkill for something like saving a DB record from a form.
00:46rlhm, well i guess I will run some tests. if i find it unacceptable I will go with my original idea.
00:46rlthanks for your input.
00:47gf3I used a macro once. Once.
00:47gf3Never again.
00:47gf3Macros. Not even once.
00:48rllol
00:49rli really think being able to shift some computation to compile-time rather then run-time is a big +
00:50rlsure the jit has run-time optimizations in place , but if it's a function with a switch statement that handles 50models +
00:51rli'm not sure how well it can optimize
00:55rlerm, sorry you wouldn't use switch statements here lol. i mean if every model is different, and every model can have a different pre,post,or default-value function to be evaluated, i don't think the jit would handle this well
00:56dnolenrl: fn invocation in Clojure is pretty cheap, you would be surprised.
00:56SegFaultAXI've never understood the irrational fear of macros.
00:56SegFaultAXEspecially in the Clojure world.
00:57RaynesIt isn't irrational and it isn't fear of macros.
00:57RaynesIt's fear of macros for stupid crap they aren't supposed to be used for.
00:57dnolenSegFaultAX: some early libraries overused macros is all
00:57SegFaultAXSure, I understand that.
00:57RaynesFunctions are wildly more flexible than macros.
00:57dnolenSegFaultAX: you have to remember Clojure attracted a lot people who hadn't used Lisp seriously before
00:57RaynesIf you can use them there isn't much point in using macros.
00:57SegFaultAXBut gf3's comments aren't the first I've heard like that.
00:57RaynesThat was a stupid joke. People make those a lot.
00:58gf3PSA: macros are cancer.
00:58RaynesAnd when they do, they usually know they're making stupid jokes.
00:58amalloythe clojure community also attracts stupid jokes
00:58amalloygf3: code generation considered harmful?
00:58RaynesMacros have a purpose. The "First Rule Of Macro Club" shit is just to prevent them for being used for purposes they aren't really meant for.
00:58gf3amalloy: I was just being silly, in response to technomancy
00:59gf3
00:59amalloyi know. you can see that i was too: considered harmful is just as silly as cancer
01:10nonubygiven two arrays [1,2,3] and [4,5,6] if I wanted to produce an array of maps [{:in 1 :out 4} {:in 2 :out 5 } {:in 3 :out 6}] what function should i look at
01:12TimMcmap
01:12TimMc&(map (fn [a b] {:in a :out b}) [1 2 3] [4 5 6])
01:12lazybot⇒ ({:in 1, :out 4} {:in 2, :out 5} {:in 3, :out 6})
01:14TimMcnonuby: ^
01:14nonubythanks Tim
01:14clojurebotthanks for your suggestion, but as usual it is irrelevant
01:14TimMcclojurebot: You're terrible.
01:14clojurebotHuh?
01:14TimMcclojurebot: forget thanks for your suggestion, but as usual it |is| irrelevant
01:14clojurebotI forgot that thanks for your suggestion, but as usual it is irrelevant
01:17amalloy~zip
01:17clojurebotzip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c))
01:28desertmonad It's probably just ignorance, but macros don't blow my mind quite like middleware and monads
01:30SegFaultAXdesertmonad: What's so hard about monads? They're just like burritos.
01:30desertmonadLuckily I haven't partaken of the burrito monad :)
01:31desertmonadSegFaultAX: to be honest, burritos blow my mind a little too.
01:33Chousukemonads aren't that weird at all in the end
01:33brainproxymonads are nice
01:34Chousukeif you want weird, you should look into type-level programming in Haskell
01:34brainproxymonad transformers are also nice
01:34brainproxybut can give you a headache
01:34Chousukedepends
01:34ChousukeTardisT certainly did to me
01:35brainproxyone level deep transformer isn't too bad
01:35brainproxybut you start going deeper and the mental overhead starts to grew exponentially
01:36Chousukesomeone wrote a monad which allows forward-flowing state in addition to reverse-flowing state and used it to implement an algorithm where you can express the calculation as if you were accessing values from the future
01:36brainproxythat's the Tardis thing, right?
01:37Chousukeyeah
01:37brainproxyI remember seeing a link to it, but never really dug into it
01:37desertmonadpiece of cake
01:37desertmonader, I mean burrito
01:37brainproxyI have yet to read a good explanation of comonads
01:38Chousukesometimes I feel Monads get a bit too much publicity as far as cool stuff in haskell goes.
01:38brainproxybut would be open to any suggestions
01:38Chousukeoh, hm, yeah
01:39technomancymy favourite thing about clojure is that you can often look at a referentially transparent function and understand exactly what it does in its entirety
01:40technomancyit makes it so a greater portion of the code is self-evident without a lot of context
01:40brainproxyi dunno
01:40technomancyand macros are more context you have to carry around
01:40brainproxyi've seen some pretty crazy functions
01:41brainproxyJim Duey's "comprehend" function in protocol-monads makes my head hurt every time I try to walk through it
01:41brainproxyit's like a purely functional implementation of do-monad macro
01:41Chousukecomonads are the dual of monads. whereas in a monad you put values in a context and perform operations within that context, a comonad is the opposite. you have a thing with a context, and there is an operation to take your value out of it.
01:42technomancybrainproxy: most people writing monads in clojure don't have "self-evident" high on their list of values
01:42brainproxyI made myself trace a couple of computations through his "comprehend" and then just decided that I would accept that it does the same thing as "do-monad" and leave it at that
01:42Chousukea zipper, for example is a comonad
01:43brainproxytechnomancy: https://github.com/jduey/protocol-monads/blob/master/src/clj/monads/core.clj#L25
01:45brainproxyanytime reduce is used to spit out a function, for me that's still like, "whoah..."
01:47Chousukethat looks like it's just a series of binds
01:48Chousukefor some reason written in pointless style. :P
01:48brainproxyChousuke: yeah, it does the same job as "do" in protocol-monads, "do-monad" in algo.monads
01:48brainproxybut no macros involved
01:49brainproxywhich is pretty nice for when you want to build other things on top of it
01:49Chousukebrainproxy: https://gist.github.com/312281 I wrote a protocol-monad thingy myself once too. my lift-function is awesome.
01:50brainproxyChousuke: interesting
01:51brainproxyChousuke: so, could you use a comonad in combination w/ a monad transformer?
01:52brainproxythe reason I ask is that sometimes when you build up a trasnformer combo thing, the "junction" between inner and outer monad is experienced to be quite "rigid"
01:53brainproxyin other words, you'd like to be able to reach in and do something with the value as it goes through the plumbing, but you just can't
01:53ChousukeI'm not really sure. I haven't seen many examples of comonads to begin with and never a comonad transformer (if such a thing makes sense)
01:54brainproxywhat i have in mind is when you use the writer monad in combination with say maybe transformer and state transformer
01:54brainproxythe typical helper methods for working with the writer's "log" just don't seem to work right
01:56brainproxywould be nice to have some piece of plumbing to stick in there somehow which lets you take extract the writer monad out of the monad sandwich, mess with it, and then let it fall back in to place
01:57Chousukethat would require the transformer stack itself to be a comonad
01:57Chousukewhich I don't think it is. since it's a monad :P
01:57brainproxyyeah, maybe so... need to learn some more haskell so I can actually read some papers on this stuff
01:58ChousukeI'm sure with the right combination of lifts and what have you, everything will work just fine
01:58Chousukeor use lenses.
01:58Chousukelenses are magic
01:58brainproxyor maybe arrows
01:59brainproxyi dunno, I barely know anything about arrows, comonads and lenses, but I didn't know jack about monads until last Nov
01:59brainproxyso maybe w/ a little more time I can dig into that stuff
02:03Chousukelenses are kind of scary
02:04brainproxyat one point I was poking at a javascript lenses library
02:04brainproxywas written by one of the guys who worked on the Flapjax reactive library for JS
02:04Chousukea while ago someone asked how to get the pair of sums from a list of pairs, and then someone came up with "over both sum" (IIRC)
02:04brainproxybut I got diverted and never really got deep into the lenses stuff
02:04ro_stwhat are lenses?
02:05SegFaultAXI saw a really good talk at the SF haskell user group about lenses. Very interesting stuff.
02:05ro_st-butts in-
02:05brainproxylenses are a way to express bidirectional computations
02:05Chousukero_st: "accessors" to data structures. on steroids and other crazy
02:06johnnyluuhello!
02:06ro_stinteresting!
02:06ro_sti'm really looking forward to the frp talk at CW
02:07brainproxyro_st: a guy name Nathan Foster did his thesis on bidirectional computation, lenses stuff
02:07brainproxyhttp://www.lulu.com/shop/john-nathan-foster/bidirectional-programming-languages/ebook/product-17382419.html
02:07brainproxyfree ebook edition of the thesis ^
02:08brainproxyro_st: who's doing the frp talk?
02:08ro_stAlan Dipert
02:08ro_sthttp://clojurewest.org/sessions#dipert
02:08brainproxywill look forward to seeing the recording
02:08ro_sthe's also doing an unsession
02:09brainproxyoh hey, it's Flapjax based :D
02:09brainproxyFlapjax was like a revelation for me
02:09piranha:)
02:09piranhasame thing
02:09brainproxyI spent months on the library, trying to understand it
02:09piranhawhat blows my mind is that it was out in 2006 or something
02:09brainproxyyep
02:09piranhaand all those years I just discarded it
02:10piranhaand now it's like I'm cured from blindness :))
02:10brainproxythe real kicker is figuing out how the scheduler works
02:10ro_stwe have a mid-sized cljs app in production now (~5000 loc) and i'm pretty sure we can cut 10-20% off of that with FRP
02:10brainproxyonce you realize how the topological sort thing works
02:10piranhathe only thing which bothers me is that I can't find good examples of structuring FRP code
02:10ro_stsince we already use event-sourcing for our client->server data
02:10brainproxythen it all starts to fall into place
02:10piranhaall the examples are for small applications
02:10ro_sti'm sure it'll be a good fit
02:11brainproxyI found that Flapjax seemed limited
02:11piranhaI'm mostly sure as well, but I'm trying to figure out myself and it's not going fast enough :)
02:11brainproxyI wanted it to do more
02:11brainproxytried twice to rewrite it
02:11brainproxywas a bit naive about what that would really entail
02:11brainproxybut I learned a lot
02:13johnnyluuanyone knows where bbloom is?
02:13piranhabrainproxy: what about lenses library btw, I can't find it :(
02:13brainproxypiranha: that's by a guy with last name Greene
02:13brainproxyhold on, i'll dig it up
02:13piranhathanks
02:13brainproxyit's pretty primitive I think
02:14brainproxybut even still, it seemed even more daunting than Flapjax
02:14brainproxyor at least at the time it did, to me
02:14piranhaheh :)
02:15johnnyluugrr .. sometimes i just wanna talk to you guys for real .. but i know you can't be honest
02:15brainproxypiranha: unfortunately, it's not collected into some nice github repo that I could ever find
02:15brainproxybut here you go
02:15brainproxyhttp://www.cis.upenn.edu/~mgree/ugrad/lenses/docs/overview-summary-lens.js.html
02:15brainproxydig in and have fun
02:16brainproxytry not to go blind
02:16brainproxyor have an anurism
02:16piranha;D
02:16piranhaokay, I'll try :))
02:18brainproxypiranha: i think the hot thing now is called "edit lenses"
02:18brainproxywhich are probably what most of us engineering types want anyway
02:19piranhahm, ok, I'll try to dig in this direction :)
02:19brainproxythe kinds of lenses that Foster et al. deal with aren't differential
02:19brainproxyyou send the whole data structure around
02:19piranhaI probably should finish with my idea of structuring of application anyway before jumping on another topic again %)
02:19piranhaoh
02:19brainproxybut edit lenses are differential
02:20johnnyluui know what you are doing and will do when i release it .. all i want is to finish my work and release it quickly since it looks so cool. but perhaps your version will be lot cooler and i really hope so :) hope it can be like before when i can ask questions and have answers .. it's not fun having to hide all the time
02:22piranhajohnnyluu: :)
02:22johnnyluuit won't be money based since i don't have the manpower .. so just ads .. but it looks cool anyway :)
03:14maxalwingsWhat is your best CSS generator library for clojure?
03:53jeffmessAs a complete noob to clojure. What is the recommended way to install clojure on OSX? Homebrew, dl installer from website, macports?
03:57bdashjeffmess: I'd do what is described at http://charlie.griefer.com/blog/2011/08/03/clojure-in-3-minutes/. basically, you don't install clojure, you install leiningen and let it manage clojure
03:58jeffmessbdash: thanks!
03:58arcatanand you can install leiningen with Homebrew, too
04:02jeffmesssweet, I already feel 2% smarter.
04:04xumingmingva question about develop clojure using emacs
04:04xumingmingvI want to auto-start nrepl repl when I open a clj file
04:05xumingmingvbut I dont want the nrepl-jack-in be started again when I open another clj file (Beause the nrepl is already started)
04:05xumingmingvapparently, the following code does not work: (add-hook 'clojure-mode-hook 'nrepl-jack-in)
04:05xumingmingv
04:05xumingmingvHow to make it work?
06:07michaelr525can i install lein 2 without upgrading all my existing projects?
06:32scottjmichaelr525: you can have lein2 and lein1 installed at the same time.
06:32no7hing@michaelr525 it should be fine if you name lein 2 f.e. lein2
06:32no7hinghaha
06:33no7hingwell, now you know for sure
06:41michaelr525scottj: hehe thanks, just tried doing exactly that and it worked.. amazing how simple it is :)
06:41clojurebotAck. Ack.
06:49hyPiRionEasy. Easy is the word.
06:51michaelr525hyPiRion: easy and simple
06:58michaelr525hmm
07:05hyPiRionmichaelr525: True that, it's simple as well.
07:11ljosHi. I am working a bit with Korma and I was wondering if anyone know if it is possible to do this query without resorting to `raw`: `SELECT date(created) FROM table;`
07:16michaelr525ljos: sqlfn, look up an example here: http://sqlkorma.com/docs
07:20ljosmichaelr525: Thanks. That works. It becomes (select table (fields (sqlfn date :created)), though this returns a very ugly map back. Fixed that with (select table (fields [(sqlfn date :created) :date])).
07:21ljosI am very impressed by the expressiveness of korma.
07:21michaelr525ljos: good, because i think i'm gonna use this slqfn too for the problem i'm actually working on right now (never used it before) :)
07:22michaelr525i like korma too
07:22michaelr525it works well for me
07:24ljosmichaelr525: the only thing I don't like right now is that I have to do (modifier "distinct") to do a SELECT DISTINCT. I feel that could have been handled without the string (e.g. just (modifier distinct) as they do with sqlfn.)
07:29johnnyluuppppaul: i hope you didn't just smile to make it look like that we are working together
07:35johnnyluui have no partners, no incubators, nothing else but me on my project
07:40michaelr525REPL server launch timed out.
07:40michaelr525why?
07:40clojurebotwhy not?
07:40michaelr525clojurebot: 'cause it's supposed to work, egghead
07:40clojurebotGabh mo leithscéal?
07:42michaelr525clojurebot: magairlí asal
07:42clojurebotNo entiendo
08:35`fogusHi all. Is Korma the go-to library for SQL
08:35`fogus?
08:35`fogusThe last time I needed SQL ClojureQL was king.
08:38michaelr525`fogus: i think so..
08:41`fogusThanks. That's the one for me then. :-)
08:51jeffmess_pretty new to clojure. Are there any projects that are great to read so I can get an idea how best to structure an application?
09:43AtKaaZis there something like splicing without unquoting? something like `~@
09:44AtKaaZoh wait, does this work? '~@
09:44AtKaaZnope
09:46AtKaaZI basically need the effect of ~@restt but I'm not within a `(...)
09:48AtKaaZok i worked around this by using ` and a let because I needed to paste a raw symbol in the returned list (ie. thrown?)
09:51AnderkentAtKaaZ: you want `(is (~'thrown? ~@rest)) - the quote-unquote produces un-namespaced symbol
09:52AtKaaZoh that's nice, thank you very much Anderkent
10:04AtKaaZhow do you compare if two lists have the same contents?
10:05AtKaaZok (= ...) is working, but I was instead evaluating the lists first
10:07daviddparkRecent upgrade to leiningen 2.0.0 now lein test results in ClassNotFoundException for clojure.java.shell.... What is the advised workaround?
10:09Anderkentdaviddpark: what version of clojure is your project using?
10:09daviddpark1.4.0
10:10Anderkenthm, works for me on 1.4.0. Were you upgrading from lein1 or lein2-preview?
10:11daviddparklein2-preview.... upgraded to lein2 using "lein upgrade" however, I then upgraded from Lion to Mountain Lion, and did a brew upgrade, which _also_ upgraded leiningen to lein2. Not sure whether brew screwed me over.
10:12Anderkentmhm, could have :P Fire up a repl and see 1. what version of clojure is advertised and 2. if (require 'clojure.java.shell) succeeds
10:16AtKaaZwhat am I missing here with lists equality? https://gist.github.com/4691902
10:17daviddparkAnderkent: 1. reports 1.4.0 and 2. requires just fine. I must be doing something stupid. thanks for your help, and I'll go back to the drawing board.
10:18Anderkentdaviddpark: yeah, unfortunately clojure compile errors are not very helpful
10:19AnderkentAtKaaZ: where does the 'a' come from?
10:19xumingmingva question about private function
10:20AtKaaZAnderkent: it's probably enough? to just look at the actual: part? but a is (def a java.lang.RuntimeException)
10:20xumingmingvwe know that private function has a meta: ^:private true
10:20xumingmingvif I manually remove this :private meta
10:20xumingmingvwill it be callable in another namespace?
10:20xumingmingvI tried, still cannt, dont know why
10:21Anderkentxumingmingv: dynamically or in the source? It definitely should be if you do it in the source. If you do it dynamically I couldn't tell (but you can call the function without doing that by accessing its var: (#'private.namespace/function args)
10:21xumingmingvin the repl
10:22xumingmingvI know I can access it with the full-qualified name
10:23xumingmingvbut I want to access it directly in the repl(ease debuging)
10:23Anderkenthow are you removing the metadata?
10:23dyresharksemantics question: if i have a decently large lambda i'm passing to reduce (on the order of 4-7 lines), is it better practice to declare/name it in a let, or just place it inline?
10:23Anderkent(you could just (def my-fn #'private.function) then do (my-fn args)
10:24xumingmingv(alter-meta! v (fn [curr-meta] (dissoc curr-meta :private))
10:24xumingmingvI checked, the :private meta is indeed gone
10:26xumingmingvAnderkent: I am writing a little tool to ease debugging, I just want to make developement as easy as it can be.
10:26xumingmingvso if remove :private meta works, that would be the best option
10:27Anderkentit works for me
10:27AtKaaZif the function is in a different namespace? Anderkent
10:28Anderkenthttps://www.refheap.com/paste/9162
10:28AnderkentAtKaaZ: I can't see what's going wrong with your code - one thing is that ' is tricky; if you call it from a different namespace the symbols might not match
10:30AnderkentAtKaaZ: also, try with (isthrown? java.lang.RuntimeException ...) instead of (isthrown? a)
10:30AtKaaZAnderkent, about his function, what happens if you don't specifically namespace the function (ie. import it? or refer to it prior to unmeta)
10:32jimdueybrainproxy: I'm working on a comonads post right now. Might get it done tomorrow, but probably not.
10:32AtKaaZstill false, Anderkent, also updated gist
10:33AnderkentAtKaaZ: that's too much pain for me to check, since I can't :require namespaces that are dynamically generated in the repl
10:33Anderkentand making the sources is effort :P
10:33Anderkentseems to work when I try it with just (refer) though..
10:33Anderkenthttps://www.refheap.com/paste/9163
10:34AnderkentAtKaaZ: can you show isthrown? as well?
10:34AtKaaZsure, sec
10:35AtKaaZdone
10:36pepijndevosThere was a pattern in core.logic to do construct lists, better than a chain of conso, right?
10:37pepijndevosMaybe... (== l (llist a b c tail))?
10:37xumingmingvok, I know what the issue is
10:38xumingmingvI first use the namespace(where my private function is)
10:38xumingmingvthen I removed the function's private meta
10:38AtKaaZdo :reload ?
10:38xumingmingvthen try to call the function
10:38AtKaaZoh nvm that would overwrite it again:)
10:38xumingmingvthe function is of course not there....
10:39xumingmingvAtKaaZ: yeah, I use the namespace again
10:39xumingmingvthe function is available
10:39xumingmingvthanks you guys
10:39AtKaaZok, not sure I got it then
10:40xumingmingvI guess when 'use' a namespace, only the public functions are made available
10:40AtKaaZusing the namespace again refreshes something in current namespace? like referrers or something? which auto-ignored private ones?
10:40xumingmingveven if we removed the :private meta
10:40AtKaaZok that makes sense
10:40AtKaaZthx
10:40xumingmingvthe previous private function is still not available
10:41xumingmingvneed to use the namespace again(to import the new public function)
10:41AtKaaZso you were not namespace qualifying the function to be called?
10:41AtKaaZthe private one
10:41Anderkentxumingmingv: yes, :use only refers public symbols
10:41xumingmingvAtKaaZ: yeah
10:41xumingmingvnot full-qualified name
10:42AtKaaZok cool this makes total sense
10:44AtKaaZso by re-using again, it updates the current ns refs to outside functions (in this case also adds one more referer in current namespace to the now public func) so like curns/former-priv-func refers to somens/former-priv-func while previously wasn't defined in curns
10:45xumingmingvyeah
10:48xumingmingvBTW, what's most convinient way to access refheap? is there a plugin?
10:53cemerickpjstadig: this might not be so hard after all...
10:53pjstadigdooooo iiiiiiiit
10:53pjstadigcemerick: you can make compiler changes, i know you can :)
10:53AnderkentAtKaaZ: I figured out your problem - in '(clojure.test/is ...) java.lang.RuntimeException is a symbol, in the result of your macro it's a class
10:53cemerickhah
10:53cemerickpjstadig: I've done so before, I just try to not make it a habit
10:54cemerickI feel like I'm blowing time when I'm this low in the stack.
10:54cemerickMight as well start writing device drivers.
10:54cemerickBut, yes, I'm doing it. Will hopefully have a changeset on github ~20m.
10:57AtKaaZAnderkent, ok I'm looking into it, but great find!
10:59AtKaaZoh that makes sense
11:00AtKaaZcan I transform that class into a symbol?
11:07AnderkentAtKaaZ: I'm not sure why you want to use eval there
11:07AtKaaZwhat else could I use?
11:07AnderkentAtKaaZ: I'd think (defmacro isthrown? [cls & body] `(is (~'thrown? ~cls ~@body)) would do it
11:08pepijndevosrawr. sometimes there are just so many data dependencies that tearing out small functions only hurts.
11:08AtKaaZbut if I don't pass a class it will fail, since I pass a symbol to a class ie. (def a RuntimeException)
11:08AtKaaZUnable to resolve classname: a,
11:10ravsterhello all
11:12S11001001,(first (apply concat (cycle ['greetings])))
11:12clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
11:12S11001001,(first (apply concat (cycle [['greetings]])))
11:12clojurebotgreetings
11:12S11001001eh, types
11:12AtKaaZ,'hi
11:12clojurebothi
11:32pepijndevosdnolen, okay, Now I see why one would want to do fresh in dcg, and why it takes so much code. awww.
11:34dnolenpepijndevos: yep
11:37dnolenpepijndevos: DCGs aren't really usable in core.logic or miniKanren so I haven't done much w/ that code.
11:37pepijndevosdnolen, why arn't they usable?
11:38pepijndevosspeedwise, syntaxwise, or ohterwise?
11:38dnolenpepijndevos: speed & memory
11:39dnolenpepijndevos: to actually use them DCGs we need environment trimming
11:40pepijndevosdnolen, why does this work in prolog? and... what is environment trimming?
11:42pepijndevosor does it only work in prologs dat do environment trimming?
11:42dnolenpepijndevos: Prolog have many optimizations in place including environment trimming
11:43dnolenpepijndevos: problem for DCGs is you have a unification per character, this means for your substitution map will contain as many bindings as characters you want to parse
11:43pepijndevoshrm :(
11:43dnolenso for anything but the smallest inputs, DCGs are useless in miniKanren & core.logic
11:44pepijndevosdnolen, oh, I'm parsing word by word, on single sentences.
11:44dnolenpepijndevos: so less of problem, but still a problem.
11:44pepijndevosdnolen, where can I read about this trimming?
11:45dnolenpepijndevos: the solution is to have something that looks more like an interpreter environment instead of a big substitution map.
11:46dnolenpepijndevos: I think "Warren's Abstract Machine: A Tutorial Reconstruction" covers it
11:47pepijndevosthanks :)
11:50dnolenpepijndevos: I haven't looked into it much, it would require some dramatic refactoring.
11:50pepijndevosdnolen, I suppose. For now I'm just curious what it is.
11:50dnolenbut perhaps not ... ? I've only thought about it a little bit.
11:51dnolenpepijndevos: it just about discarding variables once you leave a goal scope
11:51pepijndevosdnolen, I'm having tons of fun writing a DCG impl and a system that you can ask simploe questions
11:51dnolenpepijndevos: sweet!
11:52dnolenpepijndevos: for interactive small inputs, yeah, I imagine they're fun and work well!
11:52pepijndevosdnolen, I'm thinking I should write a redis connector for core.logic :)
11:52dnolenpepijndevos: rad!
11:54pepijndevosdnolen, if either the redis or the dcg turn out nicely, is that something to contribute?
11:55pepijndevosI know you have a dcg already, but if I get fresh to work nicely, it's a lot simpler to look at the code and see what it is doing.
11:55dnolenpepijndevos: the DCG code isn't exactly complicated, if it's not marked improvement - I don't think so. no on including anything to do w/ redis.
11:56pepijndevosok
11:56pepijndevosI though since you have datomic in there already..
11:56alexnixonI have two threads, each with a reference to the same atom. If one thread reset!'s the value of the atom, then afterwards the other thread reads the value of the atom, is it *guaranteed* that the second thread read see the updated value?
11:57pepijndevosdefine afterwards
11:58alexnixonthe first thread called .interrupt on the second, causing an InterruptedException
11:58dnolenpepijndevos: datomic was just there as simple example of how to integrate, it's also experimental
11:59pepijndevosok, sure. I'll just put it on it's own then.
11:59pepijndevosalexnixon, you know you cna also at watchers to an atom?
11:59pepijndevosbut ye, I do believe it should be reset always
11:59pepijndevosan atom is not async
12:00alexnixonpepijndevos: thanks - I'll take a look at watchers
12:02alexnixonpepijndevos: yeah it isn't async, but I couldn't find any documentation to explicitly say whether writes are immediately visible on all threads (even though I strongly suspect they are)
12:04cemerickOK, who's the local asm expert? pjstadig, hiredman?
12:04pjstadigexpert no
12:04pjstadigbut i could try to answer a question
12:05cemerickone sec, pushing
12:11spligakIs this a reasonable approach for supplying the first parameter to a batch of functions? https://gist.github.com/4692634
12:15cemericknm, I got it; had a hard time remembering the .newInstance, .dup, .invokeConstructor dance
12:15cemerickpjstadig: ^^
12:16pjstadigcool
12:18alexnixonspligak: an alternative would be to make with-connection bind a dynamic var, and have "query" use that instead.
12:22spligakalexnixon, I'm unfamiliar with dynamic vars. Reading the doc page on them now.
12:23spligakso this would allow me to make a thread-local top-level connection value?
12:24alexnixonspligak: a dynamically-scoped binding (which IIRC is conveyed to futures et al spawned from within the scope)
12:25alexnixonseems like you want something similar to this: https://github.com/aboekhoff/congomongo/blob/master/src/somnium/congomongo.clj#L163
12:27spligakahihi, interesting, he's pulling in that *mogo-config* from his config over here https://github.com/aboekhoff/congomongo/blob/master/src/somnium/congomongo/config.clj
12:27spligakwhoa. I meant to say "aha"
12:27spligakI suppose I also meant to say "mongo"
12:29spligakalexnixon, This is pretty neat. I'll play with this. You didn't find my example horrifying, though?
12:30alexnixonspligak: not horrifying at all, just a bit awkward to use as you'd (due to familiarity with other with-xxx scopes) assume that you could stick arbitrary clojure inside the macro
12:33spligakalexnixon, I'll keep that in mind. I appreciate your help.
12:33jchaunceyanyone know of a guide for attaching the intellij debugger to a leiningen process thats running?
12:35alexnixonspligak: np
12:47brainproxyjimduey: great! well, whenever you get done writing it, i look forward to reading it!
12:49aaelonydoes clj-time support converting unix timestamps to readable date strings?
12:50ldhyep! see the clj-time.coerce namespace
12:51aaelonyldh: works! thanks :))
12:57ldhaaelony: np :)
12:59Thallasios_Xelonhello guys :)
13:06ravsterhello all
13:07Thallasios_Xelonhelo ravster
13:08Thallasios_Xeloni am confused about using lazy sequence,my code doesnt work with normal concat,but with a hand-made concat it works...
13:08pppaulhey
13:09Thallasios_Xelonwhen you write code with lazy-seq you have to think about it,or think them as normal sequences?
13:09pppauli'm trying to make a route in ring/compojure with a wildcard at the end… not having any luck
13:09pppaultried (GET ["/documents/*] [] myfun)
13:09pppaulit's not matching, though
13:10alexnixonThallasios_Xelon: can you post code to illustrate your problem?
13:12Thallasios_Xelonalexnixon when you use lazy-seq you think of them as normal sequence when you write code?
13:13alexnixonThallasios_Xelon: depends what you mean by a "normal sequence"
13:15ldhppaul: have you tried (GET "/documents/*" [] myfun) ?
13:28daviddparkI am hoping to get a little help with destructuring. In using carmine to work with Redis on a different host than localhost, I need to invoke (make-conn-spec) with some arguments and I cannot get it right. Details at https://gist.github.com/4693104 for anyone who can give me a quick pointer.
13:29gtrakdaviddpark: you're using the varargs trick when you don't mean to, get rid of &
13:29gtrakthen your first example should work
13:30daviddparkgtrak: not my code... that is the function definition in carmine. I'll ask the author of the code. Thanks for your quick feedback!
13:30alexnixondaviddpark: (make-conn-spec :host "example.com" :port 9999 :password "insecure" :timeout 900 :db 1)
13:31daviddparkalexnixon: Thanks! I did not try that. Would not have thought to...
13:31TimMc~mapply
13:31clojurebotYou could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))
13:31gtrakmapply?
13:31clojurebotYou could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))
13:35gtrakdaviddpark: the trick is to understand the difference between an arglist of [{}] and [& {}], the second is implemented as applying hash-map to the args seq, which splits the arglist into pairs of kv's
13:37TimMc[& {}] is a toothy gremlin disguised as a clever convenience.
13:38thalassios_xelon(apply clojure.set/intersection (set (map to_keep set1 (repeat (count set1) set1)))))
13:38thalassios_xelonit has lazy sequence and it doesnt work
13:39gtrakit's explained about halfway down in this post: http://clojure.com/blog/2012/02/17/clojure-governance.html
13:39daviddparkgtrak: Thank you for that explanation. I see the difference now.
13:40thalassios_xelonits say clojure.set/intersection zero arguments............
13:40thalassios_xelonas if the lazy seq did not produce anything
13:40thalassios_xelondo you know why?
13:41hiredman,(apply intersection ())
13:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: intersection in this context, compiling:(NO_SOURCE_PATH:0)>
13:41hiredman'(require 'clojure.set)
13:41hiredman,(require 'clojure.set)
13:41clojurebotnil
13:41hiredman,(apply clojure.set/intersection ())
13:41clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: set$intersection>
13:42hiredman(apply clojure.set/intersection '(1 2)) => (clojure.set/intersection 1 2)
13:42hiredman(apply clojure.set/intersection ()) => (clojure.set/intersection)
13:42thalassios_xelonis it possible that the problem comes from lazy-seq
13:42thalassios_xelonor my code just returns () and its a error?
13:42gtrakthalassios_xelon: you're applying the contents of a set... you want to intersect two sets
13:43gtrakit makes no sense what you want to do there from what you wrote
13:43thalassios_xeloni want to interset a list of sets
13:43gtraka set of sets?
13:43gfredericks,(apply clojure.set/intersection [#{1 2 3} #{2 3 4} #{3 4 5}])
13:43clojurebot#{3}
13:44amalloyTimMc: i read the first half of that and was trying to see how [& {}] was shaped like a gremlin
13:44TimMcamalloy: What, you still don't see it? :-P
13:44gtrak,(apply clojure.set/intersection (set [#{1 2 3} #{1 2 3} #{1 2 3}]))
13:44clojurebot#{1 2 3}
13:45thalassios_xelonis it possible that the lazy-seq causes the arguments to be (), or my code is producing the ()
13:45gtrak,(set [#{1 2 3} #{1 2 3} #{1 2 3}])
13:45clojurebot#{#{1 2 3}}
13:45gtrakdoes that make sense?
13:45thalassios_xeloni dont know how to use lazy sequences,is it hard?
13:46dabdanyone knows if the cond-let macro that was in clojure.contrib.cond move to somewhere else?
13:46dabdmoved*
13:46gtrakthalassios_xelon: lazy-seq is fine here. The higher level structure makes no sense.
13:48thalassios_xeloncan it happen to need the value of a lazy-seq ,and dont have it?
13:48gtraknot in the way I think you mean
13:49thalassios_xelonusing lazy-seq is something that i need to take care of,or is automatic?
13:49gtrakI've never once had to write lazy-seq to use lazy-seqs
13:49thalassios_xelonok gtrak thx ,i am totally new in clojure :)
13:49thalassios_xeloni will read more
13:50gtraklaziness isn't the culprit here, I think it's a misunderstanding of what map and apply do
13:50thalassios_xelonok :) i will try again
13:57gfredericksI'm curious what (^:once fn* [] ...) is supposed to accomplish
13:58gfredericksmy guess so far is that it's used on functions that are guaranteed to be called once
13:58ravsterHow do I set langohr up so that it doesn't error and die when I get a connectionrefused error?
13:59hiredmangfredericks: it causes closed over values to be cleared after the first call, I believe
13:59ravsterI don't think I want to do a try/catch over the entire file.
14:00hiredmanavoids head holding by delays and lazy seqs
14:00gfredericksoh fascinating; I don't get the error I would expect by calling such a function more than once though :/
14:00gfrederickse.g., (let [x 10] (^:once fn* [a] (+ x a)))
14:00hiredmanravster: don't use global connection objects like that
14:01hiredmangfredericks: not sure, but it may also cache the result
14:01hiredmana classical fp thunk
14:01gfredericksI called it with different args even
14:02hiredmanhuh
14:02hiredmanlooks like :once is actually no longer used, it may be left over from before the more aggresive locals clearing went in to the compiler
14:04hiredmanall the :once/oneTimeUse stuff in the compiler is commented out
14:04frozenlockRaynes: Any opinion on mongodb? I see you used it on refheap.
14:06amalloyhiredman: really? i thought i found one spot somewhere
14:06ivaraasenargh, profiling macros is hard
14:07gerunddevfrozenlock: I've used mongo with congomongo a bit.  I've also used mongo a fair amount and Couch DB a lot.
14:08hiredmanamalloy: could be, I just did a cursory look, and I'm not sure how up to date my checkout is
14:08frozenlockgerunddev: What do you think of it? Seems HN hates it to death.
14:08amalloyno, i think you're right
14:08frozenlockgerunddev: I do use it with congomongo and find it really convenient, but I wonder for the long term. (bigger DB)
14:08amalloyi just looked even more cursorily last time, apparently
14:09amalloyfrozenlock: HN hates everything to death
14:09amalloyeventually, HN will hate itself to death
14:09technomancyamalloy: that's already well under way
14:11ravsterhiredman: okay, will try to change that. thanks.
14:12gerunddevfrozenlock: I like elements of Couch and mongo.  Document stores are so great that the pro / cons of each seem to mean less.
14:14kaoDdocument stores are not great, they're just convenient... in some cases :P
14:14gerunddevfrozenlock: Mongo has horizontal scalability baked into the design more than Couch (which had it added in Big Couch).
14:15gerunddevamendment - great for the kinds of problems I'm solving
14:15kaoDI once worked (for profit) in a project based around MongoDB
14:15kaoDwhat's fun about it is that it didn't need scalability
14:15kaoDbut actually needed ACID
14:15frozenlockgerunddev: Nice. Thank you, I appreciate your input.
14:16frozenlock,ACID
14:16clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ACID in this context, compiling:(NO_SOURCE_PATH:0)>
14:16hiredman~apropos ACID
14:16clojurebotHydrochloric acid is a Chemical Compound. (http://www.freebase.com/view//m/0dc0x)
14:16bprkaoD: seems like noSQL is a poor choice then?
14:16amalloygood try, clojurebot
14:16hiredmanclojurebot: maybe next time
14:16clojurebotmultimethods are http://clojure.org/multimethods
14:16gerunddevfrozenlock: http://en.wikipedia.org/wiki/ACID
14:16kaoDbpr: it was indeed, but apparently NoSQL is fashionable now among project managers
14:16TimMchiredman: Is ~apropos new?
14:17hiredmanyes
14:17ivaraasenah, managers
14:17kaoDthat's why "I hate MongoDB" or "I love NoSQL" make no sense at all
14:17kaoDthe right tool for the right job
14:17kaoDbut I'm just a codemonkey, who cares
14:21gtrakmaybe there are more markets for negations? I love NoCurlyBraces
14:23gtrakor notAgile
14:24frozenlockWhat style is preferred, (fn [a &[b]] ...), or (fn [a & b] (first b) ...) ?
14:24technomancynoXML
14:24amalloyneither of those
14:24amalloy(fn ([a] ...) ([a b] ...))
14:24gtraknoPreference
14:25amalloybut if you really can't bear to have multiple arities, certainly the first of your suggestions
14:25gtrakjust go with the flow man...
14:25kaoDtechnomancy: NoXML was actually JSON's original name
14:26ChongLiway better name
14:26frozenlockamalloy: thanks, I'll try with multiple arities to see what it looks like in my fns.
14:30gerunddevHas anyone used datomic?
14:30bpra little
14:31SegFaultAXkaoD: When is Mongodb the right tool, though? (I'm not anti-mongo, I just have a hard time coming up with a case for it a lot of the time)
14:32kaoDSegFaultAX: when your data is mainly documents
14:32kaoDACID is not needed
14:32kaoDand scalability is important
14:33splunkright, it seems like there are cases when an app's domain logic maps very closely to "document store"
14:33gerunddevSegFaultAX: If the bulk of your queries are not aggregate operations (like show me the average of all X)
14:33kaoDdata mainly documents means you're not going to do much in your queries besides projection (no fancy shit like grouping and so)
14:33gerunddevIf you want to enforce schema when you consume data, not write it
14:34DaoWenare there any other languages that do multimethods like clojure (i.e. on a dispatch function)?
14:34bprcommon lisp
14:34kaoDDaoWen: all do, but the dispatch function is fixed :P
14:34SegFaultAXThe only time I've really had use for mongo is when I wanted to throw a whole shitload of data somewhere and I didn't care if it was consistent at all.
14:35kaoDSegFaultAX: well, that's a good use case for MongoDB
14:35gerunddevAlso if you would like to precompute much of the needed outputs and being stale is OK.
14:35SegFaultAXkaoD: Garbage data that you want to make queryable? Sure.
14:35kaoDanother common use case: documents
14:36DaoWenbpr: what is it called in common lisp? I was looking at defmethod but it looks like it only dispatches based on the types of the parameters.
14:36dnolendo CL generic methods allow provide a dispatch fn?
14:36S11001001dnolen: no
14:36dnolenyeah I didn't think so
14:36bprno, they don't
14:37bpri misread the question and conflated the dispatch fn with multiple dispatch
14:37ivaraasendnolen: ordering the Reasoned Schemer ATM :)
14:37dnolenivaraasen: cool! fun stuff
14:37SegFaultAXivaraasen: I just picked that up to! :)
14:38gerunddevdnolen: I've been using core.logic in multimethods a lot lately.  Specifically to look at maps with complex logic that infers schema on read and passes to a version of the function that appears to be able to handle the data you are passing in.
14:38dnolenbrain melting stuff (if you don't already know Prolog)
14:38dnolengerunddev: very cool
14:39kaoDis there a prolog-like library for clojure ?
14:39DaoWenkaoD: have you looked at core.logic?
14:39hiredmanhttps://github.com/clojure/core.logic
14:39gerunddevdnolen: Fun to work in.  Thanks for all your work!
14:39kaoDhmmm
14:40dnolengerunddev: no problem, happy to hear you're finding it useful!
14:41SegFaultAXdnolen: Are you talking at Clojure/West?
14:41kaoDconso, resto, membero, lol
14:41dnolenSegFaultAX: only at the miniKanren confo
14:42SegFaultAXdnolen: Cool!
14:42SegFaultAXdnolen: Did core.logic start as a port of miniKanren?
14:42SegFaultAX[into Clojure]
14:42ivaraasendnolen: definitely looking forward to it. I read too few books anyway
14:42dnolenSegFaultAX: it did, the original version 2 years ago was more or less a direct translation
14:43dnolen~200 lines of code
14:43clojurebotall ur code r belong to us
14:43AimHereReasoned schemer is one of the oddest tech books you'll ever read
14:43SegFaultAXivaraasen: You bought the paperback version right? I bought it for kindle and it's just awful. Had to return it and order the paperback version.
14:43dnolenSegFaultAX: it's about 20X bigger now of course. But it also contains every major version of miniKanren in one system.
14:44dnolenplus lots of Clojure specific niceties optimizations etc
14:44ivaraasenSegFaultAX: I tend to avoid Kindle books in general for the same reason
14:44SegFaultAXivaraasen: Well I mean it's great for novels and stuff. But for books that you expect to have eg formatted code, I definitely agree.
14:46dnolenthis is too good - http://twitter.com/swannodette/status/297430540959752192
14:49ivaraasenI wonder if I could use core.logic to implement a strategy pattern for geophysics data. would be pretty awesome
14:51gerunddevbpr: Sorry I dropped the thread there, but did you get to use datomic for something that went out or for exploration?
14:51SegFaultAXIIRC ro_st is using Datomic for his project.
14:51bprgerunddev: the project i'm using datomic on is in alpha testing atm
14:52bprgerunddev: i'm using it with dynamodb as storage
14:53gerunddevAny specific attributes of it that served your needs better than other DBs?
14:53bprgerunddev: my experience with it isn't too large atm, but i do have to say that it's a joy to use from clojure
14:54bprgerunddev: adding transactions back into very scalable storage is the biggest
14:55kaoDbpr: transactions and scalable sound antagonic to me
14:55kaoDhow does DynamoDB resolve the issue?
14:55bprkaoD: if you need high write throughput, then maybe
14:55kaoDaaah, good point
14:57gerunddevbrp: Cool, thanks for the info.
14:57bprkaoD: we chose dynamo b/c it's hosted, and b/c it's easy to tune the throughput characteristics
14:57bprthat's something else that may be very nice. With datomic you can swap out your storage pretty easily
14:58bpr(well, relatively speaking)
14:58kaoDI don't know datomic, let me Google it a bit
15:00bprgerunddev: i hope it's useful.
15:03bprgerunddev: one pain point is that, as far as i can see, there isn't much knowledge/guidance about how to structure queries to be performant.
15:03bprgerunddev: that said, queries are horizontally scalable, so that eases that pain somewhat
15:05SegFaultAXAnd also local to the querying process.
15:05bpryes
15:07gfredericksdoes anybody know why this cheshire function isn't done purely with a protocol? https://github.com/dakrone/cheshire/blob/master/src/cheshire/generate.clj#L82
15:07gfredericksit has a check for the protocol at the beginning (line 85) but then a whole bunch of manual type dispatch
15:09amalloygfredericks: it looks to me like he wants to include a default jsonable implementation but let you override it
15:09gfredericksamalloy: but you can already override protocol impls, no?
15:09amalloyi think so, but i doubt if it's recommended practice
15:10gfrederickshmm
15:10gfredericksdoes that suggest some sort of double protocol pattern?
15:11amalloycuriously, it looks like he might be failing to handle objects that implement the JSONable backing interface instead of extending the protocol
15:11SegFaultAXamalloy: Would a multimethod work well here?
15:11gfrederickstoo slow I imagine
15:11amalloyyes, probably too slow
15:12dnolengfredericks: it seems weird to me - I don't see why he doesn't do all those cases in a default and then you can override by implementing the protocol for your own types.
15:12gfredericksdnolen: so a giant cond in an (extend-type Object ...)?
15:13dnolengfredericks: yes, and then people can override if they like w/ extend-type for PersistentVector etc
15:14dakronegfredericks: because it's faster than protocol dispatch
15:15dnolenthough even that is questionable in my opinion, I think best to just have defaults like I've said and only implement JSONable on types you've constructed yourself.
15:15dnolendakrone: you mean non-inline implementations of a protocol
15:16dnolenthough I'd be surprised if the difference is really really large
15:16gfredericksdnolen: you're saying the library author or the user should avoid extending JSONable to 3rd-party types?
15:16dakronednolen: difference is about 2x
15:16dnolengfredericks: if it's avoidable yes
15:16dnolendakrone: yeah that's about what I'd expect
15:16gfredericksdnolen: I'm curious why; I thought that use case was half the point of protocols over interfaces
15:17dakrone"I don't see why he doesn't do all those cases in a default and then you can override by implementing the protocol for your own types" - because it's slower to do that
15:17dakronednolen: ^
15:18dnolengfredericks: extend-type w/ protocols & types you don't control is still very close to monkey patching.
15:18S11001001dnolen: the haskell name for this is very good
15:18gfredericksit doesn't have the name-collision problem of monkey patching
15:19S11001001adapted here, "orphan extensions"
15:19clojurebotI don't understand.
15:19gfredericksor the "possibly mucking with internal state"
15:19clojurebotI have a "while" loop. Where I check some statements. If one of them is true then i need to increase one of my local var by other var.
15:19dnolendakrone: yes it makes sense - you wanted that last bit of perf
15:19amalloychill out, clojurebot
15:19gfredericksI don't think I've seen a criticism of this more-limited definition of monkey-patching
15:19dnolengfredericks: it has implementation collision problems tho - key point is manipulating types *and* protocols you don't control.
15:20gfredericksare the downsides related to two libraries trying to make the same protocol extension?
15:20dnolengfredericks: yes that's what I was referring to
15:21gfredericksif the user is the one doing it (rather than a 3rd-party library author) there's not much danger is there? if a 3rd-party lib were interested in the same extension that would be hard to miss I would think
15:23dnolengfredericks: no I don't think the danger is very big - just pointing out there is a still some issues to consider. I think the Rust folks came up w/ a solution for this? maybe not ...
15:23hiredmanI had a sort of multimethod looking set of macros that would inline as a big cond
15:25hiredmanhttps://gist.github.com/1856326 definline for multimethods
15:26ivaraasenhiredman: nice
15:26dakronehiredman: suppose I could give it a try with pjstadig's polyfns too now that that's out
15:27hiredmanit is pretty gross
15:27borkdudewhat's the best source for clojure yasnippets?
15:27hiredmanI guess the impl of defdispatched isn't in there
15:27hiredmanI wonder what happened to it
15:27hiredmanhttps://gist.github.com/1856336 heh, next gist
15:28ivaraasenhiredman: yeah, looks slightly evil. I have some horrible macros for doing operations on double arrays myself.
15:29hiredmanyou can do some neat stuff there
15:29hiredmanhttps://github.com/hiredman/ed25519/blob/master/src/ed25519/core.clj#L122 reads like a normal clojure for, and the code runs fine if it is
15:29hiredmanbut it is actually this https://github.com/hiredman/ed25519/blob/master/src/ed25519/replacements.clj#L5
15:29ravsterhow do I get lein to remove all old versions of libraries in my ~/.m2?
15:30ucbborkdude: I started collecting some myself and then realised you don't really need them (maybe try/catch constructs). What sort of snippets would you have use for?
15:30ravsterlein clean doesn't seem to do it.
15:30borkdudeucb I actually don't know, but I just discovered yasnippet (can you believe it) and I wanted to see what people have already made
15:30gfredericksclearly the best answer is ruby refinements
15:31ucbborkdude: ah, I see. Writing your own snippets is really easy mind you.
15:33ivaraasenhiredman: looks nice. these are mine: https://www.refheap.com/paste/74154847eed5cc99ddb1bf687
15:33ivaraasenafill! is extremely handy
15:34hiredmanivaraasen: the for example there is not really intend as an array operations library, it is an experiment in optimizing clojure without rewriting it
15:48janiczekhi guys, i got somehow tangled in macros ... is there a normal way to do (eval `(sorted-set ~@some-map)) ? when i do (sorted-set some-map), the set has only one element - the map ... i would like its contents
15:48mattmoss(apply sorted-set some-map) ?
15:49janiczekoh! :)
15:49janiczekthanks
15:49mattmossnp
15:49gfredericksso I'm trying to figure out how to use cheshire's generate-stream to send a JSON response without having to buffer the whole thing in memory first; it seems like this requires executing generate-stream on another thread, does that sound right?
15:49gfredericks(i.e., "after" returning the ring response with an InputStream in it)
15:52amalloygfredericks: it looks like it, annoying as that is. it kinda seems like json *could* have been written to return an InputStream that produces data on demand
15:52dakronegfredericks: amalloy: patches/issues welcome :)
15:52amalloydakrone: nah, it's probably the fault of jackson or whatever you use, not cheshire
15:53amalloygfredericks: you can steal the async-sending code from https://github.com/amalloy/ring-gzip-middleware/blob/master/src/ring/middleware/gzip.clj#L10 if you want
15:53amalloythough maybe you need something totally different; it seemed relevant but i haven't looked very closely
15:54weavejesterThere's a function in Ring piped-input-stream that allows you to connect an outputstream to an inputstream
15:54gfredericksthat's probably the next thing I need
15:54weavejesterhttps://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/io.clj#L10
15:54weavejesterRing also accepts a lazy seq for its body
15:55gfredericksyeah that would seem like a useful feature for cheshire
15:56dakronegfredericks: if you put an issue in with exactly what you need I can work on that
15:56tmciverweavejester: I'm trying to find a ring middleware I swear I've seen that added a content type to the Accept header based on the file extension of a uri . . .
15:56weavejesterTo the accept header?
15:57gfredericksdakrone: sure
15:57tmciveryes, of the request map
15:57tmciverDid I dream it?
15:57weavejesterSo if someone went for /foo.txt, it would add an Accept header of text/plain to the request?
15:57tmciverYes
15:58tmciverI've written such middleware for myself but I thought I saw it in an official place. Maybe not.
15:58weavejestertmciver: I've heard that discussed, but I don't know if it was implemented.
15:59tmciverWould something like that be a sensible addition to standard ring middleware?
16:00weavejestertmciver: Maybe. Implement it as a third-party library first, though. See if people use it.
16:00tmciverSounds good, thanks.
16:00gfredericksdakrone: thanks!
16:21pppauli'm using ring, attempted to pipe a couchdb attachment stream (png) to my client… having issues doing this
16:21pppaulanyone can point me in the direction of an example?
16:21gfrederickspppaul: what kind of stream object do you have?
16:21pppaulno idea
16:21pppaulusing clj-http.client
16:22gfrederickshave you tried returning the stream directly as the :body of the ring response?
16:22pppauli have tried returning the response i get from couchdb (as a whole) with and without the (response) helper functions
16:24pppauljust tried returning the :body of my clj-http response. that didn't work
16:24gfredericksand what happens?
16:24pppaul500 error
16:25pppauloh, the error may have been from #spy/d
16:25dakronepppaul: are you sending {:as :stream} with your clj-http response so the result is a stream instead of a string?
16:26pppaulno
16:26pppauldidn't know of this
16:26ppppaul(response (:body couch-response) :as :stream)
16:26ppppaulthat look ok?
16:26dakronesomething like (let [resp (:body (http/get "http://aoeu.com&quot; {:as :stream}))] {:status 200 :body resp})
16:27pppaulgetting 500 errors for that
16:27pppauldakrone making my code look like yours
16:27pppaulworks
16:27pppaulthanks :D
16:28dakronepppaul: np, glad it works for you
16:56FoxboronUsing NREPL, how do i hide the Nrepl Error buffer when evaluation with -
16:56FoxboronC-Mx*
16:57Foxboron(with emacs ofc)
17:14ToBeReplacedFoxboron: not sure if it's what you mean, but maybe look at nrepl-popup-stacktraces
17:19FoxboronToBeReplaced: if you evaluate a form inside a .clj file with nrepl, and its wrong. It just straight too the nRepl error buffer. nrepl-popup-stacktrace set as nil dosnt solve it either.
17:25dabdhow to submit a bug report on a core library function?
17:25S11001001~where jira
17:25clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
17:25S11001001ok clojurebot
17:25S11001001dabd: http://dev.clojure.org/jira/secure/Dashboard.jspa
17:26amalloyreally? i'd say step one is to mention it in #clojure and find out it's not a bug at all
17:26dabdi found that re-seq will stack overflow if given a regex with a repetition operator {} relatively large.
17:27S11001001amalloy: yeah
17:27S11001001dabd: reproduce with raw java.util.regex fns?
17:27amalloydabd: (a) re-seq delegates directly to java, so it will never get fixed in clojure
17:27dabdsay (re-seq #"someregex{1000}" somestring) -> boom
17:27dabdah nvm then
17:27hyPiRionIt's generally java's fault
17:27S11001001I blame java for stuff
17:27sshackQuestion. In a lein project, can I add to the class path. I'm trying to add mathematica's jlink jar file to my project so I can use clojuratica.
17:28S11001001it's pretty cold in Boston again
17:28S11001001damn Java
17:28dabdso re-seq will compile the regex during read time
17:28hyPiRionKind of like how you shouldn't do #"(a|b)+", as #"[ab]+" is better
17:28dabdit invokes a non tail recursive java function?
17:28hyPiRionWell, won't stack overflow at least
17:28amalloy&(re-seq #"x{1000}" (apply str (repeat 1000 "x")))
17:28amalloyhyPiRion: yeah, that's just a known-bad regex
17:28S11001001,(java.util.regex.Pattern/compile "someregex{1000}")
17:28clojurebot#"someregex{1000}"
17:29dabdamalloy actually i tried larger than 1000. It works for 1000 lol
17:29amalloyor, well, at least (a|aa)* is bad
17:29dabdi tried 1326
17:30amalloydabd: works fine for me. i think the regex you posted is fine, and you're having trouble with some other regex you haven't mentioned
17:30dabdweird it works for your example but not in my code
17:30amalloyor with something else
17:30dabdyes probably that
17:30hyPiRionamalloy: Any form containing pipes are bad if they can be converted into non-pipes. In general.
17:31hyPiRionActually, I got a heisenbug due to those darn pipes
17:31amalloyhyPiRion: hogwash. character classes might be a little faster, but that's not the problem; (aa?)* is the same problem
17:32hyPiRionamalloy: That would expand to (a(|a))*, wouldn't it?
17:32hyPiRionAnyhow, the Java regex compiler isn't exactly superb.
17:33dabdmaybe someone can help me with the regex?
17:33dabdhere is the example that is blowing up the stack (re-seq #"N(:(([0]*?\.\d*)|1|0|1\.0)){1326}" (apply str "N" (repeat 1326 ":1")))
17:34dabdthe regex is supposed to recognize N: followed by floats between 0 and 1 separated by colons
17:34amalloyhyPiRion: java's is as good as anyone else's, really
17:34technomancyI forget, is it PCRE-compatible?
17:34amalloyit says it is, but i know of at least one problem
17:35sshackUh. Hi, is there a way to modify the classpath in a lein project?
17:35amalloy(perl-compatible regular expression compatible, indeed)
17:35technomancyamalloy: I prefer perl-compatible-compatible
17:36technomancysshack: who is trying to give you a jar to use that isn't in a repository?
17:36hyPiRionamalloy: Oh right, not many implement Thompson. Shame.
17:36sshacktechnomancy: Wolfram mathematica.
17:37amalloyhyPiRion: i agree, it would be nice if they could recognize when it's possible to do that
17:37technomancyok, step 1 is to tell them they're wrong. =) step 2 is to get it into the local repo; that can be done with the lein-localrepo plugin or mvn install:install-file
17:38lazybot⇒ ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... failed to paste: Connection to https://www.refheap.com refused
17:39amalloyuhoh, really? that should have timed out a long time ago
17:39sshacktechnomancy:#1, have you tried telling Stephen Wolfram he's wrong?
17:39sshacktechnomancy: #2, sounds like a solution. Okay.
17:39technomancyheh
17:40technomancyclojurebot: same reason we don't hunt the wooly mammal
17:40clojurebotreason is , and ought only to be the slave of the passions, and can never preted to any other office than to serve and obey them -- Hume
17:40sshackLein-localrepo would let me keep my jar artificet in scm, right?
17:40technomancyclojurebot: same reason we don't hunt the wooly mammoth?
17:40clojurebotthe reason to use the immutable types is that it saves you from all that stuff; if you don't use them you don't get the benefit.
17:40technomancygrrrr
17:40technomancyclojurebot: same reason we don't wear animal skins
17:40clojurebotReason is, and ought only to be the slave of the passions, and can never preted to any other office than to serve and obey them -- Hume
17:40technomancyclojurebot: you're hopeless; falling back to google
17:40clojurebotNo entiendo
17:41amalloy~mammoth
17:41clojurebotIt's greek to me.
17:41hyPiRion~greek
17:41clojurebotI don't understand.
17:41hyPiRionmuha.
17:41technomancyhttp://www.penny-arcade.com/comic/2005/06/06
17:41abp~greek
17:41clojurebotNo entiendo
17:42technomancysshack: theoretically you can do that if you use a file:// URL in :repositories, but git is abysmally bad at storing binary files
17:42sshackI'm using mercurial. It's in a similar boat.
17:42technomancyclojurebot: woolly mammoth is <reply>same reason we don't wear animal skins or hunt the woolly mammoth: because we're not savages! http://www.penny-arcade.com/comic/2005/06/06
17:42clojurebotRoger.
17:43technomancyclojurebot: next time you better have that ready for me so I can appear quick-witted. don't screw this up.
17:43clojurebotmultimethods are awesome!
17:43technomancyyes, they are, clojurebot. they are.
17:43amalloyignore him, technomancy. he's just trying to get back on your good side
17:43technomancyhaha
17:44amalloyi've noticed if you ask him anything about time, he finds an excuse to mention mulTIMEthods
17:44technomancywhoa
17:44amalloyclojurebot: what time is lunch?
17:44clojurebottime is limited
17:44amalloyoh well
17:44technomancyalso a good point though
17:45technomancywell, for us carbon-based life forms anyway
17:45gfredericksmore importantly it wasn't what amalloy wanted
17:45dabdis there a way to apply reduce indexed. That is as I am reducing the sequence I also have access to the index of the current item?
17:45hiredmangood point
17:45hiredmanclojurebot: botsnack
17:45clojurebotThanks! Can I have chocolate next time
17:45technomancygfredericks: yeah, he's following some twisted N laws of trolling robotics
17:45mattmoss1claw shrimp
17:45amalloydabd: one way is to reduce over a sequence that includes indexes
17:46dabdbut that way I have to traverse the sequence twice
17:46hyPiRiondabd: (reduce (fn [a [i b]]) (map-indexed vector original-seq))
17:46amalloyno you don't
17:46amalloy(reduce (fn [acc [i x]] ...) 0 (map list (range) coll))
17:46amalloyclojurebot: laziness |means| not traversing anything twice
17:46clojurebotYou don't have to tell me twice.
17:47gfredericksI think he did that on purpose.
17:47hiredmanmust be
17:47pppaulthank you so much dakrone <3
17:48hyPiRiongfredericks: He dies everything on purpose.
17:48hyPiRion*does
17:48amalloy(inc clojurebot)
17:48lazybot⇒ 17
17:48dakronepppaul: sure! ...err for what? :)
17:48pppaulring stuff an hour ago
17:49dabdamalloy: thanks
17:54sshacktechnomancy: It was a good idea. But now I have to figure out some JNI stuff. It wants to interface with a native library. Sigh.
18:10frozenlockinteresting java->clojure http://tapestryjava.blogspot.se/2013/02/crafting-code-in-clojure.html
18:24seangroveHrm, curious what a clojure-first angular.js would look like
18:28rplacaquestion: what is the approved way to use rlwrap with lein repl in lein2?
18:29rplacaand is rlwrap considered the best choice?
18:29amalloyrplaca: lein should bundle whatever readline behavior you need
18:29rplacait doesn't seem to
18:30hyPiRionrplaca: REPL-y has some history bundled
18:30rplacaat least, up arrow does nothing when I run lein repl by itself
18:30technomancythat's an improvement over clojure, which does something like ^[[ when you hit up arrow =\
18:31rplacatechnomancy: perhaps, but not exactly what I was looking for
18:31technomancyrplaca: what terminal emulator are you using? $TERM value?
18:31rplaca:)
18:31rplacatechnomancy: xterm
18:31technomancydo you have an ~/.inputrc?
18:32rplacanope, should I?
18:32technomancyno, but sometimes it can interfere
18:33technomancydoes M-f, M-b, C-f, etc work?
18:34rplacatechnomancy: yes!
18:34rplacahow about that
18:34rplacais it just not remembering history somehow?
18:34technomancyso does history work in a single session and just gets forgotten when you restart?
18:35rplacano, I was just trying it in a single session
18:35rplacai figure inter-session is the advanced case :)
18:35technomancymight raise an issue in https://github.com/trptcolin/reply
18:36rplacalein repl is just launching reply with the right environment?
18:36technomancymore or less
18:37rplacatechnomancy: k, thanks
18:37technomancynp
18:45wizmonkywI have never written any clojure but I have wanted for quite some time. is the books any good or what is the best resource channel for learning clojure?
18:46nDuffwizmonkyw: There are several good books.
18:46SegFaultAXSeveral of the books are quite good.
18:46nDuffwizmonkyw: Do you find that you personally learn best starting with high-level concepts, practice, or a mix?
18:46wizmonkywthey arent outdated?
18:46nDuffwizmonkyw: Not really.
18:46nDuffwizmonkyw: ...the language doesn't change that quickly.
18:46wizmonkywI don't know.. maybe a mix
18:47SegFaultAXwizmonkyw: http://www.amazon.com/Clojure-Programming-Chas-Emerick/dp/1449394701/ is really good.
18:47nDuffhttp://www.clojurebook.com/ then
18:47nDuff(same one)
18:47SegFaultAXwizmonkyw: For that matter so is http://www.amazon.com/Joy-Clojure-Thinking-Way/dp/1935182641/
18:48wizmonkywhave any of you read both?
18:48nDuffwizmonkyw: ...I tend to recommend JoC for folks who learn best with the high-level overview first (that includes me), Clojure Programming for everyone else.
18:48SegFaultAXwizmonkyw: I have.
18:48nDuff...and they're both worth reading.
18:48wizmonkywok cool
18:48SegFaultAXI concur with nDuff
18:49SegFaultAXwizmonkyw: It also sorta depends on what kinds of projects you want to work on.
18:49SegFaultAXwizmonkyw: Or what stuff you find interesting.
18:49wizmonkywI did some haskell for a couple of weeks, just playing and I loved it. and I write as much functional javascript style as I can. as I work with javascript single page web apps mostly. so want to learn more about functional in a modern language
18:50gtraktechnomancy: grrrrr on slime removal from clojure-mode, took me an hour to figure out :-)
18:50wizmonkywits a general purpose language right?
18:50gtrakbut now I know how that works
18:50nDuffwizmonkyw: Very much so, yes.
18:51wizmonkywwould love to make some os x apps
18:51palangohey, I just read about lazy evaluation on wikipedia and tried the following: (count [1 2 3 (/ 1 0)]) and that throws and exception
18:51wizmonkywthat is possible through jvm right?
18:51palangoshouldn't a lazy language run this?
18:51wizmonkywor can clojure handle gui in os x?
18:51amalloypalango: clojure has eager evaluation
18:52wizmonkywor.. is there any famous libs/frameworks for that
18:52nDuffwizmonkyw: Once upon a time, Apple made a big deal about the effort they were investing into making the Java experience on OS X a good one. I haven't tracked how that's held up over time.
18:52nDuffwizmonkyw: ...that said, it's certainly possible.
18:52wizmonkywok cool will have to check
18:52AimHerewizmonkyw, clojure's OSX GUI support is likely the same as Java's
18:53nDuffLast I remember, the core Overtone folks were mostly using OS X
18:53gtrakpalango: you'd have to thunk it all to lazy-eval it
18:53SegFaultAXAnd you know how beautiful Java's native look and feel is. Mmmm good.
18:54nDuffpalango: ...in terms of GUI libraries, Seesaw is the premier thing.
18:54nDufferr.
18:54nDuffwizmonkyw: ^^
18:54wizmonkywcool
18:54wizmonkywclojure it is :)
18:54wizmonkywback to use my emacs skills :)
18:54wizmonkywused to write ruby at my last work but changed some months ago
18:54wizmonkywso not the same use for emacs anymore
18:55nDuffwizmonkyw: The screenshots in the presentation at http://darevay.com/talks/clojurewest2012/ are taken on OS X.
18:56nDuffwizmonkyw: ...also, that talk as a whole should give you an idea of some of the differences between what Java-interop code in Clojure looks like, vs code using native Clojure libraries.
18:56wizmonkywnDuff: damn cool pictures. liked what I saw!
18:56wizmonkywwill really give it an honest try. looks a lot of fun
18:57wizmonkywthe OO languages are so the same. want to think in another way etc when I code at home
18:57wizmonkywand possible future projects
18:57wizmonkywthere is clojurescript right? :) might do something in that but I understand it has not so much to do with clojrue but some parts rights
18:57wizmonkywright
18:58nDuffwizmonkyw: It's a subset of the full language, pretty much.
18:58nDuffwizmonkyw: ...there's something to be said for writing both the client and server sides of your code in Clojure. :)
18:58gtrakwizmonkyw: you could do like light table and run an embedded node+webkit
18:58wizmonkywnDuff how is clojure (with the libs around the language etc..) as a REST api webservice?
18:59nDuffwizmonkyw: There are plenty of libraries/frameworks to choose from there.
18:59wizmonkywcool, because I make mostly web stuff but 90% on the client
18:59wizmonkywso just need web services really so could come in to use early then
18:59wizmonkywanyone standing out a bit longer then the rest?
19:05nDuffwizmonkyw: Pretty much everything builds on Compojure, and Compojure builds on top of Ring.
19:05nDuffwizmonkyw: ...so, even if you're going to use higher-level libraries on top of it, I suggest learning Compojure.
19:20desertmonadkeep calm, compoje yourself, and everything will be alright.
19:22firefuxwizmonkyw: and learn jetty
19:25desertmonadwizmonkyw: btw, there are several clojure books, including the one recommended earlier on Safari Books Online. The free trial is a pretty limited as I recall, but the subscription is monthly and might be worth it to you.
19:43desertmonadis there a way to reference the last evaluation result in the repl?
19:43amalloy*1
19:43desertmonadamalloy: thanks
19:47hyPiRionalso note down *2 and *3. I'd guess you know what those stand for.
20:56hiredmanis there an nrepl proxy/demultiplexer yet? I want to have a single nrepl end point, but route to another nrepl based on session id (or something)
23:06john2xwhat's clojure's equivalent to python's PIL (Python Imaging Library)?
23:07ChongLiyou could use imageJ or fiji
23:07ChongLiit'
23:07ChongLiit's not the greatest
23:08ChongLifiji might be better
23:08ChongLihttp://fiji.sc/
23:18nodenameCan anyone tell me how to create an entity with Korma and save it as a table into the database?