#clojure logs

2013-03-26

00:01xeqitieTYT2: line 7, ((client/get ...)) will attempt to call the result of (client/get ...) as a function
00:01tieTYT2ohhh crap
00:01tieTYT2thanks
00:01tieTYT2i wish that bubbled up to tell me "line 7"
00:02tieTYT2i thought it was deep down in the clojure libraries
00:02xeqiusually there is a longer stack trace, sometimes they get eaten, not sure if its lein or a jvm flag bein set
00:02xeqi.. is it (pst) that will print out the last stacktrace?
00:03tieTYT2seems to
00:03tieTYT2that is so weird
00:03tieTYT2how does it cut off the top?
00:03tieTYT2that being the case, (pst) is essential. Thanks
00:06xeqitieTYT2: what version of lein are you using?
00:08tieTYT22.0.0
00:08xeqihttps://github.com/technomancy/leiningen/issues/1025
00:08xeqihas something you can put in the project.clj at the bottom to fix it eating stacktraces
00:10tieTYT2thanks
01:28tieTYT2why am i getting this error? http://pastebin.com/L9iUfJHX
01:30tieTYT2oh...
01:30tieTYT2i think i know why
01:30tieTYT2java problem, not clojure problem
01:38tieTYT2anyone know if it's a bad idea to program with a cygwin repl open while you write your real code in the intellij La Clojure library?
02:08tieTYT2what's a more idiomatic way to write this code in clojure? (defn img-as-file-on-fs [url] (.getAbsolutePath (File/createTempFile "img" (str "." (FilenameUtils/getExtension (.getAbsolutePath (io/file url)))) (io/file "images/"))))
02:10tomojonly thing I can suggest is to give names to more things
02:10tieTYT2you mean like in a let?
02:10tomojI can't really imagine what kind of idiom you're thinking of..
02:10tomojright
02:11tieTYT2ok i've been doing that in other places, let me try with this
02:11tieTYT2thanks
02:11tomojtook me a while to understand what it was doing because I didn't know File/createTempFile
02:11tomojbut..
02:11tomojthat doesn't mean you should name things
02:11tomojotherwise you'd have to name everything you ever passed to a function :)
02:12tomojmy first thought was that it is perfectly idiomatic
02:13tieTYT2this is my change: (defn img-as-file-on-fs [url]
02:13tieTYT2 (let [extension (str "." (FilenameUtils/getExtension (.getAbsolutePath (io/file url)))) output-dir (io/file "images/")] (.getAbsolutePath (File/createTempFile "img" extension output-dir))))
02:15tieTYT2i'm surprised it's idomatic. it seems clumsy to me. It took a while to figure out how I was getting class cast exceptiosn
02:16tomojmeh https://www.refheap.com/paste/e14264e41cbe02e168f90f6b0
02:16tieTYT2here's an idea for a library I just had. Something that merges the functionality of File, FileUtils and FilenameUtils into one protocol. Is that a good idea or is it a solution looking for a problem?
02:17tieTYT2hrm I need to learn about that -> and ->> thing
02:18tomojyou don't mean one defprotocol right?
02:18tieTYT2one defprotocol, but File and String would be an impl
02:18tieTYT2(i've never made a protocol, so I don't remember the exact names
02:19tomojoh, like IFileNamed or something?
02:20tieTYT2I suppose. All I know is I don't want to be using any of those static or File methods in there
02:21tomojwell you can define wrapper functions, I dunno what protocol would make sense
02:21tieTYT2ah true
02:21tieTYT2so maybe a library full of wrapper functions
02:21tomojI don't have an answer to your actual question "good idea.."
02:22tieTYT2that's ok. I'll learn clojure more before I revisit it
02:22tieTYT2there's this awesome haskell book that's free called Learn You A Haskell. I wish there was one like that for clojure
02:24tomojwell, somebody bought the domain
02:26tieTYT2not loading in my browser
02:29arrdemtomoj: learn you a clojure?
02:29arrdemalejandro gonzlez apparently... learnyouaclojure.com
02:29tomojyeah
02:30tieTYT2oh, well different guy wrote the haskell one
02:30tomojcloju.re is also parked
02:31tomojbut not learnyouacloju.re..
02:41RaynestieTYT2: I'm trying. In my not very copious spare time.
03:00tieTYT2Raynes: good luck
03:19jaimef(get "/hello/:a/:b/:c" "Hello to #{a} and #{b} and #{c}") ;; now that's sinatra like
03:39tomojjaimef: what's that from?
03:39jaimefthinatra
03:40jaimefsorry wrong channel
03:40tomojah, didn't seem very clojuresque :)
03:40jaimefit's very non-lisp despite being elisp
05:22Sonderbladewhat's the best clojure library for writing a parser? there are to many to choose from :p
06:49MikeSethtype hints for method arguments are only a performance optimization, correct? they're not meant to specify which kind of argument a methond expects?
06:52tomojnot sure what you mean by "specify"
06:52tomojthey don't act like argument type preconditions (which would throw an error if the type was wrong at runtime)
06:52tomojnot sure what you mean by "method" either
06:58ambrosebsMikeSeth: do you mean adding hints to specify which overload a method should dispatch to?
06:59ambrosebsI'm not actually sure if it helps with ambiguous methods?
06:59ambrosebsBut it basically helps load a specific method at compile time rather than relying on reflection at runtime.
07:03tomojambrosebs: btw, is something like core.typed necessary to know as much about the types as the compiler?
07:03tomojor is all the tag inference the compiler does also represented in jvm.tools.analyzer output?
07:04ambrosebstomoj: core.typed currently just uses the analyzer output. core.typed checks whichever method is loaded by the compiler.
07:05ambrosebstomoj: it's a good question whether/how easily we can do better.
07:06tomojhmm, I'm not actually sure what my question is
07:09tomojoh
07:09tomojwhen I looked at some analyzer output before it looked like :tag wasn't useful
07:09tomojbut I think I was just looking at it wrong
07:11ambrosebstomoj: :tag isn't useful beyond pre-loading interop forms.
07:13tomojright, I was considering making it useful for something else
07:13tomojvia a macro that looks an analyzer output
07:13tomojbut I think that doesn't really make any sense unless you just do core.typed
07:15ambrosebstomoj: what for?
07:19tomojdo you know applicative functors?
07:22tomojanother way to describe it I think is the problem of determining serious/trivial for a cps transform
07:22tomojcurrently I plan to just mark the serious expressions (abusing @ or ~, or creating a new special form inside the macro)
07:23tomojbut I'm wondering if erring towards assuming serious, with some rudimentary type inference (like the compiler's?), could be good enough
07:26tomojlike if something is tagged ^String I don't need to cps there
07:26ambrosebstomoj: I don't know much about either topic.
07:28tomojwell, anyway, it looks like the analyzer output has exactly what I thought it should :)
07:29tomoje.g. in (fn [^String a b] (let [c a] c)), inside the body of the let you can go back up to the param and get the tag
07:30tomojthough :tag is not automatically inferred it seems
07:34clgvoh clojure's maps have much better usability than comon lisp's ones...
07:35clgv(setf (gethash :a ht) 1) is pretty ugly compared to `assoc` ...
07:40tomojI implemented the curry example from the expansion-passing style paper
07:40tomojhttps://www.refheap.com/paste/e5e1a4d1c5df0f9ec6c283e4f
07:40tomojnot too happy — 1) do we really need *magroexpanding*? 2) gotta be a better interface?
07:40clgvdefmagro? :O
07:47tomojhmm, was some nonsense in the docstring :). https://www.refheap.com/paste/50104bba92033ed0889af0ff6
07:47tomojthink it's also buggy, but.. in the end of the EPS paper they mention passing around a syntax table along with the expand fn
07:48tomojthat would bring our arity to 4 since we have the env as well
07:48tomojmaybe pass around a dispatch-map or something..?
08:12kalasjohnny2000I have a $lein trampoline cljsbuild repl-listen up and running, and my ns looks like (ns something.else (:use [one.dispatch :only [react-to delete-reaction fire]]) but still can't (fire :hello) in my cljs-repl.
08:13kalasjohnny2000(one.dispatch/fire :hello) works, though. And other imports seems to work as well.
08:14kalasjohnny2000or no, they don't, not in the repl.
08:14kalasjohnny2000I go to the namespace with (in-ns 'something.else)
08:27tomojkalasjohnny2000: that used to happen to me
08:27tomojit recently started working
08:27tomojI thought I remembered some change somewhere that caused it to start working, but can't find it now
08:28tomojI don't use cljsbuild's repl-listen, though, I use `lein repl` with piggieback
08:28tomojbut I can't reproduce your problem with repl-listen either
08:28tomoj(I'm on clojurescript master, but dunno if that's why)
09:13TimMcWhere's a good channel to bug people about monads? I'm working through some tutorials.
09:16borkdudeTimMc maybe #haskell?
09:20TimMcThey'll throw random symbols at me!
09:21Iceland_jackTimMc: I can answer some questions, but the monads themselves are probably more impressive than what monads are
09:24Anderkenttechnomancy: any way to silence lein output when using `lein run` ? I.e. stuff like 'Retrieving lib-name.pom from clojars'
09:28TimMc,(for [[s v] (ns-publics 'clojure.core) :let [d (:doc (meta v))] :when (and d (re-find #"DEPRECATED" d))] s)
09:28clojurebot(add-classpath replicate agent-errors clear-agent-errors)
09:35TimMcIceland_jack: Basically, my only question is: Isn't a monad really more like a quesadilla?
09:35TimMc(I think I've actually confused myself enough for today, and should let this stuff churn in the back of my mind for a bit.)
09:36Iceland_jackIf you have real questions feel free to ask me in PM.
09:36borkdudeMonad is more like plumbing things together, so instead of passing water in and out of functions you return the hose
09:37borkdudeHere is a photograph of a programmer working on some monadic stuff: http://en.wikipedia.org/wiki/File:Plumber_at_work.jpg
09:39TimMcIceland_jack: Thanks, I appreciate it.
09:45TimMcOh, possible insight: I should not be trying to understand a given domonad form as composition of domonad + some monad, but instead as a monolithic form. E.g. clojure.core/for instead of domonad + sequence-m.
09:46jweissI'm trying to write when-some-let. It's like when-let, but the condition is when *any* of the bindings evaluate to logical true, the body is executed with the bindings. i'd like to have destructuring work too, but looks like calling destructure directly will not work. (for example it binds the whole map to a gensym behind the scenes)
09:47jweissi thought of just walking all the left hand side expressions to extract symbols, but i don't see any functions available that will traverse inside maps.
09:49TimMcjweiss: You can introduce intermediate bindings and rely on let to do the magic.
09:50jweissTimMc: sorry i'm not sure i follow
09:50TimMchttps://github.com/clojure/clojure/blob/clojure-1.5.1/src/clj/clojure/core.clj#L1684
09:50TimMcEach binding in your when-some-let becomes two bindings.
09:52TimMc(when-some-let [a 1, [b] [5 6]] ...) => (let [t0 1, a t0, t1 [5 6], [b] t1] (when (and t0 t1) ...))
09:53TimMct0 and t1 would be gensyms, here.
09:54jweissTimMc: ah, but what I really want is for the condition to be (or a b). that's different than (or t0 t1)
09:54jweissIOW i want to or all the bound symbols
09:54borkdudecould it be that java.lang.Integer was the default before instead of Longs for int literals?
09:54TimMcEr, right. (or t0 t1)
09:54jweissb is not the same as t1
09:55borkdudeor I have never really evaluated the code that's here in front of me
09:55TimMcjweiss: Oh, so you want something different from how when-let works, I see.
09:57jweissi'd want (when-some-let [{:keys [a b]} {:c 1}] [a b]) to return nil
09:58jweiss,(when-let [{:keys [a b]} {:c 1}] [a b])
09:58clojurebot[nil nil]
09:59jweissonly way i can think to do this is walk the LHS expressions to extract symbols, but i can't even find a way to descend into {:keys [a b]} without rolling my own
09:59jweissflatten and postwalk won't do it
10:00TimMcYou just want all symbols in an expression?
10:01jweissTimMc: yeah i think so
10:02TimMc,(filter symbol? (tree-seq coll? identity '{:keys [a b [c]]}))
10:02clojurebot(a b c)
10:02jweissah right, tree-seq :)
10:02TimMcThat's a quick and dirty approach, but it might be all you need.
10:02jweiss(inc TimMc)
10:02lazybot⇒ 36
10:02borkdudecan someone explain what the var "unquote" is about? can you use it instead of ~?
10:02jweissyeah, i think for my purposes that will work fine, thanks!
10:03jweiss,(let [x 1] `(unquote x))
10:03clojurebot(clojure.core/unquote sandbox/x)
10:04jweiss,(let [x 1] `(~x))
10:04clojurebot(1)
10:04jweisshm that is not quite the same
10:04jweiss,(let [x 1] `((unquote x)))
10:04clojurebot((clojure.core/unquote sandbox/x))
10:07jjttjj`is there any particular reason it's a bad idea in laser to use its select function to select a subset of the html document you want to transform, like you can in enlive? so you can create multiple templates from multiple html files?
10:11borkdudeis ~ better explained as evaluation or substitution?
10:12TimMcborkdude: Substitution. It's not so much evaluation as exemption from *not* being evaluated.
10:12TimMcOr perhaps injection.
10:13TimMc,'~x
10:13clojurebot(clojure.core/unquote x)
10:20tylerbrain asplode today: code as data is neat, but the real benefit i find myself having is that coding with data naturally comes from that paradigm
10:21jtoyI found that one library, cld messes with my logging, it hides it all or something, normally if i dont include thts library i see all of stdout in my repl. is there a way i can fix this?
10:29borkdudeIs it safe to say that the primary reason for sexps being used is macro support?
10:34scottjborkdude: sexps predate macros
10:34borkdudescottj ok, so it is not safe to say.
10:34scottjborkdude: idk :)
10:36tbaldridgescottj: read up on fexprs, they existed before macros, and are more flexible, normally at a performance cost
10:37tbaldridgescottk: fexprs are basically macros that run at run-time.
10:37tbaldridgethey were discontinued in the 70's and macros were invented. http://en.wikipedia.org/wiki/Fexpr
10:42borkdudewhat part of clojure does macroexpansion, the reader or the compiler?
10:42dnolenborkdude: compiler
10:43dnolenborkdude: though macroexpansion is after read and before actual compilation
10:43scottjtbaldridge: interesting
10:43borkdudetbaldridge indeed interesting, tnx for bringing that up
10:43borkdudednolen tnx
10:44hyPiRiontbaldridge: Hmm, that's fancy. I know Paul Graham wanted runtime macros for Arc, but didn't know they were studied and "out in the wild".
10:46tbaldridgehyPirRion: yeah, fexprs really don't work well with compiled lisps (like Clojure). I do wonder sometimes if a tracing JIT (like PyPy) couldn't make these viable again. But I haven't found a "must have" use case for fexprs yet.
10:47pjstadigfexprs are a bad idea, and were abandoned for a reason
10:47pjstadigsupposedly John Shutt has reconceived them in the kernel language to make the viable, but not everyone is on board with his work
10:48hyPiRionOne "concern" would be that people would overuse fexps, but I can see places where they could be useful
10:48jweissany nrepl.el users know how to do the equivalent of slime-eval-last-expression in the repl? C-x C-e does it in a source file but not in the repl.
10:48pjstadigone of the big problems with fexprs was dynamic scoping, which isn't really an issue anymore, but there were other problems
10:48hyPiRionnot sure if the pros outweight the cons though, I haven't really thought much about it
10:49number36can someone tell me
10:49number36what could this mean ?
10:49number36java.lang.RuntimeException: Unmatched delimiter: )
10:49number36i am solving 4clojure problems
10:49number36if it help
10:49pjstadignumber36: you have an extra closing paren somewhere
10:49number36pjstadig thank you
10:50jweissok wow, could it be as simple as just binding nrepl-eval-last-expression? wonder why that isn't the default
10:52jcromartieI am trying to get out of OOP mode
10:53jcromartieI keep thinking in terms of superclasses
10:53jcromartielike, oh I should be able to inherit this-or-that
10:53jcromartieand then override
10:53Ember-composition over inheritance my friend :)
10:53Ember-even in the oop world
10:53jcromartieindeed, but I'm still getting the hang of it
10:53jcromartielike, I am working on a data model
10:53jcromartieI implemented one model namespace
10:54jcromartienow when I go to implement another I find it's just copy/paste and find/replace
10:54jcromartieI think I'll allow that to happen *once* but then it's time to abstract
10:54TimMcscottj: Nonsense, macros predate upon sexps! (Oh, it's a homonym. :-P)
10:55TimMcThis is what happens when you're married to a biologist.
10:55jcromartieso I'm thinking I need *something* that provides basic CRUD on a collection with a validator function right?
10:56jcromartieeither way. I should just make it work first, add tests, then refactor
11:03jcromartiemultimethods to the rescue?
11:13jtoyI have a fn in a namespace defined as: (defn is_american? [json] (eval (user_json_query "(is_american? json)" "find_all_americans"))) when i test it, it says is_american? cant be found, which makes me think it is using the namespace from the repl instead of from the namespace the code is in
11:13jtoyis there a way I can make this read form the namespace of the file it is in instead of the repl?
11:19jcromartiejtoy: your repl has a current namespace too… by default it's 'user, so either change it with in-ns or require or use your namespace
11:20jcromartiethat is, change it with "in-ns", or else import your namespace with "require" or "use"
11:20corecodeis there a way to send an expression/buffer to nrepl, so that expression and result appear there?
11:25DaReaper5i am having an issue with clj-time
11:26DaReaper5.toDate seems to be off by 1 day
11:26DaReaper5(.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01")
11:26DaReaper5how do i use the clj bot?
11:28DaReaper5hello?
11:28clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline DaReaper5
11:28DaReaper5hu clojurebot
11:28DaReaper5hi*
11:28DaReaper5how do i use you
11:28DaReaper5-help
11:28DaReaper5:P
11:28bbloom,(+ 5 10)
11:28nDuff,(.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01")
11:28clojurebot15
11:28clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
11:28nDuff,(.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01"))
11:28clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clj-time.format>
11:28bbloom&(- 20 3)
11:28lazybot⇒ 17
11:29DaReaper5dam
11:29DaReaper5so i cant use the bot
11:31nDuffHrm. With clj-time being a wrapper around JODATime, I'd be surprised if its logic were actually broken.
11:31nDuffLess surprised if it had some unintuitive behaviors relating to time zones and such.
11:32Ember-I'm 99.9% certain that clj-time isn't broken due the reasons nDuff just said
11:32DaReaper5oh god im wrong
11:32DaReaper5its something weirder
11:32Ember-joda-time is way too production proved
11:33DaReaper5map2(java.util.HashMap. {"date" (.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01"))})
11:33DaReaper5that causes the issue
11:33nDuffDaReaper5: ...also, that first code gives me back #inst "2012-01-01T00:00:00.000-00:00", which is what I'd expect.
11:33DaReaper5yes
11:34DaReaper5{"date" (.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01"))}
11:34Ember-I'd look at that map2 function whatever it does
11:34nDuff{"date" #inst "2012-01-01T00:00:00.000-00:00"} <- also looks normal.
11:34DaReaper5and the resulting HashMap have different date values
11:34nDuffWhat's map2?
11:34DaReaper5map2 is the issue
11:34DaReaper5its a hashmap
11:34DaReaper5do you get an issue with java.util.HashMap. ?
11:34nDuffDaReaper5: Can you provide a reproducer?
11:34Ember-why not just use hash-map ?
11:35DaReaper5map2(java.util.HashMap. map1) is my current way of converting to a hashmap that java can use
11:35Ember-using java.util.HashMap is kinda dangerous in clojure anyway since it is mutable
11:36Ember-oh, java interop
11:36DaReaper5ya interop
11:36nDuffDaReaper5: This "map2" is not a standard library function.
11:36nDuffDaReaper5: Where do you get it from?
11:36DaReaper5nDuff sorry map2 is a variable name
11:36DaReaper5in a let
11:36Ember-but doesn't java take clojure maps just fine?
11:36Ember-imho clojure maps implement java.util.Map
11:37nDuffDaReaper5: (java.util.HashMap. (hash-map "date" (.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01")))) <- looks fine to me.
11:37Ember-and due to that you can just pass clojure maps for java code
11:37nDuffDaReaper5: ...also, what Ember said. Unless you're using a Java library that _really_ requires a mutable map...
11:37Ember-if your java side of things takes java.util.HashMap as parameter then it's time to change it to accept java.util.Map
11:38Ember-there is absolutely no reason to force HashMap as parameter
11:38DaReaper5but why would it be changing the value?
11:38nDuffEmber-: ...I _could_ see a sufficiently evil, poorly-designed API mutating maps that it's given rather than only using them as input.
11:39nDuffDaReaper5: Have you demonstrated that "changing the value" in a way that anyone other than you can reproduce?
11:39Ember-nDuff: yeah, but there is still no _reasonable_ reason for that :)
11:39nDuffDaReaper5: A standalone, self-contained reproducer would be helpful here.
11:39Ember-that's just plain ugly
11:39DaReaper5what date is returned for you when you execute this:
11:39DaReaper5map2(java.util.HashMap. {"date" (.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01"))})
11:40DaReaper5that reporduces it for me
11:40Ember-and what is the implementation of map2
11:40nDuffDaReaper5: that isn't code that can be run standing alone!
11:40nDuffDaReaper5: It requires an enclosing let, if nothing else.
11:40DaReaper5(println (java.util.HashMap. {"date" (.toDate (clj-time.format/parse (clj-time.format/formatters :year-month-day) "2012-01-01"))}) )
11:40Ember-if map2 uses map internally then you should be aware that map returns a lazy sequence
11:40nDuffAhh. Now I'm seeing it. #<HashMap {date=Sat Dec 31 18:00:00 CST 2011}>
11:40DaReaper5ya
11:40nDuff...yup, calling this a time zone issue.
11:40DaReaper5wierd
11:41nDuffWhen it's being generated by the Clojure printer, it's UTC
11:41nDuffhere it's being printed in CST
11:41Ember-ah true
11:41nDuffso it's exactly the same time, just represented two different ways.
11:41DaReaper5haha
11:41DaReaper5 so i have to specify the tiem zone some how?
11:41Ember-LocalDateTime in joda time
11:41Ember-has no time zone information in it
11:42Ember-in clj-time I think the function is local-date-time (duh)
11:42nDuffDaReaper5: ...only if you really want to. I mean, the outputs are unambiguous as they are.
11:42DaReaper5nDuff used in an sql query it does not take into consideration the time zone it hink
11:42DaReaper5think*
11:42nDuffDaReaper5: By the way, you can reproduce this without using clj-time at all.
11:42Ember-makes life easier when you don't have to take time zones into account but they are there for a reason
11:43nDuff,(println (java.util.HashMap. {"date" #inst "2012-01-01"}))
11:43clojurebot#<SecurityException java.lang.SecurityException: denied>
11:43Ember-aww
11:43nDuff&(println (java.util.HashMap. {"date" #inst "2012-01-01"}))
11:43lazybot⇒ #<HashMap {date=Sat Dec 31 16:00:00 PST 2011}> nil
11:43DaReaper5ha
11:44tbaldridgelazybot: you are less secure it seems
11:44DaReaper5hmmm so how should i go about this
11:45nDuffDaReaper5: ...so, JDBC actually _does_ specify behavior around timezones.
11:46nDuffDaReaper5: ...see the javadoc at http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setTimestamp%28int,%20java.sql.Timestamp,%20java.util.Calendar%29
11:46DaReaper5actually it might be displaying right
11:46DaReaper5used right***
11:46DaReaper5in sql
11:46DaReaper5but it is displaying wrong in my report
11:47DaReaper5should i do time zone compensation on my display side?
11:47DaReaper5(i am building a report from the data)
11:48DaReaper5... i guess i need to write some java code to do it on the reporting side
11:48nDuffDaReaper5: clj-time gives you helpers to specify the timezone to use.
11:49DaReaper5even if i do not specify it, shouldnt it be consistent?
11:50nDuffDaReaper5: Sure.
11:50DaReaper5but its not
11:50nDuffDaReaper5: ...Sure it is, within each printer.
11:50DaReaper5my printer is showing 2 different values
11:51DaReaper5depending on the data structure it is in
11:51nDuffRight, because the HashMap thing doesn't delegate to the Clojure printer
11:51nDuffbut does its own thing.
11:51nDuff...but why would that matter for reporting?
11:51nDuffYou're not going to put a HashMap's representation into a report, or at least I'd hope not.
11:51DaReaper5my report says today's date is the 31st when i wanted the 1st
11:52DaReaper5the hash map provides parameters to a jasper report
11:52DaReaper5one of those parameters is the day of the request
11:52jcromartiewhy does the compiler choke on this code: (throw (Exception. "cannot save invalid object"))
11:52jcromartieif I run that in the REPL it works fine
11:52nDuffOkay. Then you need to look into how Jasper handles times.
11:52DaReaper5ya
11:52nDuffThat's not a printer thing at all.
11:52DaReaper5gah
11:52nDuff...and Jasper is presumably going to do the default Java thing
11:52Sonderbladewhat emacs mode(s) do you use when coding in clojure? currently using nrepl but it is very flaky
11:52nDuff...and default to the local timezone
11:52nDuff(which isn't UTC, hence, the 31st)
11:53nDufferr, isn't UTC in your case.
11:53DaReaper5so i should specify in my parse that i want the local time zone
11:53DaReaper5... possibly
11:53jcromartieSonderblade: I have kind of given up on nREPL mode for now… just use clojure-mode and a lein repl most of the time
11:53jcromartiealong with midje autotest
11:53ppppauljcromartie, why why why?
11:54DaReaper5nDuff do you know how do do a parse of "2012-01-21", specifying time zone?
11:54ppppaulwhat is flaky about nrepl Sonderblade
11:54nDuffDaReaper5: ...it's only right there in the clj-time README.
11:54jcromartieppppaul: well for one, I can't disable the broken color output from midje autotest.
11:55ppppauloh, i've never used midje
11:55nDuffDaReaper5: ...What's the actual business logic? Are your reports _really_ supposed to be operating on UTC, or on local time?
11:55jcromartieppppaul: and the problems with output from other threads that make getting output from Jetty rather a pain
11:55nDuffDaReaper5: ie. should something happening at 11:00PM UTC on that day be included in that year's report, or the next one?
11:55Sonderbladeppppaul: the longer the nrepl buffer the slower it goes, if you add a dependency you need to restart emacs otherwise nrepl won't see the change
11:55jcromartiei.e. in any other context, (println ….) works, but not in a compojure/Jetty handler in nREPL in Emacs
11:56ppppauljcromartie, if logging is an issue you may be interested in https://github.com/hoytech/Log-Defer
11:56DaReaper5nDuff: date range is provides for the search, as well as todays date. Those values are used int he sql query and also displayed
11:56DaReaper5they are displayng wrong
11:56nDuffDaReaper5: Wrong -- they're displayed correctly.
11:56DaReaper5i have not checked if the data is wrong
11:56jcromartieSonderblade: you can use nrepl-restart to get the (preumably Leiningen) dependency
11:56nDuffDaReaper5: ...rather, they're displayed correctly _for local time_
11:56ppppauljcromartie, i used spyscope for debug printing in emacs
11:56nDuffDaReaper5: ...so, they accurately reflect (in local time) what your database is including in its search.
11:57DaReaper5nDuff then i need to make sure that clj-time is parsing in local time
11:57nDuffDaReaper5: Exactly! And the clj-time readme discusses that.
11:58Sonderbladejcromartie: yes but that leaves the old jvm running so after a few restarts i still need to kill all dangling jvms and restart emacs
11:58jcromartieSonderblade: dang, didn't notice that
11:58jcromartiethat's pretty bad
11:58jcromartiewhat about nrepl-quit first?
11:58Sonderbladethis is on windows
11:59nDuffDaReaper5: (clj-time.local/to-local-date-time "2012-01-01")
12:00Sonderbladehaven't tried it yet, but at this point i'd rather have something more mature than nREPL
12:00DaReaper5nDuff yupp testing that now
12:01DaReaper5i did not realize before that clj-time.local/to-local-date-time could be used to parse a string
12:01DaReaper5thanks again nDuff
12:02DaReaper5i think my report is near ready for production now
12:02tgoossensI'm preparing a talk on "why clojure was created". How would you respond to the question: "Isn't programming in clojure a step backwards towards procedural programming ?"
12:02tgoossens*scratch towards :p
12:04nDufftgoossens: My first attempt might be something like this: "Programming in Clojure is _less_ procedural than most other languages; the use of lazy, functional idioms lets you focus on your data, not on operations done to it. [Examples here]"
12:05ystaeltgoossens: The dogma of object orientation is a misguided dream which pulls us relentlessly away from simple expressions of computation, and by chaining operations to objects, imprisons us forever in the shackles of mutable state.
12:05jcromartieseems like defprotocol and deftype result in a lot less code than multimethods
12:05ystael</purple>
12:06borkdudeanother thing that comes up often: why does clojure promote programming with naked/basic datastructures instead of your own datatypes? if this works better, why aren't people passing hashmaps instead of objects in java?
12:07jcromartieborkdude: obviously because that doesn't always work better
12:07ystaelborkdude: Alan Perlis had a good aphorism about this: "It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures."
12:08tgoossenswho is alan perlis?
12:08borkdudetgoossens you have this quote in your presentation ;)
12:08tgoossensborkdude: i know. And i like the quote. But i"m trying to find out more about the guy himself
12:09tgoossensand why it would be legitimate to put it into my talk :)
12:09borkdudejcromartie can you name an example where it doesn't fit?
12:09ppppaulSonderblade, i don't add dependencies much. i clear the buffer when it gets slow. i don't see how these are really big issues. i'm interested in knowing about your workarounds or solutions.
12:09tgoossensborkdude: java is a statically typed language. Maybe that is one part of the puzzle
12:10bbloomtgoossens: surely the wikipedia article is a good starting point for that question :-)
12:10jcromartietgoossens: the fact is that in Clojure you have the *option* of usng the great datastructure-oriented facilities (map/reduce/filter, the seq abstraction, destructuring, etc.)
12:10tgoossensbbloom: obiously, but maybe you know some anekdotes ;)
12:11jcromartietgoossens: OR using things like powerful ad-hoc inheritance (multimethods) or hiding the data structure entirely (deftype)
12:11tgoossens(i'm going to play the role of the guy who asked the question)
12:12tgoossensBut i want to encapsulate irrelevant information, maps don't allow me to do that
12:12jcromartieoops
12:12jcromartiethat was borkdude
12:12jcromartietgoossens: encapsulate for who? whose sake?
12:12jcromartiei.e. if you hide it or don't, who cares?
12:13jcromartieand if you do care, then use deftype
12:14tgoossens"doesn't that pollute my interface? And what if i want to change the underlying representation. Without getters i cannot do that" (i'm still playing the role of the questioner)
12:14Sonderbladeppppaul: for me, 2 screenfuls is enough to cause nrepl to lag alot
12:14borkdude(doc deftype) ;;=>
12:14clojurebot"([name [& fields] & opts+specs]); Alpha - subject to change (deftype name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the current namespace, the give
12:14jcromartie:) got it
12:14borkdude(deftype name [fields*] options* specs*)
12:14borkdude Currently there are no options.
12:14borkdudelol
12:14ppppaulSonderblade, what platform?
12:15ppppaulSonderblade, i can handle 10-30 before i need to clear the buffer
12:15nDufftgoossens: "The conventional approach in Clojure is to provide functions that operate on your data -- the role is very much akin to that of getters in Java"
12:15borkdudetgoossens you are playing devil's advocate, which is good, because I get the same questions from colleagues who frown upon clojure because it's not OO
12:16tgoossens"Because making maps is like making my fields public. And then what if I choose a wrong representation. Then everyone who is dependent on my structure will not be compatible anymore"
12:16tgoossensborkude : i'm actually asking questions that people ask me as well yes
12:16borkdudetgoossens what if you expose a getter that was wrong
12:16nDufftgoossens: "If someone is dependent on your structure, instead of dependent on your function interface, either you or they are Doing It Wrong"
12:16Sonderbladeppppaul: windows 8
12:17nDufftgoossens: "If you want to describe your maps as 'private', use namespaced keys; this expresses that they're implementation details, able to be changed, and that others shouldn't rely on them directly"
12:17tgoossensborkude: what do you mean with wrong is this situation?
12:17borkdudenDuff I don't get it. If I use Ring, I expect a request map to have certain things, for example?
12:17borkdudetgoossens subject to change wrong
12:17nDufftgoossens: "This works well in the Python world, where no private variables exist, but it's an understood social contract that members and methods starting with underscores aren't available for public access"
12:17nDuffborkdude: Sure -- in that case, they're part of the public interface.
12:18ppppauli'm on ubuntu with a custom kernel... emacs on windows may be less preformant
12:18nDuffborkdude: If someone wants to have members that _aren't_ part of the public interface, but hidden behind a layer of abstraction, that's available (by convention) as well.
12:18tgoossensborkdude: i could introduce a new getter that does the right thing. And everyone using my old getter will still be able to
12:18ppppauli've never used windows to develop, cept with eclipse and MS stuff
12:18nDuffs/your maps/members of your maps/
12:19tbaldridgetgoossens: I would also say that this sort of thing happens less often in Clojure.
12:19borkdudetgoossens the same would be the case in clojure: you would have to provide the old key-value for backward compatibiltiy?
12:19tgoossensnduff: "with function interface. Do you mean like the public interface of a class?"
12:20modulusHi there. So is there a canonical way to make a websocket client on clojure?
12:20tbaldridgein OOP it's super easy to get a class hierarchy wrong, with data, it happens less often, and when it does, it's normally just a renaming of a few keys, or the data in a assoc-in vector
12:20borkdudeI like the analogy of webservices though: if big systems are supposed to talk to each other via immutable basic data, why not apply this on a smaller scale as well
12:21tgoossenstbaldridge: "Can't i solve this by composition instead of inheritance in an OOP language?"
12:21nDufftgoossens: "It's very much a similar concept -- also, like Java interfaces, a set of functions isn't tightly coupled to a specific object type, so protocols or multimethods can be used to provide different implementations to be used with different types of data"
12:23pbostrommodulus: personally, I just use direct js interop, you could also consider putting a wrapper around the js interface, there's only a few functions, I don't think there is a canonical websocket library at the moment
12:23ppppaulmultimethods can come in very handy
12:24ppppauli've only used them in-place of if/switch statements
12:24tgoossensnDuff: "but how can a map ensure robust software if you don't obligate a certain interface like a java interface? If you have really large maps, does't this become a problem?"
12:24jcromartieppppaul: I'm using them in my data layer
12:24jcromartieppppaul: e.g. a repository is just a map with a :db :collection and :validator
12:25jcromartieand the repository operations dispatch on the collection name
12:25moduluspbostrom: javascript interop? not sure i get this. i want to run clojure on jvm and use it as ws client. is it possible to use javascript from there?
12:25ppppaultgoossens, i've done work with xml-seq where my maps were so big they would crash emacs.... but so long as i didn't print them out operations on them were fast.
12:25pbostrommodulus: sorry, I misread, ignore what I said
12:26tbaldridgetgoossens: that's what tests are for. If you have proper tests, you can change the map representation, and then run tests to make sure it works.
12:26tgoossenspppaul: its not the performance now. I'm wondering whether it is still do-able because maps don't obligate a certain form??
12:26lazybottgoossens: Definitely not.
12:26borkdudeppppaul you might want to (set! *print-level* …) and/or *print-length*
12:26tbaldridgelazybot: what are you talking about?
12:26lazybotIt's AWWWW RIGHT!
12:27ppppaulborkdude, i would reduce the map to something small before printing.... printing out an xml-seq isn't so useful anyway
12:27tgoossens"In java for a person i would make an IPerson interface. And there can be different representations of it. How is that not good? (for robustness, extendabillity)"
12:28mpenetambrosebs: is `untyped-ann` something you plan to add in the near future? (I have no idea how difficult it is to implement)
12:30tbaldridgetgoossens: IPerson is fine, but the problem is when you get to more complex interfaces. Think for instance of IBachelor...
12:30ambrosebsmpenet: It seems like an important feature. It should probably be added before 0.2.0
12:30nDufftgoossens: "If you're providing a function interface as the only supported and documented means of access, and using namespaced keys to explicitly declare map contents private, you _are_ obligating its use -- any reasonable code review of a component which uses someone else's namespaced keys contrary to documentation will reject it out-of-hand"
12:30tbaldridgeIBachelor should have "putBeerInFridge", and perhaps "goFindADate"...
12:30mpenetambrosebs: great
12:31tgoossensnduff: "so what you are saying is, that the representation of the map here doesn't matter. The functions you use just have to be able to use it?"
12:31tbaldridgeSo in this type system, what is a monk (doesn't find dates) or a Mormon (doesn't drink beer)?
12:31tbaldridgeWith data you don't have to worry about that, based on certain criteria you can modify the data at will. You're free to mix and match, and compose operations.
12:32tbaldridgetgoossens: have you seen the talk "simple vs easy" by Rich?
12:32borkdudetbaldridge NotImplementedException :P
12:32tgoossenstbaldrige: yes. i've seen them all (remember i'm still kinda impersonating/acting + putting in my own uncertainties)
12:33pbostrommodulus: I think Jetty has a websocket client
12:33tbaldridgewell in that case I'll give you the completely arrogant answer: it sounds like it's a problem, until you try it and realize it's not.
12:33tgoossenshehe
12:33belakAre there any good IRC bots written in Clojure? Or, what would be a good project to start with?
12:34modulushmm, i thought jetty was a webserver
12:34tgoossensnow a real question of my own
12:34tgoossenswhy did we invent syntax anyway then (if it is really that great) ?
12:34tbaldridgejust like dynamic typing. People say "I'll never know if my program works", but spend 4 months in the language and you'll say "what was I thinking this is awesome".
12:34modulusbelak: a good proejct would be a websocket client library ;-)
12:34tgoossensWhy are we where we are now
12:34kursion2Jetty is a middlewar
12:34belakmodulus: sorry, I meant a good project t start learning with
12:35borkdudeDon't know this, but doesn't Pedestal support websocket things maybe?
12:35belak*to
12:35moduluspedestal? hmm, will check.
12:36tbaldridgePedestal supports SSE (server sent events). They are only one direction (server->client) but they are better than long-polling. Web sockets are not yet implemented.
12:37danielglausertbaldridge: What's the best way to find out how SSEs work?
12:37tgoossensok thanks guys for the discussion :)
12:37pbostrommodulus: http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/websocket/WebSocketClient.html
12:37borkdudetgoossens syntax because if familiarity (infix math instead of prefix, etc) I think
12:38moduluspbostrom: thanks, i was hoping not to have to go to java, but i guess that's life.
12:38tbaldridgedanielglauser: the implementation is only about 145 lines of Clojure: https://github.com/pedestal/pedestal/blob/master/service/src/io/pedestal/service/http/sse.clj
12:39tbaldridgeThe idea is that you keep the socket open, then send event: eventid \n data: <data> \n\n so each message is separated via a CRLF.
12:40tbaldridgethat's all there is to it, the rest of that file is magic to keep the socket from closing, and to allow any thread to send data
12:41pbostrommodulus: yeah, I hear you, in my limited experience using websockets for a hobby project, the web ecosystem in general has been slow to adopt, see for example ngnix only added support for websockets a month ago
12:41mpenetLong Polling has an advantage still, it passes proxies and other weird server configs out there. No that I like it better, I do not.
12:41tbaldridgehttps://github.com/pedestal/samples/blob/master/server-sent-events/src/server_sent_events/service.clj this file shows an example that sends a message from a random thread, printing the thread-id
12:41tbaldridgethat's the nice thing about SSE, it is long polling
12:42moduluspbostrom: unfortunately i need ws because the API that i need to use from the server uses it ... otherwise i'd probably try something else
12:42mpenetah, it seemed to me it was based on response streaming
12:42tbaldridgeeh....you're right. my bad
12:42mpenet:)
12:43tbaldridgeit's long response time, so I suppose the proxy could cut off the connection because it sees there's little data being sent.
12:43tbaldridgeI hate proxies/firewalls that think they know better about your connection than you.
12:43mpenetlong polling costs more in resources (constant restart of hanging request), that's one downside
12:44ppppaultgoossens, syntax is a layer over the AST... it is useful, but has many limitations and people who use lisp usually don't like these limitations.
12:44mpenetbut it's supported by pretty much everything, always good to have a fallback on this
12:48mpenettbaldridge: not only long response time, but also some config will just drop anything past the first chunk for instance
12:51biomunkyhi all, i've cloned the cascalog project from github. When i start the tutorial i get a classnotfound exception for hadoop.fs.FileSystem (i have followed the instructions in the README) - anyone got a suggestions for fixing this
12:53ambrosebsmpenet: I've created an issue FWIW http://dev.clojure.org/jira/browse/CTYP-25
12:54mpenetthanks!
12:55mpenetambrosebs: just a thought, "instead of tc-ignore" does that mean it will go away? I think both can be usefull
12:56ambrosebsmpenet: tc-ignore will be staying for a few more versions yet.
12:56mpenetok
13:05duncanmhello all
13:14danneuIs there a better way to specify that a symbol represents a collection of one? (def word "apple"); (intersection (set [word]) #{"apple" "chair" "house"})
13:17bbloomlike a collection wrapped apple?
13:17bbloomi like: wrapple :-)
13:21danneuafter typing that out i realize it's saying exactly what i want it to.
13:21danneuie this is a coll of strings, not a coll of chars.
13:25gaverhaeHi all. I'm blocked by something that should be trivial : what's the easiest way to set *assert* to false using leiningen ?
13:26borkdudegaverhae what is assert for?
13:27borkdudegaverhae my guess (set! *assert* false)
13:27gaverhae*assert* is the global var that controls pre- and post-conditions during compilation
13:28borkdudepre- and postconditions are checked at compile time?
13:28gaverhaeSo I basically need a way to ask leiningen to execute (set! *assert* false) before compilation, in the compilation thread
13:28gaverhae*assert* is checked at compile time to enable/disable pre/post conditions
13:28borkdudegaverhae you can put this in your :init settings in profiles.clj
13:29gaverhaeThanks !
13:29borkdudegaverhae or in some other profile, project specific
13:29gaverhaeIs it possible to get that via the commandline instead of putting it into project.clj, so it can be more selective ?
13:30ppppaulanyone here have experience using jclouds?
13:30hiredmanyeah, it hurt
13:30borkdudegaverhae I don't know, try in #leiningen
13:35hyPiRiongaverhae: humm, that should be doable, let me check it out
13:35duncanmdanneu: i thought you can use a set as an IFn
13:36duncanmhmm, maybe i don't understand, nevermind
13:43ebaxtIs there a url-rewrite middleware for ring? Something like rack-rewrite maybe?
13:47ebaxtSuppose I can use a servlet filter http://tuckey.org/urlrewrite/
13:49hyPiRionebaxt: well, there's the wrap-base-url in hiccup-middleware, you may want to look a bit on that one
13:50ebaxthyPiRion: Thx, I'll have a look
13:50hyPiRionIt's not what you want, but making a rewriter out of it should be rather simple (assuming it's not very large)
13:50hyPiRionnot exactly *
14:02grebusanyone know if there's the equivalent of memfn for field access in clojurescript? I can't find it
14:02dnolengrebus: doesn't exist
14:04grebusdnolen: oh, thanks. looks easy to write, is there some gotcha I should look out for if implementing it myself, such that it didn't make it to clojurescript core?
14:05dnolengrebus: does memfn work for fields & methods? I never use it.
14:07amalloydnolen: it should work for fields in jvm-clojure, but in cljs it has to generate .-member instead so it won't work
14:08grebusdnolen, amalloy: yeah, memfn doesn't seem to work for fields
14:08dnolenamalloy: yeah that's why I asked, so grebus - I don't see how it could work.
14:08dnolengrebus: oh hmm
14:08grebusdnolen: #(.-bla %) is the equivalent, right?
14:09n_b,(doc memfn)
14:09clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls."
14:09Glenjaminis there a way to get leiningen to tell me which checkout dependencies it's using?
14:09TimMc,((memfn indexOf s f) "memfn" "m" 1)
14:09clojurebot2
14:09technomancyGlenjamin: `ls checkouts`
14:10Glenjaminthe app is acting like it's not using it :S
14:10technomancyGlenjamin: you could try `lein checkouts`
14:10technomancyerr
14:10technomancy`lein classpath`
14:11borkdudetechnomancy ls checkouts? I've never seen a checkout directory in a lein project
14:11Glenjaminbingo, that's handy
14:11Glenjaminthanks technomancy
14:11borkdudeah wait, checkout dependencies
14:16arrdemis there a way to make fnparse not die if there are remaining tokens?
14:17RaynesDecide to maintain it and take over project ownership.
14:17dnolengrebus: yes
14:17duncanmhey, dnolen
14:17hyPiRionRaynes: That's the correct way to do it.
14:17dnolenduncanm: hullo
14:17duncanmdnolen: did you see that some guy on fonc found the paper alan mentioned before? the one about control structures
14:19dnolenduncanm: hep, downloaded :)
14:19dnolens/hep/yep
14:19duncanmyeah, me too
14:19duncanmdnolen: are you working on clojurescript much these days?
14:22dnolenduncanm: yes
14:22duncanmdnolen: i've been trying out typescript, but i have a question that also concerns clojurescript -
14:22dnolenduncanm: what's up?
14:23duncanmdnolen: with all these APIs defined in CPS style, i find it really hard to start working from the REPL
14:23dnolenduncanm: JS apis?
14:23duncanmyeah
14:23dnolenduncanm: right, Clojure people are coming w/ various solutions for that
14:24duncanmoh, i'm interested in finding out what ideas they have
14:24duncanmdnolen: also, i was writing a little server that deals with git repos, so i was using the fs module
14:24dnolenduncanm: lots of stuff to look at, FRP, Javelin, Chris Grangers's stuff, Kevin Lynagh's stuff etc
14:25duncanmdnolen: i actually don't know how it fits together, but i was looking for some way to do fluid variables, so that i can bind process.cwd() within some scope
14:25dnolenduncanm: are you doing node stuff?
14:25duncanmdnolen: yeah
14:25duncanmdnolen: so far, i've used a lot of async.js (with typescript)
14:25dnolenduncanm: yeah, there's a lot less CLJS activity there though Bodil is forging ahead
14:26duncanmdnolen: and there were these ideas i have (from working with lisps in the past), and i realized the clojurescript people are the only ones who'd know what i'm talking about
14:27duncanmthings like fluid variables, or using the REPL to incrementally build things up -- the JS people don't really know these habits/techniques
14:28duncanmi'm a bit rusty with clojure/cljs, but would with-open work correctly if the body is a bunch of async calls?
14:28malynduncanm: Bodil's Red Lobster looks pretty great for working with Node.js-style async APIs -- https://github.com/bodil/redlobster
14:29duncanmmalyn: ahh, indeed
14:30duncanmneat
14:30duncanmdnolen: thanks for the referecnes
14:30duncanmdnolen: i'm interested in rxjs too, which is kinda in the same space
14:30dnolenduncanm: np, take a look around people are working on fun stuff these days
14:31tomojhmm are cells not places?
14:31dnolenduncanm: CLJS is still rough around the edges but we're making progress
14:31duncanmdnolen: typescript is quite interesting, and they're about to make a big release in a few weeks
14:33dnolenduncanm: I find it theoretically interesting but it doesn't really solve any of the problems I actually have JS (types are really low on my own list of important things)
14:33duncanmdnolen: i've been using it to learn the APIs, for that it's pretty handy
14:35dnolenduncanm: makes sense, is TypeScript able to infer types for all of the Node.js API or something?
14:35dnolenor do they ship w/ that
14:35dnolen?
14:35duncanmdnolen: they have these foo.d.js files which include 'typings'
14:35clojurebotNo entiendo
14:36duncanmdnolen: and they're adding more to the type system, so soon you can write something like this
14:36dnolenduncanm: yeah, so do they ships w/ types for Node.js, I've Underscore.js & jQuery (though the types are so broad it doesn't seem that helpful)
14:36duncanm interface Document {
14:36duncanm createElement(tagName: string): HTMLElement;
14:36dnolenI've seen types for Underscore.js & jQuery I mean
14:36duncanm createElement(tagName: 'canvas'): HTMLCanvasElement; }
14:36duncanmwhich is kinda neat
14:36duncanmdnolen: yeah, there are github repos where people collect these typings
14:36duncanmdnolen: the types will get tighter once they put in generics
14:37duncanmhttp://blogs.msdn.com/b/typescript/archive/2013/03/25/working-on-typescript-0-9-generics-overload-on-constants-and-compiler-performance.aspx
14:37dnolenduncanm: ah nice - one can hope Typed Clojure can do something like that for people who want that when they need it.
14:37duncanmdnolen: right
14:37duncanmdnolen: cljs might(?!?) be able to get there via typed clojure
14:37duncanmanyhow
14:38dnolenduncanm: yes, ClojureScript is probably simpler to type than CLJS even given lack of subtyping around protocols but Ambrose probably has more to say about that.
14:39dnolenCLJS simple than CLJ I mean of course.
14:42dnolenduncanm: still, TypeScript is really interesting, I've been trying to keep up w/ it and Dart as well.
14:50dnolenduncanm: that said the fact people are writing 100KLOC codebases w/ TypeScript doesn't bode well for the semantics of the language IMHO :P sounds like they're bringing worst practices to JS runtimes.
14:50tbaldridgednolen: but it's typed, that means you can hire any dev off the street and he can't produce bad code!
14:50tbaldridge:-P
14:51tbaldridgeI said it before TypedScript came out, and I'll say it again. MS hates dynamic languages. That's all the thought process that went into TypedScript, imo.
14:51duncanmdnolen: yeah, i haven't had time to look into dart
14:52duncanmtbaldridge: but what about VS and IDispatch? ;-P
14:52duncanmeek, i mean, VB
14:52TimMc,((memfn get [x y]) {[1 2] 42} [1 2 3 4]) ;; hyPiRion, a new abomination for you
14:52clojurebot42
14:52dnolenduncanm: TypeScript & Dart both feel like lighter weight Javas to me. So it's hard for me muster much excitement beyond compiler / type nerdery.
14:52TimMcOr maybe that's an old one.
14:53hyPiRion,(doc memfn)
14:53clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls."
14:53duncanmdnolen: how do you feel about programming in javascript?
14:54hyPiRion,(macroexpand-1 '(memfn hello [x y]))
14:54clojurebot(clojure.core/fn [target190 [x y]] (. target190 (hello [x y])))
14:54dnolentbaldridge: btw, your LLVM talk was rocking!
14:54duncanmdnolen: i've been trying to learn JS, and embrace it - and i find TS to offer some nice additions, while not deviating too much from JS
14:54duncanmi haven't done any serious JS programming before this
14:54hyPiRionTimMc: Well, that's a new one for me, at least.
14:54hyPiRionI knew about the funny things you could do with memoize though
14:55dnolentbaldridge: basically covered the same ground as an EDSL in Haskell talk I saw at TechMesh, but a bit more impressive IMO
14:55ivanTodoMVC needs a time slider
14:55hyPiRion,(let [mem-conj (memoize conj)] [(mem-conj '(1) 2) (mem-conj [1] 2)])
14:55clojurebot[(2 1) (2 1)]
14:55dnolenduncanm: been doing for 7 years, it's fine I don't hate it or love it.
14:55TimMchyPiRion: Oh yeah, that's a "good" one for sure.
14:55duncanmdnolen: ah
14:56TimMchyPiRion: Good times arguing about what, exactly, is broken there.
14:56hyPiRionyeah
14:57tbaldridgednolen: thanks! I had a blast giving the talk.
14:57konr_6in which library is '-?>>'?
14:57Bronsacore.incubator
14:57ivancore.equality
14:57Bronsawat
14:57konr_6thanks!
14:57ivanI was making a joke about an earlier thing ;)
14:57Bronsaoh, ok
14:59hyPiRionAhh, I was sad when I saw that Clojure + LLVM was presented at Clojure/West. I soo wanted to watch that one.
15:02mikerodIt seems to me that `defmethod` does not ensure that the the `fn-tail` argument given to it has the correct number of arguments. The correct number being the number of arguments of the dispatch function defined with `defmulti`. Is this a correct observation?
15:03avishaihi
15:03amalloymikerod: the dispatch function can take any number of arguments, so it would not be possible to ensure what you're talking about
15:04avishaii need a little help with require
15:04amalloy(defmulti counter [& args] (count args)) (defmethod counter 0 [] "called with nothing!") (defmethod counter 1 [x] "called with one arg")
15:04avishaiwhen i use the repl i can 'require my clj file
15:05avishaibut when running a clojure file it doesn't work
15:07mikerodamalloy: So in the case of variadic args on the defmulti I see your point. However, It seems to me, from your example, I could have (defmethod counter 10 [x y] "I can't be called")
15:08mikerodIt would take 10 args for the dispatch fn to match, but when this method is dispatched upon, it will throw an arity exception.
15:12amalloymikerod: sure, and when you've solved the halting problem you can start work on analyzing every dispatch function to see what kinds of fntails are valid
15:12amalloybut until then, there's not really much we can do
15:14grebusI can't get the clojurescript browser-repl to recognize my macros, is that normal?
15:15mikerodamalloy: I understand it is probably difficult. I was just verifying that I understood that the number of arguments must match in this sort of scenario. I appreciate the insight!
15:15amalloyyep, they have to match, and the compiler can't check it for you
15:28dnolengrebus: you need to make sure they are loaded by eval'ing the ns form
15:36grebusdnolen: thanks, I tried that, in line with your advice at http://stackoverflow.com/questions/12337509/how-can-macros-be-evaluated-using-the-clojurescript-repl, but when I try evaluating the ns form from the browser repl I get "Could not locate <namespace with macros>.__init.class or <namespace with macros>.clj on classpath" … I'm using clojurescript-mode in emacs, if that's of any significance.
15:53TimMcThis Pedestal thing... is it going to fulfil my lifelong dream of having a single-page app that can generate its HTML either on the client or on the server, and either as a whole page or in as-needed fragments?
15:54avishaiis there a macro that returns a lazy sequence of nested function calls? like (x f(x) f(f(x) ...)
15:54hyPiRionavishai: reductions
15:54avishai10
15:54avishai10x
15:54TimMcavishai: repeatedly, and it's a fn
15:54hyPiRionno wait, iterate
15:54TimMcOh, no, iterate
15:54hyPiRion,(take 10 (iterate inc 1))
15:54clojurebot(1 2 3 4 5 ...)
15:54TimMcconvergence!
15:54avishaicool
15:55hyPiRion,(take 10 (reductions + (range)))
15:55clojurebot(0 1 3 6 10 ...)
15:56dyreshark,(take 4 (range))
15:56clojurebot(0 1 2 3)
15:56TimMc,(reductions (fn [_ r] r) (iterate inc 0))
15:56clojurebot(0 1 2 3 4 ...)
15:58hyPiRionTimMc: well, that is also one way to write (map identity ...)
16:02TimMc,(reductions (comp peek vector) (iterate inc 0))
16:02clojurebot(0 1 2 3 4 ...)
16:02hyPiRion,(binding [*print-length* 10] (pr (reductions #(- %2 %1) (reductions + (range)))))
16:02clojurebot(0 1 2 4 6 9 12 16 20 25 ...)
16:10TimMcThat's a neat sequence.
16:10tomoj&(let [q clojure.lang.PersistentQueue/EMPTY] (identical? q (pop q)))
16:10lazybot⇒ true
16:10tomoj&(pop [])
16:10lazybotjava.lang.IllegalStateException: Can't pop empty vector
16:10bbloomtomoj: i was just grumbling about that yesterday :-P
16:11tomojwhich one? :)
16:12bbloomi guess an exception is reasonable sometimes? i dunno. i hate exceptions :-P
16:12bbloombut i really just want (pop vector ::not-found)
16:12bbloomwell not really
16:12bbloomi guess that's peek
16:13bbloomand i guess peek does return nil
16:13tomoj(first nil ::not-found) ? O_o
16:13bbloomno, it's last
16:13tomojyeah, I mean for seqs
16:13bbloombut i want vectors
16:13bbloomlast is linear time
16:13bbloompop is constant time last for vectors
16:14enquorayogthos: is clj-pdf a straight-up port of cl-pdf?
16:14tomojwell, sure, (peek nil ::not-found) for vectors - by analogy, then, (first nil ::not-found) for seqs?
16:14bbloomoh, yeah maybe
16:14bbloombut there is 'or
16:14bbloomwhich isn't quite the same
16:15bbloom(or (first s) ::not-found) will be incorrect on '(nil)
16:15bbloomand substitute ::not-found with ::empty
16:15tomojI guess you can do (if (seq coll) (peek coll) ::not-found)
16:16tomojwhich is particularly idiomatic for seqs/first
16:16bbloomyeah, i tend to do that sort of thing somewhat regularly
16:16tomojwhereas for ILookup that doesn't work, nor nthnext, so they both get not-found args
16:17tomojer
16:17tomojhmm why did I think nthnext had a not-found
16:18tomojoh it's nth
16:19yogthosenquora: I haven't actually heard of cl-pdf :)
16:19enquoraguess it isn't then
16:19TimMc,(nth [] 0 :nope)
16:19clojurebot:nope
16:19yogthosenquora: it's a wrapper around iText inspired by hiccup syntax
16:19enquoraand, I see a reference to itext
16:19enquora:-)
16:19enquora:-( that should be
16:20yogthosI needed to make reports at work and after looking at the options decided to roll my own :P
16:20enquorahttp://www.fractalconcept.com/asp/cl-pdf
16:20yogthositext is kind of painful on its own :)
16:20bbloomtomoj: TimMc: yeah, i think i want a not-found for first and peek :-)
16:20enquorawe need to generate pdfs from the same codebase on server, in browser and iOS
16:21enquorawas hoping to find a clojurescript pdf library
16:21enquoracl-pdf isnt'it
16:21bosieis there a quicker way than doing #(not (nil? %))
16:21yogthosenquora: I did make this :) http://instantpdf.herokuapp.com/
16:21yogthosenquora: https://github.com/yogthos/instant-pdf
16:21yogthosit's a rest service that accepts json and returns a pdf back
16:21enquoranice
16:21yogthosso you could call it from js pretty easily :)
16:22yogthosit wraps the clj-pdf inside
16:22enquorawith no http? ;-)
16:22enquoraby browser, I mean offline
16:22yogthosahh
16:22yogthosyeah won't be much good without network connection :)
16:22enquorascientific/engineering reports with very dense layouts
16:22yogthossounds like fun :)
16:22enquoraback to working with raw pdf primitives
16:23yogthosshiver
16:23enquoranot so bad in lisp :-)
16:23yogthostrue true :)
16:23tieTYT2i've been told new clojure devs go overboard with macros and protocols. What about with ->?
16:23enquorait isn't working with the pdf primitives that's the problem
16:23enquorait's generating tables using css like layout directives, crossing pages
16:23yogthostieTYT2: -> is very handy
16:24tieTYT2yogthos: yeah it seems pretty cool
16:24bosiea not-nil? built-in that is
16:24yogthosenquora: yeah these things get tricky fast
16:25yogthostieTYT2: basically it flattens out your nested expressions and helps readability a lot in my opinion
16:25enquorahaven't started yet, but it seems to me we can create a PDF-analogous data structure in clojure, and reify it when we're done
16:25tieTYT2ok then i'll start incorporating it
16:25tieTYT2what about ->>? That one seemed like it required more thought to me
16:25papachanhi
16:25technomancydoes anyone override the :base profile in Leiningen (or even know how that works to begin with)?
16:25yogthostieTYT2: its just whether you want your argument to be first or last
16:26tieTYT2oh so it is
16:26tieTYT2i didn't notice that
16:26papachanif i compile my script in clojure into Jar. i can add it to my android project, or any java project?
16:27yogthospapachan: you can add them to java projects, but you have to expose a Java compatible api using gen-class
16:27tieTYT2so (-> arg form) is the same as (->> arg form) as long as form has only one argument?
16:27yogthospapachan: good tutorial here http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html
16:28yogthostieTYT2: yup
16:28papachanyogthos: thank you. i take a look a this so
16:29tieTYT2k
16:31Rich_Morin_Looking at http://dev.clojure.org/display/community/Project+Ideas, I don't see a way to add entries. Help?
16:32hyPiRionRich_Morin_: " If you don't have Confluence access please submit your idea, following this template to the clojure mailing list with the subject prefix [GSoC Idea]."
16:32tieTYT2what a cool page
16:32hyPiRionI would try to register on dev.clojure.org first and check out if I could edit the entry.
16:33Rich_Morin_That's the funny thing; it has me logged in.
16:33hyPiRionRich_Morin_: Have you signed the CA?
16:34Rich_Morin_I filled in and mailed a Clojure CA to RH months ago.
16:35Rich_Morin_and I seem to be listed on http://clojure.org/contributing
16:35Rich_Morin_Owell, I'll just use email.
16:35hyPiRionRich_Morin_: yeah, saw you there. Ask on the clojure-dev mailing list for Confluence access
16:36tieTYT2yogthos: can you think of any other things like -> that I should know to write more idiomatic code?
16:36amalloytieTYT2: for-comprehensions. the more experienced i get, the more of them i use
16:36tieTYT2amalloy: is that related to haskell list comprehensions?
16:37amalloymeh
16:38tieTYT2this? http://clojuredocs.org/clojure_core/clojure.core/for
16:39amalloyyes
16:39tieTYT2ok
16:39tieTYT2thanks
16:43arrdemgah... is clojure-doc making any attempt to provide clojuredocs' namespace-pathed URLs?
16:47arrdemaand that's a no.
16:52hugodI'm trying to get titanium to connect to cassandra, and keep getting "NoAvailableHostsException: [host=None(0.0.0.0):0, latency=0(0), attempts=0] No hosts to borrow from com.netflix.astyanax.connectionpool.impl.RoundRobinExecuteWithFailover.<init>" - I've no idea what's wrong...
16:54nickmbaileylooks like astyanax is trying to connect to 0.0.0.0, try setting your rpc_address to an actual ip instead of 0.0.0.0
16:55nickmbaileybut i've never set up titan or used titanium fwiw
16:57hugodoh, in the cassandra config? I'll give that a go
16:58akhudekI'm trying to write a deftype that extends ISeq but end up getting AbstractMethodError clojure.lang.RT.seqFrom
16:58akhudekNot sure what I'm doing wrong, have first, next, and more implemented correctly.
17:02squidzI just read about being able to program C/C++ and compile to javascript with very good speeds using llvm bitcode with firefoxs asm.js. It made me wonder how hard it would be to convert clojure to llvm bitcode and what kind of advantages that might have.
17:03akhudeksquidz: very hard, though I think the clojurepy guys are trying it so that they can target native code and python better
17:05squidzso they would first go from bitcode then to python? I dont really know anything about bitcode so forgive my ignorance
17:05yogthostieTYT2: this is worth looking at https://github.com/bbatsov/clojure-style-guide
17:05akhudeksquidz: I'm not that clear on the details. If you are interested, take a look at their mailing list.
17:06yogthostieTYT2: and yeah for macro is very handy
17:06dobladezanybody here attended Stuart Sierra's session at ClojureWest? (title "Clojure in the Large" ) ?
17:07squidzakhudek: if you could easily go from llvm bitcode to other languages that would be pretty useful. Not just for compiling to javascript
17:07dobladezI got good ideas from it, but I'm still looking for ways to organize module dependencies better... I guess I missed something
17:08akhudeksquidz: yes, it would, though it's a big undertaking
17:09nDuff...most of the schedule still up in the air, but it looks like they have some good keynotes lined up.
17:10nDuff(Also, an excuse to escape Austin in early July will be welcome).
17:10dobladezI liked the idea of having a System object, and manage components' lifecycle from there. However, I don't see myself passing the system object (or subcomponents) around as arguments all over the place
17:12hugodnickmbailey: thanks - that seems to have got me further
17:18amalloyhah, i just found ([] {}) in my code. it's like a whirlwind tour of clojure's syntax
17:20stuartsierradobladez: You don't have to pass the system object everywhere.
17:20AimHereThe main trouble with clojure's syntax is that it doesn't use angle brackets enough
17:20dobladezstuartsierra: do you know of any opensource project to draw ideas from?
17:21amalloy&(let [<> {}] (<> {} []))
17:21lazybot⇒ []
17:21stuartsierradobladez: not totally. You can see some of these ideas at work in Pedestal.
17:22akhudekHm, so looking at clojure.lang.RT it seems that simply implementing ISeq isn't enough?
17:22dobladezstuartsierra: Thanks. For the example of supporting multiple DB impls... at System creation time I instantiate my DB impl, and then I currently "set-db!" into a var on a 'db' namespace
17:22TimMcAimHere: Let me introduce you to the swiss arrows project...
17:23stuartsierradobladez: That works.
17:23dobladezthen, the db namespace is my db api that the rest of the app uses, "hiding" the actual impl. Otherwise, all application code somehow needs to obtain a reference to the db impl instance
17:24stuartsierraYes, I prefer to do that via arguments or closing over the necessary values when I create the system.
17:24stuartsierraBut sometimes tooling (e.g. Servlets) makes that harder.
17:25dobladezI'll continue experimenting... and pushing the idea of using arguments a bit further
17:25dobladezthanks again
17:25stuartsierraYou're welcome.
17:26avishaihi
17:26avishaii'm going through the euler exersices
17:26asteveeuler RULES!
17:26pl6306I interacting with an existing swing app from clojure. Basically I call a load method which loads something in swing async. In java I would wait for a property to added to a swing control before continuing. How best should achieve this clojure?
17:27avishaiand while doing number 4 i get java.lang.StackOverflowError
17:27pl6306In java I would do thread.sleep while polling for a property
17:27pl6306Is there an idiomatic way to do this in clojure?
17:28avishaitook the brute force approach
17:28technomancypl6306: deref a promise
17:29avishaibut why stackoverflow?
17:29grebusstill having lots of trouble with macros in a bREPL… I'm eval'ing the ns form with its :use-macro's and such from the bREPL, but I'm throwing a java.io.FileNotFoundException to the effect that the clj files defining the macros aren't on the classpath. They were on the classpath enough to compile the cljs… what other classpath should they be on?
17:30dobladezpl6306: may be look at promises and futures
17:31amalloyakhudek: yes, pieces of clojure.lang assume that any IPersistentCollection also implements the related j.u.collections interfaces, even though the clojure.lang interfaces don't actually extend them
17:32akhudekamalloy: I just figured it out, I needed to also implement seq on the seqable class and declare it as Sequential
17:33akhudekhttps://www.refheap.com/paste/2b5587dcaea9b72fa0954d015
17:34amalloyakhudek: why do you even have a protocol for this?
17:34dobladezpl6306: also, in case you haven't seen it: https://github.com/daveray/seesaw. Looks really good
17:36anthonyuwhat is the syntax i should use so that this macro (https://gist.github.com/anthonyu/636b13b5d13f4520711d) could handle an arbitrary number of columns?
17:36akhudekamalloy: you mean why not use bit-set built in?
17:36amalloyno, i mean why does next-bit exist as a protocol?
17:36akhudekamalloy: oh, probably because of a poor design on my part
17:36amalloyjust implement first/next/more and use your bitsetseq like an ordinary seq
17:37akhudekoh, I see, yes, I can just implement it all in BitSet
17:40pl6306I saw seesaw however this an app that has already been built by another team. I sort of get the promise concept however where do I call thread.sleep while waiting for the UI to finish loading?
17:40pl6306In the function that will populate the promise?
17:40technomancypl6306: if you deref the promise it will block until the promise is delivered
17:40technomancyno sleeping required
17:40dobladezpl6306: the idea of use a promise is to avoid sleeping
17:41pl6306I need something to poll the UI thread to see if the work is done
17:41pl6306how can I block until something like a label is loaded?
17:41nDuffpl6306: Do you want to _poll_, or do you want to _block_?
17:42nDuffpl6306: If you want to _block_, just use deref.
17:42pl6306Both I want to block execute until (polling) the UI has finished loading
17:42dobladezso, one thread blocks on a promise, then the thread doing the work delivers the promise
17:42nDuff...
17:42nDuff*sigh*.
17:42pl6306I know
17:42nDuffpl6306: Why do you want to block by polling?
17:42nDuffpl6306: Why don't you let deref handle the blocking for you?
17:43nDuffpl6306: That way there's no polling involved -- just a notification when the promise is delivered.
17:43dobladezgotta go
17:43pl6306I get the part of deref blocking on a promise.
17:59anthonyuhow does one pass arbitrary arguments and a body to a macro?
18:00jeremyheileranthonyu: Pass in the arguments in a collection? Pass in the body in a (do ...)?
18:01nDuffanthonyu: typically, the same [... & args] approach used for normal variadic functions
18:02technomancyanthonyu: you can do something like this: (eval (apply #'clojure.core/defn () {} 'myfn []))
18:02technomancybut it's really not a good idea
18:03anthonyuok, which part is the bad idea? the '(eval (apply' or the rest?
18:03technomancy(sorry, assuming you don't control the macro that is)
18:03technomancyif you control the macro just take & args
18:04tomojanthonyu: why?
18:05anthonyutomoj: i am making a macro that creates a test table with an arbitrary number of columns, then runs the body, then drops the table
18:06anthonyuhere is the gist: https://gist.github.com/anthonyu/636b13b5d13f4520711d
18:06anthonyuthat one works, but only with exactly two columns
18:09thm_proverare clojure futures guaranteed to execute? for example, I have a bunch of code (mostly gui update code), that I want to be certain that will be executed asap in an async fashion
18:10thm_provermy current idea is to throw them to an agent, but I'd prefer to not have agents around
18:10thm_proverso can I just stick them in futures, and will they edecute, even if I never deref the future?
18:10jeremyheileranthonyu: I would just pass in the cols as a vector.
18:10arrdemyes, futures will be evaluated eventually with or without derefs.
18:10thm_proverarrdem: how soon is "eventually" ?
18:11arrdemthm_prover: depends on how many futures exist at once...
18:11tomojanthonyu: that won't work
18:11tomojyou need some way to tell where the cols stop and the body starts
18:11anthonyui see
18:12tomojperhaps (with-test-table [table cols & body]), and cols is a vector of cols?
18:12arrdemthm_prover: it's async, but futures are executed from an eager worker queue so more or less as hardare threads become available.
18:12anthonyutomoj: thanks, that worked
18:13rdfiis anyone using ClojureCLR?
18:14thm_proverarrdem: do agents or futures have higher priority, or are they the same worker queue?
18:15jeremyheilerthm_prover: Are you using Swing? If so, I'd be careful using multiple threads.
18:15bosiecould someone please tell me how i have to rewrite (defn run ...) so i dont need to flatten so very often? https://www.refheap.com/paste/01f1e9fbddc589cdb322f8145
18:15technomancyrdfi: very few
18:15thm_proverjeremyheiler: I'm using SWT. I'm using (. display asyncExec ... ) so I'm safe for those updates. However, I do have updates taht involve calculations before talking tot eh SWT thread.
18:15jeremyheilerthm_prover: Cool
18:19rdfitechnomancy: do you know if it is still being actively developed?
18:20technomancyrdfi: I vaguely believe so
18:20technomancydoesn't strike me as particularly practical though
18:28chessguyis there some obvious way to get a quick frequency count of all the items in a vector? i can imagine several ways to write it, i'm just wondering if there's support for it in clojure.core
18:29technomancychessguy: freq<TAB>?
18:30nDuff,(doc frequencies)
18:30clojurebot"([coll]); Returns a map from distinct items in coll to the number of times they appear."
18:31nDuffchessguy: find-doc is your friend.
18:32chessguywow, i didn't think it would actually be called that
18:32nlewThe worst part of writing clojure is the constant nagging feeling that there's a more concise core function to do what you need
18:34technomancynlew: read through core.clj a couple times; it should help =)
18:35nlewtechnomancy: It's mostly the functions that *aren't* in core that are the worst. "There must be something, right? Right?" and then I scour the web. :)
18:35nlewTo no avail!
18:35technomancyyeah, and in that case findfn won't help you =)
18:36chessguyor if you don't think of a good name for what you're looking for until you ask for it, and then you look like a moron...
18:36Raynestechnomancy: Technically findfn works for any namespaces, it's just that we can't put all namespaces ever made on the classpath for it. :p
18:36RaynesAnd the more you add the slower it is and it is already pretty slow.
18:36technomancyRaynes: right; search time constraints
18:36nlewRaynes: It still can't find functions that don't exist though. :P
18:37RaynesThis is true.
18:37technomancyit would be cool to write a findfn that could accept an arbitrary :dependencies set loaded up via pomegranate
18:37chessguywow. core.clj is nearly 7k lines...
18:37chessguyi'll be in my bunk...
18:38technomancyheh
18:39bosiehow would i recursively compute a list of lists without having to flatten lists?
18:40hiredmanfor, or more generally mapcat
18:41bosiehiredman: hm
18:42hyPiRionRaynes: http://www.youtube.com/watch?v=5Q9x16uIsKA#t=1156s <- That for Clojure would be a nice replacement for $findfn
18:42hyPiRionI can put it up as an issue for lazybot for you
18:42bosiehiredman: https://www.refheap.com/paste/01f1e9fbddc589cdb322f8145 line 33 gets a list (p) and runs map on it. in the map i call the method again
18:42bosiehiredman: i tried mapcat there but that didn't work
18:43hiredmanbosie: that is pretty gross
18:44bosiehiredman: i know
18:44hiredmanso stop doing it gross
18:44bosiewould love to, hence i ask
18:45sturnerIs there a way to recompile java source files after specifying :java-source-paths ["src/java"] via the repl?
18:45hiredmanhttps://github.com/hiredman/datalog/blob/master/src/datalog/core.clj uses concat and for to return the results of a depth first search as a list
18:46bosiehiredman: search-with-rules?
18:47hiredmanno, all of it, the structure
18:47tieTYT2what's the point of defining using a let at the top level?
18:47tieTYT2err
18:47tieTYT2what's the point of using a let at the top level
18:48bosiehiredman: i dont follow
18:48hiredmaneverything returns a list(lazy sequence), and you concatenate results together
18:48bosiehiredman: most functions i see are not recursive there though?
18:49tieTYT2this is from a library Raynes wrote: http://pastebin.com/xssDhumH
18:49tieTYT2i don't understand why he put the let on the outside there
18:49nDuff...
18:49tieTYT2instead of nested under the defn
18:49nDuffyou quote Raynes' code, but you don't use Raynes' pastebin to do it?
18:49RaynesHahaha
18:49RaynesIt's fine, it's fine.
18:49tieTYT2he has a pastebin?
18:50nDufftieTYT2: refheap.com
18:50arrdemrefheap.com
18:50hyPiRion~refheap
18:50clojurebotrefheap is gist
18:50amalloy(inc clojurebot)
18:50lazybot⇒ 20
18:50winkit's not called a pastebin, that's the flaw
18:50nDufftieTYT2: ...which, unlike pastebin.com, isn't a hive of annoying animated ads.
18:50tieTYT2k i'll use that in the future
18:50hiredmanbosie: search is called at the top of the stack, and most things called by search also call search
18:50RaynestieTYT2: Really though, no worries.
18:50tieTYT2https://www.refheap.com/paste/3f500be5d06f34745a39e332c
18:50arrdemthe downside is that Raynes reads pastes and will mock you in channel if you post something horific...
18:51nDufftieTYT2: ...so, what that's doing is closing over the let
18:51amalloyclojurebot: nDuff is <reply> Please don't use pastebin.com: there are lots of annoying animated ads
18:51clojurebotRoger.
18:51nDuffHeh.
18:51Glenjaminis there an advantage of having the let outside like that?
18:51RaynestieTYT2: I could have put the let in the inside, but if you look I'm using 'homedir' in two places. Furthermore, "user.home" never changes. If I put the let on the inside then I'm doing unnecessary (albeit trivial) computation every time.
18:51tieTYT2what does closing over the let mean?
18:51Glenjaminoh right, for both variants of the function
18:51nDufftieTYT2: Inheriting its value from an outer context, roughly.
18:52bosiehiredman: ok, looking at psearch then
18:52chessguytieTYT2: i feel like there was just a discussion about that issue on the clojure mailing list the other day. did you see that?
18:52tieTYT2chessguy: nope
18:52chessguylet me see if i can dig it up
18:52hiredmanbosie: psearch calls search, search calls other things, other things call search, etc
18:52RaynestieTYT2: Putting the let on the outside means that those two pieces of code are only evaluated once ever, whereas if I put them on the inside they would be recalculated on every single call to this function.
18:53Glenjaminisn't that the sort of thing the JIT should be worrying about?
18:53nDuffGlenjamin: ...no?
18:53Glenjaminalthough i suppose they're not pure
18:53Glenjaminso that doesn't hold
18:53nDuff*nod*.
18:53hyPiRionGlenjamin: That's more of a compiler issue. It has no knowledge whether the function is pure or not. If it were pure, then perhaps
18:53chessguytieTYT2: https://groups.google.com/d/msg/clojure/tTCZuzmz_6M/Ke7iKcDxpZQJ
18:54tieTYT2chessguy: thanks
18:54tieTYT2Raynes: won't it only be computed once because it either uses the 0 param or the 1 param option, but not both?
18:55GlenjamintieTYT2: subsequent calls
18:55tieTYT2oh
18:55Glenjamin[(home) (home)]
18:56RaynestieTYT2: I'm not really sure what you mean. The let is on the outside, so those things are evaluated first when Clojure reads and evaluates this code. Next, the function is created and it closes over those values, so that when you call the function again those values are reused and not recalculated.
18:56tieTYT2now as an api user (client) all I see is the home function, right? This doesn't change anything about how I call it
18:56RaynesNo.
18:56RaynesIt's the same.
18:56tieTYT2i see, cool
18:56tieTYT2ok i think i get it
18:59Glenjaminit does mean if you add a user, you'd have to restart the app :p
18:59tieTYT2weird thing, I was actually thinking about writing a library just like this last night
19:00bosiehiredman: honestly, thats hard to penetrate for me
19:00chessguyhm. i feel like reading core.clj just leaves me with more questions
19:00technomancychessguy: most of the answers are "because the necessary macro hasn't been defined yet" I bet
19:01technomancyit's not idiomatic code at all
19:01chessguytechnomancy: oh, it doesn't define its macros?
19:01technomancyit does, but later down in the file
19:01chessguylike (def list (. clojure.lang.PersistentList creator)), i can't find a definition for creator
19:01technomancyoh, well . is a macro that's hard-coded into the compiler
19:02technomancyso creator doesn't have to resolve
19:02chessguyoh, i mis-read it. never mind
19:02hiredmanbosie: you can think of it as avoiding flatten because the responsibility for ensuring a particular result is wrapped in whatever the correct number of lists (0 to whatever) belongs to whoever adds the item to the result
19:03chessguyi thought it was (.clojure.lang.PersistentList creator)
19:04hiredmanif function F recursively calls itself, and F returns a flat list, if I append {} to the result of calling F, the result will never have {} wrapped in an extra list
19:05bosiehiredman: thats my problem actually
19:05bosiehiredman: F returns a list of lists because of the map
19:06bosiehiredman: which is fine, cos the end result is a list of lists
19:06hiredmanbosie: you need to get serious about your base cases, make sure they all result in a flat list, because if you mapcat a function over a list of flat lists, unless that function produces nested lists, you will get flat lists
19:07bosiehiredman: the recursion stops and returns [[1] [2] [3]]. i can't return a flat list
19:08hiredmanbosie: yeah, but you can call that a X and a list of X's is your flat list
19:08Glenjaminhrm, why does the #record[a b] form only allow fully qualified names?
19:09bosiehiredman: ok
19:09hiredmanso is [[1] [2] [3]] a result or a collection of results?
19:09bosiehiredman: thats one result
19:10hiredmanso it needs to be returned as [[[1] [2] [3]]] or (list [[1] [2] [3]])
19:10bosiehiredman: the end result (i.e. what run should return) should be [[[1] [2] [3]] [[5] [6]]]
19:10hiredmanso your functions should always return results at a consistent level of nesting
19:10bosiehm
19:11hiredmanif the final result is a collection of results, and intermediate results should be too
19:11bosiegotcha
19:15geraldo1st time in a clojure pub. good night ppl
19:28shriphanihi everyone. I see a bunch of csv libs around. Is there anything you recommend? Anything to do an append (I only see 'read' and 'write' and would rather not fseek myself.
19:28Glenjaminarohner: yo, did you get a chance to look over the pull request for bond?
19:28arohnerGlenjamin, not yet, sorry
19:29Glenjaminno worries
19:33RaynesTo whoever pasted https://www.refheap.com/paste/12977 if present in this room: there is a sql language option.
19:34RaynesAlso, wee almost 13k pastes.
19:35Glenjaminhrm
19:35Glenjaminit's non-obvious how to get a new paste when viewing a paste
19:35Glenjaminto me, at least
19:35Glenjamini guessed "click the name of the site"
19:36bosiehiredman: dude. you were right
19:37bosiehiredman: thanks a lot. i never would have thought about the same nestedness of the function
19:37bosiehiredman: s/function/return value
19:57arrdemis there some way that I can find out what namespace a generated function resides in?
19:58arrdemso if I have an error that I can localize to the invocation of "$fn_375" can I figure out which fn that is?
19:59technomancyfor unknown reasons the compiler does not attach metadata to anonymous functions
19:59amalloyarrdem: $fn_375 isn't a function name that i can imagine the compiler ever generating
19:59seanmsI have a question about nrepl about its classpath
20:00seanmsI am trying to figure out how nrepl determines the path, I'm trying to modify an internal build tool to be able to use nrepl w/o lein
20:00arrdemamalloy: I'm looking at a stacktrace here which shows an invocation of fn_375 it seems in algo.monads
20:01amalloyso paste a stacktrace
20:01seanmsI found a stackoverflow question stating that nrepl uses lein for classpath resolution, but havent been able to find the connection between the two
20:01technomancyseanms: nrepl doesn't determine the classpath at all
20:02seanmsand setting the java classpath does not seem to have an effect
20:03arrdemhttps://www.refheap.com/paste/12981
20:03technomancyseanms: that's almost certainly not right; the classpath you provide to the java command should be the only thing that matters unless you're instantiating dynamic classloaders.
20:04arrdemhttps://github.com/clojure/algo.monads/blob/master/src/main/clojure/clojure/algo/monads.clj#L578 it seems
20:04seanmstechnomancy: thanks, I'll look into it further
20:07SgeoAre there nice Spring MVC guides for people used to sane languages?
20:07SgeoMy job is going to involve Spring MVC :/
20:07SgeoAlthough it's not as bad as I feared
20:08SgeoI think
20:12amalloyarrdem: my point was that you can't figure anything out from "$fn__375", but "clojure.algo.monads$state_t$m_bind_state_t__373$fn__374$fn__375" tells you everything you need to know
20:13arrdemamalloy: ok thanks then.
20:14arrdemI think I'm going to be able to show that this is either a bug in fnparse or monads but we shall see...
20:17arrdembloody...
20:17brehautarrdem: its much more likely to be in fnparse than contrib.monads, unless you are using monad transformers
20:17arrdemwell not sure what it is but I found a fix...
20:18amalloybrehaut: his link was to state-t, so...
20:20brehautfwiw then, i ran into some trouble writing generic lifted accessors that worked nicely with both (state-t maybe-m) and (state-t seq-m)
20:21brehautbut the basic state and maybe/list operations worked correctly
20:21arrdemhere yall go
20:21arrdemhttps://www.refheap.com/paste/12982
20:22arrdemit comes down to user error... if a fnparse matcher yields non-nil it is assumed to be a success state and treated as a monad.
20:23arrdemI had code in the tail position which didn't return nil..
20:23arrdemso it was trying to treat junk values as a monad and bad things were happening.
20:23hiredmanfnparse :(
20:23supersymsigh ... chrome, what a project :S
20:23brehauthiredman: what particularly about it?
20:23arrdemI haven't had real issues with fnparse yet.. but that was a friggin waste of an hour.
20:24hiredmanbrehaut: is there an up to date fork?
20:24brehauthiredman: factual seem to have taken over
20:24brehauthttps://github.com/factual/fnparse/
20:25hiredmanthat is kind of neat
20:25arrdemmy only complaint about the factual fork is that they didn't do the docs too
20:25brehautarrdem: but the docs have always been a bit rubbish, so thats not really a loss
20:25arrdemtruth.
20:25hiredmananyone, the guy kept rewriting it and changing it
20:25arrdembut good docs still.
20:25hiredmanwho knows if want I have remotely matches whatever factual's fork is based on
20:26brehauthiredman: it looks like they are sticking with approximately whatever the 2.x series was
20:26arrdembrehaut: doing good APIs is hard... and a skill I haven't learned yet.
20:26hiredmanyeah, I think mine is pre 2.x
20:26arrdemyeah the last api Choi documented is almost exactly correct
20:27arrdemthere's one thing but I don't remember what it is.
20:27hiredmanI'll just run that part of clojurebot on clojrue 1.2.1 forever
20:28brehautlol
20:29arrdemw00t my parsers no longer explode!
20:29brehauthaha i love that the fnparse docs still list java -cp… as the right way to get fnparse into your project
20:29hiredmanoh, wait, 2.2.4 maybe I can update some time
20:29brehautand by love i mean :'(
20:30arrdemhiredman: if I could figure out your codebase updating it shouldn't be too bad..
20:30brehaut~arrows
20:30clojurebotarrows is http://ro-che.info/ccc/12.html
20:31hiredmanhttp://1.bp.blogspot.com/-3sd5vm2YSoA/T8LXHbyyVjI/AAAAAAAABQo/PttNNJhp__8/s1600/Arrowed.JPG
20:31brehautPANASIAN CUISINE
20:53chessguyhm. this doesn't work? (defn foo [c] (new c 0 0))
20:58brehautchessguy: new is a special form. its first argument is not evaluated
20:58lsoachessguy: shouldn't that be a macro
20:59brehautchessguy: if you want to runtime instantiation of unknown classes, you probably want to look at .newInstance on the Class class
21:00brehautor perhaps some reflection
21:00chessguyfair enough
21:00chessguythanks
21:11jcromartieis defstruct dead?
21:11jcromartiepretty much right
21:13arrdemI think so...
21:13arrdemthere just isn't a compelling reason for it. either use a raw map or define protocols and a type.
21:13amalloyif not, ask someone to hand you a hammer and a stake
21:14arrdem~hammer
21:14clojurebotPardon?
21:14arrdem~stake
21:14clojurebotI don't understand.
21:14amalloyhe's very polite about it though
21:14arrdemthis much is true.
21:19gfredericksapparently rich doesn't like removing things
21:19gfredericks(like defstruct)
21:20TimMcor taking things out of alpha
21:20gfrederickshaha
21:21TimMc,(binding [*print-length* 25] (pr (for [[s v] (ns-publics 'clojure.core) :let [d (:doc (meta v))] :when (and d (re-find #"(?i)alpha" d))] s)))
21:21clojurebot(add-watch promise pop! deliver assoc! defrecord remove-watch conj! transient ex-info dissoc! deftype persistent! *print-readably* *compiler-options* ex-data disj!)
21:22gfrederickswoah man
21:22gfrederickspromises are pretty old
21:22TimMc*print-readably* is spurious ("alphanumeric")
21:23TimMcand transients, and defrecord...
21:23TimMc"transients: may be transient"
21:24thm_proverhttp://hpaste.org/84699 <-- why does "good" work yet 'bad" ends up not working? it gives me an error of "nable to resolve symbol: ocr-4638 in this context, compiling:(main.clj:112:3) class clojure.lang.Compiler$CompilerException"
21:25jeremyheilerthm_prover: What is match?
21:25thm_proverclojure.core.match
21:28thoradamHello everyone, I just started with Clojure, writing it feels fun but alien, looking for comments, is this fairly idiomatic? https://www.refheap.com/paste/12984
21:30arrdemthoradam: well it isn't correct.. shouldn't your base case be (not (zero? depth))
21:30arrdem,(not (zero? 1))
21:30clojurebottrue
21:30arrdem,(not (zero? 0))
21:30clojurebotfalse
21:30dnolenthm_prover: hrm, it maybe the case that you can't match classes with core.match. I know there's no test case for something like that.
21:31thm_proverdnolen: I bet you can't patch this in < 5 minutes. </reverse-psychology>
21:31thm_proverdnolen: as a hack, should I do a match on (string (type 20)) and match vs "java.lang.Long" ?
21:31dnolenthm_prover: that should probably work
21:32arrdemthoradam: other that that, this looks fine.
21:32arrdemone could use (inc n) and (dec n) rather than +1 and -1...
21:33arrdemnot sure if using the set #{\( \)} and contains? is "better" than your (or)
21:33thoradamarrdem: Hmm, you mean as opposed to (neg? depth), it seems to work. Thanks for the inc dec tip.
21:34tieTYT2i need to write a function that checks if a string contains a bunch of substrings in it. I'd like to write something that's like (not-any? (contains s "x") (contains s "y"))... is there a convenient way to write this?
21:39thm_proverdnolen: actually, on second thought
21:39thm_proverdnolen: could you help me patch match ? I'd like to learn more about pattern matching
21:39thm_proverdnolen: and you seem to be afmiliar with the codebase
21:39dnolenthm_prover: well I wrote most of it
21:40thm_proverdnolen: looks like I win the IRC lottery for today
21:41arrdemOk my turn. Now that I've resolved my fnparse issues, what do you guys think of this?
21:41arrdemhttps://github.com/arrdem/sad
21:42arrdemI'm especially concerned about the way I'm structuring the rule name stack in runtime.stack
21:44thm_proverdnolen: is the problem with "LiteralPattern" in match.clj ?
21:50TimMcSomeone posed this question at work: Is there a *nice* way of getting the map constructor from a defrecord's class object?
21:51TimMc(An example of not nice: demunging the fully qualified classname into namespace and record name.)
21:52leifptieTYT2, (not-any? #(.contains s %) ["x" "y" ...])
21:52amalloyTimMc: i don't think so. i'm leaning towards the opinion that it might be impossible to have such a feature, but i'm not sure about that
21:52TimMcThere doesn't even seem to be a good way of getting the order of the fields, which would make the positional constructor useable.
21:53TimMcamalloy: How so? There could be a static field with the ns-qualified symbol.
21:53amalloyi suppose that's true. i was imagining only bad ways to do it
21:54amalloythat has some problems, though, still: an old version of a redefined defrecord would still seem to have a valid constructor function, but it would construct a different class
21:54TimMcThat's true anyhow.
21:55TimMcGetting the constructor for the original classloader... I have no idea how difficult that might be.
22:00dnolenthm_prover: that's possible
22:02akhudekis there another interface other than Counted for implementing a faster but not constant time count operation?
22:03dnolenakhudek: don't think so
22:05akhudekhm, that's too bad
22:07dnolenakhudek: probably not a big deal to implement it anyway, people call count on seqs.
22:07chessguywhat's considered idiomatic about sync/dosync and alter? should they always be used in the same function? or is it ok for a function to open a transaction and somehow pass in a function which does the alter?
22:08akhudekdnolen: was just worried that it might break the complexity of some standard algorithms
22:08akhudekthough I guess it will be faster than iterated count!
22:20supersymthats enough learning clojure for one night, it can be overwhelming to say the least
22:20gfredericks(inc clojure)
22:20lazybot⇒ 10
22:21thm_proverdnolen: sorry, I got disconnected, if ou said anything about match, can you please repeat it?
22:21chessguysupersym: i feel your pain. i've been drinking from a fire hose for the last week or two trying to learn it
22:22supersymanyone who can recommend a good resource on actually the process of crafting nested functions? I've never been fullbread functional programmer before
22:22supersymyeah... I get along nicely with lists, but it feels like I'm years behind
22:23gfrederickssupersym: by "nested functions" do you mean just generally working with higher-order-functions?
22:23chessguyi'm fortunate in that i spent a few years dabbling in haskell
22:23supersymyeah
22:23supersymheh... yeah I have xmonad running now so I can learn a bit there as well
22:23supersymbut I already made peace with the fact that this is gonna be a tough cookie the next year :)
22:23chessguyi've always wanted to play with xmonad, but never managed to get it running
22:24chessguysupersym: ooh, i can make a recommendation
22:24chessguyhang on, let me find it
22:24chessguythe sicp videos: http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/
22:24chessguythey're scheme-based, but still largely appropriate for clojure
22:26amalloyi prefer the book to the lectures, personally, but both are good; use whichever one suits your preference
22:27chessguyagreed, both are good. i tend to learn more from watching videos
22:28supersymsweet - thanks
22:28supersymi've been trying to mix lispels a bit already to get a better learning effect :)
22:29chessguyhm. be careful with that, it sounds like it could get confusing fast
22:31supersymperhaps yes, its not like I am going really deep in emacs at the moment, or scheme - but you are probably right with the details of how the languages are implemented
22:31amalloylispels?
22:31gfrederickssurely it is the plural of lisp
22:31supersym:D
22:32amalloyi dunno, i would say a lispel is a list: the fundamental construct that makes up a lisp, in the same was a pixel makes up a pixture
22:32gfredericksa lispel is a single paren
22:34danielglausergfredericks: please balance that paren
22:35brehaut
22:35gfredericksI shall not.
22:36brehautthat one balances nicely by itself
22:36gfredericks"lispel": a left paren; "lisple": a right paren
22:36supersymahhh.. i got it
22:37supersymsilly me i forgot all about closures ><
22:38amalloydon't feel bad. for a long time, so did emacs
22:38chessguyhaha
22:38supersymwell i dont know the plural of lisp, lisps I'd say but I'm a n00b... in our language it resembles speaking in a hardly understandable fashion
22:39chessguyi'd say lisps too
22:39supersymso I figured my attempts are like stuttering
22:39supersymyup
22:40supersymI work in LT fulltime tho when chrome works
22:40supersymI got overtone's emacs-live running
22:40supersymbut teh insta-repl is such a great feedback/learning tool
22:41chessguyLight Table is nice. i've been using it a lot, too. i can't help but feel like i'm not quite using it right, though
22:41chessguylike i know Chris has said he pretty much works on Light Table purely within Light Table now, and I can't imagine using LT for anything big the way I use it
22:44amalloychessguy: ibdknox could probably do it with just a pencil
22:44chessguyhaha, true
22:44chessguythat guy's ridiculous
22:44bbloompencil? psha. i code in pen.
22:44bbloombut only b/c sharpies are expensive when you write as much code as i do
22:45bbloom(disclaimer: i make a ton of mistakes and write and rewrite about a billion times. pencil isn't even remotely malleable enough to handle the number of errors i make. please ignore everything i say)
22:46shriphanihello does anyone have experience with incanter ? I am trying to use time-series-plot and I get this: No matching method found: add for class org.jfree.data.xy.XYSeries and I don't invoke add anywhere….
22:48bbloomshriphani: use (pst) to print a stack trace & look for your code in the stack
22:51supersymdown the rabbit hole
22:53supersymI physically feel nausea sometimes ... endless possibilities. And looong ago since I had actually had to do some hard work/math
22:54supersymchessguy: yeah with Chris, I bet he has tweaked tons of fun parts of the IDE...from what I've seen with that game they were developing
22:54supersymI assume you could create extra windows, buttons and what not if you know what to call
22:55supersymbut since there isnt much documentation,... I haven't snooped around much and don't know enough about reflection to poke around
22:56supersymbut i also feel something as infinitly flexible as clojure, you can do with notepad even in a great and fun way once you master the language
23:06danielglausersupersym: I'm far from a master but I find the tools *really* help
23:48supersym(assoc [2 4 5] 6 7)
23:51hyPiRionUh.
23:51hyPiRion"Caused by: java.lang.ClassFormatError: Invalid method Code length 69270" <- ?
23:53hyPiRionIs that some sort of upper limit for Clojure?
23:54amalloyhyPiRion: yes. you have a macro expanding to a very large single function, or are AOTing a very large data structure
23:54xeqihyPiRion: https://groups.google.com/forum/?fromgroups=#!topic/clojure/tlAxjnJE1pA
23:55hyPiRionmeh
23:55hyPiRionOh well.
23:57hyPiRionIt's not aot'd though, but oh well.
23:58ivanI think it is time to picket Oracle to raise the method size limit
23:59hyPiRionWell, it's just... a very long backquote, that's all