#clojure logs

2012-12-04

00:25basicsenseihey guys, in eclipse+ccw how could I specify javadoc sources to leiningen dependencies(they are unmodifiable and I cannot add them manually) maybe something to add in project.clj ?
00:29basicsenseiI'll try :classifier "sources"
02:14replacaDidn't someone just post a new tuorial on zippers? I thought it was on clojuredocs, but I don't see it there. Does anyone know what I'm talking about?
02:19replacaoh, it's on clojure-doc.org. confusing naming
02:19Raynesreplaca: Yeah, Michael should write documentation on the names of the documentation websites.
02:19RaynesSince is so gung-ho about documentation.
02:22replacahah!
05:55WokenFuryanyone run into java.lang.ClassNotFoundException: clojure.tools.logging.impl.LoggerFactory when using clojure.tools.logging?
05:56WokenFurypops up randomly on deployments and only a lein clean seems to fix it
05:56WokenFurycan't reproduce it reliably either
06:03AnderkentDoes anything other than dot (. Class member) treat classname symbols specially (i.e. Class != (do Class))?
06:03Anderkent(and who came up with that -.-)
06:08clgvWokenFury: I got that one when I did not have org.slf4j/slf4j-log4j12 as dependency
06:09clgvAnderkent: better use (Class/member) for static constants and methods and (.member obj) for non-static ones
06:11WokenFuryclgv: how strange. I'm using logback tho. let me try
06:12WokenFuryaha. datomic docs told me to exclude that from deps
06:12Anderkentclgv: I'm not writing code, I'm instrmenting code, don't have the luxury of choosing which form to use :)
06:13clgvWokenFury: I dont want to say it *is* the reason but I had the same behavior when I did not have that dep
06:14clgvAnderkent: well then a short comment: it is java interop there has to be some special form to enable it ;)
06:18Anderkentclgv: yes and I can handle the . special form, I was just wondering if any other form also did this stupid ClassName != (do (whatever) ClassName). try/catch could, I guess, it also handles class names
06:21clgvAnderkent: when you use a symbol it will be resolved to the class and you get a Class object. in the dot special form that needs to be omitted since you want to access a static member of the class whose symbol you used and not on the instance of the class "Class"
06:22clgv&(type Math)
06:22lazybot⇒ java.lang.Class
06:22Anderkentclgv: that's exactly the annoying behaviour I am talking about, I'm aware of how that works, what I was asking is whether there are any *other* special forms than dot that do it
06:22Anderkentand yes seems (catch Exception) does the same
06:23clgvAnderkent: yeah. and deftype/defrecord constructors as well: (deftype MyType ....) (MyType. ...)
06:25clgvAnderkent: but you can detect special forms automatically via `special-symbol?`
06:25Anderkentyes, but not whether they do this or not
06:25clgv&(special-forms)
06:25lazybotjava.lang.RuntimeException: Unable to resolve symbol: special-forms in this context
06:26AnderkentI want to recurse into special forms, but for some I have to handle their arguments specially
06:27clgvyou will have to read their docs and try them out to be sure.
06:27Anderkentunfortunately many are not documented :)
06:27clgvwhat exactly do you do?
06:27Anderkentcode coverage
06:27clgvof test? docs?
06:28yediyediis there a standard or spec or something for making persistent models of boolean relations
06:28Anderkentpardon? Of arbitrary code, though I only run clojure.test tests currently
06:29clgvAnderkent: I meant what should cover the code ;)
06:30AnderkentI instrument the code by walking the source with statements that record whether a particular form was executed, run clojure.test and then collect the results
06:30clgvah ok.
06:31clgvdid you try loop-recurs yet? that might give you another dimension of problems ;)
06:32clgvfn-recur is the same...
06:32Anderkentno, they're fine, loop have the same syntax as let and recur I can wrap
06:32clgvno. I meant that you can't wrap code arround a recur since it has to be in tail position
06:32AnderkentI wrap it so that it stays in tail position
06:33clgvso you do not wrap the recur itself and also not transitively its surrounding forms?
06:34clgvdo you use a look-ahead to detect a nested recur then?
06:35clgvAnderkent: do you have an elegant implementation for that that you are allowed to share?
06:36AnderkentI don't need to - all my wrappers put the original form at tail position so recur 'just works'. Think (recur (f1 arg1) (f1 arg2)) -> (do (capture <id>) (recur (do (capture <id2>) (f1 arg)) (do (capture <id3>) (f2 arg2))))
06:36Anderkentthe recur is still in tail position
06:36Anderkentand I'll be open sourcing this eventually, but right now it's not ready yet
06:39Anderkenthavent thought of protocols yet, that might be trickier
06:39clgvah ok. I have the problem that I need to capture the return value - so I would need a look-ahead or avoid wrapping completely.
06:40clgvyou mean capturing the protocol invocation for different types?
06:43Anderkentah, defprotocol just does deftype* ? Then it might just work. But reify I'll have to handle like new/./catch I suppose
06:44Anderkentstill undecided whether I should match these before or after macroexpansion.
06:44clgvyeah defprotocol is a deftype with several interfaces implemented
06:45clgvyou could also hook into deftype before it is called (robert.hooke lib)
07:14rkzddd#
07:34tgoossensIn a board game. A robot has a position {:position[ x y]}. There is also a "board". I have move functions for robot position but they do not involve the board. Is it a good idea to make a "move-on-board" function that uses the move-robot functions?
07:34tgoossensfor the record, a board must contain a collection of all the pieces that are on the board in some form (like a set or a map of position -> piece)
07:35tgoossensand if i move the robot forward this should also change in the board that contains the piece
07:36tgoossensor was it an initially bad idea to define position on the robot?
07:36tgoossensmaybe those position keys in the robot map should be added by the board
07:36tgoossensso that a robot is defined indepentently of the type of board it is used on
07:39Anderkenthaving the board know where each robot is makes sense to me. The robot then can ask the board what's around it no matter what shape the board has
07:42tgoossensanderkent: do you suggest that a robot has a reference to its board?
07:42tgoossens*are you suggesting
07:43Anderkentah, depends. Is a robot a piece controlled by something else, or an individual actor? If it's controlled by something else then it doesn't have to, but if it acts on its own it has to know what's around it
07:43tgoossenshow i currently see it is
07:44tgoossensa client will ask the board what pieces are on each position
07:44tgoossensand then it must be able to say
07:44tgoossensthat pieceX on position [a b] must be moved "forward"
07:44tgoossenscurrently i'm using no references, atoms or whatsoever
07:45tgoossensso
07:45tgoossensmove-on-board
07:45tgoossensshould return a new board to that client
07:46tgoossensi need to go now. But please if you were intending to answer / say something please type so that later i can read it :)
08:08AnderkentWhat's the point of doing (let [] <exprs>) ?
08:09tomojtgoossens: why does a robot need to know its position?
08:09clgvAnderkent: I heard it is used to avoid locals-clearing which could happen in a (do <exprs>) - but that was a while ago
08:09tomojmy position is always (0,0,0)
08:10clgvAnderkent: you found it in some macroexpansion I guess ;)
08:19cshellWhat is the best way to flatten a nested map structure (graph)?
08:23Anderkentclgv: yeah, I'm looking at defrecords as it seems I'm not handling them right :P
08:23Anderkentcshell: does flatten do what you want?
08:24Anderkentah, doesn't work on maps, just sequential colections
08:24cshellyeah, it's returning an empty sequence
08:24cshellthanks though :)
08:24clgvcshell: tree-seq might help you if you want a traversion
08:25cshellclgv: I'll give that a try, thanks!
08:25clgvbut only if it is a tree (not a general graph)
08:25cshellso no cycles?
08:26cshelland everything connected to the root?
08:26Anderkentno backlinks
08:27Anderkentand only one route from root to any given node
08:27clgvcshell: no. you'd get an infinite sequence that might not visit all of your graph
08:28cshellah okay
08:28clgvcshell: well if it is a general graph you now have to define what "flat" means
08:29cshellYeah, I'm just trying to go through a nested map and extract all the keys
08:29clgvwell you can do that with tree-seq
08:30clgvsince your nested persistent map has leafs at some level
08:30clgv*leaves
08:32cshellso the branch? is just a check to see if there are any children?
08:33clgvbranch? checks if there might be children. the other function returns them but it is allowed return an empty seq
08:37vakoselhi all, newcomer .. what is the best way to get familiar with the language ? resources, ide.. i googled but i 'd appreciate any opinion
08:38cshellvakosel: cemerick's Clojure Programming is a good book
08:38clgvvakosel: what's your background?
08:39vakoselas a programmer? or so? win32 c++, python , c# litlle java
08:39clgvin general: read a book and play with the exampoles and concepts presented in it...
08:39vakoselwindows ok
08:39vakoselide?
08:39clojurebot(as an aside, 1 is a symbol designating the numeric value 1)
08:39clgvdo you like ides like eclipse?
08:40vakoseli know it from pydev
08:40sam7I'd like to change parts of a string, driven by a simple pattern matcher. So far, I have the following, but it looks real inefficient as it goes from string to list and back. Any better ways? (apply str (map #(if (= %2 \-) %1 %2) old-str new-in-template))
08:40vakoselso eclipse witn counterclockwise is ok?
08:41clgvI use CCW for 2 years now
08:41vakoselexcellent..i will do that
08:41clgvits development speed increased since laurent is sponsored for one day a week
08:42clgvsam7: clojure.string/replace
08:44sam7clgv: I looked at string/replace, but didn't see how to make it do what I want. If old-str is "12345" and new-str is "-B-D-", I want the function to return "1B3D5"
08:47clgvsam7: like that #(do (require 'clojure.string) (clojure.string/replace "12345" #"[24]" (fn [x] (case x "2" "B" "4" "D"))))
08:47clgvoops
08:47clgv&(require 'clojure.string)
08:47lazybot⇒ nil
08:47clgv&(clojure.string/replace "12345" #"[24]" (fn [x] (case x "2" "B" "4" "D")))
08:47lazybot⇒ "1B3D5"
08:48clgvsam7: if you replace everything you can also iterate over each character and use a stringbuilder to creat the new string incrementally
08:49sam7clgv: That's just a hardcoding of one case. I want each character in old-str to remain the same where new-in-template is "-", but to be replaced by the new char otherwise. (See my code above.... it's way more succint than I can write in prose)
08:50clgvsam7: the iterate over each character and build the enw string within a stringbuilder
08:51sam7clgv: Not 100% sure what you mean. Looking up stringbuilder now.
08:52cshellIt's Java StringBuilder
08:54sam7cshell, clgv: I see. Ok, guess it's time for me to learn the interop stuff... unless one of you would be kind enough to write a code snippet for lazy me.
08:55clgvsam7: well you could also profile whether you really need that change. if it's no bottle neck you could use your time better ;)
08:56the-kenny,(let [old "12345", new "-B-D-"] (reduce str (map #(if (= \- %2) %1 %2) old new)))
08:56cshellclgv: could he convert his string to a sequence of chars and then apply a map to the converted sequence and his transform rule?
08:56clojurebot"1B3D5"
08:56sam7That's exactly what I have now. (see above).
08:56the-kennyWhoops.
08:56the-kennyDidn't read that much backlog, sorry
08:56sam7(I'll be back in about 20 minutes; need to shuttle my kids around)
08:57clgvcshell: yeah, he is doing that like in the-kenny's snippet^^
08:58clgvcshell: if you need fast string construction on the jvm you'll end up with stringbuilder sooner or later
08:59cshellclgv: ah, gotcha thanks
09:05cemerickcshell: thanks for the mention :-)
09:07cshellcshell: np :)
09:08cshellcemerick: I'm trying to collapse the results of aether/dependency-hierarchy into a sequence - do you have any recommendations for how to do that?
09:11sam7(back)
09:12cemerickcshell: just the keys of the graph coming out of resolve-dependencies will give you a seq of dependencies
09:13clgvcshell: a dependency hierarchy is a DAG so you could use tree-seq on each "root"
09:13clgvbut if there is a better api function use that one ;)
09:16cshellcemerick: I'm trying to get to it via leiningen.core/dependency-hierarchy - it's kicking back the DAG
09:17cshellclgv: I've been trying tree-seq but I can't figure out what the right inputs are - I'm using map? for the branch? param
09:18clgvcshell: if those are all maps `map?` is fine. as child function you probably have a keyword, e.g. :depends-on
09:22gfredericksso there's still not an easy way to specify CLJS-version with lein-cljsbuild?
09:23the-kennygfredericks: Yes! Include it as a dependency
09:23gfredericksoh hm. so if I publish my own on clojars, will it recognize it given it would have a different group-name than org.clojure?
09:24gfredericksprobably it will end up with both and they will have a maven-off to determine the winner?
09:24the-kennyHm, maybe. But you could :exclude the original one, right?
09:24gfredericksthat sounds plausible
09:25cemerickcshell: hum, ok; you'll have to walk it, then; might as well rip off the walk-deps fn from https://github.com/technomancy/leiningen/blob/master/src/leiningen/deps.clj
09:26AnderkentHow can I update the version of reply lein is using? Do i just put a newer one on classpath?
09:28the-kenny:*
09:29clgvAnderkent: since leiningen is installed via a standalone jar I doubt that
09:29Anderkentsucks, because tab completion seems broken
09:29Anderkentoh well, guess I wait for next preview someday
09:31cshellcemerick: Awesome, that's perfect - thanks!
09:33clgvcshell: so these are no maps after all ;)
09:33clgvcshell: (tree-seq sequential? second deps) should work then
09:34clgvcshell: ah no. you want to visit the first entries... well then walk-deps is easier...
09:35cshellclgv: I'm still learning - but thanks for all your help:)
09:36clgvcshell: that's it (map first (tree-seq sequential? second deps))
09:37cshellclgv: where did you get deps from?
09:38cshellleiningen.core/resolve-dependencies?
09:38clgvcshell: that's your input. the same you would give to walk-deps
09:38clgvcshell: I just inferred it's structure from the code of `walk-deps`
09:39cshellah, yeah it's dependency-hierarchy :)
09:43Anderkentnooooooooooooooooooooooooooooooo, dynamic classloader gets me again
09:43Anderkentand this time I have no idea how to fix it, geh.
09:47Anderkent.. Can I modify a clojure.core private variable somehow? (without using java reflection, that is)
09:49mdeboardthat's probably not what you want to do
09:49Anderkentnevertheless
09:51clgvAnderkent: what happens with dynamic classloader?
09:52Anderkentclgv: currently I'm loading the ns to instrument, then instrumenting it, then evaling the instrumented form (thus redeffing everything in the namespace)
09:52Anderkentthe problem is when a namespace declares some types, they will already exist and when redeffed clojure will create a new dynamic classloader that *should* capture all resolutions for that class name
09:53Anderkenthowever it seems that references to the class name within the instrumented code resolve to the *old* class, so things like instance? checks will fail
09:54AnderkentI could try to work around this by not loading the ns before instrumentation, but then I need to trick clojure into thinking this ns was already loaded (so it doesn't re-load it from file on any requires)
09:54Anderkentthus my question about private vars
10:04clgvAnderkent: you could just read the namespace file an instrument it and then compile it
10:05clgvAnderkent: reloading can be prevented as well, there is map or set that contains loaded namespaces and is used to decide whether to load a namespace or not
10:07tgoossensi have a function "place-on-board" which is used to place a piece on a board. if for example an invalid position is given. Should the function just return the original board? return nil? exception (yuk?) ?
10:07tgoossensjust returning the board, then you don't know whether something went wrong
10:08tgoossensexceptions can be used to identicate a particular problem
10:08tgoossensnil just says "you screwed up"
10:10ivaraasencshell: any luck solving your problem?
10:10cshellivaraasen: I'm looking at the walk-deps function and trying to base my solution of that
10:10nDufftgoossens: personally, I'd use slingshot's throw+ to pass back an exception that actually has context/data attached.
10:11ivaraasencshell: any particular requirements? do you just want the keys?
10:11cshellivaraasen: yes, just the keys
10:11cshellivaraasen: all the way down
10:11ivaraasencshell: gimme a sec
10:11cshellivaraasen: awesome, thanks
10:14ivaraasencshell: this might work https://www.refheap.com/paste/7283
10:16cshellivaraasen: yes, I think that does it!
10:17cshellivaraasen: thanks much!
10:18ivaraasencshell: np
10:23clgvcshell: use mapcat instead of map+flatten
10:24ivaraasenclgv: good point
10:24clgvcshell: keepcat would be perfect but does not exists ;)
10:28tgoossensvector [1 2 2 1] how can i remove only 1 element that matches predicate : (remove-first 2 [1 2 2 1]) --> [1 2 1]
10:29mdeboardso (remove-first 2 [1 2 2 2 1]) would yield (remove-first 2 [1 2 2 1]) ?
10:29mdeboarder, would yield [1 2 2 ]
10:29mdeboardwow, nevermind, you know what I mean.
10:30tgoossensok :p
10:30tgoossensjust a function that removes the first element that matches the predicate and then stops
10:31mdeboardWell, doesn't stop, it continues iterating through the collection based on your example
10:33tgoossensyeah. but i need a function that only removes first occurence. If it doesn't exist already in core, i'll write it myself
10:33tgoossensjust wondering :p
10:34joegallo_,((fn [e s] (let [r (take-while #(not= e %) s)] (concat r (drop (inc (count r)) s)))) 1 [2 1 1 2 3])
10:34clojurebot(2 1 2 3)
10:34mdeboard,(into #{} (filter #(= 2 %) [1 2 2 2 1]))
10:34clojurebot#{2}
10:34joegallo_can almost certainly be made cleaner
10:34tgoossensmm
10:35hyPiRion,(let [[a b] (split-with (partial not= 2) [1 2 2 2 1])] (concat a (rest b)))
10:35clojurebot(1 2 2 1)
10:35joegallo_ooh, yes, i like that.
10:38mdeboardMan this channel will eat all your time if you let it, it's like a constant drip of brain teasers
10:38tgoossensthanks
10:38tgoossensmdeboard: i know
10:38mdeboarde.g. tgoossens's question :P
10:38tgoossensi really should start studying now :p
10:39hyPiRionmdeboard: It's scary, yes.
10:39DrPheltRightIt's interesting even for those who don't speak much if at all
10:39tgoossens:D
10:42borkdudetgoossens hehe…
10:42tgoossensborkdude: 4real :p
11:12jweiss,(let [templ (partial partial format)] ((templ "foo %s %s") "baz" "quux"))
11:12clojurebot"foo baz quux"
11:13jweisssomething seems weird to me about (partial partial format) but seems the most succinct way to write it.
11:15hyPiRionUh, wouldn't just (partial format "foo %s %s") be just as good?
11:17clgv(let [templ #(apply format %&)] ((templ "foo %s %s") "baz" "quux"))
11:17clgv,(let [templ #(apply format %&)] ((templ "foo %s %s") "baz" "quux"))
11:17clojurebot#<MissingFormatArgumentException java.util.MissingFormatArgumentException: Format specifier 's'>
11:18clgvah forget that ^^
11:59borkdudeif I want a VPS, what is a recommended minimum amount of memory for basic JVM apps (so, what does it take to boot Arch linux for example and run the JVM)
11:59mdeboardjvm for what?
11:59borkdudeclojure
12:00mdeboardDepends what your Clojure program does
12:01mdeboardI'm not being obtuse/difficult btw
12:02borkdudemdeboard I know. but would for example 256 MB suffice to host a tictactoe game (theoretical example) ;)
12:02mdeboardSure
12:03ucbanybody going to the skillsmatter meet up tonight?
12:18borkdudebtw how do people host a leiningen/compojure app on a linux server, just start lein run&?
12:26technomancy_borkdude: lein trampoline run or uberjar from inside an upstart job is probably the simplest
12:27borkdudetechnomancy_ tnx
12:27borkdudetechnomancy_ trampoline isn't yet default behavior?
12:28borkdudetechnomancy_ upstart is ubuntu specific?
12:30S11001001borkdude: correctness over speed.
12:30borkdudeS11001001 what do you mean?
12:31S11001001borkdude: that safety by default, rather than speed by default, is good general practice
12:32S11001001borkdude: you have too many variables to eliminate already when debugging without worrying about whether some unnecessary optimization is screwing you up
12:33borkdudeS11001001 ok I see
13:15ohpauleezFor all Vim users: https://github.com/tpope/vim-foreplay
13:15ohpauleezTim Pope's nREPL env for vim works nicely
13:15ohpauleezparedit + VimClojure + Foreplay is working well for me
13:24technomancy_huh; why does it still need vimclojure if it's using nrepl?
13:25thmzltsyntax highlighting/indenting?
13:25technomancy_oh, I see
13:28thmzltI haven't tried it myself, I use emacs for lisp stuff and vim for the rest
13:29ohpauleezthmzlt: I was in the exact same camp until Clojure - Vim support is pretty nice
13:32pbostromI want to build a simple RPC handler where I send a message to the handler which then reads the message and dispatches the specified function. I can think of three ways to implement this: 1) Send a symbol to the handler, which then resolves the symbol in some predefined namespace 2) Send a keyword to the handler, which then does a lookup in some predefined map of functions 3) Send a keyword, but pass it to some predefined multimetho
13:32pbostrom Any thoughts on the best approach? I prefer 2 (map of functions) but wanted to solicit other opinions.
13:33technomancy_pbostrom: a multimethod *is* a map of functions
13:33pbostromyeah, but it's a lot more typing
13:33pbostromthey are essentially the same though?
13:34technomancy_well a multimethod can dispatch on an arbitrary function rather than just a key, but apart from that yeah
13:38thmzltohpauleez: after playing with it for 10min, my impression is that it doesn't feel right :)
13:38ohpauleezthmzlt: Fwiw, I have a repl instance running in the footer panel of a tmux window
13:39ohpauleezso I'm in vim, banging on cpp and c!!
13:39ohpauleezthen toggle over to the repl to poke at stuff
13:39ohpauleezor just have a scratch file
13:40ohpauleezbut it supports all the things I need: omnicomplete, multiple nrepl, goto file, source, evaling, and the repl tools (docs, apropos, etc)
13:40ohpauleezplus, redefine (working correctly)
13:42mpenetpbostrom: also a multimethod is extendable at runtime, a map not so much, unless you wrap it in a atom
13:44thmzltohpauleez: I guess I can get used to it. I just didn't like the editing part, but it feels pretty solid
13:44thmzltplus I am spoiled by emacs-live
13:45ohpauleezthmzlt: emacs-live is pretty solid. paredit.vim, surround.vim, and VimClojure are the bare-minimum for me.
13:48andrewmcveighohpauleez: Is there a trick for getting it to work? I'm getting classpath errors.
13:49ohpauleezandrewclegg: No, but I have found one bug I don't know how to fix (regarding it shutting down and exiting cleanly)
13:49ohpauleezandrewmcveigh: ^
13:49ohpauleezI have started up on a lein2 project from a cold start
13:50ohpauleezand I've done it for a lein2 project that I had a running repl isntance for
13:50ohpauleezboth worked just fine for me
13:50andrewmcveighhmm, I think it's trying to fall back to "java clojure.main"
13:50ohpauleezahh
13:51pbostromthanks technomancy_ and mpenet, I've tried it both ways, I think it's more obvious what's going on with the multimethod, and easier to extend like you said, I wasn't sure if maybe a mulimethod was overkill, I also felt weird disregarding the first argument in every defmethod for some reason
13:51ohpauleezYeah, Tim put a note in the README that he's in way over his head (which is hard to believe)
13:52andrewmcveighI'll give it an hour to try getting it working... got real work to do :-)
13:52mattmoss&(mapcat (fn [a] (map (fn [b] [a b]) [1 2 3 4 5])) [:a :b :c :d :e]))
13:52lazybot⇒ ([:a 1] [:a 2] [:a 3] [:a 4] [:a 5] [:b 1] [:b 2] [:b 3] [:b 4] [:b 5] [:c 1] [:c 2] [:c 3] [:c 4] [:c 5] [:d 1] [:d 2] [:d 3] [:d 4] [:d 5] [:e 1] [:e 2] [:e 3] [:e 4] [:e 5])
13:52mattmossAnyone know of lib fn that does that?
13:53amalloywat. just use 'for
13:53mattmossoh, duh. *smack self*
13:53amalloy&(for [a [:a :b :c :d :e] b [1 2 3 4 5]] [a b])
13:53lazybot⇒ ([:a 1] [:a 2] [:a 3] [:a 4] [:a 5] [:b 1] [:b 2] [:b 3] [:b 4] [:b 5] [:c 1] [:c 2] [:c 3] [:c 4] [:c 5] [:d 1] [:d 2] [:d 3] [:d 4] [:d 5] [:e 1] [:e 2] [:e 3] [:e 4] [:e 5])
13:54mattmossthanks
13:54mattmossbrain dead today, i am
13:58negevwhats wrong with this? (fn mult [x y] x * y)
13:58borkdudenegev infix vs prefix notation
13:58borkdudenegev this ain't no Haskell
13:58borkdudenegev (fn mult [x y] (* x y))
13:58negevwell im reading a book called the joy of clojure
13:59negevahh i see
13:59negevso why when i try to do this on the next line: (println "The result of 9 x 9 is " (mult 9 9))
14:00negevdoes it say it can't find mult in the current context
14:00S11001001negev: fn is pure
14:00S11001001negev: it doesn't bind a variable or have any side effect whatsoever
14:00negevdid i want def?
14:00S11001001negev: yep.
14:00negevok, so what does fn do ?
14:00josteinkfor those interested: https://github.com/josteink/lein-drip
14:00andrewmcveighohpauleez: this "target/repl-port" is just a file with a number in right?
14:00S11001001negev: there are *lots*, *lots* of times when you *just* want to make a function.
14:01josteinknegev: syntax to create a lambda
14:01josteinkwithout binding it to a variable name
14:01negevah i see
14:01negevso you use the fn block in the def
14:01josteinkwhat would be a first step if I want to move my lein-pluging from githib to clojars? :)
14:01negevi get it now
14:02josteinknegev: can also be used in a map
14:02josteink(map (fn [x] (+ 1 x)) numbers)
14:02tpopeandrewmcveigh: I tried to make the classpath stuff (and everything, really) completely transparent. don't be shy about opening a bug if it doesn't work out of the box
14:03andrewmcveightpope: Trying to work out if it's my vim. I'm getting back "nREPL: {}" at the moment.
14:04tpopethat's a catch all error, shouldn't happen :/
14:04technomancy_tpope: fwiw calculating the classpath only hits the network if you have snapshots
14:04tpopeah
14:06technomancy_and even that's only once every 24h
14:06tpopeis there a way to opt out? feels like something that I shouldn't be kicking off behind the scenes
14:07technomancy_tpope: you can do `lein -o classpath` or `lein -o repl`
14:07technomancy_which is kind of cheating; "-o" is actually the name of a higher-order task that activates the :offline profile
14:07tpopeawesome. is that safe on older versions of lein?
14:08technomancy_at a guess I'd say around preview5
14:08amalloywouldn't -o mean he also doesn't hit the network to resolve new dependencies he doesn't know about yet?
14:08basicsenseihey guys, how can I execute this with java code ? (set! *warn-on-reflection* true)
14:08technomancy_true; it's not good for general use
14:08tpopewell then I'll probably shy away from it
14:08technomancy_there's a way to disable it for snapshot updating only, but there's not a good CLI shorthand for it
14:09tpopeandrewmcveigh: is that error happening on any command?
14:10tpopeif foreplay.vim doesn't understand the response from nREPL, it throws basically a vim representation of the decoded bencode packet it received
14:10andrewmcveightpope: Yeah, I get the feeling that there's no communication. Not sure if that's possible. Just putting in some echo lines to see if I can work out where it's coming frome.
14:12tpopeI saw it a few times when authoring the plugin, but it was always when I was doing something wrong else where
14:12tpopelike sending a blank string as code to eval
14:12technomancy_there's an example of printing middleware in sample.project.clj that might be helpful for debugging
14:13basicsenseiis it freaking this? clojure.lang.Var.intern(clojure.lang.RT.CLOJURE_NS, Symbol.intern("*warn-on-reflection*"), clojure.lang.RT.T, true);
14:13tpopethanks, I may have a look later
14:13tpopeI need to get back to my day job, but please hit me up later andrewmcveigh if it's still an issue
14:14cemericktpope: foreplay looks great. Ping me if you need any help w.r.t. nREPL, etc.
14:14tpopecemerick: I *might* with andrewmcveigh's error :). we'll see
14:16andrewmcveightpope: I'll probably leave it until tomorrow, if I don't get anywhere with it shortly.
14:16cemericktpope: I haven't been following. :-) But, sure.
14:16tpopenothing worth following yet
14:18basicsenseithat seems to have been it
14:20ohpauleeztpope: Is there a shorthand to shut off foreplay in vimrc?
14:21ohpauleezI'm digging through the plugin stuff now (more than happy to add it in, if it's not there). Sometimes I just want to make a quick edit to project.clj (and I don't want want the whole environment up)
14:21cemericktpope: FWIW, nearly all of the clojure tooling leads are on http://groups.google.com/group/clojure-tools
14:38tpopecemerick: well now so am I
14:39tpopeohpauleez: please open a github issue, can't get into it right now
14:39ohpauleeztpope: Will do, thanks!
14:40andrewmcveightpope: I think I've tracked down the problem.
14:43tpopeandrewmcveigh: brilliant
14:45andrewmcveightpope: It's because my code is in maven layout "src/main/clojure" but I switched to lein2. So my namespaces are getting detected as "main.clojure.my-ns".
14:45borkdudewell, I hosted a noir app on a vps.. http://vps794.directvps.nl:8080/ -- but no idea what's going wrong… normally I see some kind of exception
14:45tpopeandrewmcveigh: does lein classpath report the right thing?
14:47andrewmcveightpope: OK, sorted it.
14:48andrewmcveightpope: I have too many :source-paths in project.clj
14:49andrewmcveightpope: so foreplay.vim was seeing "src" in the classpath and presuming that my namespace was "main.clojure.my-ns"
14:49andrewmcveightpope: I guess that could be a "user error"?
14:52tpopeandrewmcveigh: yep. which doesn't excuse a worthless error message
14:52tpopeandrewmcveigh: could you make an issue so I can handle it better in the future?
14:55andrewmcveightpope: Sure. Will do.
15:00cpetzoldanyone know if udp multicasting is possible with aleph?
15:02borkdudeany chance of getting more info from noir on why this goes wrong? http://vps794.directvps.nl:8080/
15:03borkdudeit doesn't run locally either as uberjar, it runs with lein run though
15:03borkdudewell it runs, but same noir error page
15:03borkdudewith lein run it works well
15:07technomancyborkdude: noir isn't very transparent with its routing unfortunately
15:07technomancycompared to compojure
15:08andrewmcveightpope: Made an issue, if you need more, let me know - I found that kinda weird to write.
15:11borkdudeI read somewhere that requiring the views could help, but when trying that I get a file not found… appname/views/common.clj argh
15:11kzarHaven't played with Clojure for a while, is noir still the main web framework?
15:12gfredericksevery time somebody asks that question 80% of the responses are "just use compojure"
15:12gfredericksor "use libraries, not frameworks"
15:12borkdudeoh I'm sorry, I typed commmon....
15:13tpopeandrewmcveigh: makes perfect sense. I assumed (require 'clojure.main.my-ns) would blow up if clojure.main.my-ns wasn't defined
15:14andrewmcveightpope: Yeah, spot on.
15:14technomancyborkdude: noir's approach of having loading the view namespaces alter an atom results in weird situations that are hard to debug when they go wrong
15:15tpopeand that's how nrepl responds if you try to eval in a non-existant ns
15:17andrewmcveighyeah, not really used nrepl much, other than on the side of vimclojure.
15:21stuartsierracemerick: ping
15:21borkdudetechnomancy ok
15:25cemerickstuartsierra: hi :-)
15:26borkdudeyeah, app works now
15:26borkdudeall memory is in use though, so very slow :)
15:31stuartsierracemerick: Hi. I think I found a bug in Friend.
15:32cemerickJust one?
15:32stuartsierra:)
15:32cemerickThat's the mandatory response, of course.
15:32borkdudeI found a friend in bugs.
15:32stuartsierraUsing http-basic auth, if the request doesn't include any authentication headers, you always get a redirect to "/login", not a 403.
15:33stuartsierraIf some anonymous requests are allowed.
15:33cemerickstuartsierra: I think Craig reported that already?
15:34stuartsierraheh, maybe he did. Didn't see a matching issue on GitHub,
15:34cemerickstuartsierra: oh, I'm thinking of https://github.com/cemerick/friend/issues/28
15:34stuartsierraYeah, different issue.
15:38stuartsierraThis is just that it tries to redirect instead of returning 403.
15:38cemerickstuartsierra: not so much an issue with the http basic workflow; more that there's no parameterization available to override `redirect-unauthorized`
15:38stuartsierraI think I have a fix, not sure if it's correct.
15:39stuartsierraBy returning an empty auth map from `http-basic` with the metadata `::friend/redirect-on-auth? false`
15:40cemerickheh, no, you don't really want to do that :-)
15:40stuartsierraok
15:41cemerickThe real fix is to add a new kwarg to friend/authenticate* that will be used instead of (the really badly-named `redirect-unauthorized`)
15:41cemerickWhich should be called unauthenticated-handler or somesuch.
15:44cemerickThat will allow you to specify what response should be sent in any unauthenticated circumstance. Reasonable prefab options would be one handler that redirects to a :login-uri (the current behaviour), another that sends a 403.
15:44stuartsierraOK. Would that still allow anonymous requests on routes that don't require auth?
15:45cemerickYes. There are only two circumstances where that handler is (and would be) invoked:
15:45cemerick(a) when no credentials are provided, and :allow-anon? false
15:46cemerick(b) when credentials are provided, but an authorization error is tossed
15:46cemericks/when/when no
15:46cemerickDoes that sound right?
15:47stuartsierraI think I have a third case: no credentials are provided, `:allow-anon?` is true, AND an authorization error is tossed.
15:48cemerickIsn't that (b)?
15:49stuartsierraOh, sorry, didn't see your s///
15:49stuartsierraYes, that is (b).
15:49cemerickIf credentials *are* provided, and an authorization error is tossed, then that's already parameterizable via :unauthorized-handler
15:50cemerick(thus why the `redirect-unauthorized` handler's name is so gawd-awful)
15:54stuartsierracemerick: OK. Tracking this at https://github.com/cemerick/friend/issues/38 . If I have time to look more into it later this week, I'll send a patch.
15:55cemerickstuartsierra: Sounds good, I've added a couple of notes to that.
15:55stuartsierracemerick: Thanks. Talk to you later.
16:01Raynesdevn: You endorsed me in Python and Ruby on Rails on linkedin? O.o
16:02ucbcemerick: you seem to be active on the couchdb/clojure front; do you think it'd make sense to have a ref system on top of couchdb?
16:02devnRaynes: You endorsed me so when I went to your profile it had a few things listed and said: "Do you endorse this person"
16:02devnspeaking of which
16:02RaynesHaha. Python *maybe*, but I've done precisely no RoR.
16:03devnthere is nothing weirder than: "Does Rich Hickey know about Clojure?"
16:03Rayneslol
16:03Hodappdevn: that is classic
16:03amalloydidn't someone ask recently "who understands persistent data structures?" and have only SPJ raise his hand?
16:03devnoh wait, it's better
16:04devn"Does Rich Hickey know about Java?"
16:04devn*facepalm*
16:04Raynesamalloy: I highly doubt it was *only* SPJ.
16:04Raynesdnolen was there.
16:04amalloyRaynes: i may have misread https://twitter.com/samaaron/status/275930177714937857
16:05RaynesYeah, it sounds like that's what he is saying, but I have trouble believing it is all.
16:05RaynesUnless dnolen wasn't in the room it *had* to be at least two.
16:05devnman, some of these endorsements... I need to prune my linkedin tree.
16:05devn"Does [NAME REDACTED] know about Servers?"
16:06devnNo, but they know about Vague...
16:06cemerickQuestions like that are purely rhetorical.
16:06devnhaha
16:06cemerickor, that's how I treat them, anyway
16:06devnBo knows Clojure. Bo knows Java.
16:06cemerick*unless* there's a free hammock up for grabs :-P
16:07devnhaha
16:07technomancylinkedin is purely rhetorical
16:07devnoh man, so... speaking of linkedin, quick story...
16:07devnI know this guy I went to high school with
16:08cemerickstuartsierra was like, "oh c'mon, anyone else besides cemerick?!"
16:08devnHis mom wrote a recommendation for him because she runs a business
16:08devnand she wrote something like "Timmy will be sorely missed."
16:08devnso embarassing...
16:09devnalmost as embarrassing as spelling embarrassing wrong
16:10devn"Does [REDACTED] CISM, PMP, MSPM, GCIH know about Cross-functional Team Leadership?"
16:11Hodappwhat are all those acronyms?
16:11devndude...no one knows
16:11devnthat's the beauty of them
16:12HodappI made a buzzphrase generator. Let's see what it has to say.
16:12cemerickdevn: If you see any of those, run, run far away.
16:13HodappUnified Digital Programming From the Platform of Internet Projection By Opening the Doors of Systematized Transitional E-Business Concept Through the Power of Guaranteed Statistical Software: Collaboratively Agile Third-Generation Consolidation
16:13devn"empower viral ROI"
16:13devn"implement granular supply-chains"
16:13devnetc.
16:13HodappRevising Platform: Conservatively Revolutionary Client Economic Synergy . . . wow, that's some cognitive dissonance
16:13Hodappdevn: this challenges me to revise my buzzword generator.
16:14devnHodapp: haha -- i use a gem call faker now and then when i need double-talk
16:14devnhttp://faker.rubyforge.org/rdoc/classes/Faker/Company.src/M000024.html
16:14devnit has a nice list
16:18zerokarmalefti was about to say leverage wasn't on the list, but it is
16:18devnbrb i need to productize transparent partnerships
16:19devnjust something i do before i revolutionize 24/7 e-business
16:20devnreminds me of: http://projects.haykranen.nl/java/
16:20devnIdentifierPrinterServerConfigurationProducerStrategyFacadeTag
16:21devnProducerExceptionThreadExporterServiceAutowirePrinter
16:21devnetc.
16:22mattmossbrain asplode
16:22mattmossbuzzwords make me ill
16:26mudgelooking for a definition of reference type, what is a reference type?
16:26bbloommudge: depends on the context
16:27mudgebbloom: well how can I understand what a reference type is?
16:27devnmudge: mudge perhaps this helps? http://clojure.org/atoms
16:27bbloomdevn: eh probably too much too fast :-)
16:28bbloommudge: in the context of java, there are two categories of types
16:28devn/perhaps/ :)
16:28bbloomreference types and primitive types
16:28bbloomin a C# or .net context, there are also value types
16:28bblooma reference type is transferred by aliasing: you copy a pointer
16:29bblooma value type is transferred by copying
16:29devnmudge: what got you looking for a definition? is there a blog post or some documentation you're reading?
16:29bbloomall primitives in java are value types
16:29bbloomtheir VALUES are copied to make new variables that point to them
16:30bbloomfor a reference type, a REFERENCE to the object is copied to make new variables that point to them
16:31bbloombut in the clojure context, it's a bit different...
16:31mudgeblloom: i see, and it is the same idea in clojure? So reference type is a pointer to a value
16:31mudgebbloom: I understand references in Java
16:32mudgedevn: I'm reading the Clojure Programming book
16:32bbloomok so in clojure, there are "reference types" in the sense that there is a distinction between values and identities
16:32mudgeokay
16:33bbloomthe idea of a "value" extends to things that you pass around by reference…. a value is somethign that is immutable
16:33bbloomit doesn't change
16:33bblooman "identity" refers to some value at some point in time
16:33bbloomfor an email address, for example, is an identity
16:34bbloomor better yet, a physical address
16:34bbloomyou can say "who lives at this street address now?"
16:34devn,(def fred (atom {:name "fred", :address "sycamore street"}))
16:34clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:34bbloomso a reference type in the clojure sense is an object that encapsulates an identity and a value as state
16:35bbloomI recommend watching http://www.infoq.com/presentations/Simple-Made-Easy
16:35devn(let [fred (atom {:name "fred", :address "sycamore street"})] @fred)
16:35devn,(let [fred (atom {:name "fred", :address "sycamore street"})] @fred)
16:35clojurebot{:name "fred", :address "sycamore street"}
16:35bbloomactually
16:35devn,(let [fred (atom {:name "fred", :address "sycamore street"})] (deref fred)) ;; @ aka deref
16:35clojurebot{:name "fred", :address "sycamore street"}
16:35bbloommudge: watch this one first http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
16:36Raynesdevn: I don't like fred.
16:36devnheh
16:36devnbbloom: what about "Are we there yet?"
16:36mudgebbloom: thanks, I get it
16:36bbloomsure that one too i guess
16:36bbloomi forget which one has the good overview of the speed walker and the photo finish and what not
16:37devnbbloom: the second video you posted is good
16:37devni believe that's the one
16:38creasethere's no reason to run lein clean before lein deps, right?
16:39devncrease: i used to do it semi-religiously, but i dont believe so, no
16:40creasedevn: thanks, yeah, same… I'm trying to wean myself off unnecessary debug rituals
16:41devncrease: the only place i would maybe still use it, and again it might be ceremony, but i just dont know the answer is: between lein 1.7 and 2.0
16:41devnif you had a lein 1.X project and are now using 2, maybe it makes sense to use it there?
16:42creasedevn: yeah, during the transition I suppose it makes sense to throw every harmless hygeine-related tool at your project
16:47creaseshoutout for lein-pedantic, by the way. saved my butt
16:48devnyeah, it's really handy
16:51devnfrenchy64/analyze + Datomic/codeq = ???
16:51lazybotdevn: How could that be wrong?
16:51devnthank you lazybot
16:54lazybotYou're does not exist in my database.
16:55tomojinteresting that clojure.core.reducers/flatten only checks for sequential?, and doesn't check for CollReduce
17:03black_joeI still don't fully understand how to link namespaces together.
17:03black_joeI have one file that is (use)ing another, but that isn't enough for functions to be recognized.
17:04black_joeAnd when I tried lein uberjar, it deleted the entire project. So I had to backup from git.
17:04mthvedtblack_joe: you need to pass the --dont-delete-everything command line switch
17:04black_joeSo what more does it take to be able to use one namespace within another?
17:05technomancycrease: there are a few cases it can be needed for snapshots with native deps
17:05technomancyclojurebot: lein clean?
17:05clojurebotlein is http://github.com/technomancy/leiningen
17:05technomancyhrm
17:05technomancylein clean most of the time is the equivalent of taking out the NES cartridge and blowing on it
17:08creasetechnomancy: hm… what are those snapshot edge cases?
17:09technomancycrease: if you pull in a new snapshot version and the native dependencies have changed, I don't know if it will clear it out necessarily
17:09technomancys/clear it out/unpack the latest version/
17:10creasetechnomancy: ah, okay… I'll remember that, thanks
17:12creaseblack_joe: that's weird, what's your ns form?
17:13black_joecrease: Actually, I found the problem. It was a Java-ism that Clojure websites / books hadn't explained.
17:13creaseblack_joe: oh, what was the Java-ism?
17:13black_joeHaving to put code into a src directory, rather than having it thrown into x place like C.
17:21tgoossensI'm really having a hard time when not intrudocing any "refs" in my board game. not sure whether it is because i'm more familiar with OO or whether it is just a sign that in fact i should use identity
17:22ohpauleeztgoossens: What game are you making? Can you pass the transformations of the board along?
17:22tgoossensi'll throw it in a gist :)
17:28tgoossensohpauleez:https://gist.github.com/4209494
17:28tgoossensohpauleez: some explanation is at the bottom file
17:31Rayneshttps://www.refheap.com/paste/7285 without the 50 space indentation.
17:31Raynestgoossens: What are you using to write the code?
17:32solussdis there a way to represent "now" with an #inst reader dispatch?
17:33solussd(just curious)
17:34technomancyI think that kind of goes against the point of reader literals
17:35technomancythey're meant to represent values, and "the current time" is a reference, not a value
17:36tgoossensraynes: i'm using sublime text 2 . why?
17:36Raynestgoossens: Set your indentation to 2. :p
17:36tgoossensits on 4 aparently
17:37tgoossenschanged it :p
17:37Raynes<3
17:37technomancyouch
17:37Foxborontgoossens, might wanna have tabs to space, and set idention to 2 :P
17:37Foxboronindention*
17:38tomojtechnomancy: how about #db/id[:db.part/user] ?
17:38cemerick,#=(java.util.Date.)
17:38clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>
17:38cemerickoh well
17:39technomancytomoj: I don't know what that means
17:39cemericksolussd: ^^ is the closest you'll get to a readable representation of "now"
17:39cemerickbut, don't use that :-P
17:39tgoossenslol its funny how you criticise my indentation but do you also maybe have some tips on what might be some better ways (maybe using identity?) ^^?
17:40technomancythe idea of the reader always returning values is violated by j.u.Date anyway, but I think that's a known design bug =(
17:41solussdcemerick: ha. I thought the first rule of #= club is not to talk about #= club
17:41solussdor, is that "ok" w/ data?
17:42cemerick;-0
17:42cemerick;-)
17:42solussdand the second rule?
17:42cemerickheh, no, putting any #= into something intended to be data-ish is nutty
17:44tgoossensi'm confused now. When do you use "2 spaces" and when "one space"?
17:45the-kennyJust use Emacs' default.
17:45solussdone space when putting the first argument to the function on a new line. :)
17:45tgoossenssolussd: thanks :D
17:45technomancyif you have to think about indentation at all you've already lost =(
17:46technomancy(unless you're the one implementing editor support)
17:46cemerickone space indents in clojure? yak
17:46solussdthis is also true- emacs indenting works great for me
17:46the-kennycemerick: I think it's about aligning [a \n b]
17:47solussdI prefer putting arguments to cond and case on a new line- emacs uses a single indent in that case
17:47the-kennyso b is directly under a and not under [
17:47cemerickoh, ok
17:47cemerickwhew
17:57tgoossensi think i'm just going to try using identity
17:57tgoossensand see how that works out
17:58tgoossensit might be quite useful for a game perhaps
18:01solussdclojure needs a conj-if e.g. (conj-if expr coll new-item) that returns the original collection if expr is falsey
18:03jweissi'm looking for a suggestion for when you have 2 dimensions of namespaces, seems like no matter how you lay them out, one dimension gets repeated over and over. is putting the dimension with the most # of namespaces as the directories, and repeating the smaller dimension in each directory, the best I can do?
18:07ChongLisolussd: (defmacro conj-if [expr coll new-item]
18:07ChongLi`(if ~expr (conj ~coll ~new-item) ~coll))
18:08solussdChongLi: yeah.. I wrote it too. :) actually, mine takes any number of [expr new-item] pairs so you can conditionally build up a collection
18:08bbloomsorella: ChongLi: clojure 1.5 has a more general form
18:08sorellabbloom, ?
18:08ChongLisolussd: ah
18:09bbloom,(clojure-version)
18:09clojurebot"1.4.0-master-SNAPSHOT"
18:09bbloom&(clojure-version)
18:09lazybot⇒ "1.4.0"
18:09bbloomhm ok those are 1.4 still :-)
18:09bbloom1.5 will have cond-> (maybe called something else)
18:10bbloom(cond-> x (test y) (conj z))
18:10bbloomand cond->>
18:12solussdbbloom: neat
18:12bbloomsolussd: https://github.com/clojure/clojure/blob/372f03e2fa63ff7c3544be82d85e8943e85e640b/src/clj/clojure/core.clj#L6728-6754
18:13bbloomin case you want to use them now
18:14solussdi do, and i will!
18:18seangroveAh, seems you can't destructure funargs in cljs with string keys if a js object is passed in
18:18seangroveBummer
18:20brehautnever underestimate the power of javascript to cause you sadness
18:20Foxboronbrehaut,
18:21Foxborondude
18:21FoxboronNever underestimate the power of ActionScript3 to cause you deep eternal sorrow.
18:21bbloomseangrove: you mean via :strs ?
18:21brehautFoxboron: a proprietary fork of javascript is woeful you say? i never would have guessed!
18:22seangrovebbloom: Didn't know :strs, was using :keys
18:22seangroveWill try it again once I fix the function
18:22bbloomseangrove: yeah, there is also :strs and :syms
18:23seangroveWill that work though if a plain js-obj is passed in?
18:23seangroveBasically doing a (.-property arg) lookup
18:23bbloomseangrove: no.
18:23bbloomILookup isn't defined on js objects
18:23seangroveYeah, didn't think so
18:23bbloomsomewhat intentionally
18:23bbloomi think
18:23seangroveMakes sense, didn't really expect it to
18:24bbloomdestructuring maps expands to very simple get calls
18:24bbloombut get depends on ILookup
18:25bbloomyou could trivially define ILookup in terms of aget
18:25bbloombut you wouldn't really want to
18:25bbloombecause then EVERY OBJECT would have a unwanted implementation ILookup
18:25bbloomalternatively, you could do something like (deftype Dictionary [] ILookup …)
18:26bbloomor (deftype Expando ...
18:26seangroveYeah, although it's just sugar, it would be nice to have in order to make the function args more explicit
18:26seangroveHmm, wouldn't that still have the same problem?
18:26bbloomit's also more general, so you'd pay protocol dispatch cost when a simple aget would be fastest
18:26seangroveIt's not such a big deal, it's for rendering templates
18:28seangroveThe flow is render template-name with cljsobject, render converts cljsobject to a js-obj, it's passed into the rendering system, but that rendering system calls out to helpers (it's Handlebars), and those helpers are looking cluttered and magical
18:28bbloomseangrove: if you always except a js-obj as the only argument, you could do a macro simpler to the fnk that's been floating around
18:29seangroveYeah, because when the helper is called from the template, it's already been converted into a js-object
18:29bbloomif (fnk [x y] …) expands to (fn [{:keys [x y]}] …) you could have (fnobj [x y] …) expand to a let binding with the appropriate agets or property lookups
18:30bbloomi assume you're trying to do something similar to the common with(templateContext) { template body here … } thing in client side template engines
18:31seangroveYeah, this is getting a bit messy anyway, but I've been putting off refactoring it and adding macros because it works for the time being
18:31seangroveI'll add that in during factor though, it looks like a great idea
18:40holois there any way for map, or other related builtin form to keep the data type from the input sequence without explicitly calling into?
18:42AimHereWell that's a tall order for map, since it can take multiple different collection types to begin with
18:42AimHereRegardless, I don't think such a thing is part of clojure, though it doesn't seem like it'd be hard to write
18:43AimHere*multiple collections of different types
18:43brainproxyholo: no, but could always do something like (apply list (map ...))
18:44brainproxyif say, you wanted to be sure you got a list as the final output of your map-based transform
18:44brainproxy(vec (map ...)) could be used to similar effect, also (apply hash-map (map ...)), you get the idea
18:45holobrainproxy, that implies the input would be a list too, if the intention was to preserve the collection type. but i heard into is the idiomatic way of doing it
18:45AimHereWell mapv already exists as a builtin version of (vec(map
18:45holoAimHere, thanks, i will try to do it
18:45AimHereIIRC, the source code for the likes of map and filter and reduce already have some type-specific code based on each collection type
18:45brainproxyholo: i'm doing something similar similar in my fork of protocol-monads
18:46brainproxythat is, when you use a m/do or a monad utility like m/lift or m/seq, you get the same type out as you put in
18:47holoAimHere, weird, i don't have mapv
18:47AimHereIt was introduced in 1.4
18:48AimHereAlso filterv
18:49holobrainproxy, but i have to know what is the input type with your examples so that i can try to preserve it
18:50brainproxyyes, in what I suggested above you do
18:50brainproxyprotocol-monads does it automatically
18:51brainproxybut I don't know what kind of transforms your're donig, so I'm not sure whether to suggest you look into using p-m
18:51holobrainproxy, oh.. thanks .. i will definitely look into it
18:51brainproxyholo: i've got a snapshot out on clojars, the parent project doesn't incoporate my changes, at least not at present
18:52brainproxyholo: https://clojars.org/org.clojars.michaelsbradleyjr/monads
18:52jkkramer(into (empty coll) (map f coll)) preserves type, although doesn't necessarily preserve order
18:52brainproxyholo: my latest work is on this branch, but nothing in there yet which introduces an api change w.r.t. to the snapshot out on clojars
18:52brainproxyhttps://github.com/michaelsbradleyjr/protocol-monads/tree/return-and-factory-refactoring
18:54holojkkramer, maybe order is not so important, for the moment. thank you
18:54holobrainproxy, looking at the source. thanks
19:01holojkkramer, that "empty" is genious
19:04brainproxyholo: just keep in mind you could run into an ordering issue w/ empty/into
19:05holobrainproxy, yes, jkkramer generously warned me of that issue. thank you for the attention
19:23devncond-> in action https://github.com/Datomic/codeq/blob/master/src/datomic/codeq/analyzers/clj.clj#L44
19:31seangroveHow can I do something like (comp .getButton .getButtonSet) in cljs?
19:35lynaghkAny ruby metaprogrammers have thoughts on making record-like things in Ruby?
19:35lynaghkGist with deets here: https://gist.github.com/4210677
19:53bbloomlynaghk: metaprogramming in ruby is pretty easy via string interpolation
19:53lynaghkbbloom: yeah, I found this SO suggestion: http://stackoverflow.com/questions/4113479/ruby-dynamic-class-definition-with-a-class-name
19:54bbloomlynaghk: you can use define_method with either a block or a HEREDOC
19:54lynaghkactually, that SO suggests that I wouldn't be able to do dynamic class definition just via string interpolation
19:56bbloomyou can do things like:
19:56bbloomer hm
19:56bbloomhow to convey this tersely....
19:56bbloomthe common meta programming pattern is to put class functions on the base type
19:56bbloomand then call them
19:56bbloomso basically self.do_meta_thing
19:57bbloomand in there, you can call self.class.send :define_method, name do |arg|
19:57lynaghkhmm
19:57bbloomlynaghk: you need to learn about ruby's "metaclasses"
19:58bbloomlynaghk: here is a decent tutorial, but the idioms are a bit old
19:58bbloomlynaghk: newer versions of ruby and activesupport include many of these helpers by different names:
19:58bbloomhttp://ruby-metaprogramming.rubylearning.com/html/seeingMetaclassesClearly.html
19:58lynaghkbbloom: thanks!
19:59bbloomlynaghk: i've got to run, but basically just study how metaclasses work and maybe peek at the source of some popular DSLs to see how they function
19:59bbloomgood luck :-)
20:00technomancyoh man, I thought for sure "metaprogramming is easy via string interpolation" was making fun of ruby
20:00scriptorisn't that perl?
20:03mdeboardyeah. everyone knows metaprogramming via string interpolation is done best with Python https://gist.github.com/16010d1fcda091024bc8
20:07nDuffQuestion about Emacs Live -- how does one get out of its open dialog without actually selecting anything? <ESC> <ESC> <ESC> doesn't work anymore...
20:08Bergle_1nDuff - ctrl-g
20:08squidzwhats the easiest way to use a anyonmous partial function in clojure? I want to do something like (reduce (partial (fn [x] ...
20:08nDuffAhh; thanks.
20:08Bergle_1nDuff = hangon esc stops for me as well
20:08ChongLiC-g becomes such a habit in emacs
20:08ChongLithat I hit it in other programs too
20:08technomancyESC ESC ESC is equivalent to C-g
20:09Bergle_1just ESC once stops it for me.
20:09Bergle_1oh.
20:09Bergle_1ive had emacs live just out and crash on me 3 times yesterday :( not to happy aobut it.
20:09Bergle_1also amazed they changed ctrl-v :(
20:10squidzbut I get wrong number of argument exceptions
20:10ChongLiBergle_1: scroll-up-command
20:10ChongLiwhat did they change it to?
20:10technomancythat's just crazy
20:10Bergle_1repeat last i think.
20:10ChongLithat doesn't make any sense
20:11ChongLiC-x z does repeat for me
20:11Bergle_1repeat last execute
20:11ChongLiI use scrolling way more than repeat
20:11Bergle_1as in "." in vim.
20:14squidzhttps://www.refheap.com/paste/7290
20:18antoineBhello
20:18ChongLihi
20:18antoineBis it possible to change the clojure[script] reader for parsing anything?
20:20ChongLiafaik clojure doesn't have user-definable reader macros (a la CL)
20:21ChongLiso if you want to work with some arbitrary (non-clojure) syntax you'll have to write your own reader or parser
20:21antoineBok
20:22antoineBhiccup style also possible
20:22ChongLiyeah hiccup just embeds a dsl in clojure syntax
20:28tickingdoes anybody know whats up with the misterious deps.js file with clojurescript ^^?
20:29tickingI assume it hase something to do with external libs and closure, but I'd be interested if it is of any significance to clojurescript development ^^
20:30antoineBit is marked as missing?
20:31tickingantoineB yeah ^^
20:31antoineBremove your main.js and rebuild it
20:31antoineBmake sure you run your experiment on a webserver, not localhost
20:32tickingantoineB, hm interesting, why is that important?
20:33tickingantoineB, I cleaned and recompiled without change, probably because of that localhost thing
20:33tickingnevertheless I'd be intrigued to know why this could make a difference :D
20:33antoineBticking: clojurescript repl don't works on localhost
20:34tickingantoineB, I never used it's repl so far, autobuild always sufficed :D
20:35antoineBticking: try serving your stuff with a webserver
20:35tickingantoineB, k any quick reccomendations :]
20:36antoineBrecomendations for what?
20:36tickingquick and dirty webservers for noir ^^
20:37antoineBi use cherokee
20:37tickingthanks :D
20:37antoineBnothing special, you setup a new name in /etc/hosts
20:39antoineBticking: i probalbly wrong, noir use jetty or netty
20:39antoineBnevermind cherokee
20:40tickingantoineB, hrhr, k when there's not _the_ obvious solution I'll do some research ^^
20:40tomojhmm, I use localhost for my repl
20:40tomojjust file:/// doesn't work, I think?
20:41antoineBtomoj: you right i made a mistake, that is file which don't work
20:42antoineBticking: i remmember how i resolved it with noir
20:43antoineBi make a fake deps.js in ressources/public :)
20:44tomojjust add <script type="text/javascript">var CLOSURE_NO_DEPS = true;</script> before your cljs script
20:44tomoj
20:46tickinghrhr
20:46tomojso satisfies? is slow, huh?
20:46muhooit may be slow, but it is so satisfying.
20:48tomojnoticed cheshire is doing (get (:impls JSONable) (class obj))
20:48tomojwhich fails if (deftype Foo [] JSONable ..)
20:49tickingtomoj, yeah that did the trick, turning on advanced optimisations seems to be the third way to solve it, I'm still wondering what it is used for :D
20:49tickingthanks
20:50tomojsatisfies? being slow makes me want to go ahead and take all my (if (satisfies? Foo foo) (-foo foo) ...) and just make the ... a default impl of the protocol :/
20:51amalloytomoj: i think that's the intended use case for default protocol impls, right?
20:51tickingalright thanks for the fish and good night :D
20:53tomojamalloy: dunno.. the fact that satisfies? becomes useless has made me wonder if there are even any good use cases for default impls at all
20:53tomojI guess if you can provide an impl for everything, then it makes sense for everything to satisfy
21:09amalloysatisfies? is a bit yucky by definition, i think. it's runtime introspection of the polymorphic structure, rather than just...using polymorphism
21:42squidzI feel like i'm having to reinvent the wheel while coding in clojure. I have to implement lot of basic functionality like get the nth element of an vector, or combine two vectors. Am I missing something?
21:42amalloy&(doc nth)
21:42lazybot⇒ "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
21:42amalloy$findfn [1 2 3] [4 5 6] [1 2 3 4 5 6]
21:43lazybot[clojure.set/union clojure.core/lazy-cat clojure.core/concat clojure.core/into]
21:43squidzsorry i meant remove the nth element from a vector
21:44amalloyneither of those operations are things that vectors can do efficiently, so there's no built-in to encourage you to be inefficient
21:45squidzwhat should I use instead of vectors for that then?
21:45amalloyusually lazy sequences, since you'll usually find you don't need indexes at all, just a stream of items
21:46amalloyusing nth is a pretty rare event for me
21:46squidzi am usually doing matrix type operations
21:46squidzworking with rows and columns
21:47amalloysure, and vectors are great for that. but you don't need to remove items
21:47amalloyor concat two matrices
21:47squidzso far ive just ben using vectors like so [[1 1] [2 2]]
21:47squidzi have to manipulate the values in the matricies usually
21:48amalloyso? assoc, assoc-in, update-in, get, and get-in are all you need
21:48amalloy&(update-in [[1 1] [2 2]] [0 1] inc)
21:48lazybot⇒ [[1 2] [2 2]]
21:49tos9&(doc get-in)
21:49lazybot⇒ "([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied."
21:49tos9&(doc get)
21:49lazybot⇒ "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
21:50squidzokay, i think i'm just not familiar with those functions yet. I haven't seen assoc-in/update-in/get-in
21:51amalloyyes, those are the functions you want. if you had functions named remove-nth and combine-vector, they'd be terrible for matrix operations :)
21:52squidzi just made these functions that deal with manipulation https://www.refheap.com/paste/7292
21:53squidzn-col and n-row return the nth row/col or return everything excluding row/col when a negative index is passed
21:54tomojb
21:54squidzwas there any way I could have avoided those functions?
21:57squidzamalloy: or is there anyway I could have used clojure'S built-in functionality more when writing my functions?
23:19patrickgombertquick language question, why don't protocols work like interfaces? Is there a reason for only having to implement a part of a protocol?
23:21tomojthey sort of do work like interfaces, in that it is similarly possible to implement only part of an interface in clojure
23:21tomojI don't know the answer you're looking for, though :)
23:22patrickgombertIn Java, for example, it's a compile error to not implement the whole interface. In clojure, however, it's not a requirement to implement the whole protocol
23:22ohpauleezpatrickgombert: Also, you can use protocols as a form of safe monkey-patching to redefine behavior/participation, so you'd want piecewise definitions then
23:22patrickgombertAh, that makes sense
23:23patrickgombertis there a construct more binding, like an interface, that requires all functions to be implemented?
23:23ohpauleezProtocols specify behaviors you want to participate in (the interfaces to larger systems/components). If you want to participate in only a part of that system, so be it
23:24ohpauleezpatrickgombert: You most likely do not want to do that. There's no real advantage
23:24ohpauleezbut if you're dying for some raw interface action: http://clojuredocs.org/clojure_core/clojure.core/definterface
23:25patrickgombertthanks
23:25tomoj..but again, clojure will happily allow you to leave out methods in an interface implementation
23:25ohpauleezagain, I strongly encourage you to make use of protocols and frame your problem in terms of participation and composition. It might help you get more mileage out of them
23:32alex_baranoskycan you add docstrings to the individual methods of a protocol?
23:32alex_baranoskyif so, anyone have an example link?
23:33tomoj..see (doc defprotocol)
23:35alex_baranoskytomoj: shows no way of doing so… but it looks like defprotocol is in fact generating vars for each methos
23:35tomojyour docs must be different than mine
23:36tomojbut since defprotocol was added in 1.2, and the 1.2 docs show an example of this, not sure how.. http://clojuredocs.org/clojure_core/1.2.0/clojure.core/defprotocol
23:37ohpauleezalso here at 1.3: http://clojuredocs.org/clojure_core/clojure.core/defprotocol
23:37ohpauleezalex_baranosky: The short answer is they go at the end
23:37alex_baranoskythanks guys
23:37ohpauleeznp
23:37ohpauleeztotally welcome
23:38tomojwonder if clojuredocs will ever disappear
23:38alex_baranoskyneither link shows doc strings do they?
23:38alex_baranoskyI'm doing this, but it seems ridiculous to have to: (alter-meta! #'not-a-map-error assoc :doc "asdffdsfasfd")
23:39alex_baranoskyoh I see
23:39alex_baranoskythanks guys!
23:39ohpauleezalex_baranosky: (deprotocol SomeProto "This is about this behavior" (take-one [this] "take one thing from it"))
23:39tomojclojure-doc.org doesn't seem to do well on google yet
23:39ohpauleeztomoj: hopefully that'll change in the future
23:40alex_baranoskythat syntax is unfortunately not what you'd expect… but I'll live :)
23:40ohpauleez:)
23:42alex_baranoskyI like to write tests like this for my open source projects:
23:42alex_baranosky(is (= [] (map str (remove (comp :doc meta) (vals (ns-publics 'clj-schema.schema))))))
23:59Knortomoj,
23:59KnorI am the best programmer in the world save only for the microsoft Chief Software Architect