#clojure logs

2013-03-29

00:01thm_proverdnolen: Professor Nolen, why is http://hpaste.org/84801 invalid match code?
00:03technomancy,(apply merge-with #(if (coll? %1) (conj %1 %2) [%1 %2]) '(["tyler" 23] ["tyler" 34] ["don" 64]["don" 82]))
00:03clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map$Entry>
00:04technomancyyou get the idea
00:04dnolenthm_prover: are you doing this in ClojureScript?
00:04thm_proverdnolen:, no in clojure, cljs is "list of files ending with *.clj"
00:04tylertechnomancy: thnx
00:04thm_proverdnolen: yeah, sorry about bad var name
00:06dnolenthm_prover: lists are special in core.match, they denote some special syntax
00:06dnolenthm_prover: dont use () use []
00:07dnolenadmitted it should give you a more sensible error
00:08technomancyis there a gsoc project to fix that? =)
00:08thm_proverdnolen: ah, https://github.com/clojure/core.match/wiki/Overview has it under "Special Syntax"
00:10dnolentechnomancy: heh :)
00:17`arrdemhum... fnparse is mucking with me agian and this time it isn't a function of my return values.
00:18`arrdemhttps://www.refheap.com/paste/13067
00:18thm_proverdoes (java.io.File. ...) actually open the file (and thus use up a descriptor), or does it just create a File object?
00:20technomancythm_prover: the latter
00:20technomancyyou need to create a reader or input-stream to open it
00:21thm_provertechnomancy: are the following two staements correct? (1) I do not need to manually close it and (2) I do not need to use with-open
00:21technomancytrue of a File object, sure
00:22thm_provertechnomancy: great, thanks!
00:22technomancy,(isa? java.io.File java.io.Closeable)
00:22clojurebotfalse
00:22technomancynp
00:24muhoois this already in clojure somewhere, and did i reinvent the wheel? https://www.refheap.com/paste/13068
00:25`arrdemI think I've seen this before... but I won't say for certain.
00:25`arrdemno that was core/replace
00:25muhoomy brain thinks in SQL, so i was trying to make a function to do f to all values in column y in a "database", can't help thinking of lists of maps as rows in an sql database
00:26`arrdemmuhoo: I think you're in the clear here.. nice snippet too. core/replace is the only similar thing I've seen and that just takes a replacement map not an update-fn map
00:31muhoo`arrdem: thanks. i've been hammocking that snippet all day, finally took a walk to the grocery store and went "oh! duh!" on the way back.
00:31supersymassoc keys can't be variables? Key must be integer exception
00:32dnolensupersym: you probably have a simple error somewhere in your code
00:32dnolen,(assoc [0 1 2] nil :hello)
00:32clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
00:33supersym(defn update-atom [n] (swap! section (assoc @section n 1)))
00:33dnolensupersym: somehow n is not an integer
00:34momomomomoI've never seen that bot before; that's neat.
00:34supersymyes very :)
00:34muhoomomomomomo: there's two of 'em, never can keep them straight
00:34muhooone is , the other is &&, i think.
00:34momomomomohaha, I like it.
00:35momomomomoThis weekend is the weekend! Only a few projects to work on, and I'll for sure (hopefully) have some time to finally crack open a clojure book
00:36supersymweird (update-atom 3) is an integer I think
00:36dnolensupersym: your swap! is wrong
00:36dnolen,(doc swap!)
00:36clojurebot"([atom f] [atom f x] [atom f x y] [atom f x y & ...]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in."
00:37supersymah
00:37dnolensupersym: you don't need those parens, not deref of section
00:37dnolens/not/nor
00:37supersymparens did it
00:37dnolen(swap! section assoc n 1)
00:37supersymthanks m8!
00:37dnolensupersym: make sure to remove @section too
00:40supersymriiight... how did I get that wrong. Cue to get to bed
00:41supersymthanks a bunch for the insights/aid
00:58augustllooking for some tips on how to do websockets from a Clojure app. Thinking I'll just deploy with java -jar. I've used Faye with Node.js before, and it seems it should work fine with the comet.d Java lib. Any other suggestions?
00:59augustls/websockets/websockets with xhr fallback/
00:59`arrdemso what's the difference between next and rest?
01:01amalloy&((juxt next rest) [1])
01:01lazybot⇒ [nil ()]
01:01`arrdemfeh ok
01:01`arrdemcheers amalloy
01:02dnolen`arrdem: rest can be lazy, next isn't
01:03`arrdemthat makes more sense. thanks dnolen.
01:27`arrdemmaybe-m just escapes at the first nil return value, right?
01:31amalloydepends whose implementation of maybe-m, `arrdem. that's what algo.monads does, but that's breaking the monad laws: using nil for Nothing means it's impossible to represent things like Maybe Maybe Int
01:33`arrdemamalloy: okay.. I think I understand that but I sure don't grok it.
01:33SegFaultAX`arrdem: Are you just curious about monads or are you trying to do something in particular?
01:34`arrdemSegFaultAX: so at the moment I'm trying to trace a bug that's somewhere between Factual/fnparse and monads since I seem to be able to reproduce it no matter what the return values from my code are.
01:35`arrdemhowever my monad-foo is weak and I need to understand them it seems before I can really follow what's going on under the covers here.
01:36`arrdemthat said it's 0035 and this project was due at 0000 so I may just hit the sack and look at this again after I get 8.
01:36SegFaultAX`arrdem: Clojure is probably a less than ideal language to learn about Monads in. May I suggest this: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
01:37SegFaultAX`arrdem: The material is not necessarily to Haskell and the introduction is sufficient to get you started assuming you already have a solid understanding of type system fundamentals.
01:40tomojconsider a protocol fn which returns either another object of the same type as `this`, or nil
01:40tomojcan we eliminate truth calls in some other way than (if (nil? (f this)) ...) ?
01:42tomoj..if you tag it boolean, it will be marked as a safe test, and it will actually be safe, even though it's not boolean?
01:42tomojs/protocol//
01:43tomojlooks like the 'seq tag has a closer meaning
01:43SegFaultAXtomoj: Why not just (if (f this) ...)
01:44SegFaultAXtomoj: nil is false in a boolean context.
01:44tomojbackground: in cljs, (if x y z) emits a call (cljs.core/truth_ x) if x is not known to be safe to put directly in a JS if test
01:45SegFaultAXtomoj: Ah, cljs.
01:47`arrdemSegFaultAX: good post, thanks
01:48`arrdemgah 10 to read that? I'm worthless good evening gents
01:48tomojdnolen: would you consider a patch which just adds a direct 'safe-test pseudotag, for use in performance sensitive code (similar to not-native)?
01:49tomojhmm
01:49tomojit wouldn't really be similar to not-native though, because I'd be tagging my public api functions 'safe-test
02:05ivanare there any reasons to have multiple classloaders other than class reloading (in the miraculous case where you manage to lose references to all objects) and tiny performance improvements in initial loading?
02:06ivanI guess I'm really asking if OSGi and similar do anything useful than I couldn't do in a hundred lines of clojure
02:40amalloyhuh? of course there are reasons. for example, clojurebot can run under clojure 1.2 and also have clojure 1.5 loaded for when he evaluates user code (i think he actually does this, but i could be way off)
02:42amalloyif there were only one classloader, what class would be called clojure.core$read? does it support #inst literals, or not? with one classloader for each clojure version, there are two classes named clojure.core$read
02:43amalloylikewise, a repl would be impossible with just one classloader: once you define user$foo by (defn foo [] 1), you can't possibly change it with (defn foo [] 2), because classes, once loaded, are immutable
02:44amalloyivan: ^
02:46tieTYT2i'm writing my first clojure project. I notice most of my functions start with a "let" and declare 2-3 things. Each result is usually passed in as a parameter to the next. The function body usually is just the last value of the "let". Does it sound like I'm doing something wrong?
02:49ivanamalloy: ah, thanks. I knew about the REPL case but forgot about about multiple versions
02:49tieTYT2here's an example: https://www.refheap.com/paste/b7e696a9b4fc50e03bf00f084
02:50tieTYT2does that look wrong?
02:50amalloytieTYT2: there's nothing wrong with that, if you think the names for the intermediate results help readability
02:50tieTYT2not only that, it would just be a nested mess if it was all together
02:51amalloyIMO it reads better as just (map get-url-to-image (html/select post image-links)), but that's a matter of taste
02:51amalloyyou don't get to call anything a nested mess unless it has at least ))))) in it somewhere
02:51amalloyand i'll probably disagree with you unless it has at least ))])}))])
02:52scottjtieTYT2: I suspect most clojurists would write that with no let. If you don't like the nesting, you can use threading (-> and ->>)
02:52tieTYT2yeah I learned about threading after I wrote this
02:52tieTYT2amalloy: what's your opinion on scottj's comment?
02:53tieTYT2(fight fight fight)
02:53amalloy*shrug*
02:53tieTYT2actually, I was more concerned about, "You're doing functional programming all wrong!" more than anything
02:53scottjtieTYT2: I agree with amalloy :) there's nothing wrong with the lets if you like them
02:53tieTYT2and it sounds like I'm not doing that, at least in an obvious way from this snippet I assume
02:55tieTYT2ok thanks for the help guys
03:29cornotahti,"I worship His Shadow"
03:29clojurebot"I worship His Shadow"
03:33cornotahti,(print "I worship His Shadow")
03:33clojurebotI worship His Shadow
05:07supersymis it ok to use functions as values for atomic hash keys like (atom {:player 1 :ops inc})?
05:08mpfundsteinsupersym: thats the whole point of first class functions
05:08supersymthats what I thought maybe atom was a 'special case' though
05:08supersymsorry for asking the obvious ><
05:08mpfundsteinsupersym: :-) no prob
05:08supersymyeah.... me like :)
05:08mpfundsteinsupersym: maybe you want to read the Joy of Clojure
05:09mpfundsteinsupersym: there is a nice chapter about handling such things
05:09supersymah yea...thnx
05:09supersymi should buy it :)
06:01squidzi'm trying to use the Shoreleave library for ajax calls, but I am getting a 404 not found error for localhost:5000/_shoreleave. Does anybody have any experience with this? anybody know why the middleware isnt creating the routes
06:04WillyfrogI probably can't help, as I'm pretty new, but you should probably show the code for defining your server accepted routes
06:05WillyfrogI suppose you are using compojure for the server, right?
06:08squidzyes
06:08squidzWillyfrog: here is a paste https://www.refheap.com/paste/13080
06:09Willyfrogyou haven't defined a _shoreleave route
06:09Willyfrogyou have /, but no /_shoreleave, I mean
06:09squidzas far as I know, the middleware should do that
06:09squidzbut maybe not
06:09squidzwhat should I pass as the handler though?
06:20Willyfrogno idea :S, sorry
06:21Glenjaminsquidz: a quick look at the source implies that you're loading the old namespace
06:21Glenjaminhttps://github.com/shoreleave/shoreleave-remote-ring/blob/master/src/shoreleave/middleware/rpc.clj
06:21Glenjaminvs https://github.com/shoreleave/shoreleave-remote-ring/blob/master/src/cemerick/shoreleave/rpc.clj
06:25squidzGlenjamin: ah yes, I was confused to which one I should use ill see if switching helps
06:27squidzso the source with shorleave.middleware.rpc is the newer version
06:50borkdudeI'm watching Simple made easy. Doesn't Clojure complect the language and it's hosting platform? =)
06:52borkdude*ducks*
06:53ucbheh
06:53Willyfrogwhy do you think so?
07:02squidzWillyfrog: okay I am using the right namespace now, but for some reason still getting the error
07:03Willyfrogit was Glenjamin who helped you ;) as I said, I haven't used that library
07:03squidzoh sorry I mean Glenjamin then
07:40TimMchiredman, Raynes, amalloy_: Y'all run sites/bots with REPLs with untrusted users. Would your security be affected by this patch? http://dev.clojure.org/jira/browse/CLJ-1176?focusedCommentId=30840#comment-30840
07:54squidzRaynes: for some reason I cant seem to edit pastes on refheap using the alt+ctr+e
08:31yedirecently realized that chinese programmers have to just memorize arbitrary pictures/blobs of text yet some are still able to program at high levels
08:31yediso http-kit makes me happy
08:31supersymwhat
08:32supersymthey arent arbitrary are they
08:33yediwell i'm speaking for the majority that don't understand english
08:38Willyfrogyou only need a couple of words in "english" to be able to program
08:39Willyfrogthere are many people with a bad grasp of english who can program (with variyng degree of hability)
08:45supersymright
08:49cornotahtiyedi, well, truth be told, some of the names of stuff also don't really make sense in English.
08:49cornotahtiAnd really, if it were Latin no one would care.
08:49cornotahtiIt's easy enough to memorize si for if.
09:05TimMcIt's not as if langauge keywords even mean what they say in English.
09:05TimMcThe names are just mnemonics that help you remember/guess/internalize their actual meanings.
09:07TimMc"reduce" can make a thing bigger than the input, "map" refers to a bit of mathematical jargon that I've only seen in linear algebra, "or" is different than the "or" we use in conversational English...
09:07Glenjamini don't see how or is different
09:07john2xanybody else having trouble skipping ahead through blip.tv videos? 
09:08borkdudejust my opinion: localized formulaes in Excel drive me nuts (my Excel version assumes Dutch)
09:08Glenjamini presume the bigger issue with localisation is fragmentation, rather than understanding
09:09TimMcborkdude: That's the worst.
09:09TimMcGlenjamin: In English, "or" usually means xor, whereas in Clojure and basically every other PL it means inclusive or.
09:10Glenjaminoh, i see
09:10Glenjamingood point
09:10TimMcHence the oft-used joke: "Would you like pizza or bagels?" "Yes!"
09:11borkdudeTimMc indeed, this also drives me nuts, because a lot of the times I don't know if people really mean xor or inclusive or
09:11TimMc(among programmers and mathematicians, at least...)
09:11borkdudeTimMc and if you ask for clarification on the subject, sometimes they don't even understand the difference
09:12TimMc:-(
09:12borkdudein our building is a sign: Don't eat and drink in the lecture room. Some have interpreted this as: don't do it at the same time.
09:17jcromartiesexy music + Clojure programming = weird feelings
09:17jcromartiebut I am OK with who I am
09:19jcromartiethe Clojure Programming book really promotes the point-free style eh
09:26jcromartieI feel like midje is great but I'm missing something
09:26jcromartieare facts really intended to be declared at the top level?
09:28jcromartieI think I'm just thrown off by the fact that loading facts runs them, so I feel like side effects are happening by just loading the namespace but that's not what's going on
09:35jemafellerwhats a functional way to go from ["a", "b", "c"] to ["a", "ab", "abc"]
09:36jemafellerI'm thinking reduce left but i think i have side effects there
09:37borkdudejemafeller mapv
09:37borkdudejemafeller no wait, I responded too fast ;)
09:37borkdudejemafeller reductions
09:37jemafellerreductions?
09:38borkdude,(reductions concat ["a", "b", "c"])
09:38clojurebot("a" (\a \b) (\a \b \c))
09:38jemafelleroh, neat!
09:38Glenjamin,(doc reductions)
09:38clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
09:38Glenjaminoh, clever
09:39jemafellerbut what's
09:39jemafeller\a \b
09:39borkdude,(reductions #(apply str (concat %&)) ["a", "b", "c"])
09:39clojurebot("a" "ab" "abc")
09:39jemafellera reference?
09:39borkdudejemafeller those are characters
09:39jemafellerit moves from string to characters freely?
09:39Glenjamin,(= "ab" '(\a \b))
09:39clojurebotfalse
09:40borkdudeah wait, even simpler:
09:40borkdude,(reductions str ["a", "b", "c"])
09:40clojurebot("a" "ab" "abc")
09:40borkdudeif you want a vector, wrap vector around it:
09:40borkdude,(vec (reductions str ["a", "b", "c"]))
09:40clojurebot["a" "ab" "abc"]
09:41jemafellerperfect
09:59jemafellerperfect
09:59jemafelleroops
10:11supersym,(defn board (let [field 0 box (apply vector (repeat 6 field))] (atom {:box1 box :box2 box})))
10:11clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Parameter declaration let should be a vector>
10:12borkdudesupersym def
10:12supersymthought so
10:13supersymwould there be a way to combine key values within the hash-map? like :area box1 box2 ..
10:13borkdudesupersym use a vector or something
10:14supersym(atom {:box1 box :box2 box :area ?)
10:14borkdudesupersym I don't know what you're trying to do, but if you need multiple values under one key, you can do ##{:a [1 2], :b [3 4]}
10:14lazybot⇒ {:a [1 2], :b [3 4]}
10:15supersymthank you
10:15supersymthat was it!
10:15jemafelleri'm find myself doing a ton of work inside a let block - is that normal?
10:15borkdudejemafeller try looking at ->, ->> or as->
10:15jemafelleri mean, turns out almost all of my code is in the let block
10:17borkdudegtg
10:17supersymduplicate key... hm
10:18supersymi get it
10:21jemafelleris there a primitive to process a collection over another collection?
10:21jemafellerlike [1,2,3] and [a,b,c] and now map with 1 and [a,b,c] then 2 and [a,b,c] etc
10:25`arrdemmornin
10:27skelternetGood morning!
10:31ToBeReplacedis there a shorthand function for (zipmap xs (map f xs)) ?
10:38stuartsierrajemafeller: Perhaps you want (map f [1 2 3] (repeat [a b c]))
10:38ystaelToBeReplaced: clojure.algo.generic.functor/fmap
10:39mikerodjemafeller: If you mean you want to apply a list of functions to a collection with map, you could do something like (map (compose f1 f2 f3) [a b c d e]).
10:40jemafelleri see.. i kind of did (map (fn (map …) ) ..)
10:41ToBeReplacedystael: not quite, but that is cool
10:41jemafelleralso is tuple or vector preferred if I want to generate pairs of things?
10:42ystaelToBeReplaced: sorry, I completely misread your code :|
10:42ToBeReplacedjemafeller: usually vectors
10:43ToBeReplaced,(seq {:foo 1 :bar 2})
10:43clojurebot([:foo 1] [:bar 2])
10:43jemafelleris vectors the most light weight for this?
10:44supersymHow would one add a .jar reference inside the repl, ns macro? I know I'm supposed to use leiningen for this (want to play with incanter a bit) but I was wondering if anyone ever does this, if it is a pain...or
10:44supersymcould be part of the reason leiningingen was made in the first place, i don't know just curious :)
10:45stuartsierrajemafeller: Clojure doesn't have a built-in "tuple" type. Vectors are it.
10:48nDuffjemafeller: ...since vectors are immutible, they're usable as keys just as Python's tuples are.
10:49nDuffjemafeller: '(1 2), by the way, is a list -- and unlike a vector, lists aren't set up for fast random access.
10:52gtrakhey, any classlojure guys here? We're trying to use it and wondering why it doesn't do print-dup on returned objects from eval-in-cl, it calls RT/printString.
10:53ToBeReplacedWhat core function does (fn [f x] (f x)) ? (not apply...)
10:53bbloomToBeReplaced: isn't that just f ?
10:53jcromartieyeah the value itself should suffice
10:54ToBeReplaced(!= (f f x) (f x))
10:54ToBeReplacedi need it for a merge-with
10:55ToBeReplaced,(merge-with (fn [f x] (f x)) {:foo inc} {:foo 1})
10:55clojurebot{:foo 2}
10:55bbloomoh misread.
10:55gtrakninjudd: ^^ re: classlojure
10:58ravsterWhen doing a 'lein deps', I'm getting the leinjacker-0.3.3 from clojars instead of 0.4.1. I don't understand why this is, since lein-ring is at the 0.8.3 version, which asks for leinjacker-0.4.1. How do I fix this?
10:58bbloomToBeReplaced: i don't think there is any such core function for "call" instead of "apply" in the javascript sense of those names
10:59ravsterI've already tried deleting leinjacker and lein-ring from my .m2 directory.
10:59ToBeReplacedbbloom: yeah i can't find one... first time i've ever had it come up
10:59weavejesterravster: It's likely you have a plugin or dependency that references the old version.
10:59weavejesterravster: Check your ~/.lein/profiles.clj file for out of date plugins
10:59bbloomthere isn't really much need for one, since there would never be any advantage over calling the function directly
10:59ravsterweavejester: okay
11:00bbloomthinking aloud: javascript only provides .call in addition to .apply because .call accepts a target "this" argument
11:00ravsterI don't have a .lein/profiles.clj, weavejester
11:00weavejesterravster: If you run "lein deps :tree" in your project directory, is lein-jacker referenced anywhere?
11:00jcromartieI hear people aren't wild about midje?
11:00jcromartieI like core.test well enough
11:01ravsterI thought that lein-ring would download the dependencies and versions that it needs too, instead of just working with whatever another lib wants.
11:01ravsterweavejester: will try that
11:01weavejesterravster: You might also want to check which plugins are being loaded in the project.clj directory
11:01weavejesterravster: It does, but you can only have one version of a library loaded in the classpath, so another plugin might take priority.
11:02bbloomToBeReplaced: i think your little (fn [f x] (f x)) is clearer, but if you want to 1) support variable arities or 2) be slightly more cryptic: #(apply %1 %&)
11:03bbloom,(#(apply %1 %&) + 5 10 15)
11:03clojurebot30
11:03ravsterweavejester: weird. leinjacker isn't anywhere in the output of "lein deps :tree"
11:04ToBeReplacedyea or just #(%1 %2) in the single arity case
11:04TimMcravster: lein-ring has a version range dependency on lainjacker :-(
11:04TimMc*leinjacker
11:04weavejesterravster: I don't think lein deps :tree shows plugin dependencies, so it was a bit of a long shot.
11:04weavejesterTimMc: A version range dependency?
11:05TimMcThe result is that you get some pretty weird dependency resolution behavior.
11:05ravsterTimMc: noooooooo . I get weird vector? (:dependencies ...) errors with 0.3.3, and its a closed issue on lein-ring with the solution of just using the latest leinjacker.
11:05TimMcHmm, now I can't find it...
11:06ravsterhttps://github.com/weavejester/lein-ring/issues/61
11:06weavejesterTimMc: Lein-Ring depends on Lein-Jacker 0.4.1, not a version range
11:06weavejesterravster: What other plugins do you have in the project?
11:07ravsterthe plugins are lein-beanstalk, -datomic, and -ring
11:08weavejesterravster: Which versions?
11:08TimMcweavejester, ravster: Cancel that, I was thinking of lein-guzheng.
11:08TimMchttps://github.com/dgrnbrg/guzheng/issues/8
11:08TimMc...which is probably the culprit here.
11:09weavejesterravster: lein-datomic uses leinjacker 0.3.3
11:10weavejesterravster: If you remove lein-datomic from your plugins, lein-ring and other plugins that use lein-jacker should work okay.
11:12ravsternooooooo, lein-datomic
11:12ravster*grumble, grumble*
11:12ravstercool, thanks weavejester
11:12TimMcravster: You should be able to exclude that dependency from lein-datomic but still use it.
11:13ravster*eye-brow raise*
11:13ravsternice, didn't know i could do that.
11:15ravsterwill look into it
11:15aroemers[A
11:15aroemers[A
11:15aroemerswhoops
11:22jcromartieI am *really* confused about the deprecated fns in clojure.java.jdbc
11:22jcromartiewhy in the world would they deprecate all of the primary functions in the example code?
11:22jcromartiewhat's the alternative?
11:23jcromartiejeezus the whole thing is practically deprecated...
11:23asteve,~
11:23clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading character>
11:23nDuffwell, for delete-rows the obvious alternative is delete!, for connection it's db-connection...
11:23asteve,(help ~)
11:23clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
11:23astevewhat does ~ do?
11:24jcromartienDuff: every single fn used in the example code is deprecated in 0.3.0… maybe that's just a forward-looking thing?
11:24nDuffasteve: ~ is unquote
11:24nDuffasteve: so, if you have `[foo ~bar], then everything but the bar is quoted
11:24nDuffasteve: see http://clojure.org/reader
11:25nDuffasteve: ...notably, unquote only works inside syntax-quote, which is ` as opposed to '
11:25astevenDuff: thanks
11:29borkdude,`~+
11:29clojurebot#<core$_PLUS_ clojure.core$_PLUS_@37c9ec>
11:29borkdude,`~,
11:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
11:31Glenjaminheh, helpful compiler error :D
11:33nDuff...well, it's a _reader_ error; the compiler isn't involved yet :P
11:33borkdude,`~#{#{}#()[]}
11:33clojurebot#{#{} [] #<sandbox$eval35$fn__36 sandbox$eval35$fn__36@1336fcf>}
11:34astevethis may be a very novice question but why would I want to dereference a function?
11:35nDuffasteve: IFn isn't dereferencable in and of itself.
11:35nDuffasteve: what's the context?
11:35astevenDuff: http://i.imgur.com/Loc0p52.png
11:36nDuffasteve: ...so, that isn't a dereference...
11:36nDuffasteve: ...it's an unquote-splice
11:36bbloomasteve: sadly, ~ and @ are tokens, but ~@ is a single token
11:36asteveah
11:36borkdude,(let [x '(1 2 3)] `[x ~@x])
11:36clojurebot[sandbox/x 1 2 3]
11:37borkdude,(let [x '(1 2 3)] `[~'x ~@x])
11:37clojurebot[x 1 2 3]
11:37borkdudeargh
11:37bbloomyeah, it's (clojure.core/unquote-splicing x) instead of (clojure.core/unquote (clojure.core/deref x))
11:37borkdude,(let [x '(1 2 3)] `[~x ~@x])
11:37clojurebot[(1 2 3) 1 2 3]
11:37bbloomif you actually DID want a deref inside an unquote, you'd need to do something like ~(deref x) or ~(-> @x)
11:38bbloomshoulda been ~& or something else less ambiguous :-)
11:38borkdudebbloom yeah, I like ~&
11:41astevemore novice questions, (1 2 3) is a sequence?
11:41borkdudeasteve '(1 2 3) or (list 1 2 3) is a normal list, but sequences get printed the same as lists
11:42borkdude,(map inc [1 2 3])
11:42clojurebot(2 3 4)
11:42borkdude,(type (map inc [1 2 3]))
11:42clojurebotclojure.lang.LazySeq
11:42borkdude,(list 2 3 4)
11:42clojurebot(2 3 4)
11:42borkdude,(type (list 2 3 4))
11:42clojurebotclojure.lang.PersistentList
11:42asteve,(2 3 4)
11:42clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
11:42asteveok
11:43borkdudeasteve the list representation is also a way to call functions, so now you are trying to call 2 as a function on 3 and 4
11:43asteveborkdude: right
11:43astevemy confusion is in and around people interchanging `(1 2 3) and [1 2 3]
11:43asteve[1 2 3] is a vector?
11:44borkdudeasteve yes and vectors are kind of the default for sequential data over lists which you normally only use in macro's
11:44jcromartieoops I made a document database :|
11:44asteve,(= `(1 2 3) [1 2 3])
11:44clojurebottrue
11:44jcromartienot one that actually makes any sense, mind you
11:45borkdudeasteve this is true because = compares contents of collections
11:45borkdude,(doc =)
11:45clojurebot"([x] [x y] [x y & more]); Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison."
11:46Willyfrog,(type '(1 2 3))
11:46clojurebotclojure.lang.PersistentList
11:46asteve,(type [1 2 3])
11:46clojurebotclojure.lang.PersistentVector
11:46Willyfrog,(type [1 2 3])
11:46clojurebotclojure.lang.PersistentVector
11:46Willyfrog;)
11:46asteve,(type `(1 2 3))
11:46clojurebotclojure.lang.Cons
11:49jemafelleris there any 'finally' in clojure?
11:49Glenjaminyes
11:50Glenjaminhttp://clojure.org/special_forms#Special%20Forms--%28try%20expr*%20catch-clause*%20finally-clause?%29
11:50asteve,(type `(1 2))
11:50clojurebotclojure.lang.Cons
11:50asteveso it's a constant but it's still a sequence, right?
11:51weavejesterasteve: Cons doesn't mean constant, if that's what you're thinking.
11:51technomancyhttps://en.wikipedia.org/wiki/Cons
11:51asteveweavejester: that is what I was thinking
11:51astevefoolish of me
11:52technomancythat said, looking at the underlying classes of lists is a good way to go crazy =\
11:52weavejesterasteve: It's a natural assumption if you haven't happened across cons cells before
11:58squidzcemerick: I am having a problem with the namespace change in your shoreleave-remote-ring library. I was getting a 404 not found error for the default /_shoreleave route, and I found out I was using the wrong namespace in my declarations. After changing it to shoreleave.middleware.rpc I am still getting the error. Do you have any ideas?
11:59squidzI can also verify in the repl that the default-remote-uri var points to "/_shoreleave"
12:01jemafelleri'm trying to guarantee a return of a resource to a pool.. with try/finally but seems to not work (scope of definition)
12:01jemafelleram I doing it wrong?
12:02nDuffjemafeller: Could you provide more detail about what you're doing and how it's failing?
12:02jemafellerlooks similar to this https://groups.google.com/forum/?fromgroups=#!topic/clojure/hsh-H8SxNHw
12:03cemericksquidz: I'm aware of the issue, though haven't dug into it (ohpauleez did the ns refactoring, and I'm still using the older bits). There's an issue for the documentation issue (https://github.com/shoreleave/shoreleave-remote-ring/issues/6). Make sure you're applying the wrap-rpc middleware properly?
12:03nDuffjemafeller: If you're generating a lazy sequence that uses the resource, that's one ready situation in which try/finally can fail to behave as expected (returning the resource before everything using it is consumed)
12:03squidzcemerick: here is a paste of how im using the wrapper https://www.refheap.com/paste/13083
12:03nDuffAhh.
12:04nDuffjemafeller: The solution given there (wrapping the try/finally within the let) isn't an entirely unreasonable one.
12:04cemericksquidz: that won't work
12:04jemafellernDuff, you mean 2 try blocks?
12:04nDuff...likewise, building a wrapper macro.
12:04squidzcemerick: what am I doing wrong?
12:04cemericksquidz: Look at the compojure example in the doc. handler/site comes last
12:05nDuffjemafeller: See the with-api-connection macro; that way, the inner try block doesn't have to be explicit.
12:05squidzdo I then have to manually supply the route? I get a 'wrong number of arguments passed' error
12:06cemericksquidz: Not sure what you mean by "manually". Should be (-> app-routes rpc/wrap-rpc handler/site)
12:08squidzcemerick: I dont think I have to restart my server right?
12:09cemericksquidz: if you passed a var into the ring adapter, no
12:09squidzhmm it doesnt seem to have an effect
12:10squidzcemerick: https://www.refheap.com/paste/13085
12:10cemericksquidz: you're passing app-routes to the jetty adapter, not handler
12:15squidzcemerick: hmm I passed #'handler to it now instead and restarted but still no change
12:21fantadrinkHello, I am having the hardest time writing a tiny gzipping function. Does anyone see what I'm doing wrong? (The un-gzipping works on test data, so I think it's the gzipping.) https://gist.github.com/anonymous/f50ea593ac5f13e64a4d
12:24jemafellerwhen i do this (let [^Pipeline p (.pipelined conn) ]
12:24squidzcemerick: okay nevermind, that did change something. It seems to work because now i'm getting a 500 error instead of a 404 so the route is now defined. Thanks for helping
12:24jemafellerlooks like the type hint doesn't work.. is there a proper way to type hint in a let block?
12:25nDuffjemafeller: That _is_ the proper way.
12:25jemafellerhmm ok
12:25nDuffjemafeller: I take it that's "didn't work" in the sense that you're still getting reflection warnings?
12:25nDuffjemafeller: What exactly is the call you're getting those warnings on?
12:25jemafelleryes.. I'm checking perhaps it's just me
12:27squidzRaynes: I messaged earlier about not being able to edit refheap pastes. I found out, that it is becaues I have my ctrl key mapped to caps-lock
12:29jemafellernDuff, well i'm trying to use bare-bones Jedis, looks like when I get a Pipeline it won't recognize 'incr' on it
12:30jemafellerexample: http://pastie.org/7163515
12:31nDuffjemafeller: Ahh -- it doesn't know the type of the %1
12:31arcatanfantadrink: i tried your example and it worked for me with no problems
12:32fantadrinkarcatan: Aaargh. :) How weird.
12:32nDuffjemafeller: I don't know the libraries you're using, but if the %1 is supposed to be a Long, for instance, try (fn [^Long x] (.incr p x))
12:32fantadrinkarcatan: Thanks, I'll restart my REPL and try again.
12:32jemafellernDuff, yep it working, thanks!
12:32nDuffjemafeller: ...by the way, I think some of that might be easier to read with doseq rather than (doall (map ...))
12:34jemafellerah! looks like carmine was my bottleneck. using Jedis i get great performance
12:34nDuffHmm. Sounds like something worth reporting to carmine's maintainership
12:34fantadrinkarcatan: OMFG, restarting the REPL worked. Even though I just created namespace 'foo to have a "clean space". Thanks again.
12:37cemericksquidz: np :-)
12:37squidzcemerick: just another quick question defremote only supports returning certain types right? I couldnt pass it a clojure map could I?
12:38cemericksquidz: anything that can be printed and read should work
12:39squidzcemerick: okay thanks
12:43mpenetjemafeller: did you use pipelining with carmine as well?
12:43jemafellermpenet, yes. i think i can identify a difference though
12:43jemafellerwhen I use Jedis, and MONITOR on Redis, I don't see the results immediately in the MONITOR
12:44jemafellerwith carmine I always do see it immediately
12:44jemafellerperhaps Jedis has some sort of queue and workers that batch even pipelines
12:44mpenetright, so jedis is fire and forget (async)
12:44jemafelleri'm not sure.. it doesn't say it is on the tin
12:45mpenetit is async: https://github.com/xetorthio/jedis/wiki/AdvancedUsage#pipelining
12:45jemafellerperhaps its pool makes for a better performance
12:45mpenetyou need to call .sync on the pipeline obj to wait for the response it seems
12:46jemafellerhmm what the… i've never seen that. I call .exec on the pipeline
12:47mpenetboth jedis and carmine use the same underlying pools (more or less), from apache commons
12:48tyleris there heredoc in clojure so i can do something like (def example-json (heredoc {"foo":"bar"})) ?
12:49mpenetjemafeller: aleph redis client works like this too: every command is pipelined and async by default. I never profiled/benchmarked it though
12:49jemafellermpenet, any idea why .exec worked for me?
12:51mpenetjemafeller: because it's one of the possible way to use it. At least it's a public method of Pipeline
12:51jemafellerlooks like it works faster than sync
12:51mpenetjemafeller: it makes sense since very often you don't care about the reply when using pipelines
12:52tyleri guess i could make a json tagged literal
12:54st3fancan anyone point me to a simple ISeq or ASeq example? i am trying to create my own collection for a special indexed dataset
12:55squidzis there something like the Maybe Monad in clojure, or is that not so idiomatic? if not, whats the usual way with working with exceptions
12:56antares_squidz: there is algo.monads but monads are not used heavily
12:56mpenetjemafeller: I doubt it's faster in reality, you just get your thread back faster since it's non blocking, but I doubt it paralelises the calls (using a pipeline would be pointless). If exec does return you the replies, then maybe it's a matter of difference in how the pools are configured
12:56squidzantares_: so its not so usual, then what is the prefered way of working with exepctions
12:56antares_squidz: start with exploring if-let, when-let and some-> in Clojure 1.5
12:57antares_squidz: if by "exceptions" you mean nil values, see above
12:57squidzthanks that is what I was looking for
12:57antares_squidz: nil evaluates to false in Clojure, that is heavily used
12:57squidzno, I dont mean nil values, but exceptions thrown by other libraries, java that is
12:57jemafellermpenet, i'm not sure what exec is then.. googling doesn't bring up a definite answer
12:58antares_squidz: then try/catch/finally and ex-info
12:59mpenetjemafeller: it seems it maps to a redis EXEC call
12:59jemafellermpenet, that doesn't make sense..
12:59mpenethttps://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/Pipeline.java#L105
13:00jimdueysquidz: https://github.com/jduey/protocol-monads
13:00squidzjimduey: thanks ill take a look
13:10momomomomoAfternoon all
13:11jack_rabbit(dotimes [_ 5] (print "mo"))
13:11hyPiRion,(repeatedly 5 #(pr 'mo))
13:11clojurebot(momonil monil monil monil nil)
13:13jack_rabbit,(dotimes [_ 5] (print "mo"))
13:13clojurebotmomomomomo
13:13jack_rabbitcool.
13:17casiondoes clojure have a decent debugger yet?
13:17casionbesides avoiding needing a debugger
13:18technomancycasion: ritz seems to be the best so far
13:18casionis ritz near slime level yet?
13:18casionI know that's a silly question
13:19casionbut indulge me please :)
13:19technomancyritz works with slime
13:19technomancyand nrepl
13:19casionI thought using slime with clojure was passé now?
13:21technomancydunno, it still works
13:21casionI haven't experimented with it much
13:21technomancyif you need slime features that aren't in nrepl you can keep using it while you wait for nrepl to catch up =)
13:22casionstill have to use swank-clojure or?
13:22technomancyritz is a swank-clojure replacement
13:22casionoh
13:22casionI guess I need to look into ritz
13:22casionthank you
13:22technomancyI think the video from the clojure conj is up? it's pretty good.
13:23casionok, great
13:23casionthank you again
13:23technomancysure; hope it works for you
13:23hyPiRionIs there anyone here who knows if there is any testing framework for Clojure 1.0?
13:24technomancyhyPiRion: there's really just clojure.contrib.test-is more or less
13:24casionhmm, video is not up yet it seems
13:24casionbut I found slides
13:24technomancytest-is became clojure.test
13:24hyPiRiontechnomancy: Hmm, okay
13:24technomancyhyPiRion: very old versions of leiningen support it
13:25technomancyarchaeology!
13:25hyPiRionOh sweet
13:26hyPiRionNot sure if I can include the :license in the project map anymore though =/ Not enough space
13:27hyPiRionOh well, research time, thanks.
13:30hyPiRionoh man, I have to go pre 0.5.0 then
13:30jcromartietechnomancy: someone was saying you had some opinions on Midje vs alternatives?
13:30jcromartieI am curious
13:31jcromartieI feel like clojure.test is much more straightforward
13:32astevewhy would you need to use an anonymous function literal #() instead of ()?
13:32jcromartieand most of what Midje does could be accomplished on top of clojure.test through libraries
13:33dnolenasteve: #(* % 2) vs (fn [x] (* x 2))
13:33jcromartie,()
13:33clojurebot()
13:33jcromartie,#()
13:33clojurebot#<sandbox$eval69$fn__70 sandbox$eval69$fn__70@2eb03d>
13:33hyPiRion,'#()
13:33clojurebot(fn* [] ())
13:33hyPiRion,(= (#()) ())
13:33clojurebottrue
13:33hyPiRionhmm
13:34astevednolen: and what is % here?
13:34dnolenasteve: an argument
13:34hyPiRionasteve: the first argument passed to the function
13:34moredogmeathi, is there a way to easily print to stderr instead of stdout? an equivalent of println for *err*?
13:34hyPiRion(binding [*out* *err*] (println "I am now printing to stderr")) <-
13:35asteve%1 is the second argument passed?
13:35scottjasteve: first
13:35asteveso % and %1 are the same?
13:35scottjasteve: % and %1 are same
13:35hyPiRionasteve: yes
13:35dnolen,(#())
13:35clojurebot()
13:35dnolenthat is pretty weird hyPiRion
13:35moredogmeatHi hyPiRion thank you again
13:35dnolena reader ambiguity?
13:36tylerhow do you define tagged literal from repl?
13:36nDuffasteve: there's never a reason to use #(...) instead of (fn [...] ...) other than terseness.
13:36hyPiRiondnolen: Yeah, it's most likely because #(...) expands into (fn* [] ( ...))
13:36tyleri saw miner do it in his talk
13:36dnolenah no
13:36dnolenhyPiRion: yeah
13:36nDuffasteve: Sometimes, terseness is enough.
13:36dnolen,(macroexpand '(#()))
13:36clojurebot((fn* [] ()))
13:36astevenDuff: makes sense
13:36hyPiRionmoredogmeat: you're welcome :)
13:37asteve,#(str "?" (name %))
13:37clojurebot#<sandbox$eval246$fn__247 sandbox$eval246$fn__247@dc4653>
13:37asteve"?" is input?
13:38nDuffasteve: '?' is a string literal, just like "foobar" or "hello world"
13:38nDufferr, "?"
13:38dnolen,(#(string "?" (name %)) 'foo)
13:38clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: string in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:38dnolen,(#(str "?" (name %)) 'foo)
13:38clojurebot"?foo"
13:38asteveah, so it's concatenating
13:38jcromartieasteve: yeah, str is used to build strings
13:38dnolen,(doc str)
13:38clojurebot"([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args."
13:39asteve,(#(str "?" (name %)) 'foo)
13:39clojurebot"?foo"
13:39asteve,(str "?" (name %) 'foo)
13:39clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:39asteve,(str "?" 'foo)
13:39clojurebot"?foo"
13:40asteve,(map (#(str "?" (name %)) 'foo))
13:40clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$map>
13:41asteve,(map #(str "?" (name %)) 'foo))
13:41clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
13:41kotarak,(map #(str "?" (name %)) [foo])
13:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:41kotarak,(map #(str "?" (name %)) '[foo])
13:41clojurebot("?foo")
13:42astevewhat did map do there?
13:43asteve("?foo") is now a lazy sequence of exactly 1 item?
13:43kotarakasteve: it applied the function to each item in the vector
13:43kotarakasteve: yes
13:43kotarak,(map #(str "?" (name %)) '[foo bar baz])
13:43clojurebot("?foo" "?bar" "?baz")
13:43asteveah!
13:45asteve,(concat ["?moo" "?oop"] (map #(str "?" (name %)) '[foo bar baz]))
13:45clojurebot("?moo" "?oop" "?foo" "?bar" "?baz")
13:46asteve,(vec (concat ["?moo" "?oop"] (map #(str "?" (name %)) '[foo bar baz])))
13:46clojurebot["?moo" "?oop" "?foo" "?bar" "?baz"]
13:46astevebam! learnin this
13:46kotarakasteve, rather into than vec + concat
13:47asteve,(into ["?moo" "?oop"] (map #(str "?" (name %)) '[foo bar baz]))
13:47clojurebot["?moo" "?oop" "?foo" "?bar" "?baz"]
13:47astevethe more you know
13:48kotarakasteve, it's faster because it works in the vector instead of going to sequence land and then going back again with vec.
13:49hyPiRion,(into ["?a" "?b"] (map (partial str "?") '[c d e]))
13:49clojurebot["?a" "?b" "?c" "?d" "?e"]
13:49astevewhat editor do you guys use? I'm wondering if there's a visualizer for vim to ensure I'm properly parenthesis'd
13:50moredogmeatasteve: I'm not an expert but I use http://www.vim.org/scripts/script.php?script_id=2501 with vim
13:50JohannVonReal programmers code with a magnetic needle and a steady hand
13:50asteveJohannVon: sure
13:50jack_rabbitasteve, I use emacs.
13:50JohannVonGod, tardive dyskenesia is a bitch, I can actually see my hands shaking if I look at them.
13:51moredogmeatDoes clojure have a reflection API for java methods and etc or just use the Java one?
13:54hyPiRionmoredogmeat: clojure.reflection
13:55tylerseq? is to [] as what is to {} ?
13:55bbloomtyler: do you mean seq? or sequential?
13:56bbloom,(map (juxt seq? sequential?) ['(1 2 3) [4 5 6]])
13:56tyleri think i mean seq
13:56clojurebot([true true] [false true])
13:56tylerim too newbish to be positive
13:56tylerah
13:56hyPiRion,(seq [])
13:56clojurebotnil
13:56hyPiRion,(seq {})
13:56clojurebotnil
13:56bbloom,(map (juxt seq? sequential? associative?) ['(1 2 3) [4 5 6]])
13:56clojurebot([true true false] [false true true])
13:56bbloomtyler: ##(doc associative?)
13:56lazybot⇒ ------------------------- clojure.core/associative? ([coll]) Returns true if coll implements Associative nil
13:57moredogmeatok thanks hyPiRion let me go take a look at clojure.reflection
13:57tylerbbloom: thnx
13:57hyPiRion,(mapv seq [[1 2] {:one :two}])
13:57clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: � in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:57bbloom,(map (juxt seq? sequential? associative?) ['(1 2 3) [4 5 6] {:foo :bar}])
13:57clojurebot([true true false] [false true true] [false false true])
13:57hyPiRion,(mapv seq [[1 2] {:one :two}])
13:57clojurebot[(1 2) ([:one :two])]
13:58tylerbbloom: im trying to recurse a json object im trying to write something using tree-seq
14:05tyleranyone know of a lib that takes a datastructure and generates an image of that structure with graphviz?
14:06lynaghkcemerick: do you have any suggestions for how to stub out friend's openid workflow during a test?
14:07lynaghkcemerick: i.e., change the openid provider URL in the login form to point to a stub under my control, and have that return the appropriate bits?
14:07cemericklynaghk: that's the long way 'round. OpenID is *big*. If you've stubbed it effectively, you've just implemented an OpenID provider.
14:07lynaghkcemerick: or would jacking into the friend openid workflow itself be a better solution? My gut feeling is that stubbing out the identity provider makes more sense
14:08lynaghkcemerick: hmm. There's not a Java servelet somewhere you're aware of that I can just jack into?
14:08cemerickBetter would be impl'ing a workflow fn that returns previously-captured credentials (or failure redirects) as provided by actual openid endpoints.
14:09cemericklynaghk: Just searching for 'java openid provider' produces a bunch of potential options, though I've not investigated any
14:09lynaghkcemerick: yeah. I dug around google for a hot minute but couldn't find any clear examples of what people do to test.
14:10cemerickstanding up a conformant openid or oauth provider is not straightforward AFAIK
14:10lynaghkcemerick: oh yeah, I believe that.
14:11cemericklynaghk: if you have a limited set of options (just google right now?), then just capturing successful and failed responses should be fine for automated testing, right?
14:11cemerickI mean, you don't actually want to include the openid junk in your test window.
14:12lynaghkcemerick: dunno, that's why I wanted to ask =) I.e., if there is expry crypto timeout stuff going on that would prevent replays
14:12cemerickyeah, there's a 60-second nonce in there, but I'm suggesting "replaying" the result of the workflow fn, so that wouldn't ever come into play
14:13supersymyeah baby!
14:14supersymI love how keys are functions that self-evaluate :)
14:14hyPiRionsymbols are too, and vectors, and maps, and sets
14:14supersymI just so much enjoy clojure programming...its like coming home
14:15TimMchyPiRion: Symbols don't evaluate to themselves.
14:15TimMcwell...
14:15TimMc(def foo 'foo)
14:15supersymright
14:15lynaghkcemerick: not sure I follow: you mean just stub out the workflow function to return the authentication map?
14:15cemericklynaghk: and/or return any auth map appropriate for the test(s) you're running, yeah
14:16lynaghkcemerick: hmm, okay. I'll look into that. thanks
14:16hyPiRionTimMc: oh right, in that sense no
14:16amalloyTimMc: supersym meant self-lookup, not self-evaluate, i think
14:16cemericke.g. just have it respond to POSTs on the :openid-uri, and the whole openid redirect game will just get short-circuited
14:16hyPiRion,('foo {'foo :bar})
14:16clojurebot:bar
14:17aroemersTimMc: symbols can look themselves up though, I think that is what hyPiRion meant
14:17cemericklynaghk: applying your patch in a minute, BTW
14:17lynaghkcemerick: awesome, thanks
14:18cemericklynaghk: now, before I start thinking about interaction workflows properly: what pen and type of paper do you prefer for that?
14:19lynaghkcemerick: I prefer pen and paper that optimize for the programmer experience.
14:19cemericklynaghk: nm, I was trying to troll you :-P
14:19lynaghkcemerick: in particular, pens with which I can make a single stroke and automatically expands into an entire twitter bootstrap wireframe
14:20lynaghkcemerick: it's pretty limited and not composable, but the important part is that it takes me only a few minutes to make a website.
14:20cemericksomeone needs to do a pencil review tumblr like the speaker-knob-feel tumblr
14:20cemericklynaghk: oh, all wizard-like!
14:21supersymamalloy: literal text from the Joy of Clojure
14:21amalloyreally? what page?
14:21supersymBecause keywords are self-evaluating and provide fast equality checks, they're almost always used in the context of map keys.
14:22lynaghkcemerick: in all seriousness, I mostly use pens that I find on the ground at hotels and other conference venues. Sometimes I go to art schools because you're more likely to score those rad micron pens and drafting pencils.
14:22supersymbut I see where you'd easily mix up that term in this case though, lookup resolves using itself to return the value
14:23cemericklynaghk: Yeah, I developed a pencil preference some years ago, bizarrely.
14:23amalloywell, that's certainly true. "keys are functions that self-evaluate" is even an accurate summary of that statement, but out of context it sounds like you mean self-lookup
14:23supersymright
14:23cemericklynaghk: you were *supposed* to say something like: WTF, just gd do it! :-)
14:27lynaghkping: stuartsierra
14:28stuartsierralynaghk: pong
14:28lynaghkstuartsierra: thanks again for your talk last week---I've gotten the tools.namespace stuff up and running with those ideas and it's pretty neat
14:28stuartsierralynaghk: great!
14:29lynaghkstuartsierra: I think there may be a problem with the refresh fn, though---if one of the namespace errors out during loading I pretty much can't load any namespaces anywhere until I restart my jvm
14:29stuartsierralynaghk: you can, actually
14:29stuartsierrafix the error, then call `refresh` again, but you may have to use the fully-qualified name `clojure.tools.namespace.repl/refresh`
14:30lynaghkstuartsierra: no dice---is this something that's fixed on master?
14:30stuartsierralynaghk: can you describe the problem in more detail?
14:30lynaghkstuartsierra I'm on 0.2.2. I can give you a minimal case if you want
14:31stuartsierraOK.
14:31stuartsierraIn 0.2.3, `refresh` will attempt to recover aliases in the current REPL namespace after a failed refresh.
14:32lynaghkstuartsierra: the problem actually crops up before I've even run refresh---it's just if I try to require an ns with a toplevel exception and c.t.n.repl into a scratch namespace
14:33stuartsierralynaghk: I think I need an example to diagnose that.
14:33lynaghkstuartsierra: I get an exception when I execute (ns scratch ...) and then running (ns scratch ...) after that gives me an error like "namespace 'ns.with.original.problem' not found"
14:34lynaghkstuartsierra: sure. let me whip up a git repo for you.
14:34stuartsierraok cool
14:36stuartsierralynaghk: Wait, before you do that, is anything in your project ever AOT-compiled?
14:37lynaghkstuartsierra: nope, not that I'm aware of, though I do specify a :main key in my project.clj
14:38stuartsierraSome versions of Leiningen automatically AOT-compile :main namespaces, even when you tell them not to. Make sure there are no files in `target/classes`
14:38lynaghkstuartsierra: yeah, it's empty
14:38stuartsierraok
14:39lynaghkstuartsierra: actually, this may be unrelated to c.t.n. since I still get the issue without that on my classpath.
14:40stuartsierrahrm
14:41stuartsierraI got nuthin'. :)
14:42jcromartiedo people really use agents?
14:42jcromartieI've asked this before I think...
14:42jcromartiebut I feel like they get no love
14:43stuartsierrajcromartie: Simulant makes heavy use of agents
14:43technomancythey get frequently abused as "a way to start a thread without touching java" I feel
14:43cemerickjcromartie: extensively
14:43technomancyor a way to avoid using executors
14:43stuartsierraI've used them for asychronous HTTP responses, e.g. long-polling
14:44hyPiRionIt sounds like a sound way to log stuff, but I've never used them myself.
14:44jcromartieI need to cache some things that are loaded periodically from various URLs
14:45jcromartieand an agent would seem like a good thing to say (send news-cache update-from url)
14:45jcromartiesend-off, that is
14:45lynaghkstuartsierra: okay, got it. It was a problem with the ns form itself---loading up something that throws an exception will only happen once, and then any namespaces after that will think that they've already loaded the bad namespace up and won't try again. Adding a :refresh-all in my scratch namespace solves the problem.
14:45mabesI've used them to write to a csv from multiple threads
14:46lynaghkstuartsierra: sorry to attribute that negativity on your project
14:47stuartsierralynaghk: no worries. I don't quite follow your explanation, but I'm glad you found the culprit.
14:47jcromartietools.namespace is my homeboy
14:47lynaghkstuartsierra: just that the `ns` form won't retry a failed require unless you explicitly tell it to.
14:47hyPiRionOh right, namespaces may be partially loaded.
14:48stuartsierrajcromartie: glad to hear it :)
14:48lynaghkstuartsierra: also, just fyi 0.2.3 hasn't been published yet.
14:48stuartsierrayes
14:48stuartsierravery soon
14:48lynaghkcool =)
14:48stuartsierramaybe today even
14:48jcromartiealthough it seems to have issues with midje autotest
14:49asteve,(map symol ["?one" "two"])
14:49clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: symol in this context, compiling:(NO_SOURCE_PATH:0:0)>
14:49asteve,(map symbol ["?one" "two"])
14:49clojurebot(?one two)
14:50stuartsierrajcromartie: not surprising, since Midje autotest is trying to do the same thing.
14:50asteve,(vec (map symbol ["?one" "two"]))
14:50clojurebot[?one two]
14:50jcromartieyeah
14:53hyPiRionasteve: mapv would do the same job :)
14:54asteve,(mapv symbol ["?one" "two"])
14:54clojurebot[?one two]
14:54asteve,(atom [])
14:54clojurebot#<Atom@e6be76: []>
14:55asteveI'm going to assume atom does not mean atomic
14:55asteveso what does it mean? :)
14:55nDuffasteve: atoms are one of Clojure's concurrency primitives.
14:55nDuffasteve: ...and actually, yes, changes to them _are_ atomic
14:55technomancyTom Swift and his Atomic Reference Type
14:55gfredericksan atom is a reference type
14:55antares_asteve: atoms are atomic references, see http://clojure-doc.org/articles/language/concurrency_and_parallelism.html
14:56nDuffasteve: ...atomic and uncoordinated, vs refs which are coordinated in transactions
14:56TimMcasteve: You're wondering about atoms in the not-a-cons sense, yeah?
14:56asteve"This is one of the most hardcore guide of the entire Clojure documentation project. "
14:56astevehah
14:56asteveclojure where cons means construct and atom means atomic
14:57nDuffasteve: The dead-tree books cover this well
14:57nDuffasteve: ...and no, atom doesn't exactly mean atomic.
14:57nDuffasteve: ...(atom []) creates an atom
14:57nDuffasteve: ...which is one of the reference type used for atomic operations, but that doesn't mean "atom" means "atomic".
14:58nDuffasteve: I do strongly recommend Programming Clojure (for something focused on practice), or The Joy Of Clojure (for something focused on theory).
14:58asteveah, my mistake
14:58lynaghkcemerick: does the auth map have to have the ::friend/workflow metadata?
14:59lynaghkcemerick: having (constantly {:identity ... :roles #{...}}) as my workflow function isn't workin' (nil response)
14:59nDuffasteve: ...in particular, IMHO, The Joy of Clojure has a gentler introduction to the concepts behind Clojure's concurrency model than what that page has.
14:59cemericklynaghk: it needs :type ::friend/auth meta
14:59cemerickthe ::friend/workflow meta is merely informative IIRC
15:00astevenDuff: ok, I've got a lot of time for reading next week so I'll pick it up
15:00astevethanks
15:00lynaghkcemerick: okay, cool. So I should use the `make-auth` fn in friend.workflows
15:00cemericklynaghk: yeah, probably easier
15:01nDuffErr, sorry -- the focused-on-practice book I meant to recommend was Clojure Programming [http://www.clojurebook.com/], not Programming Clojure.
15:02tieTYTwhen should I decide to use comp vs expression threading?
15:02antares_asteve: not sure I understand your remark
15:03antares_asteve: you expected atom to mean something else?
15:03jcromartietieTYT: it is a style decision, sometimes it seems cleaner one way or another
15:03jcromartietieTYT: you can go way overboard with comp and partial, but sometimes it's the right tool for the job
15:04tieTYTi see
15:04jcromartie,(map (partial str "prefix-") [1 2 3])
15:04clojurebot("prefix-1" "prefix-2" "prefix-3")
15:05jcromartieis clean, but not shorter than #(str "prefix-" %)
15:05gfrederickspartial would be useful if it were a single character long
15:05hyPiRionThen again, (partial str "prefix-") is exactly the same as #(str "prefix-" %).
15:05hyPiRionisn't*
15:06jcromartienot exactly, no
15:06hyPiRion,(map (partial str "prefix-") [1 2 3] [:a :b :c]) ; Useful in certain contexts
15:06clojurebot("prefix-1:a" "prefix-2:b" "prefix-3:c")
15:06jcromartiesexy!
15:06jcromartiecomp/partial always win when it's variable arity
15:06Apage43,(for [n [1 2 3]] (str "prefix-" n))
15:06clojurebot("prefix-1" "prefix-2" "prefix-3")
15:07Apage43is still shorter than the original partial
15:07jcromartiebut the original question was about vs -> and ->>
15:07jcromartieand we failed completely to address that
15:07hyPiRionwhich is now totally derailed
15:07hyPiRionyeah
15:08tieTYTthat's ok, i learned other things
15:09jcromartie,(->> [500 600 700] (map str) (map reverse) (apply str))
15:09clojurebot"(\\0 \\0 \\5)(\\0 \\0 \\6)(\\0 \\0 \\7)"
15:09jcromartienot quite what I had in mind
15:09jcromartie,(->> [500 600 700] (map str) (map reverse) (map #(apply str %)))
15:09clojurebot("005" "006" "007")
15:09lynaghkcemerick: ah, (constantly ...) doesn't work because it'll put you into a redirect loop. You need to check the uri in the workflow fn and only return an auth map once. in this case, just returning an auth map when the user hits "/openid".
15:09jcromartie,(map (comp (partial apply str) reverse str) [500 600 700])
15:09clojurebot("005" "006" "007")
15:10Apage43,(map #(->> % str reverse (apply str)) [500 600 700])
15:10clojurebot("005" "006" "007")
15:10hyPiRion,(for [v [500 600 700]] (->> v str reverse (apply str)))
15:10clojurebot("005" "006" "007")
15:11jcromartietoo many ways to do one thing !
15:12Apage43For me it comes down to what seems like a nicer way to read what's going on. ->/->> read to me as "take x, then do f to it, then do g to it"
15:12jcromartieif you were going to use a Java method or constructor, then you would have to use threading
15:12Apage43I read comp as "f of g of x"
15:12jcromartiethreading macros*
15:12danneu"too many ways to do one thing" <- from whence idioms are born
15:12hyPiRionhm, is there no function which takes a seq of chars and return a string?
15:12jcromartiedanneu: "I propose a new unified way!"
15:12jcromartienow there are n + 1 ways :)
15:12jcromartiehyPiRion: apply str, no?
15:13jcromartie(apply str (seq "asdf"))
15:13jcromartie,(apply str (seq "asdf"))
15:13clojurebot"asdf"
15:13hyPiRionjcromartie: yeah, but that's using apply.
15:13jcromartie(partial apply str) :)
15:13jcromartienow it's a function :P
15:13cemericklynaghk: Yeah, the workflow fn is still a handler (and so needs to match only appropriate routes, etc). Sorry, glossed over the `constantly` in your previous msg.
15:13hyPiRion,(clojure.string/join "" (seq "asdf")) ; I suppose
15:13clojurebot"asdf"
15:14jcromartie,(clojure.string/join (seq "asdf"))
15:14clojurebot"asdf"
15:14jcromartiewe have a winner
15:14hyPiRionoh bleh
15:14hyPiRiontoday I learned.
15:14hyPiRion(inc jcromartie)
15:14lazybot⇒ 3
15:14jcromartie3… dang
15:14jcromartieI gotta get cracking
15:15lynaghkcemerick: thanks for the tips---this approach is working great. Maybe after it's running for a few months I'll factor all of this stuff out into some real docs+example repos.
15:15zerokarmalefthyperion: clojure.string/join just does (apply str coll)
15:15cemericklynaghk: PR's welcome for concrete use cases in friend-demo
15:15lynaghkcemerick: will keep that in mind.
15:16danneu(map (comp join reverse str) [500 600 700])
15:16hyPiRionzerokarmaleft: oh, I see why now
15:17hyPiRionapply str [...] needs to only read two items to know what to dispatch on
15:17hyPiRionand it's using a stringbuilder under the covers, so apply str isn't that bad.
15:17tieTYTApage43: isn't threading more like "take x, then do f to it, then take that and do g to it"?
15:18hyPiRiontieTYT: yeah, that's correct
15:18hyPiRionLet me find a good example (if I have any)
15:19hyPiRionhttps://www.refheap.com/paste/13090 <- example from actual code I have
15:20tieTYTthat looks clean
15:20tieTYTwhy all the parens? Those are optional right?
15:20tieTYTif you're just passing one param total
15:21hyPiRionyeah, they are optional, I just want to indent properly
15:21tieTYTeg: showdown doesn't need the parens
15:21tieTYToh ok
15:21hyPiRionIt's just a matter of preference, I guess.
15:28st3fandoes anyone know a project that implements ASeq?
15:28hyPiRionst3fan: I suppose you mean ISeq?
15:29hyPiRionWell, Clojure does anyway
15:35amalloyhyPiRion: why :on-turn instead of just :turn or [:on :turn] or something? it seems like you lose the connection between turn-card and turn-betting, for no real gain
15:38tomojis that CPS'd or are all the players bots?
15:38tomojor neither
15:39hyPiRiontomoj: depends, all players may be bots, but may have people in the game too
15:40hyPiRionamalloy: because it reads better, and because it doesn't really matter in the rest of the code
15:41hyPiRionPerhaps I could've done :on :turn, but well
15:41tomojso just block in that function on their responses
15:42hyPiRiontomoj: yeah
15:42jayunit100hmm Could not locate clojure/tools/logging__init.class or clojure/tools/logging.clj on classpath: <-- isn't this standard in clojure? or is there a lein dep i need to add .
15:43__zeroIs there any way to limit the number of threads launched by calling future?
15:43__zero(I don't know if what I'm asking actually makes sense)
15:44stuartsierra__zero: future uses the same thread pool as send-off
15:45stuartsierraYou can change that to a thread pool with a maximum size with `clojure.core/set-agent-send-off-executor!`
15:45amalloyjayunit100: no, it's in the clojure.tools.logging project
15:45jayunit100[org.clojure/tools.logging "0.2.6"] <-- thanks
15:46__zerostuartsierra: thanks i'll look that up
15:53jcromartieisanybody from Prismatic here?
15:56jayunit100is there a way at the repl to see what is available in the "clojure.tools.logging" namespace? sorry… forgot some clojure
15:57stuartsierrajayunit100: clojure.repl/dir
16:00jayunit100stuartsierra: ah thanks thats a really important trick
16:02stuartsierraYou're welcome.
16:02supersymweet
16:02supersym*sweet even
16:03radsI'm trying to get set up with the project at https://github.com/emezeske/lein-cljsbuild/tree/master/example-projects/simple
16:03radsit doesn't seem like my server files are reloading when I change them
16:03radsis there something more I need to do to make that work?
16:05jayunit100ok - so I've got the lib working in "lein test", but for some reason the (use *) directive fails in the "lein repl" . https://gist.github.com/jayunit100/5273274 <-- am i doing something crazy here?
16:05hyPiRionjayunit100: you need a ' in front of the vector
16:06hyPiRion,(use '[clojure.string :only ()]) ;; example
16:06clojurebotnil
16:06jayunit100gotcha thanks
16:12RaynesThat's a feature.
16:12cztomsikis it possible to filter collection using predicate taking two parameters? filtered item and last successfully tested item?
16:13hyPiRioncztomsik: last successfully tested item?
16:14hyPiRionElaborate on that one.
16:14mpenetanyone knows how to pass optional params to carmine such as limit, withscores etc?
16:15cztomsikto turn [1 2 3 1 4] into [1 2 3 4] (testing if next item is bigger than previous one)
16:15mpenetprobably just as strings + value, but I am not 100% sure
16:15mpenetex for zrevrangebyscore
16:15cdh473cztomsik: afaik, there isn't a core function for that
16:15radsdoes anyone have an example of a compojure project that does automatic reloading?
16:15cztomsikprevious == previous which was bigger last time :)
16:15TimMccztomsik: I think I'd go straight to loop/recur for that.
16:15hyPiRionwell, if you're happy with not being lazy:
16:15cdh473you can definitely roll your own though
16:16weavejesterrads: If you're using lein-ring, that will handle it automatically for you
16:16cztomsikI'd like to not solve it in terms of recursion
16:16radsdoes it matter if I'm using clojurescript, thus my server files are in src-clj, not src?
16:17weavejesterrads: Not with the very latest lein-ring
16:17cztomsikbut i am not sure if it is solvable otherwise :)
16:18hyPiRion,(let [v [1 2 3 1 2 4]] (reduce (fn [a b] (if (< (peek a) b) (conj a b) a)) (-> v (get 0) vector) v))
16:18clojurebot[1 2 3 4]
16:18radsweavejester: aha, that was it, my lein-ring was outdated
16:18radsthe example project from lein-cljsbuild is very out of date
16:19radsty
16:19cztomsikhyPiRion: how about feeding it with range?
16:20hyPiRioncztomsik: well, this one isn't lazy, so that would bork stuff
16:20hyPiRionYou'd have to make a lazy-seq function then.
16:20cztomsikyep, anyway thx - I think the best I can invent here is lazy-seq :)
16:21cztomsikhyPiRion: thx, I am still quite new to this :)
16:21hyPiRionnp
16:23hyPiRionoh, might be valuable to know that you could do ##(let [foo (fn f [x] (if (zero? x) x (f (dec x))))] (foo 10))
16:23lazybot⇒ 0
16:23hyPiRionthe (fn f [...] part
16:24cztomsikhyPiRion: self-referencing?
16:31radshas anyone worked with the git api using clojure?
16:31radsit looks like there are no bindings for libgit2 for java
16:32cdh473http://www.autismgames.com.au/game_eyecontact.html
16:33cdh473crap
16:33cdh473that was the wrong channel, excuse me
16:37dnolen,(let [v '(1 2 3 1 4)] (first (reduce (fn [[xs l] x] (if (< x l) [xs l] [(conj xs x) x])) [[] (first v)] v)))
16:37clojurebot[1 2 3 4]
17:01gynnahttp://xeroticmomentsx.blogspot.com/2013/03/amateurgallery.html
17:02RaynesI guess if you read the URL it is fairly obvious that that link is NSFW, but I'll go ahead and put this here anyways.
17:02stuartsierraProbably full of malware too.
17:03RaynesIt's full of boobs, mostly.
17:03RaynesI unfortunately did not read the link before clicking it.
17:03rboydyou're fired
17:07rboydhttp://michaeldrogalis.tumblr.com/post/46560874730/beautiful-separation-of-concerns
17:07rboyd"I was going to write a nice narrative about how I wrote some beautiful code, but I’m just going to show it to you."
17:08rboydI'm trying to imagine how beautiful the code would have to be in order for that soundbite to not rub me the wrong way
17:10nDuffThat _is_ actually pretty awesome.
17:15tieTYTi don't get how this works
17:15tieTYTthat link
17:15tieTYTohh, there's no def(n)
17:15tieTYTso it just runs that code when you require it
17:19tomojit seems pretty obvious to me that "simply don’t require dire-example.logging!" is not an acceptable answer
17:22mjg123Anyone know if it's possible to use something like (read-line) to get user input in light-table?
17:29ravsterhow do I get a printout of all liberator resources for a request? with their values?
17:32`arrdemwhat happened to #clojure....
17:33`arrdemthese links I don't even
17:33ravster`arrdem: ?
17:34`arrdemmy scrollback shows Raynes and cdh473 posting random stuff. anyway.
17:34RaynesI didn't post anything
17:35`arrdemanyone tried to fake a goto in clojure?
17:35RaynesI hope not.
17:35cdh473`arrdem: hmm? i made an accidental post to a site, just because i was in the wrong channel
17:35amalloy$google lambda the ultimate goto
17:35lazybot[The Original 'Lambda Papers' by Guy Steele and Gerald Sussman] http://library.readscheme.org/page1.html
17:35`arrdemamalloy: relax I know this is evil
17:36RaynesDude, you're getting people way mixed up.
17:36amalloywhy would i need to relax? i linked you to a paper
17:36Raynesamalloy: He thought you were me, I think.
17:37`arrdemRaynes no I'm just insane. all is well.
17:37brain_shim_heyo
17:37`arrdemamalloy: thanks for the link, those papers are in my to read stack but I forgot about em
17:38mjg123What options do I have for teaching clojure to a group of 20-ish people? Not going to have reliable internet so I'd like some easy self-contained repl or ide to work with.
17:38brain_shim_If I have a LazySeq, and it looks like a hash map, how do I return only values that match a specific key?
17:39brain_shim_Like I have a big list of :text and :href, and I only want the :href
17:39`arrdembrain_shim_ filter?
17:39`arrdem,(doc filter)
17:39clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
17:39brain_shim_gracias
17:41`arrdemI was just curious.. my compiler builds to a GOTO based IR and it'd be humorus if I could directly evaluate it in Clojure since it's already almost valid clisp
17:41`arrdems/clisp/cl ; before someone else points it out
17:41supersymahhh... tech rush of good music and programming Clojure :)
17:41supersym*floats away to turn op teh vol*
17:42`arrdemsupersym: share ze gud stuff my track just ended
17:43supersymI'm actually making my first youtube lists :P
17:44supersymhttp://www.youtube.com/playlist?list=PLxz13xdIVCTbte5elY5f_sCgMVFDdweas
17:44supersyma bit nostalgic but great dance tunes :)
17:45`arrdem(inc supersym)
17:45lazybot⇒ 1
17:46supersym:D
17:49aaelonyif I use Compojure in a project and start up with lein ring server-headless, can can I connect via repl and make live changes, or do I need to (use or) require clojure.tools.nrepl.server in my project?
17:50technomancyaaelony: better to launch with lein repl and run a jetty from inside it
17:50aaelonytechnomancy: I'm unfamiliar, can you recommend a good link to read up?
17:51hyPiRionaaelony: not sure if this is what you want, but lein ring server-headless listens to changes in the source files, and would reload them if needed
17:51aaelonyby run a jetty inside, that is a function call to jetty ?
17:51technomancyaaelony: yeah, lemme find a link
17:51`arrdema while ago I answered some guy's question here about how to embed a port-bound repl in an application. Is that something anyone's ever seen done seriously?
17:52technomancyaaelony: https://github.com/technomancy/syme/blob/master/src/syme/web.clj#L139
17:52aaelonyhyPiRion: yes, that is really awesome. I'd like to continue to test out new things though while its live though...
17:52hyPiRionaaelony: ah, right
17:52aaelonythings that might break
17:52aaelony:)
17:52aaelony;)
17:53aaelonytechnomancy: that's awesome, thanks for the link :)
17:54technomancyaaelony: yeah, I basically never use lein ring; I much prefer the primacy of the repl
17:54technomancyit reloads when you tell it to vs some imperfect heuristic of file-watching
17:55brain_shim_how can i retrieve a key from a PersistentArrayMap?
17:55brain_shim_like the value of that particular key
17:55aaelonyhonestly, I'm looking to read up on examples to do it with nrepl but a bit confused as to where the use cases are and how they match up with what I want ...
17:56`arrdembrain_shim_: get or treat the map as a function with the key as an argument
17:56aaelonyreloads on demand are exactly what I want.
17:56`arrdemor if you have a keyword key then you can make it the function with the map as an arg
17:56aaelonyon demand meaning "when you tell it"
17:57brain_shim_`arrdem: I can almost see what you're saying.
17:58technomancyaaelony: yeah, IMO starting a ring server should be no different from calling any other repl function
17:58`arrdembrain_shim_ (get map key) or (key map) or (map key)
17:58brain_shim_`arrdem: ah
18:00aaelonytechnomancy: cool. basically I'd like to start the server up (within screen or something) and repl-in (if that's a verb) when I want to, do make changes or try things out, debug, etc...
18:00technomancyaaelony: oh, for production?
18:01technomancynot so keen on that for production unless it's a toy app
18:01aaelonyit's a toy app
18:01technomancyI'm thinking of that more as a development strategy
18:02aaelonythat said though, it'd be interesting to hear what people recommend from experience, both as a dev strategy and in production
18:08amalloy`arrdem, brain_shim_: note that (key map) only works for keys which are keywords or other similar self-looking-up objects. very handy, and works most of the time, but (get map key) is the most general
18:12jemafelleri'm trying to rationalize choosing Clojure over Scala.
18:13jemafellerthe logic i'm applying is - I can use Clojure for what it is, and for performance - I can always use bare Java (which is faster than Scala in any case)
18:13jemafellerso based on that logic, I rarely have a reason to bother with Scala
18:13jack_rabbitjemafeller, How about the syntax? Lisp is much nicer than what I've seen from scala, IMO.
18:14jemafellerjack_rabbit, it's already given I like clojure better than Scala - the syntax, the developer tooling and the community
18:14nDuffjemafeller: http://hammerprinciple.com/therighttool/items/clojure/scala
18:14jack_rabbitWell I'd call that reason enough right there.
18:14jemafelleri'm just trying to handle my own mental challenges - the "what if's"
18:15`arrdemyeow... good link nDuff
18:16amalloyI OFTEN GET ANGRY WHEN WRITING CODE IN THIS LANGUAGE. nice
18:16jack_rabbitvery funny.
18:16jemafellerlol
18:16jack_rabbitI've been to that site before when considering haskell vs erlang.
18:18tieTYTwhy is there 7% for this: THIS LANGUAGE HAS A STRONG STATIC TYPE SYSTEM
18:18`arrdemdoes Clojure provide any gurantee that a macro won't infinitely expand? I don't think so...
18:19amalloy`arrdem: how could it? you can write any macro you want
18:19`arrdemtieTYT because scala compiles to static types while clojure is entirely dynamicly typed
18:19jack_rabbitI think he means why is there even 7%.
18:19amalloy(demacro explode [x] `(explode (list ~x)))
18:20hiredmanthe compile expands macros in a non-iterative way, so the stack will eventually blow
18:20hiredmanor did last I checked
18:20`arrdemamalloy: yeah... just contemplating whether to provide a "real" (infinite OK) macro system inside this compiler or whether I should stick to C's "fake" (one expansion only) macro system.
18:20jack_rabbitMaybe we can kill clojurebot?
18:20`arrdemjack_rabbit: it's been done before... he's even been rooted before.
18:20jack_rabbitHeh.
18:20amalloyhiredman: still does
18:21jack_rabbitCan you spam the channel with it? I'm tempted to try, but don't want to get booted.
18:21jack_rabbitAlso don't really want to spam the channel.
18:21`arrdemjack_rabbit: not really. I've tried..
18:21`arrdemthe bots ignore each other so no mutual recursion..
18:21Apage43Typically you can only get it to send one line of output per line of input
18:22`arrdemand that.
18:23`arrdemoh the heck with it. I clearly need a real macro system to implement pascal.
18:23jack_rabbit,(map #(println %) (range 10))
18:23clojurebot(0\n1\n2\n3\n4\n5\n6\n7\n8\n9\nnil nil nil nil nil ...)
18:24jack_rabbit,(doseq [x (range 10)] (println x))
18:24clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n
18:24jack_rabbitHeh. I see those newlines in there.
18:26tieTYT`arrdem: so why didn't clojure get 0%?
18:26`arrdemtieTYT: probably because you can argue that clojure is staticly typed under the hood
18:26`arrdemit's just that the exposed runtime (what we think of the language) is dynamicly typed.
18:26jack_rabbitAlso you can provide type "hints" for performance.
18:27jack_rabbitWhich sort of exposes the static nature of the underlying system.
18:27jack_rabbitWait. I'm thinking weak vs. strong.
18:27`arrdemso the clojure we're talking about here goes to Java at the end of the day. hence the (:gen-class) stuff, interfaces and IFn etc.
18:28amalloy`arrdem: that's a silly argument. go further under the hood, and it's all just registers and RAM in any language
18:28`arrdemamalloy: heh I just reached that conclusion when I started thinking about Lisp 1
18:28amalloythe language that you actually use, clojure, is dynamically typed
18:29`arrdemAll hail the Turing Machine, integers are all we have and all we shall ever need. HAIL!
18:30jack_rabbitPoor Alan.
18:34holohi
18:36jack_rabbithola, holo.
18:36holohello jack_rabbit
18:37holocan someone point me in the right direction to implement captchas? I can't find any clj lib
18:38jack_rabbitMight look into a Java captcha library.
18:38jack_rabbitI'm sure there's one or two floating around.
18:38holojack_rabbit, I guess that would be the second best way hehe
18:38mpenetrecaptcha is good enough for most cases
18:39jack_rabbitI would think it would be trivial to nicely wrap the most common functions of one of those libraries in a nice clojure-ey way.
18:40jack_rabbitI'm excited for clojure to get onto Microsoft's CLR, purely for the reason that I think it'll gain some momentum there.
18:40holoI could summon myself to do that
18:41holothanks jack_rabbit mpenet
18:41jack_rabbitAny time, dear holo.
18:44tjgilliesis there a reason symbols can't start with numbers?
18:45jack_rabbitProbably makes symbols unnecessarily difficult to parse.
18:45jack_rabbit(My guess)
18:45tjgilliesah
18:45tjgillies(inc jack_rabbit)
18:45lazybot⇒ 1
18:45`arrdemwow... a recursive implemntation of macroexpand is only 11 lines... I love lisp.
18:45Willyfrogmany languajes don't allow variables to start with numbers
18:46amalloy11 lines?! how did you manage to spend 11 lines on that?
18:46jack_rabbitI know in CL, numbers can have suffixes, etc. that modify them, so differentiating symbols that start with numbers from numbers with suffixes would be difficult.
18:46`arrdemjack_rabbit: to be more exact the Java definition of a symbol requires that it match approximately [a-zA-Z][a-zA-Z0-9]*
18:46tjgillies,(var? 'symbol)
18:46clojurebotfalse
18:47WillyfrogI was pointing it to reinforce the parse, not meaning a symbol is a var
18:47`arrdemamalloy: https://www.refheap.com/paste/13101
18:47tjgilliesahh
18:47tjgilliesits java thing
18:47tjgillies(inc `arrdem)
18:47lazybot⇒ 1
18:48`arrdem$karma arrdem
18:48lazybotarrdem has karma 1.
18:48`arrdemQ_Q this is what I get for changing nics
18:48amalloyjava doesn't have symbols (or at any rate, they're an internal thing that's totally different from clojure symbols)
18:48jack_rabbit$karma jack_rabbit
18:48lazybotjack_rabbit has karma 1.
18:48jack_rabbitcools.
18:48amalloyand your macroexpander does something totally different from clojure's. you have to expand the outer form first, not the inner forms
18:49`arrdemamalloy: no.. I recur over the sub-expressions first using map
18:49`arrdemline 3
18:49amalloyyes, that is exactly what i am saying you must not do
18:49`arrdemoh I misread your first.
18:49`arrdemah ok.
18:50tjgillies(inc amalloy)
18:50lazybot⇒ 46
18:50amalloyanyway, 11 lines is reasonable if you're actually walking the whole form; i thought you had managed to spend 11 lines just expanding the outermost form
18:51amalloyand you should really map macroexpand over the whole expr, not just the rest. eg, what about ((memfn size) (ArrayList. 10))?
18:52Willyfrogyou can have a symbol like _1
18:52Willyfrogit would be weird, but close to "starts with a number"
18:53`arrdemWillyfrog: I use that one all the time, the _ prefix is for "ignored value". it's great in argument destructuring.
18:53`arrdemamalloy: hum... so really I want to map macroexpand... and just return the result?
18:54`arrdemno I still have to do the first lookup and apply.
18:54amalloyright. but once you do that, you just map macroexpand over the result
18:56`arrdemhum.. so I really want to define macroexpand to be macroexpand of first, lookup & transform on rest, macroexpand rest & cons.
18:58tjgilliescan i set data readers from lein user profile?
18:59tjgilliesseems weird i have to keep them in a file
19:07brain_shim_If I have a LazySeq of strings, how can I perform a split on "\n" on each of the strings?
19:11Apage43brain_shim_: do you want a seq of seqs or just a single seq of all ines?
19:11Apage43*lines
19:12brain_shim_seq of seq
19:12Apage43,(map clojure.string/split-lines ["a\nb\nc" "d\ne\nf"])
19:12clojurebot(["a" "b" "c"] ["d" "e" "f"])
19:13brain_shim_I love this bot
19:13brain_shim_Thanky!
19:13Apage43you'll want to require clojure.string of course
19:14brain_shim_:)
19:18tjgilliesdamnit datomic has ruined me, now im pissed theres no datalog for ruby (that i can find)
19:21hiredmanhttps://github.com/spariev/mini_kanren
19:28radswhy is there a libgit2 binding for "Chicken Scheme" and not clojure? :(
19:28amalloy$google java libgit2
19:28lazybot[libgit2: a Git Linkable Library · GitHub] https://github.com/blog/752-libgit2-a-git-linkable-library
19:29amalloy(i dunno if there is one, but my point is you should be looking in java)
19:30radsit doesn't look like there are any java bindings either
19:30radswhich is surprising to me
19:30radsyou think clj-native would be the way to go?
19:38john2xtrying out Luminus, when I do a login with reddit.clj (https://github.com/sunng87/reddit.clj), how do I save a session of it?
19:39Willyfrogmaybe with http://www.luminusweb.net/docs/sessions_cookies.md
19:40hyPiRionOh, sexy, the new clojure-mode is more pleasing to the eye in zenburn.
19:44Bronsaoh, I didn't even notice
19:45john2xWillyfrog: oops missed the topics list at the right. thanks!
19:45Willyfrog:)
19:45WillyfrogI'm currrently looking at luminus, so it was easy to link ;)
19:54technomancyrads: probably because everyone on the jvm uses jgit?
19:55technomancy(even though it's not as good)
19:55radsyeah, you're right
19:55radsit seems to be good enough for my purposes (trying to aggregate the git log of multiple repos)
19:57technomancyjgit is fine for read-only stuff
20:03Willyfrogtime to hit the bed
20:03Willyfroggood night!
20:20moredogmeathi, does anyone know how to convert a vector [] to an array of Java Object?
20:20moredogmeatObject[]?
20:20clojurebot,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 10 25))
20:21tieTYTCompilerException java.lang.RuntimeException: Unable to resolve symbol: doc in this context, compiling:(NO_SOURCE_PATH:1:1)
20:21tieTYTthis is in counterclockwise
20:22amalloy(into-array Object ...)
20:25moredogmeat(into-array Object [3 4])?
20:26moredogmeatthank you amalloy
20:29john2xcan't i use a defrecord outside of a file?
20:30john2x(outside of the defrecord's namespace?)
20:30john2xreferring to this code: https://github.com/sunng87/reddit.clj/blob/master/src/reddit/clj/core.clj `login` can use the `RedditClient` record, but I can't refer to it in the REPL.
20:31bttfbeen learning clojure for a little while now, wondering what are some of the best libraries to use to host a personal blog? i'm running nginx on my webserver and would like to reverse proxy it to an clojure-run webserver.. ring and compojure look good, any suggestions ?
20:31john2x*use it in the REPL
20:33john2xbttf: I'm trying out Luminus at the moment (built on ring and compojure). Coming from a Python/Django/Flask background, it's pretty familiar. But maybe it's overkill for a personal blog, I dunno.
20:33bttfinteresting
20:34john2xmostly because it uses clabango as the templating engine.
20:34bttfhow does clabango compare with hiccup ?
20:38brain_shim_I have a LazySeq of PersistentArrayMap's (yay type!). How can I select-keys for each entry in my LazySeq?
20:38`arrdem(inc supersym) ;; damn good playlist
20:38lazybot⇒ 2
20:38john2xbttf: haven't tried hiccup, but from what I can see, they look completely different. all the other templating engines are really alien to me, since I've only been exposed to Django/Jinja. :-/
20:38bttfoh ok
20:39john2xclabango was such a relief
20:42john2xah, so you need to require and import the record to use it in a different namespace
20:48amalloybrain_shim_: how is this different from your last question?
20:50brain_shim_amalloy: I googleled until I could phrase it in clojure nomenclature?
20:53`arrdem.. and from that you can't google up the selection operations?
20:54hyPiRion,(map #(select-keys % [:a :c]) [{:a :b :d :g} {:b :c :a :e :c :g} {:a 1 :b 2}])
20:54clojurebot({:a :b} {:c :g, :a :e} {:a 1})
20:55hyPiRionof just as a list comprehension
20:55brain_shim_hyPiRion: Thanks.
20:56jack_rabbitIs it possible to have "static" variables inside functions similar to how it's done in C?
20:56jack_rabbit(without declaring them globally)
20:56amalloyevery variable is static if you never mutate it
20:57jack_rabbitBut I can't reference x inside a function unless I def it, which changes its value.
20:58jack_rabbitAnd static in C doesn't mean that it doesn't change. It means that it retains its value across calls.
20:59hyPiRionjack_rabbit: then no.
20:59technomancyclojure has locals and vars
20:59hyPiRionjust define an atom outside or within a closure
21:01`arrdemjack_rabbit: so I think you need to clarify what behavior you are looking for.
21:01amalloymy point was that if values never change, you can't tell a c static from a c constant
21:02amalloyand since clojure encourages you not to change things...
21:02jack_rabbitI'm writing a function memoize-fn which accepts a function and its arguments and either executes it or returns the previous results of that function which will be stored in a map. The map therefore will need to be maintained across calls, but I don't particularly want it to be accessible outside the function.
21:02`arrdemare you looking for a global static value, a global but mutable value or a local static?
21:02amalloyjack_rabbit: is there a reason you don't want to just use clojure.core/memoize?
21:02SegFaultAXjack_rabbit: Why you no use memoize?
21:02jack_rabbitamalloy, It's just an exercise.
21:03amalloyso read the source of memoize. you'll see what techniques are available in clojure
21:03amalloythen you can write it your own way
21:03`arrdemjack_rabbit: so what you want to do (probably) is define a closure with an atom.
21:04jack_rabbitOkay. I understand clojures, but don't understand what you mean by that, which signals to me that I need to continue reading before I try to implement this function. Thanks, guys.
21:04SegFaultAXjack_rabbit: Do you know what a closure is?
21:04jack_rabbitYes.
21:05SegFaultAXjack_rabbit: I just want to make sure you're not getting confused with Clojure, the language.
21:05jack_rabbitNo.
21:05`arrdem,((let [x 3] (fn [] x))) ;; closure should work...
21:05clojurebot3
21:06jack_rabbitBut even that would need to be stored globally, right?
21:06`arrdemwhat do you mean by stored globaly?
21:06jack_rabbitHow would I keep track of the closure?
21:07jack_rabbitExcept for a globally accessible symbol?
21:07`arrdemyou don't have to.
21:07`arrdem
21:07`arrdemthat binding is constant across calls to the returned anon function.
21:07hyPiRion(let [x (atom 0)] (defn foo [y] (do-something-with y) (println "called" (swap! x inc) "times"))) <- example of a clojure
21:07SegFaultAXjack_rabbit: I think you don't know what a closure is. Google or StackOverflow might help here.
21:07hyPiRiondangit, closure
21:07jack_rabbitOkay. Back to reading for me, then.
21:07jack_rabbitThanks, guys.
21:07hyPiRionjack_rabbit: ^ look at that example and play with it, it should work
21:08jack_rabbitOH! It's a closure around a function definition?
21:09hyPiRionjack_rabbit: yeah
21:09jack_rabbitVERY VERY cool! I'd never even considered that possibility!
21:09jack_rabbitGood then. I do understand closures, I just hadn't considered the possibility of using them in that way.
21:10`arrdemjack_rabbit: there's a book on this.. let over lambda. if you want to see evil & amazing things done with closures.
21:10hyPiRionheh
21:10SegFaultAXjack_rabbit: Now if you do (source memoize) at your repl as amalloy suggested, you'll have a good idea of how the clojure.core function works by comparison.
21:10`arrdemI still only understand about a quarter of it.
21:10jack_rabbitI'll check it out.
21:10hyPiRionjack_rabbit: you can also do (def foo (let [x (atom 0)] (fn [y] ...)))
21:10jack_rabbitSegFaultAX, Do you by chance know where source is defined? It's not interned in my user package.
21:11holo(inc jack_rabbit)
21:11lazybot⇒ 2
21:11SegFaultAXjack_rabbit: clojure.repl/source
21:11holo(inc mpenet)
21:11lazybot⇒ 1
21:11jack_rabbitCool.
21:11gfredericks,(apropos "source")
21:11clojurebot(*source-path* source source-fn resource)
21:12gfredericks,(map resolve (apropos "source"))
21:12clojurebot(#'clojure.core/*source-path* #'clojure.repl/source #'clojure.repl/source-fn nil)
21:12SegFaultAX,`source
21:12clojurebotclojure.repl/source
21:13jack_rabbitcool.
21:13jack_rabbitJudging by the memoize source, I was on the right track.
21:13jack_rabbit(You guys too with the closure)
21:14holo(inc amalloy)
21:14lazybot⇒ 47
21:15`arrdemDAE think that should really be inc! ?
21:15hyPiRion(swap! amalloy inc)
21:15jack_rabbitMust be legacy CL syntax. :)
21:20hyPiRion,((`[~@(ns-map((`[~@(meta #'source)](*))(*)))](#(* % %)(*(+(*)(*))(+(*)(#(* % %)(+(*)(*)))))))(*))
21:20clojurebot#'clojure.repl/source
21:28MikeSethi think i accidentally wrote a nrepl client
21:30jack_rabbitcongrats. Most accidents aren't that happy.
21:42jack_rabbitOkay. When I do (def x (ref 5)), why can I then do (def x (ref 3))?
21:42jack_rabbitAnd the change is seen across threads?
21:43jack_rabbitIs it just that clojure allows you to do something dangerous?
21:43`arrdemas C is evidence languages have no duty to protect agains programmer stupidity...
21:44`arrdems/agains/against
21:44jack_rabbitSure, but HLL's often times do.
21:44jack_rabbitI wasn't sure if this was the case or not.
21:44`arrdemif I just (doc) var, it isn't clear what the multithreaded behavior is.
21:44`arrdemhowever atoms provide multithreaded gurantees so I'd just use those.
21:44jack_rabbitSo to be clear: In this case, clojure allows you to do something dangerous by redefining bindings to that reference.
21:45seancorfielddef changes the root binding of x (as I understand it) so all threads see the change to x
21:45`arrdemcorrect.
21:45seancorfieldyou shouldn't use def to change a var tho', just to create it initially
21:46jack_rabbitWhat should you use to change a var?
21:46seancorfieldyou should instead use the appropriate functions for operating on the ref (or atom)
21:46jack_rabbit(I understand I should use ref-set to change a reference.)
21:46jack_rabbitOkay. That's what I thought. I was just experimenting with the language.
21:47jack_rabbitSo re-def'ing a binding to a reference is a dangerous no-no.
21:47seancorfieldIn Clojure, you don't change Vars (except in weird situation).
21:47`arrdemjack_rabbit: it isn't dangerous.. it's just weird.
21:47seancorfieldRe-def'ing any Var is a bad idea / weird/
21:47jack_rabbit`arrdem, But can't you run into concurrency issues when you do that?
21:47seancorfieldMostly, data is supposed to be immutable.
21:48`arrdemjack_rabbit: no, var defs are atomicaly synchronized.
21:48seancorfieldThen you use controlled mutability (atom, ref, agent) to deal with state that really has to exist and be mutable.
21:48SegFaultAXjack_rabbit: Vars have a root binding and a thread local binding. Also, see clojure.core/alter-var-root
21:49jack_rabbitAccording to this article I'm reading, alter-var-root is used to atomically set a new root value, implying that def does not atomically achieve this.
21:49SegFaultAXjack_rabbit: See the first part of what I said.
21:50seancorfieldwhich article?
21:50seancorfieldfyi, from our production code base... Clojure source 65 files 10834 total loc, 881 fns, 445 of which are private, 123 vars, 2 macros, 17 atoms
21:50SegFaultAXjack_rabbit: It is possible to have a thread local binding differentiate from the root. You might also be interested in defonce.
21:50seancorfieldonly 17 atoms in 11kloc and no refs
21:50jack_rabbitseancorfield, http://java.ociweb.com/mark/clojure/article.html
21:50seancorfieldand almost all of those atoms are caches
21:51SegFaultAXseancorfield: Not much coordination needed, eh?
21:51jack_rabbitseancorfield, Look at the reference types section.
21:51seancorfieldjack_rabbit: that article should be more clear that its very rare to change Vars
21:51jack_rabbitSo why have alter-var-root if def does it atomically anyway?
21:51seancorfieldalthough the article does say "The use of Vars is often frowned upon because changes to their values are not coordinated across threads."
21:52jack_rabbitRight!
21:52jack_rabbitThat's my confusion.
21:52jack_rabbitWhat does "coordinated across threads" mean?
21:52seancorfieldSegFaultAX: our mutable state lives in MongoDB and MySQL mostly :)
21:52seancorfieldjack_rabbit: pretend the article doesn't show you how to change Vars - it isn't ideiomatic Clojure so don't worry about it
21:53SegFaultAXseancorfield: Sure, but refs provide coordination where atoms do not. That's why I said that. :)
21:53SegFaultAXjack_rabbit: Except for when you need to change vars, that is.
21:53hyPiRionjack_rabbit: you know that cores have their own L1(and possibly L2) cache? It essentially means that those caches won't be updated, which may mean that other threads use an older version of the contents of a var
21:53jack_rabbitThat's not a satisfactory answer in my view. I'll google it if I have to, but if you all have an answer, I'm interested in knowing the answer.
21:53seancorfieldSimple answer: never change a Var.
21:53ivaraasenhyPiRion: just Clojure stickered all the thing, BTW
21:53SegFaultAXUnless you need to.
21:54seancorfieldClojure's Vars are not like variables in other languages.
21:54hyPiRionivaraasen: nice, seet
21:54jack_rabbithyPiRion, Okay. So even though my thread saw the update to the binding, there's no guarantee that it will at any particular time when I re-def it?
21:54hyPiRion*sweet
21:54tomojdef can't do it atomically
21:54tomojyou would have to read the current value and then def
21:54hyPiRionjack_rabbit: as far as I can understand, yes.
21:55jack_rabbithyPiRion, Okay. Thanks a ton. That's exactly what I wanted to know.
21:55SegFaultAXjack_rabbit: Always be cautious of people who use words like "always" and "never".
21:55seancorfieldesp. when they have both in the same sentence :)
21:55jack_rabbitSegFaultAX, I'm learned in the ways of avoiding those terms.
21:56`arrdem(inc Sgeo)
21:56lazybot⇒ 2
21:56SegFaultAXI can think of at least one reasonable usage of var altering I've seen.
21:56seancorfieldI'm always cautious of SegFaultAX ... doh!
21:56SegFaultAX;)
21:56`arrdemthe one time I altered a var was when I stuck a repl port in the back of my server as an experiment.
21:56hyPiRionI always avoid those terms. muahahah
21:56`arrdem5/5 do not recommend.
21:56`arrdembut it did work.
21:57ivaraasenseancorfield: nice amount of macros, BTW. I tend to overuse them myself
21:57SegFaultAXI was thinking more along the lines of technomancy's robert.hooke lib.
21:57seancorfield`arrdem: yeah, actually just today i ran two def's via nrepl on our running production servers
21:57SegFaultAXhook-scopes is basically just a ball of var altering goodness.
21:57seancorfieldneeded to apply a hotfix to a function without restarting the app
21:58SegFaultAXseancorfield: What could possibly go wrong!?
21:58seancorfieldwe don't run nrepl servers all the time... we start and stop them when we need them
21:58seancorfieldand mostly try to avoid hotfixes on the live, running app
21:58seancorfieldbut we're sure glad clojure gives us the _option_
21:59hyPiRionErlang is interesting when it comes to that. You can do safe code updates and version bumps without shutting down the service.
22:00SegFaultAXAnd what a painful thing that could be. Especially before rebar.
22:00hyPiRionOh yeah. Without rebar, stuff is amazingly painful. Though I still find it painful, mostly because I haven't mastered the arts yet.
22:01ivaraasenhyPiRion: this is the lib I was talking about earlier today: https://github.com/MichaelDrogalis/dire
22:01seancorfieldanyways jack_rabbit welcome to clojure!
22:01jack_rabbit:)
22:01jack_rabbitI'm a CLisper, so I'm working my way into the purely-functional world from the mutable-mess world.
22:02jack_rabbit*purely*
22:02seancorfieldah, yes, I often forget traditional Lisp was impure in that respect...
22:02SegFaultAXivaraasen: That's pretty cool.
22:02jack_rabbitseancorfield, You can write it functionally, but the opportunities not to are too present to avoid.
22:03SegFaultAXWell CL isn't really functional at all. I mean, sure you can write it that way, but lots of idiomatic CL is fairly imperative.
22:03jack_rabbitSegFaultAX, Exactly.
22:03seancorfieldback in the 80's, when i first started doing FP, i used LispKit (Peter Henderson's subset of Lisp), Miranda and SASL... plus a little ML... and then developed my own FP lang as an academic research project
22:03jack_rabbitseancorfield, You're old.
22:03SegFaultAXStrange.
22:03jack_rabbit:)
22:03SegFaultAXYou used all the precursors to Haskell but not Haskell?
22:04seancorfield"Lispkit Lisp is a lexically scoped, purely functional subset of Lisp" - wikipedia
22:04seancorfieldSegFaultAX: I've used Haskell as well, but by the time it appeared, I was a professional C / C++ developer... :(
22:04jack_rabbitHaskell is pretty cool. I'm working my way through LYAH, as well as picking up clojure.
22:05seancorfieldI went from the glory of pure FP to the horror that is C and the hell that is C++... then Java for a decade... then finally Groovy, Scala and now Clojure! Yay!
22:06hyPiRionivaraasen: oh, the supervisors lib. Thanks a bunch
22:06jack_rabbitseancorfield, C is pretty cool. C++ isn't bad as long as you can avoid the extreme black-hole-like pitfalls.
22:07seancorfieldI was on the C++ Standards Committee for eight years so I probably helped create some of those black holes... sorry! :)
22:07hyPiRionThe issue is that you can't avoid those black holes, it seems like.
22:07SegFaultAXFrom my limited experience with C++ plus the horror storries my colleagues have shared with me over the years, I'm inclined to disagree.
22:07cdh473jack_rabbit++; pure FP makes me feel too limited, i need some side effects snuck in there
22:08hyPiRionI tend to say I use C with a data structure interface, because that's essentially what I do when I write C++.
22:09jack_rabbitIn my mildly-experienced opinion, (just an opinion) you CAN avoid pitfalls in C++ if you are some sort of guru. But most programmers writing C++ apps are far from gurus, and C++ makes it really easy to shoot yourself in the foot.
22:09SegFaultAXhyPiRion: That's probably a pretty inefficient way to use C++. Why not just use C, then?
22:09cdh473hyPiRion++; i end up writing C in C++ whenever i try c++
22:09jack_rabbitI just write my own vtables...
22:10ivaraasenat least C++ isn't Matlab. just saying.
22:10jack_rabbitgiant ugly dereferencing bedamned.
22:10hyPiRionSegFaultAX: Legit question, indeed. I tend to use it for programming competitions, where quick and dirty is what counts
22:10SegFaultAXhyPiRion: Ah, yea. That's basically the only time I ever use straight Java as well. TopCoder.
22:11jack_rabbitI've grown to hate programming competitions. Having a clock be the deciding factor in the "goodness" of a program seems completely bass-ackwards.
22:11hyPiRionSegFaultAX: yup
22:12SegFaultAXI worked on a team that built a cross-platform game engine targeting Android 2.3+ and iOS 5+. It was an interesting experience which probably colors my opinion of C++ a lot, especially since most of /my/ work on the project was on the cross-platform piece.
22:12SegFaultAXIt was really, really challenging.
22:13jack_rabbitHow well does C++ interface with Apple's Objective-C?
22:13SegFaultAXMost of the other engineers were on the graphics part of the engine. But me and one other guy worked on the device facing native parts.
22:14SegFaultAXjack_rabbit: C++ actually works pretty well on iOS from my experience. Of course we were doing something rather specific (game engine) so I can't really talk about the overall level of compat.
22:14SegFaultAXBut for our purposes it actually was pretty smooth.
22:15mattmossI don't understand why people hate C++. Used it for years just fine.
22:15SegFaultAXThat's essentially the only time I've ever worked in C++ in a professional context. And if I had to choose, I mightn't ever return.
22:15jack_rabbitmattmoss, I agree.
22:16SegFaultAXmattmoss: In my case, I think it was more trying to build native wrappers for two relatively disparate platforms. I can't speak to the experience of others.
22:16jack_rabbitGranted, I think that maintainability is a big issue.
22:16jack_rabbitIt seems to me that the older a chunk of C++ software gets, the more bugs develop in it, and the more slowly it incorporates new features.
22:17tomojs/C++//
22:17SegFaultAXjack_rabbit: That's just software.
22:17jack_rabbitIt seems to lack some of the abstraction necessary to build on an existing code-base.
22:17jack_rabbitSegFaultAX, True.
22:17SegFaultAXjack_rabbit: Bitrot is language agnostic.
22:17`arrdemhow valuable do you guys think a Clojure implementation not backed by the JVM would be?
22:17jack_rabbitSegFaultAX, True, but some languages make it easier than others to avoid it.
22:17SegFaultAX`arrdem: You mean like backed by JS or the CLR?
22:17jack_rabbitAnd C++ seems particularly bad at avoiding it.
22:17mattmossI'd say that poorly-written C++ is *really* bad, but well-written C++ is fine and dandy. I spent a few years doing one platform port after another will few issues (Aside from older experience as well).
22:18`arrdemSegFaultAX: sorta.. I've been kicking around this idea for an OS designed to do nothing but run clojure in some sort of micro-runtime.
22:18`arrdemwhere that runtime != jvm
22:18SegFaultAXWee, lisp machines are coming back!
22:18mattmossLet's put a lisp machine on a GPU, that'd be fun.
22:18jack_rabbitSegFaultAX, `arrdem, There are already a few OSes out there that are lisp-based.
22:18`arrdemthat's bloody stupid and you know it
22:18SegFaultAX`arrdem: First I think you should build a game where you can do anything. ;)
22:19`arrdemSegFaultAX: Minecraft. done. next?
22:19mattmosslol
22:19jack_rabbitPfft.
22:19`arrdemthat shit's turing complete man..
22:19mattmossClojure on redstone?
22:19`arrdemfrikkin z80 in redstone.
22:19`arrdemmattmoss: no.
22:19mattmossheh
22:19jack_rabbitYeah, my brother built a 7-bit calculator with a decimal display.
22:20ivaraasenanyone care to recommend some decent C++ tutorials?
22:20SegFaultAXivaraasen: C++ Primer!
22:20SegFaultAXivaraasen: Also, bookmark this: http://en.cppreference.com/w/
22:20`arrdemah that brick of a book...
22:20mattmossI'm hesitant to start recommending tutorials at the moment until I see some good stuff for C++11.
22:20jack_rabbitAlso cplusplus.com.
22:21mattmossThen again, I haven't really been looking, spending most time lately with clojure. And lua (omg).
22:21SegFaultAXmattmoss: Probably take another year before the books start catching up.
22:21mattmossSegFaultAX: Yup. Until then, there's Dylan! (wtf)
22:21mattmossj/k
22:21SegFaultAXmattmoss: I love Lua! And I hate it. Lua's a great language. :)
22:22SegFaultAXLua is*
22:22jack_rabbitIt's interesting how fast C++ shifted towards Objective-C once Objective-C started rising in popularity.
22:22ivaraasenSegFaultAX: thanks
22:22SegFaultAXjack_rabbit: Huh?
22:22mattmossSegFaultAX: I'm tempted more toward Squirrel over Lua, but don't use any of it enough right now.
22:22jack_rabbitSegFaultAX, All the new pointer types have been around in Objective-C since its invention.
22:23jack_rabbit^new C++11 pointer types.
22:23jack_rabbitAnd a lot of the other features, IIRC, are already implemented in Objective-C.
22:23SegFaultAXmattmoss: We use Lua heavily in our game engine so I've worked with it quite extensively. Fun tidbit: I also looked at integrating gambit into our engine so I could use Lisp instead of Lua for scripting our engine!
22:23jack_rabbityeah, gambit is pretty awesome.
22:24SegFaultAXUsed* The company is now defunct.
22:24jack_rabbitI've actually read that you can compile gambit binaries to run on bare metal.
22:24mattmossSegFaultAX: Haven't seen gambit. If I worked on another game engine, I might do Squirrel (lua-like), or some wild genetic mangling of functional and event driven.
22:25mattmossSegFaultAX: Where were you at?
22:26jack_rabbitRegardless of the actual underlying dialect, I haven't found a language yet whose syntax I prefer to a Lisp.
22:26SegFaultAXmattmoss: PM'd
22:38jack_rabbit[]
22:40jack_rabbitWell okay, but I don't think I typed that^
22:43tjgillieswhat do you guys use to encrypt passwords?
22:44jack_rabbitMD5
22:45tjgillies....
22:45tjgilliesi hope you're joking
22:45jack_rabbit:)
22:45tjgilliesi used bcrypt in ruby land
22:45tjgilliesbut i don't see any bcrypt clojure stuff jumping out from google
22:46eggheadtjgillies: we use http://www.mindrot.org/projects/jBCrypt/
22:46xeqiyep, jbcrypt
22:46tjgilliesegghead: thnx
22:47tjgilliesi love that clojure has such every interop with java
22:47tjgillieseasy*
22:47xeqialso take a look at https://github.com/cemerick/friend if you're building a web app
22:48eggheadya, friend is great
22:49tjgilliesah i saw the friend talk at clojure west
22:49tjgillieslooked pretty cool
22:54SegFaultAXI like friend in particular because in a lot of ways it's a pretty direct translation of warden.
22:55SegFaultAXAnd warden could not be more simple for what it does.
23:18`arrdemis there a good way for me to run tests via lein & nrepl?
23:18`arrdemgoogle is looking pretty sparse on this matter.
23:18jack_rabbitWhat do you mean by tests?
23:19`arrdemif I define tests using core.test, I can invoke them via `lein tests` or such from zsh
23:19`arrdemI'd like to do so w/o leaving The One True Editor
23:19jack_rabbithmm.
23:20SegFaultAX`arrdem: Check out Midje! https://github.com/marick/Midje
23:20`arrdemcheers Seg
23:21jack_rabbit(inc SegFaultAX)
23:21lazybot⇒ 1
23:21jack_rabbitOh, the novelty!
23:21gtrakanyone have an example of coordinating a version number between a dependency and a corresponding lein-plugin?
23:21gtrakI'm just hard-coding it in a project middleware right now, feels wrong: (update-in project [:dependencies] conj '[nodisassemble "0.1.0-SNAPSHOT"])
23:24gtrakcan a lein plugin access its own version number? that would help a lot
23:24SegFaultAXgtrak: I like the name of that lib, by the way. Johny 5 would be proud.
23:24gtrakthank you :-)
23:25SegFaultAXTiff-an-y.
23:25gtrakbasically, I'm storing all the bytecode of classes in a map, then I can disassemble run-time eval'd classes
23:25jeremyheilergtrak: I don't see why not. The plugin accepts the project map as its first argument.
23:25gtrakthe plugin exists to turn on jvm instrumentation
23:25gtrakhrm..
23:26gtrakI guess the plugin would look itself up then
23:27thm_proverI have a string s, which contains xml. What is the correct way to parse s? (clojure.xml/parse s) appears to want a file rather than a string; and I'd prefer to not write out to a temporary file.
23:27technomancyhttps://lein-survey-2013.herokuapp.com/results <- posted a summary of the results to the Leiningen survey
23:27thm_proverit seems kind of stupid to go from memory to disk, only to go back to memory
23:27technomancykind of interesting to me; not sure if it's interesting to others =)
23:27gtrakthm_prover: http://clojuredocs.org/clojure_core/clojure.core/xml-seq ?
23:27st3fanomg -> also accepts partials .. (-> {:a {:b 20}} :a :b (* 20))
23:27andyfingerhutthm_prover: Take a look at with-in-str
23:27st3fani had no idea .. this will simplify my code so much
23:28gtrakst3fan: -> is syntax, not quite the same as partial-eval
23:28jeremyheilerthm_prover: You could use clojure.data.xml/parse-str
23:30gtrakthm_prover: clojure.xml/parse probably takes a stream
23:31gtrakhttp://docs.oracle.com/javase/6/docs/api/java/io/ByteArrayInputStream.html is what you want, dunno if there's a shortcut somewhere
23:31tomoj&(clojure.xml/parse (java.io.StringBufferInputStream. "<foo></foo>"))
23:31lazybot⇒ {:tag :foo, :attrs nil, :content nil}
23:32tomojoh, that's deprecated
23:32tomojsays you're supposed to use StringReader, but what if you need an InputStream?
23:32gtrakor StringReader is fine I guess
23:32gtrakyou can call clojure.java.io/input-stream on the reader if you like
23:33tomojoic
23:34tomojdoesn't appear to work
23:35gtrakhuh
23:36tomoj&(-> "<foo></foo>" java.io.StringReader. org.xml.sax.InputSource. clojure.xml/parse)
23:36lazybot⇒ {:tag :foo, :attrs nil, :content nil}
23:37gtrakmaybe it goes the other way, stream to reader
23:37thm_provergtrak: clojure.data.xml worked great, thanks!
23:37tomoj&(-> "<foo></foo>" .getBytes clojure.java.io/input-stream clojure.xml/parse)
23:37lazybot⇒ {:tag :foo, :attrs nil, :content nil}
23:38tomojI wonder if those are different?
23:38thm_provertomoj: do you not have to close the new input-stream?
23:38thm_proveror are input-streams not file descriptors?
23:38gtrakyea... check out (def default-streams-impl {:make-reader (fn [x opts] (make-reader (make-input-stream x opts) opts)) ....
23:38tomojwell close is a noop on byte array input streams
23:39jeremyheilertechnomancy: The summarized comments were interesting to read.
23:44technomancyjeremyheiler: cool; glad I'm not the only one who likes reading that kind of thing =)
23:45jeremyheilertechnomancy: Also, some of the non-summarized comments are humorous :-P
23:45technomancyjeremyheiler: yeah, like the guy who wants me to visit the bay area clojure group, huh? =)
23:47jeremyheilertechnomancy: haha yeah. and the guy that claims it sets his hair on fire.
23:47`arrdemlolwat
23:47jack_rabbit`arrdem, must be an old conversation.
23:48andyfingerhutIt is mentioned in the first sentence at leiningen.org
23:50jack_rabbitGood to know, yogthos.
23:51andyfingerhutInspired by the story "Leiningen versus the ants" http://www.classicshorts.com/stories/lvta.html (I still haven't read it despite being intrigued by the story idea a year or so ago -- now is a good time)
23:51jeremyheilerandyfingerhut: ooo, thanks for that link! Ive been meaning to check it out, but it always slips my mind.