#clojure logs

2012-10-20

00:50l1xo hai
00:51l1xis there a way to avoid nil being printed?
00:51l1xwhen i lein run my app its happening and i would like to get rid of it by default
00:53julsonl1x: does your app have a main method?
00:53l1xit does
00:54aduI had a question tho
00:54aduwhy is it so hard to use web noir with clojure 1.4 and lein2?
00:54frozenlo`it is?
00:54julsonl1x: the nil should be the result of the function being called. You could try returning something else...
00:54aduits hard
00:55l1xjulson: i would like to return nothing
00:55julsonadu: I haven't had issues with that configuration
00:55frozenlo`Me neither.
00:55l1xyeah i have it running on my laptop too
00:56julsonl1x: I don't think you can... since functions must return something by definition. Unless you fiddle around with your stdout
00:56l1xi see
00:57l1xit is just annoying that there is not idiomatic answer yet i guess :) it should be possible
00:58julsonyeah it should be possible.
00:58julsonyou could try something with Java interop
00:59julsonand create a class with a public static void main method
01:00aduhow does one use lein-noir with lein2?
01:00Raynes`lein new noir myproject
01:00Raynes`
01:00RaynesDon't install anything at all.
01:01adu"lein noir new myproject"
01:01RaynesNo, lein new noir myproject
01:01julsonRaynes is correct
01:01julsonif you're using lein2
01:01adureally?
01:01RaynesI promise.
01:01julsonyes
01:01aduthat doesn't make any sense
01:01RaynesI wrote leiningen's new task. It makes perfect sense.
01:01aduthat goes against every documentation at http://webnoir.org/
01:01julsonthat's kinda outdated
01:02aduwuh
01:02aduthen why am I following it
01:02julsonI think the documentation's for lein1
01:02l1xyes
01:02RaynesThat's because the website documents the current release of noir which was pre-lein2.
01:02frozenlo`adu: Raynes wrote a big part of Noir, I would listen to him :P
01:02aduok
01:02Raynesfrozenlo`: Naw.
01:02RaynesI wrote small pieces and moved other pieces.
01:02RaynesI still couldn't tell you how half of it works.
01:02aduAHA
01:03aduit is "lein new noir myproject"
01:03Rayneswebnoir's code examples are generally fine. It's installation instructions and stuff that is confusing.
01:03RaynesI need to talk to ibdknox about getting the 1.3.0 final release out.
01:03adufascinating
01:03RaynesSo documentation can be updated and stuff.
01:04aduthanks :)
01:04l1xyeah lowering that barrier helps
01:04l1xi had to ask it on irc :)))
01:04frozenlo`Raynes: don't you break 1.3.0-beta! ;-)
01:05Raynes:p
01:05aduand I was about to switch to joodo :P
01:06Rayneswat
01:06RaynesThat's a thing?
01:06RaynesHuh, that is a thing.
01:06RaynesI've never heard of that.
01:07julsonoh wow.
01:07RaynesThe formatting of his map in his "Leiningen 2" example does not inspire confidence.
01:08aduapparently, joodo and noir have the same dependancies, so at first I thought they were interchangable
01:09RaynesI mostly just use Compojure these days.
01:09l1xmy only problem with clojure is the memory usage
01:09adumaybe I should try a site that uses only that
01:09RaynesLooks like joodo is an 'in addition to' thing vs a replacement thing.
01:09RaynesWhich is nice. Libraries > frameworks any day of the week.
01:10Raynesl1x: You can limit it to a certain extent.
01:10FrozenlockRaynes: I've heard that a lot. Was Noir getting in the way?
01:10Raynesl1x: amalloy and I do that for all of our stuff.
01:10l1xRaynes: sure, but it is not enough for me
01:10aduboth joodo and noir depend on Ring, Compojure, and Hiccup
01:10l1xi want to write apps with 5-10Mb memory usage
01:10RaynesThen you probably want a non-JVM language.
01:10l1x(which is possible even with Ruby for example)
01:10RaynesIt comes with the territory. Not much you can do to avoid it.
01:11l1xi guess you have few options
01:11RaynesI have 8GB of RAM now. I want it to use more memory.
01:11adulol
01:11l1xRaynes: i got it :)
01:11l1xin production i use 24G/24core
01:12l1xbut sometimes it is not about who's dick^H^H^Hserver is bigger
01:12RaynesAnyways, on a more serious note, you could check out Clojurescript + nodejs. Unfortunately, the nodejs support is moderately buggy. I think the worst bugs have been cleared out though.
01:12RaynesThere is also clojurepy if you're into snakes.
01:13aduI've heard some terrible things about nodejs
01:13RaynesCould do some Haskell.
01:13l1xwel well well
01:13l1xi could do it with Ruby + eventmachine
01:13RaynesYou certainly could.
01:13RaynesYou could do it in Forth.
01:13l1xi prefer Ruby's syntax over JS
01:14l1xoch, actually i was working with Forth :)
01:14l1xthis is how old i am
01:14RaynesI prefer Clojure's lack of syntax over most things.
01:14aduFYI, I'm not a lisp person, I'm a scheme person, but then after writing a couple scheme interpreters, and half a scheme compiler, I realised that (define (f x)) is bothersome, hence the recent conversion to clojure :)
01:14l1xRaynes: sure
01:14l1xme too
01:14RaynesScheme is a Lisp.
01:14l1xbut there is no point of spinning up the JVM sometimes
01:14l1xall i am sayin'
01:15RaynesI write Ruby sometimes too.
01:15Rayneshttps://github.com/Raynes/refh
01:15julsonspeaking of clojurescript. does anyone have a good workflow for using both cljs and clj in one project?
01:15aduright, but (defn) is shorter, and separates out the function name, which looks really nice
01:15RaynesI needed fast startup speed in this case, so Clojure was out of the question. I might have done clojurescript if the node support wasn't broken to shit at the time.
01:16l1xhehe
01:16l1xknowing clojure also makes your imperative code better, at least this is my experience
01:16RaynesI would have wrote it in Haskell, but I've mostly forgot everything I've learned about Haskell.
01:17RaynesWell, I never had any imperative code. I went into Ruby *from* functional languages.
01:18dfdcan anyone suggest how I stub something out in Midje? I want to avoid actually sending an email (trying to stub out drewr's postal library: https://github.com/drewr/postal)
01:18RaynesWhat does 'stub' mean?
01:19aduI've noticed I think that way too, when I want to map something, I think "how to I (map f xs) with a foreach loop?"
01:20dfdRaynes: I mean, avoid having the function actually get called when my code-under-test is hitting that library
01:21dfdRaynes: I'll point you to this old classic too if you aren't familiar with the subject: http://martinfowler.com/articles/mocksArentStubs.html ...worth a read.
01:21RaynesMakes sense.
01:22RaynesI thought at first you wanted to comment out a piece of code.
01:23dfdRaynes: yeah, it does sound like that! But no, I just want to avoid sending out emails, while testing that I'm calling the mailing function. I understand how to verify it's being called in Midje, but I'm a bit clueless when it comes to stubbing the function out completely at the same time.
01:24Raynesdfd: Maybe with-redefs
01:24Raynes(with-redefs [println +] (println 2 3)) = 5
01:25dfdRaynes: ooh, that looks promising, thank you!
01:26dfdRaynes: actually, that looks just right--there is a perfect example at the bottom here using it to test HTTP: http://clojuredocs.org/clojure_core/clojure.core/with-redefs
01:26dfdRaynes: thanks so much!
01:26RaynesYou, sir, are very welcome.
01:27julsonoh wow. I learned something new today. awesome
01:28Sgeowith-redefs doesn't work with Java methods, right?
01:29RaynesNo.
01:30RaynesIt works by pointing vars at something new.
01:30RaynesIf you want to change a Java method, I suggest poison and a smooth drink to see you off.
01:31SgeoDarn
02:17wei_using compojure, what's the easiest way to serve a special page when a mobile user agent is detected?
02:19Rayneswei_: You can use middleware that checks the user agent, or if you want to do it in each of your routes, you can just check for the user agent and do whatever.
02:20wei_is there a middleware that everyone uses or should I just roll my own?
02:21SgeoPlease please please, if someone is trying to access an article on their phone, don't direct them to the mobile front page and utterly ignore where they were trying to go
02:21Sgeohttp://xkcd.com/869/
02:24wei_haha, thanks. I'm planning to serve the same content, but in a different format
02:25SgeoHmm. I'm not a web dev, but I'm curious, what's wrong with just using CSS to control it?
02:32wei_it's a travel planner, a single-page app with a big google map in the center. some of the features don't translate very well to mobile.
02:34mjcif you're on a mobile device, you're likely already traveling. the app would be redundant.
02:35wei_right. you're usually just referring to your itinerary
02:36SgeoMap could be hidden with CSS though, although I guess not sending it and not sending the code is better
02:43wei_come to think of it, it'd be ideal if one could use the mobile app offline. wouldn't it be awesome to build a native app using clojure!
02:44SgeoI think there's something in HTML5 that allows a page to load from cache and do some stuff offline
02:45SgeoI guess you'd be using ClojureScript though
02:45wei_still awesome. my main app is mostly in clojurescript
02:47lpvbSgeo: how do you like Clojure compared to haskell?
02:47Sgeolpvb, I still have written less code in Clojure than Haskell, and my preference for Clojure over Haskell is still based mainly on academic thoughts rather than actual usage
02:48Sgeo(In particular, macros and ease of changing running code)
02:48callenlpvb: I have pragmatic reasons for preferring clojure.
02:48Sgeolpvb, but I do miss some Haskell stuff
02:49callenlpvb: rapidity of development, interactive development, just plain prefer a lisp, macros, lein instead of cabal (cabal is a goddamn horror), java libraries are more practical and better tested than Haskell ones, better escape-hatches for leaving the overall paradigm as necessary...
02:49lpvbcallen: haskell has interactive development
02:49callenlpvb: easier to write code you undrstand the behavior of in Clojure than Haskell. The lazy semantics in Haskell can be hell in how prolific they are.
02:49callenlpvb: Haskell hasn't 100% embraced them, it's not comparable to clojure at all.
02:50lpvbyou guys don't find the lack of strong typing to cause tricky type errors?
02:50callenhell no.
02:50Sgeocallen, pervasive laziness has some benefits. See the fact that Clojure is only getting a way to stop a reduce in 1.5
02:50callenSgeo: I don't care.
02:51lpvbI abuse laziness alot
02:51callenit's not like python/ruby/java where a type error can occur from the multitude of arbitrary operations and methods that can be wrong in a given context.
02:51SgeoI'd prefer to have static typing, but not convinced about lack of it outweighing the other things
02:51callenin a Lisp, most things are list-esque and just work.
02:51callenthere are fewer avenues for dynamic typing to bite you in Clojure, than in Python/Ruby
02:51callenlower degree of dimensionality of access
02:51lpvbfor instance, I turn whole strings into list of words and grab the first 2 or something and I know the rest of the words won't be operated on
02:51callenfewer "traps" too.
02:51Sgeocallen, not sure I agree. Maybe you have a function expecting a map with keys :foo :bar and :baz
02:52SgeoYou accidentally make something just with :foo and :bar
02:52SgeoFunction blows up
02:52callenSgeo: no programming language can save the brain dead.
02:52callenSgeo: clojure's access patterns are still far more consistent and less error prone than Python or Ruby or Tcl.
02:52lpvbI like the syntax of clojure and macros, but I'm scared to jump out of the type system safety net
02:52callenTcl is a goddamn horror for writing reliable code 'in the large'
02:52lpvbto even bother using it over haskell
02:53callenlpvb: there's a type system in clojure, just not one that changes your diaper for you at compile time.
02:53Sgeolpvb, at least, Clojure does have lazy sequences
02:53callenlpvb: code accordingly. take advantage of the freedom.
02:54callenlpvb: in particular, the pattern in lisps/python/ruby is to prototype the concept with potentially incorrect code until you get the basic idea right, then begin "firming" it up as you go.
02:54rcglpvb, you can always add some "safety net" using test-driven development
02:54SgeoAlthough I think there should be a collection of macros or functions or something for easily defining lazy data structures and functions to act on them.
02:54callentests are actually empirically more useful for creating reliable code than type systems anyway.
02:54callencode reviews are the process-level thing shown to be most useful.
02:55callentests can provide a "bottom" or minimum level of guarantee, and there's an equivalent to Haskell's QuickCheck for Clojure.
02:55callenit seriously doesn't matter though.
02:55callenthe problem with the world isn't that your code isn't perfectly type-checked, it's that it doesn't exist yet.
02:56callensolve the problem of writing code that solves problems, worry about perfecting it later.
02:56brainproxy isn't someone working on a typed clojure extension thing?
02:56brainproxy(maybe that's been mentinoed already...)
02:56callenbrainproxy: typed racket is a thing too.
02:57SgeoWhat's worse? A library that doesn't exist, thus prompting someone to write code for their use case, or making a library that has a subtle error, thus causing someone to use it, but it fails horribly for them?
02:57callentyped racket is moderately...popular. Relatively speaking.
02:57brainproxysure, the former is proabably informed by the latter
02:57callenSgeo: the problem with most libraries isn't bugs, but sub-optimal design or API.
02:57callenSgeo: bugs can be fixed, fundamentally incorrect approaches are irreconciliable.
02:57callenquicker iterations and design-phases such as a lisp can enable are more likely to prevent you from fucking that stage up.
02:58callenhaskell has a habit of making my code more crystalline and rigid in design than I like.
02:59callenin Clojure and Python, if I notice an impedance mismatch between my problem and my code, I'm a lot more likely to just fix it
02:59brainproxyi think the merits of being able to have strongly typed components in a clojure library will only become apparent, or perhaps will be proved as not-so-useful, once that extension hits beta and folks start experimenting with it
02:59callenwhereas in Haskell I am punished with an infinite series of irritating type errors because I flipped like one monad lift around.
02:59shachafHey, it's robink.
02:59callenhey it's shachaf
03:01ivan,((fn [{:keys [a b]}] (+ a b)) {:a 2})
03:01clojurebot#<NullPointerException java.lang.NullPointerException>
03:02ivanis there a way to :mandatory-keys or somesuch?
03:02ivanmacro hackery with precondition?
03:07ivanoh right, I want :or
03:08Sgeo,((fn [{:keys [a b]}] a) {:a 2})
03:08clojurebot2
03:09SgeoHmm, no easy way to tell if a key was provided?
03:09SgeoReliably, I mean.
03:09SgeoI could use (let [sentinel (Object.)] ...)
03:09ivanyeah, that's what I was thinking
03:12mattmoss&(assert (contains? {:a 1 :b 2} :c))
03:12lazybotjava.lang.AssertionError: Assert failed: (contains? {:a 1, :b 2} :c)
03:14ivan,((fn [{:keys [a b] :as opts}] (contains? opts :c)) {:a 2}) ; Sgeo
03:14clojurebotfalse
03:14SgeoGood point
03:16ivanClojure's destructuring really makes me hate everything else
03:17SgeoHaskell's pattern matching?
03:18ivanmight work, I've barely used Haskell
03:20shachafivan: Prolog's unification?
03:20shachafUnification is the future.
03:26doomlordwhat to call this hof:- (?? f [a b c d..])->[(f a b)(f a c)(f a d)..(f b a)(f b c..)] i.e. f invoked on every potential pair from a sequence,
03:29SgeoSome combination of juxt, apply, and permutations
03:29shachafLike a cartesian product?
03:29SgeoWait, there is a permutations function somewhere, right?
03:29shachafI guess you're not taking the diagonal.
03:29SgeoWait, not permutations
03:29doomlordiits easy enough to do imperatively :)
03:29mindbender1I hope more light will be thrown on the issue of disentangling at the conj!
03:30doomlordi've got an implementation in clojure but not sure its the most elegant
03:30mindbender1rhickey promised this!
03:31doomlordi need every pair , and every tripple aswell. (i'll stop there but i thought it would be possible to write one generalized, every n-tuple ..)
03:31hiredmanhave you seen partition?
03:31shachafdoomlord: (a,a) is a pair. :-)
03:31hiredmanoh, right
03:31Sgeomindbender1, disentangling/
03:32doomlord(not doing the diagonal; and its assumed f a b = f b a)
03:32mindbender1especially how the problem of inheritance is solved with clojure as it seems so pervasive among frameworks theses days
03:33hiredmanmindbender1: the way to disentangle inheritence is to not do it
03:33shachafdoomlord: If f a b = f b a, then why are you doing both?
03:33doomlord(equiv of (for i=0..n {for j=0..i { result.append(f(i,j))} ))
03:33doomlordnot doing both
03:34mindbender1hiredman: but it's done greatly in the closure lib
03:34doomlordgiven a list of N, its N(N-1)/2 invocations
03:34mindbender1and then clojurescript is built on it
03:34hiredmanmindbender1: and it is done a lot in the jre, but clojure is built on that
03:35mindbender1yes but how then do we label everything
03:35mindbender1and know how to interop
03:36doomlordcurrently i'm doing it by mapping ranges with indexing inside but it should be possible to do for lists with no random acess
03:37mindbender1especially when it comes to ui components
03:37hiredmanhttp://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/
03:38doomlord(c version for linklist would be, for (a=list; a; a=a->next){ for (b=a->next; b; b=b->next){ doSomething(a,b);}} ) ... i guess thats easy to do recursively, but how to do it for a method that can be parallelized
03:40doomlordah its nested maplists in lisp i think.. does clojure have one like that..
03:42SgeoDo you mean like for?
03:42Sgeo,(for [a [1 2 3] b [4 5 6]] {:a a :b b})
03:42clojurebot({:a 1, :b 4} {:a 1, :b 5} {:a 1, :b 6} {:a 2, :b 4} {:a 2, :b 5} ...)
03:42Sgeo,(for [a [1 2 3] b [1 2 3]] {:a a :b b})
03:42clojurebot({:a 1, :b 1} {:a 1, :b 2} {:a 1, :b 3} {:a 2, :b 1} {:a 2, :b 2} ...)
03:43doomlordnot what i was after but that is interesting
03:44Sgeo,(catmap (fn [x] [(dec x) x (inc x)]) [1 2 3 4 5])
03:44clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: catmap in this context, compiling:(NO_SOURCE_PATH:0)>
03:44doomlord,(for [a [1 2 3]] (for [b (range a)] {:a a :b b}))
03:44clojurebot(({:a 1, :b 0}) ({:a 2, :b 0} {:a 2, :b 1}) ({:a 3, :b 0} {:a 3, :b 1} {:a 3, :b 2}))
03:44Sgeo,(mapcat (fn [x] [(dec x) x (inc x)]) [1 2 3 4 5])
03:44clojurebot(0 1 2 1 2 ...)
03:44doomlordnearly
03:45doomlordyeah i've found "mapcat" from an earlier experiment; i've used that in my current implementation of this(the outer pass is a mapcat)
03:45SgeoFun fact: You can consider for to effectively be built on mapcat
03:45doomlordhow so..
03:47Sgeo,(mapcat (fn [x] [{:a x :b 4} {:a x :b 5} {:a x :b 6}]) [1 2 3])
03:47clojurebot({:a 1, :b 4} {:a 1, :b 5} {:a 1, :b 6} {:a 2, :b 4} {:a 2, :b 5} ...)
03:48SgeoIf you know Haskell: mapcat is =<< on sequences, and for is do notation on sequences
03:48doomlordheh i know a little haskell, i've used >>= but not =<<
03:49Sgeo>>= is just =<< with the arguments in the opposite order
03:49lpvbClojure/Scala/Erlang have a lot of real world jobs compared to other functional languages
03:50SgeoErm, what I said is true, but I think I meant to say that =<< is just >== with the arguments in the opposite order
03:50Sgeo>>=
03:50SgeoOh, I guess for is more like a list comprehension than do notation, due to the implicit return]
03:51Sgeo,(for [] 5)
03:51clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: >
03:51doomlordis there something like commonlisps 'maplist'
03:52SgeoIf there is, it isn't Haskelly. It seems to not be ... actually, I thought of a way to do it in a typesafe manner
03:52doomlordclojure has a mix of lazy seqs and eager eval?
03:53SgeoWait, no, it's easily done type-safely, I'm a derp
03:54Sgeodoomlord, Clojure itself is strict/eager, but lazy seqs are objects that when seq operations are done on them, they don't do them immediately
03:54SgeoSo yes
03:55Sgeodoomlord, hmm, maybe trickery with reduce?
03:56doomlordto write 'maplist' .. something recursive using 'rest' i guess
03:57doomlord(recur?)
03:57Sgeoreduce makes no sense I think
03:58doomlorddidnt thinkso for this
04:00doomlordok lisp version,nearly: (maplist(lambda(x)(mapcar(lambda(y)(list (first x)y)) (cdr x))) '(1 2 3)) -> ((1 2)(1 3)(2 3) NIL)
04:01doomlordmy current clojure implementeation differs in that it's using maps over ranges so its having to do random access.. whereas the above works on lists
04:01RaynesPlease, God, spaces.
04:04SgeoIs this acceptable to Clojure, as in, would it work?
04:04Sgeo((somemacro someothermacro) some stuff)
04:04SgeoAs in, somemacro is a macro that takes an argument and expands to a macro name
04:05RaynesIt should, I think.
04:07SgeoMuahaha! Macro composition!
04:07Raynes(defmacro somemacro [n] ''n)
04:17doomlord (defn maplist[f ls] (if (first ls) (concat (seq (f ls)) (maplist f (rest ls)) ) (list)) )
04:17doomlord(does 'rest' return the same type as seq)
04:18doomlordoops last should be nil not list
04:21doomlordoh and i think i want 'recur' instead ?
05:07wingyI have always thought that after the . is a namespace and after the / is a variable
05:08wingy(type (range 5)) gives me clojure.lang.LazySeq … which apparantely is a class?
05:08SgeoYes, from what I've heard type is roughly obsolete
05:08wingyso I thought shouldn't it be clojure.lang/LazySeq .. or is it a Java convention that is used?
05:08SgeoJava classes aren't stored in vars
05:09wingyokay
05:09wingymakes sense then
05:09wingySgeo: why is type obsolete .. what should i use to determine the type then?
05:10Sgeoclass
05:10Sgeo,(class (range 5))
05:10clojurebotclojure.lang.LazySeq
05:10wingyokay
05:10SgeoFrom what I've heard, type is a throwback from when there was another way to specify a type
05:10SgeoI should note that I'm not an expert
05:10wingyclass makes more sense .. you hear its a class :)
06:10devn,(class (range 0 0 0))
06:10clojurebotclojure.lang.LazySeq
06:10devn,(class (range 0 10 2))
06:10clojurebotclojure.lang.LazySeq
06:10devn,(class (range 0 10439843 2))
06:10clojurebotclojure.lang.LazySeq
06:22wingyhttp://www.infoq.com/presentations/DSL-Clojure
06:22wingymakes me think about using Midje instead of clojure.test :)
06:22wingyand other libraries as dsls like logic
06:32si14hi there. Am I right that Noir is the most advanced Clojure web framework at the moment?
06:32si14"last commit: 1 month ago" looks kinda scary
06:34RaynesOne month looks scary...?
06:34RaynesAnyways, the author has been busy with other things lately, so things have been slow. I try to merge pull requests and such when I can.
06:35RaynesThat said, I tend to use Compojure.
06:35RaynesNot because Noir is outdated/not good, but because I like Compojure better.
06:35RaynesNeither is more advanced than the other.
06:37si14Raynes: isn't Noir based on Compojure?
06:38RaynesNoir is built on top of Compojure.
06:38wingywhich makes Noir more than Compojure .. but perhaps you dont want that kind of abstraction
06:38si14ah, I see.
06:38clojurebotPardon?
06:38RaynesIt adds on a more stateful routing DSL and comes with several useful libraries. I've moved those libraries into a library called lib-noir that you can use from compojure though.
06:39si14just wondering what's the state of the art is.
06:39RaynesMost people use Compojure, lots of people use Noir. Either is fine.
06:39ivanwhat do you guys think of underscores in numeric literals like 1_000_000_001?
06:40si14it's strange that there is no popular (?) combination of Noir/Compojure and ClojureScript.
06:40RaynesI think that doesn't work.
06:40si14at least for validators it seems essential.
06:40ivanright, I kind of wish it did
06:40ivan(it does in Java 7)
06:40RaynesI think it's hideous.
06:40ivanwell, the comma is already taken
06:41ivanand it is not i18n
06:41Raynessi14: I'm not sure what that 'combination' would look like.
06:41RaynesMost people just have projects with clojurescript, compojure, and lein-cljsbuild.
06:43si14Raynes: I don't know, it's wishful thinking. Templates that can be rendered on the server and on the client, universal validators for server and client, stuff like this.
06:44andrewmcveigsi14: that's fairly easily possible
06:44andrewmcveigsi14: you don't need noir for that.
06:45ivanhttp://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html
06:52si14andrewmcveig: I know, it's just handy to have stuff already done for you, like Rails.
06:54ivanI guess I can always have a macro that does this, but it seems kind of lame: user=> (n "1000 2000 4514")
06:54ivan100020004514
06:54andrewmcveigsi14: I suppose it depends on what you're looking for...
06:55si14andrewmcveig: stuff that can be done with Rails, basically :)
06:55si14andrewmcveig: just like Clojure better
06:56andrewmcveigsi14: compojure + a few libs do enough for me, but not as much as rails.
06:56alex_baranoskycan you do this kind of Javascript object properly access via ClojureScript? => a["3"] ?
06:57alex_baranoskyI have some JS I was playing around with converting to CLJS, but it has some JSON object that it receives from the server that have keys of "1", "2", "3" etc
06:57ivan(aget a "3")
06:58alex_baranoskyivan: thanks
07:01alex_baranoskyanother CLJS question - how do I reference undefined?
07:02ivanmaybe js/undefined
07:05alex_baranoskyivan: will try that
07:05ivanthere may be function in Closure Library's base.js that does the undefined/null check you want
07:05ivanundefined is the devil
07:06alex_baranoskyivan: that did it
07:06shachafhi ivan
07:06ivanhi
07:06alex_baranoskywhere are the good cheat sheets and references online for CLJS?
07:06shachafI think JavaScript undefined is positively nice compared to Haskell undefined.
07:06shachafThe *real* devil is the halting problem.
07:06ivanalex_baranosky: there's a beta O'Reilly book but I have no idea what's in it
07:07alex_baranoskyyeah, I just bought it :)
09:13bonegaShould nrepl-jack-in set cwd to project root? For me it defaults to $home
09:41bonegano matter, there was something weird going on
09:53rod_hi, i've just started using datomic with compojure - but now all stdout seems to get supressed - is there some logging/options i need to configure? thanks
10:39rod_i've got a database connection which could change over the lifetime of the program, what's the best way to keep this around - i'm think about using a ref or an atom, is this a good/bad idea?
10:55cemerickdnolen: sorry for the patch churn. :-|
10:56dnolencemerick: no problem, that's an interesting bug in the compiler
10:56cemerickYeah. I never thought to look at the generated output.
11:03dnolencemerick: I usually sanity check with by modifying the tests to compile w/ {:optimizations simple :pretty-print true} and look at the generated file.
11:04cemerickNoted; I'll aim to do the same until my instincts get better.
11:07dnolencemerick: if it's simple it also easy to check generated js via the REPL w/ (fn [] expr)
13:19samratis anyone using emacs-live with evil-mode? its behaving really annoyingly with nrepl
13:19Kruppesamrat: what kind of annoying
13:20Kruppesamrat: not moving to the next prompt annoying?
13:33samratKruppe: yes, how can I fix that?
13:35Kruppesamrat: This bugreport talks about it https://bitbucket.org/lyro/evil/issue/209/not-moving-cursor-to-prompt-in-comint-like
13:35Kruppesamrat: you can fix it with some advice to the function called when you press return
13:36Kruppesamrat: fixed it for me anyways
13:52ssideris_are there any examples of mixing clojure and clojurescript i.e. having the *same* code run on the server and the browser?
13:52ssideris_I don't know how to set up my project
13:53ssideris_erm, nevermind: https://github.com/emezeske/lein-cljsbuild/blob/0.2.9/doc/CROSSOVERS.md
15:01SgeoIs there a way to define my own binding forms?
15:04gfredericksSgeo: you mean such that let/fn/loop would participate?
15:04metajackis there a way to have nrepl.el do a browser repl?
15:04Sgeogfredericks, yes
15:05metajacklein cljsbuild repl-listen seems to connect itself but not allow nrepl clients to connect
15:12gfredericksSgeo: I don't think there's any built-in way. The cleanest thing you could do is just define your own let/fn/loop macros and use in your own code
15:13AtKaaZhey does anyone know why https://github.com/Datomic/day-of-datomic recommends to start lein repl 2 with trampoline ?
15:18AtKaaZcan we access clojure's AST at runtime? ie. if we wanted to vizualize the code
15:19ChongLisomeone else will correct me if I'm wrong, but I think clojure's code is the AST
15:19ChongLithat's what it means to be a homoiconic language
15:19AtKaaZit compiles to java bytecode though
15:20AtKaaZbut i need to know if I can access it, read only at least
15:20ChongLithe bytecode?
15:20AtKaaZno, the ast
15:20AtKaaZthe clojure code as it is in the ast
15:21AtKaaZwhich probably means i see no macros, they'd be already expanded
15:21ChongLilike after macroexpand?
15:22TimMcChongLi: There are two problems: 1) The reader changes the surface syntax e.g. #(%) into the deep syntax, and 2) the compiler builds an AST that doesn't always match the deep syntax.
15:22ChongLiah
15:22ChongLishouldn't he able to run some low-level function to get that result?
15:23AtKaaZChongLi, I think after the eval part of the REPL, each macro use is replaced with the expanded macro
15:23AtKaaZbut not after the R phase
15:23ChongLihave you looked at the clojure source code?
15:24AtKaaZnot really
15:25TimMcAtKaaZ: Eval comprises several steps, one of which is AST building.
15:26AtKaaZTimMc, you mean the AST is not yet existent at the read phase? only at the eval phase? not implying that I know
15:27TimMcRead, macro-expand, build AST, compile, run, serialize results, print.
15:28TimMcs/compile/turn into byte-code/
15:28tgoossens_I have a lazy sequence that i want to convert to a string. (
15:28tgoossens_and I am 100% sure that the sequence is finite
15:28tgoossens_for example
15:28TimMcAtKaaZ: Read has to happen before macro-expansion, which has to happen before eval.
15:28tgoossens_'(a b c) i want it so print like "a b c"
15:29AtKaaZTimMc, are the first two read/writing the text ?
15:29gfredericksfoo' wasn't valid syntax in 1.2?
15:29TimMcgfredericks: Nope!
15:29gfredericksso 1.2 has slow maths also?
15:29TimMcgfredericks: S11001001 showed me a cool trick with that.
15:29AtKaaZ,foo'
15:29clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo' in this context, compiling:(NO_SOURCE_PATH:0)>
15:30AtKaaZwhat's that supposed to do? except in case of *'
15:30Sgeo,(clojure.str/join " " '(1 2 3))
15:30clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.str>
15:30Sgeo,(require 'clojure.str)
15:30clojurebot#<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/str__init.class or clojure/str.clj on classpath: >
15:30Sgeo,(require 'clojure.string)
15:30clojurebotnil
15:30Sgeo,(clojure.string/join " " '(1 2 3))
15:30clojurebot"1 2 3"
15:30SgeoCould also ##(apply str '(1 2 3))
15:30lazybot⇒ "123"
15:31SgeoEr, guess not
15:31AtKaaZ,(str '(1 2 3))
15:31clojurebot"(1 2 3)"
15:31SgeoJust use clojure.string/join
15:31AtKaaZ,(str (list 1 2 3))
15:31clojurebot"(1 2 3)"
15:31AtKaaZyep join =)
15:32Sgeo,(doc interleave)
15:32clojurebot"([c1 c2] [c1 c2 & colls]); Returns a lazy seq of the first item in each coll, then the second etc."
15:32TimMc...but don't use interleave here, it's silly.
15:32Sgeo,(doc intersperse)
15:32clojurebotExcuse me?
15:32TimMcSgeo: interpose
15:32Sgeo,(doc interpose)
15:32clojurebot"([sep coll]); Returns a lazy seq of the elements of coll separated by sep"
15:32TimMcnot that either
15:33Sgeo,(apply str (interpose " " (map str '(1 2 3))))
15:33clojurebot"1 2 3"
15:33AtKaaZlol
15:33TimMcgfredericks: ##((first [+' +]) Long/MAX_VALUE 1)
15:33lazybot⇒ 9223372036854775808N
15:33Sgeo,(doc with-out-str)
15:33clojurebot"([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
15:33AtKaaZ,(apply str (interpose " " '(1 2 3)))
15:33clojurebot"1 2 3"
15:33tgoossens_the join worked :)
15:33Sgeo,(with-out-str (apply print '(1 2 3)))
15:33clojurebot"1 2 3"
15:34Sgeotgoossens_, yeah. We're just messing around
15:34tgoossens_sure thing! thanks for helping. I'll be posting what i'm doing very soon. its something very cool :D
15:35TimMc,(first [+' +])
15:35clojurebot#<core$_PLUS__SINGLEQUOTE_ clojure.core$_PLUS__SINGLEQUOTE_@4db3ea55>
15:35TimMc^ do that in v1.2 and you'll get _PLUS_ instead
15:35TimMcand they do the same thing
15:35Sgeo,#'with-out-str
15:35clojurebot#'clojure.core/with-out-str
15:36Sgeo,(meta #'with-out-str)
15:36clojurebot{:macro true, :ns #<Namespace clojure.core>, :name with-out-str, :arglists ([& body]), :added "1.0", ...}
15:36AtKaaZtgoossens_, https://www.youtube.com/watch?v=0SARbwvhupQ
15:36Sgeo,(doc with-meta)
15:36clojurebot"([obj m]); Returns an object of the same type and value as obj, with map m as its metadata."
15:36tgoossens_what is it about?
15:36tgoossens_ok
15:36tgoossens_i get it :p
15:37tgoossens_sorry about that :D
15:37AtKaaZlol, it's about keeping it secret for too long being too bad for you:)
15:37AtKaaZpotentially:)
15:37SgeoAtKaaZ, I tend to blab about what I want to do then never actually do it
15:37AtKaaZSgeo, same lol
15:38SgeoAlthough hey, I finally wrote the bot that I told some channel I was going to write... in Tcl, because it was during my recent Tcl phase.
15:38tgoossens_i'll keep it open in the background while working
15:38AtKaaZif you like to keep it private until it's ready to be released, that's a video to look at:)
15:38AtKaaZSgeo, what does it do?
15:39ToBeReplacedanyone have a recommendation for logging ring server requests? https://github.com/pjlegato/ring.middleware.logger looks solid to me, but wondering if there's others out there
15:39AtKaaZSgeo, this one might be good for you lol(and me) https://www.youtube.com/watch?v=NHopJHSlVo4
15:40tgoossens_i'll take a look at it thanks :D
15:47tgoossens_Wow
15:47tgoossens_that video (of google IO)
15:47AtKaaZany good?
15:47tgoossens_the situations they describe are shockingly similar of what i'm experiencing in my project at university
15:47AtKaaZsweet
15:48AtKaaZsynchronicity ftw:)
15:48tgoossens_in fact, they describe the problems we encountered the past few weeks, well... exactly :p
15:48tgoossens_someone worked on something for 1 week, even when asked did not provide any info of how and what he was doing exactly
15:48tgoossens_then everything had to come together
15:49tgoossens_and he wrote redudant stuff
15:49AtKaaZthat's exacttly what I was thinking of when I gave you the link:)
15:49tgoossens_next week i was going to address that problem to the group. better watch that video entirely :D
15:49AtKaaZbut in all fairness you did say "very soon" so it probably doesn't apply to you
15:50AtKaaZright on
15:50tgoossens_yeah. In maximum 1 hour or so (i am writing the blogpost ) :D
15:50tgoossens_but nevertheless shockingly useful video!
15:50AtKaaZcool
15:52tgoossens_it has been one month i've been looking into clojure. It were the most interesting programming days i've got in all time :p
15:53tgoossens_ok. this is getting interesting: "avoiding the trap"
16:07ohpauleezlynaghk is bending open the fifth dimension with core.logic as we speak
16:07AtKaaZwhat's the 4th one?
16:08tgoossens_how can i get this to work: (read-string (clojure.string/escape "(println "test")")) probably messing up with the quotes
16:08Bronsa(read-string (clojure.string/escape "(println \"test\")"))
16:09tgoossens_thats not really what i need
16:09tgoossens_i want to do this:
16:09tgoossens_(read-string "(println "test")") . because this didn't work , i tried with escape
16:09AtKaaZI think maybe you need a macro?
16:10AtKaaZthat will escape things for you
16:10tgoossens_so it doesn't evaluate? (not sure never created a macro before)
16:10SgeoI think a reader macro might actually be more stylish here, but Clojure doesn't really have a way to make your own
16:11AtKaaZ,(#(count %&) "(println "test")")
16:11clojurebot3
16:11SgeoIt didn't complain about test?
16:11AtKaaZit's the 2nd arg:D
16:12Bronsa,(doc test)
16:12clojurebot"([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception"
16:13Sgeotgoossens_, is there a reason you're putting code in a string like that?
16:13Sgeo,(println '(println "Test"))
16:13clojurebot(println Test)
16:14Sgeo,*print-readably*
16:14clojurebottrue
16:14Sgeo...
16:14tgoossens_yes
16:14tgoossens_but
16:14tgoossens_i'm just wondering
16:14tgoossens_if a load in a string
16:14tgoossens_into
16:14tgoossens_(from-string)
16:14ohpauleezAtKaaZ: The 4th dimension is time
16:14tgoossens_and there are already double quoutes in the string
16:14tgoossens_how i can keep them
16:14Sgeo,(doc from-string)
16:14clojurebotexcusez-moi
16:15AtKaaZohpauleez: ok
16:15tgoossens_so that later on
16:15tgoossens_when i want to print it again
16:15tgoossens_the output
16:15tgoossens_is again
16:15Sgeo"This string has no quotation marks"
16:15tgoossens_" (println "test") "
16:15Sgeo"This string has one quotation \" mark inside it"
16:15SgeoShouldn't need to do anything special
16:16ohpauleezThe fifth one? Well let me tell you - it involves a lot of whiskey and IPAs
16:16Sgeo,(println "(println \"Test\")")
16:16clojurebot(println "Test")
16:16SgeoNote that that \" is just how to represent a string in syntax
16:16SgeoThe string itself does not contain \
16:16tgoossens_yes
16:16SgeoHmm
16:16AtKaaZohpauleez: 5th one is all possible combinations 4th dimensions?
16:16Sgeo,#"testing\"testing"
16:16clojurebot#"testing\"testing"
16:17AtKaaZohpauleez: what's IPAs?
16:17ohpauleezIndia Pale Ales
16:18AtKaaZSgeo, any way to automatically quote?
16:18SgeoAtKaaZ, at the reader level?
16:19SgeoWell, as mentioned before, might be possible to write a macro to do it
16:19tgoossens_ok that io video made me think
16:19AtKaaZI thought maybe there's already something like that
16:19SgeoHmm, I don't need to declare functions in a special way in order for macros to use them, right?
16:19tgoossens_i'm not going to get forward if I don't explain what i'm doing
16:19tgoossens_:p
16:20SgeoAtKaaZ, regex reader macro might do something, maybe?
16:20tgoossens_i'll write the blogpost with the half-working code. And then i'll post a link here
16:20AtKaaZSgeo, possibly, if I had any exp. with it :))
16:22AtKaaZcould the ArityException maybe tell exactly how many args are expected? or there could be those variable arity methods which would make this unlikely?
16:22AtKaaZvariable=multiple
16:23alex_baranoskyanyone know how to reference 'this' in CLJS?
16:23SgeoAtKaaZ, hmm?
16:23Sgeoalex_baranosky, there's a macro for it
16:23Sgeothis-as I think
16:24AtKaaZ,(#("%") "!")
16:24clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval27$fn>
16:24AtKaaZSgeo, it says that I passed 1 arg, but maybe it could also say how many args can I pass? like 0 or between min/max 0/0 :))
16:25AtKaaZin case of multiple arity methods could be min/max 0/3 ie. when I pass 4
16:25SgeoAtKaaZ, don't know, don't complain to me
16:25alex_baranoskySgeo: thanks…. seems a bit wonky
16:25AtKaaZgood point, sorry:)
16:25SgeoBut that lambda takes 0 args
16:26xeqi(fn ([a]) ([a b c]) ([a b c d e]) ([a b c d e f & more]) ; [1,3,5,7+] could get ugly
16:26AtKaaZ,::pst
16:26clojurebot:sandbox/pst
16:26xeqi* 6+
16:27xeqihmm guess that collapse down to [1,3,5+]
16:28AtKaaZHow do I know in which namespace is (pst) ?
16:28Sgeo,(resolve 'pst)
16:28clojurebot#'clojure.repl/pst
16:29Sgeo,(resolve 'nonesuch)
16:29clojurebotnil
16:29AtKaaZawesome! thanks Sgeo
16:29Sgeoyw
16:29hyPiRionwhaat
16:29hyPiRion,((resolve '+) 1 2)
16:29clojurebot3
16:29AtKaaZfor some reason that ns was unloaded or something
16:30Sgeo,(ifn? #'+)
16:30clojurebottrue
16:30hyPiRion,((resolve (symbol (str "ev" "al"))) '(+ 1 2))
16:30clojurebot3
16:30hyPiRionWell, that's not secure.
16:31xeqiit isn't?
16:31Sgeo,((resolve (symbol "eval")) '(+ 1 2))
16:31clojurebot3
16:31Sgeo,((resolve (symbol "eval")) '(eval '(+ 1 2)))
16:31clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:32SgeoHow is eval a security hole?
16:32AtKaaZ,((resolve (symbol "eval")) '(def ghost1 1))
16:32clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:33AtKaaZ,((resolve (symbol "eval")) '((resolve 'def) ghost1 1))
16:33clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:33hyPiRion,((resolve (symbol "def")) foo 1)
16:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>
16:33Sgeo,((resolve (symbol "def")) foo bar)
16:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>
16:33hyPiRiondurr.
16:33SgeoOh, right
16:33AtKaaZ,((resolve (symbol "eval")) '((resolve (symbol "def")) ghost1 1))
16:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ghost1 in this context, compiling:(NO_SOURCE_PATH:0)>
16:33SgeoWe could make a macro to do it
16:33AtKaaZ,((resolve (symbol "eval")) '((resolve (symbol "def")) 'ghost1 1))
16:33clojurebot#<NullPointerException java.lang.NullPointerException>
16:33SgeoWe should be able to ... hmm
16:34AtKaaZnpe?
16:34AtKaaZoh right, it's calling it:)
16:34Sgeoalter-var-root is accessible
16:34SgeoSet some var to a function, alter the metadata to turn it into a macro.
16:35SgeoThen, with our macro, we could... perhaps use a custom macro to call def directly
16:35AtKaaZnope I was wrong, something else happens
16:35SgeoIt has to, right
16:35Sgeo?
16:35hyPiRionno.
16:35AtKaaZjava code maybe?
16:35SgeoDarn
16:36AtKaaZspecial form?
16:36SgeoWhat's a function that no one cares about?
16:36SgeoWe could hijack it
16:36AtKaaZlol
16:36Sgeo,(doc alter-var-root)
16:36clojurebot"([v f & args]); Atomically alters the root binding of var v by applying f to its current value plus any args"
16:36xeqitrying to do it in such a hard way
16:37Sgeo,(use 'clojure.zip :only 'zip)
16:37clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception: Unsupported option(s) supplied: :only>
16:37hyPiRionthat's fine.
16:37Sgeo,(use ['clojure.zip :only 'zip])
16:37clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
16:37Sgeo,(use '[clojure.zip :only zip])
16:37clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
16:38hyPiRion,(use '[clojure.string :only [zip] :rename {zip foo}])
16:38clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.IllegalAccessError: zip does not exist>
16:38hyPiRionwhoops.
16:38hyPiRion,(use '[clojure.string :only [join] :rename {join foo}])
16:38clojurebotnil
16:38hyPiRion,(foo "," [1 2 3])
16:38clojurebot"1,2,3"
16:39xeqi,foo
16:39clojurebot#<string$join clojure.string$join@30a491e9>
16:39SgeoHmm, if a legal macro expands into illegal code, the code won't be run, will it?
16:39hyPiRionTrue
16:40Sgeo,(intern *ns* 'x)
16:40clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:40Sgeo,((resolve (symbol "intern")) *ns* 'foo)
16:40clojurebot#<IllegalStateException java.lang.IllegalStateException: foo already refers to: #'clojure.string/join in namespace: sandbox>
16:40Sgeo,((resolve (symbol "intern")) *ns* 'bar)
16:40clojurebot#'sandbox/bar
16:40AtKaaZ,(resolve 'def)
16:40clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:40AtKaaZ,(resolve (symbol "def"))
16:40clojurebotnil
16:41SgeoAtKaaZ, def is a special form, so has no var associated
16:41AtKaaZthank you for that
16:41SgeoSo, what shenanigans should I attach to bar?
16:41AtKaaZthat means you can't rename it right?
16:42SgeoThe most useful would be a macro that expands into code to do def
16:42SgeoWait, n
16:42Sgeono
16:42wingy_if i make a datomic query and get 10 entity ids .. then i loop through them to realize each one of them .. will datomic make 10 new requests to database?
16:42SgeoMacro that expands into a function call with the given string
16:43AtKaaZCompilerException java.lang.RuntimeException: Can't specify more than 20 params,
16:44AtKaaZMAX_POSITIONAL_ARITY = 20
16:44Sgeo,((resolve (symbol "alter-var-root")) #'bar (fn [f-str & args] (apply (resolve (symbol f-str)) args)))
16:44clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: bar in this context, compiling:(NO_SOURCE_PATH:0)>
16:45SgeoOh come on
16:45Sgeo,((resolve (symbol "intern")) *ns* 'bar)
16:45clojurebot#'sandbox/bar
16:45Sgeo,((resolve (symbol "alter-var-root")) #'bar (fn [f-str & args] (apply (resolve (symbol f-str)) args)))
16:45clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.String>
16:46AtKaaZI suppose if you have to have more than 20 params you're doing it wrong:)
16:46SgeoI'm confused
16:46SgeoAtKaaZ, it would be good for concat to take more than 20 params
16:46SgeoBecause it could be given a large sequence via apply concat
16:46AtKaaZoh i see
16:47AtKaaZ,(apply concat '(1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1))
16:47clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
16:47AtKaaZI'm using it wrong, checking:)
16:47xeqi,(apply concat (repeat 30 [1]))
16:47clojurebot(1 1 1 1 1 ...)
16:48AtKaaZwow that's neat
16:48AtKaaZthat repeat thingy
16:49hyPiRion,(take 30 (cycle [1]))
16:49clojurebot(1 1 1 1 1 ...)
16:49AtKaaZI guess it only complains on defn
16:50xeqi(take 30 (iterate identity [1]))
16:50xeqi,(take 30 (iterate identity [1]))
16:50clojurebot([1] [1] [1] [1] [1] ...)
16:50xeqiaww
16:50hyPiRion,(mapcat identity (take 30 (cycle [1])))
16:50clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
16:50hyPiRion,(mapcat identity (take 30 (repeat [1])))
16:50clojurebot(1 1 1 1 1 ...)
16:51AtKaaZooh i see why it works it uses applyTo with 1 parameter
16:52SgeohyPiRion, that mapcat identity is basically a Haskell join, right?
16:52AtKaaZ,(defn foo [a b c d e f g h i j k l m n o p q r s t u v w x y z] (println z))
16:52clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:53hyPiRionSgeo: It's basically the same as apply concat
16:53AtKaaZ,((resolve (symbol "defn")) foo [a b c d e f g h i j k l m n o p q r s t u v w x y z] (println z))
16:53clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>
16:54AtKaaZ,(var clojure.core/defn foo 1)
16:54clojurebot#'clojure.core/defn
16:54AtKaaZ,(quote clojure.core/defn foo 1)
16:54clojurebotclojure.core/defn
16:54AtKaaZthat's what they have in common
16:54AtKaaZextra params ignored
16:54ForSparePartsHow do I declare a dependency on generic.math-functions in lein?
16:56xeqilooks like thats in clojure.algo.generic.math-functions
16:57xeqi*clojure.algo
16:57ForSparePartsxeqi, Well, I found this, too: http://richhickey.github.com/clojure-contrib/generic.math-functions-api.html
16:57lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/generic.math-functions-api.html and try to stop linking to rich's repo.
16:57xeqiblah, I meant algo.generic
16:58xeqibeing a "contrib" its in maven, and search.maven.org w/algo.generic gives 0.1.0 as the latest version, so I would expect [org.clojure/clojure.algo "0.1.0"]
16:58AtKaaZ,((var-get (var clojure.core/defn)) foo 1)
16:58clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>
16:59AtKaaZlol I get this instead: ArityException Wrong number of args (2) passed to: core$defn clojure.lang.AFn.throwArity (AFn.java:437)
16:59tomoj&((fn [& args] (->> args (iterate next) (take-while identity) (filter (comp #{:foo} first)) first second)) 1 2 :foo 3 4 5 6)
16:59lazybot⇒ 3
16:59tomojgotta be an easier way to write that, right?
16:59ForSparePartsxeqi, The API reference says "v1.2" -- is that not what I'd want?
17:00xeqiForSpareParts: that was when it was in monolithic contrib
17:00ForSparePartsOh.
17:00AtKaaZ,var-set
17:00clojurebot#<core$var_set clojure.core$var_set@28827875>
17:01ForSparePartsxeqi, So, In the future, how do I figure out how to specify a library I want for lein?
17:02ForSparePartsI think I'm not totally clear on the syntax yet -- I don't have much experience with Maven, either.
17:03tgoossens_that IO video was really nice
17:04xeqi[orgname/libraryname "version"] ; in this case orgname="org.clojure" libraryname="algo.generic" version="0.1.0"
17:04zackzackzackI'm trying to pull in some java files and use some classes defined in there. A bunch of exceptions are getting thrown though because the java class relies on some other files. Any ideas about what I am doing wrong?
17:04ForSparePartsxeqi, Thanks!
17:07xeqi&((fn [& args] (second (drop-while (complement #{:foo}) args))) 1 2 :foo 3 4 5 6)
17:07lazybot⇒ 3
17:07xeqitomoj: ^ ?
17:07AtKaaZ,(with-local-vars [axx 1] (var-set axx (resolve (symbol "defn"))) (@axx 'foo [] 1))
17:07clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IObj>
17:07tomojah yes, much better, thanks
17:07AtKaaZ,(with-local-vars [axx 1] (var-set axx (resolve (symbol "defn"))) (@axx 'foo [] println))
17:07clojurebot(def #< clojure.lang.AFunction$1@5bd8c455> (clojure.core/fn))
17:07AtKaaZweird, I dno what happened lol
17:08AtKaaZI get this in my repl: IllegalArgumentException First argument to defn must be a symbol
17:08AtKaaZ,*clojure-version*
17:08clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
17:09xeqiif you knew the argument count would be even ##((fn [& args] (:foo (apply hash-map args))) 1 2 :foo 3 4 5)
17:09lazybot⇒ 3
17:11AtKaaZ,(#(with-local-vars [acc 1, cnt %] (while (> @cnt 0) (var-set acc (* @acc @cnt)) (var-set cnt (dec @cnt))) @acc) 10)
17:11clojurebot3628800
17:11amalloyxeqi: you need the argument count even *and* foo appearing as an odd-numbered index
17:11tomojneither of which is the case
17:11AtKaaZ"imperative-style code" http://clojuredocs.org/clojure_core/clojure.core/with-local-vars
17:12xeqiamalloy: ah true, and its prolly better written as a destructure there anyways
17:13AtKaaZdid you guys catch that with = on records from the maillist?
17:13tomojactually, fuckit
17:14tomojI'll just decide there are an even number of args
17:14xeqiin that case ##((fn [& {:keys [foo]}] foo) 1 2 :foo 3 4 5)
17:14lazybot⇒ 3
17:16AtKaaZhttps://groups.google.com/forum/?hl=en&amp;fromgroups=#!topic/clojure/PqTRSIJeTtI
17:16AtKaaZI tried .equals instead of = and yields different results :)
17:16AtKaaZfor this (= (AA. 1) {:a 1})
17:16ForSparePartsI'm still confused about lein -- I added a dependency to project.clj, ran lein deps from my project directory, and it seemed to download, but I still can't load it in my project. Any idea why that would happen?
17:17AtKaaZyou're loading it with use?
17:17xeqiForSpareParts: how are you trying to load it?
17:17tomojbe sure to restart your repl to pick up the new dep
17:18ForSparePartsxeqi, (ns my-namespace (:require lib))
17:18ForSparePartstomoj, did that.
17:19ForSparePartsAtKaaZ, just with :require, which causes an error. Can't find the library on my classpath.
17:20AtKaaZlike (:require [lib]) ?
17:20AtKaaZis that the same btw?
17:21ForSparePartsI'm not totally sure. They seem to have the same effect.
17:21tgoossens_Hi
17:21tgoossens_i finished the blogpost
17:21AtKaaZyes you're right just tested
17:21tgoossens_finally you will know what i was trying to do:p
17:21AtKaaZtgoossens_ link?
17:21tgoossens_it is far from ready, but nevertheless here it is:
17:21tgoossens_http://tgoossens.wordpress.com/2012/10/20/funix-enhancing-the-linux-terminal-by-thinking-functional/
17:22tomojForSpareParts: well, maybe check `lein classpath` for the jar you want. then `jar -tf the.jar` to see what namespaces are actually available
17:22tomojif the jar is on your classpath, contains foo/bar.clj, and you do (:require foo.bar)... it should work
17:23SgeoWait, you can do that? o. o
17:23tgoossens_i will have to go now. I'll be back tomorrow probably in the irc
17:23AtKaaZis it lein jar or java jar?
17:24AtKaaZfor this `jar -tf the.jar`
17:24tgoossens_if you have any remarks or comments please post it on the blog so I can read them :D
17:24tgoossens_(using the webchat irc right nowà
17:24tgoossens_Thanks for all the help and see you soon!
17:24SgeoThose quotes should, in principle, still be there
17:24Sgeo,(println (str "hello"))
17:24clojurebothello
17:24Sgeohmm
17:24xeqiAtKaaZ: that would be the jar command installed by the jre(jdk?)
17:25tomojAtKaaZ: just "jar"
17:25xeqi,(prn (str "hello"))
17:25clojurebot"hello"
17:25Sgeoxeqi, ahaa
17:25AtKaaZok, not in my path but I'll make it so;)
17:25tomojyou could also just open the jar in emacs. or of course just check the project docs if you trust them
17:26ForSparePartsSo, it *looks* like the library is there. If I've installed algo.generic...
17:26ForSpareParts(:require [clojure.algo.generic.math-functions]) would load math-functions for me, right?
17:26ForSparePartsThere's a jar on my classpath that contains a clojure/algo/generic/math_functions.clj
17:26AtKaaZdoes that mean you don't have to prefix them with that namespace?
17:26xeqithat should load them
17:27tomojthe error says "could not find clojure/algo/generic/math_functions.clj" or whatever?
17:27xeqithough you prolly want to include something like :as math
17:27ForSparePartstomoj, Yeah.
17:27Sgeotomoj, in Leiningen, can I put standalone jars in my classpath just by putting them in some directory?
17:27ForSparePartsShit, I think it worked this time.
17:28tomojSgeo: yeah, but you're not supposed to
17:28tomojyou have to abuse some other option like :source-paths
17:29xeqiI think technomancy has been recommending abusing :resource-paths, as its more explicit its the wrong thing
17:29SgeoDon't care.
17:29SgeoThe jar in question is generated from JNAerator
17:29SgeoWhat _is_ the "right thing"?
17:30xeqiput the jar in a repo
17:30tomojlein-localrepo is better than :resource-paths but not as good as putting it in clojars (or some other repo)
17:38tomojcan't decide if this is appropriately convenient or inappropriately "clever" https://gist.github.com/7e2a8accb472a1af96a8
17:39tomojI guess :unique/identity or :unique/value would make the weird pairness of :unique go away, which seems less clever
17:40ForSparePartsDoes clojure cache the results of functions so that it doesn't have to run them again?
17:41ForSpareParts(for a given set of args, I mean)
17:41tomoj,(doc memoize)
17:41clojurebot"([f]); Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use."
17:41tomoj(in other words, not unless you ask it to)
17:41ForSparePartstomoj, OK.
17:42tomojsince it has no way of knowing whether a particular function is referentially transparent :/
17:42ForSparePartsI'm trying to write a function that depends on getting the current time from a new java.util.Date object, but it seems like it keeps using the same one.
17:42jayunit100(for [x [0 1] y [0 1]] (print "cell [" x " " y "] \n")) <--- has nils in side of it :(
17:43tomojfor?
17:43clojurebotfor is not a loop
17:43jayunit100why would a list comp have nils
17:43tomojyou want (doseq [x [0 1] y [0 1]] (println "cell [" x " " y "]"))
17:43amalloyjayunit100: because print always returns nil, bro
17:43jayunit100ah ooooops yeah.
17:45jayunit100hello clojure ! its been a while :)
17:46ForSparePartsI assume you mean the game of life, but I like the idea that you're trying to write a functional version of just.. life.
17:46awkoramahi everyone
17:47Frozenlo`ForSpareParts: Writing a function of oneself would be recursive, because it would too try to write this function :P
17:48awkoramacan anyone help me with following not working? (map [(seq (.. 100N getClass getMethods)) .getName ] )
17:48Bronsawhat are you trying to do?
17:49awkoramajust print the names of methods in BigInt
17:49awkorama(nothing useful, just messing around in REPL really)
17:49Bronsa,(map #(.getName %) (-> 100N .getClass .getMethods))
17:49clojurebot("add" "equals" "toString" "hashCode" "byteValue" ...)
17:50awkoramaso .getName is not a function ?
17:50Bronsanope
17:50jayunit100@ForSpareParts ha
17:50Bronsayou have to wrap it, methods are not first-class as functions are
17:50jayunit100arg my function nested in a let isn't being invoked it seems.
17:51awkoramai see, ok thx
17:51tomojseems like clojure.reflect should have method? and field?
17:52jayunit100https://gist.github.com/3924931
17:52doomlordwhat is the .something .. an identifier for a method lookup?
17:52jayunit100^^ Any thoughts on why the for in "play" isn't being invoked?
17:52tomojfor is not a loop
17:52tomojyou want doseq
17:53doomlordfor returns a lazy sequence?
17:54jayunit100@doomlord hmm
17:54jayunit100oh duh and the repl always evils it
17:54jayunit100s/evils/evals
17:55doomlordtis confusing to use the word 'for' as not a loop imo :) but i can live with that
17:56SgeoThis is a good motivation for the Haskell way of doing I/O
17:56doomlordi'm not convinced
17:57doomlordhaskell's is very interesting but there are other valid approaches imo.
17:57SgeoYes, but just notice that Clojure's approach here does occasionally cause confusion
17:58doomlordmonads cause confusion too :)
18:00tomojhah
18:00doomlordis the clojure convention just "do" for imperative constructs ? (doseq, dotimes, do... , doto)
18:01tomojsome people say "when" also suggests imperative
18:01doomlordso far i'm enjoying clojure a little more than haskell.. i like its ability to make adhoc datastructures
18:02technomancyare there other languages that provide laziness for seqs only?
18:02doomlordclojure is a lot of fun.. and i wish i'd learned lisp 20 years ago
18:02tomojI think I read "because it has an implicit do" oslt, but so does fn..
18:04technomancyfn is more general though. when is more specific than if
18:04doomlorddoseq is more like a loop with (saving you writing out a lambda..) but is there an imperative version of map,(domap?) or do you use 'dorun/doall' on the map.
18:04tomojyeah, I hadn't convinced myself
18:04technomancydoomlord: there's mapv, but if you use it for side effects clojurebot will come chastise you once you push your code.
18:05Sgeodoomlord, it's not so much that Clojure "lets" you make ad-hoc datastructures as it is that it's idiomatic in Clojure in a way that it's not in Haskell
18:05amalloytechnomancy: i don't know that i'd say clojure provides laziness but only for sequences. it seems to me that between macros and lambdas it lets you put laziness wherever you need, and eg delay is a built-in non-seq lazy construct
18:05SgeoHaskell culture wants things to be typesafe. But there's no reason you can't just use Maps all the time, in theory
18:05doomlordin haskell i find the slightly broken record system irritating
18:05technomancy"This emu really thinks your code would be clearer if you used doall instead of mapv." <- http://www.buzzfeed.com/expresident/animals-who-are-extremely-disappointed-in-you
18:06technomancyamalloy: you know what I mean
18:06technomancyout of the box
18:06amalloySgeo: aren't maps homogenous in type? ie, you can't easily do {:foo 1 :bar "foo"} in a Map
18:07Sgeoamalloy, good point. I was thinking more along the lines of a use-case I had a while ago where type-safety in terms of keys and their correct types would have been nice, but difficult to implement
18:07Sgeoamalloy, could use Dynamic, iirc
18:07doomlordmaybe i should make myself a (domap function collection)
18:07doomlordor is that just mapv
18:07amalloy(def domap (comp dorun map))
18:07doomlordreading 'do' as imperative is nice and clear
18:07Rayneshttp://www.haskell.org/haskellwiki/Heterogenous_collections
18:08tomojfor no good reason I did not expect dorun to be a function
18:08Raynestomoj: The 'do' is a fair enough reason to think it to be a macro.
18:09amalloyhey, maybe this time i know enough haskell to understand that wiki entry
18:10SgeoCould probably make a Prelude that just has functions that take and return Dynamic
18:10doomlordis there something to return amodified collection, eg (modify {:a 1 :b 2 :c 3 :d 4} {:a 10 :c 30}) ===> {:a 10 :b 2 :c 30 :d 4}
18:10ohpauleeztomoj: Thanks for all your help on that CLJS ticket
18:11Sgeo,(doc assoc)
18:11clojurebot"([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."
18:11amalloy$findfn {:a 1 :b 2 :c 3 :d 4} {:a 10 :c 30} {:a 10 :b 2 :c 30 :d 4}
18:11lazybot[clojure.set/union clojure.core/conj clojure.core/into clojure.core/merge]
18:11doomlordwow, findfn
18:12amalloyRaynes: now that you've made it so slow, you have plenty of time to file your nails
18:12Rayness/made it so slow/fixed all my broken dangerous shit/
18:12technomancyhow could findfn not be slow?
18:12SgeoRaynes, oh, did you fix the hole that other person found?
18:12amalloytechnomancy: it was outrageously fast when the sandboxing was a little less zealous
18:13Raynestechnomancy: It used to be fast when the sandboxing sucked.
18:13technomancyoh wow, you don't even bother filtering by arity?
18:13amalloynope. just call ALL the things
18:13doomlordis there some findfn web app caching everything
18:13RaynesNo.
18:13RaynesCaching would be pretty darn smart though.
18:14RaynesTurns out we're pretty darn stupid.
18:14SgeoWhat, as in memoization?
18:14RaynesAs in caching.
18:14Sgeohmm, what's the difference?
18:14technomancyRaynes: what are the odds someone would actually do the same query twice between boots of the bot though?
18:14RaynesYou could just store it in a db, technomancy.
18:14doomlordover the entire community of programmers, over many months..
18:15Raynestechnomancy: It'd only really need to be refreshed for new versions of Clojure. Even then, not really, since they never change anything.
18:15doomlordyou could also use it for naming. "i'm after a function that does this; i think it would be called ..."
18:15TEttinger$findfn [\a \b \c] "abc"
18:15lazybot[clojure.string/join]
18:15TEttingernice
18:16doomlordfindfn [1 2 3] [3 2 1]
18:16TEttinger,(str \a \b \c)
18:16clojurebot"abc"
18:16doomlord$findfn [1 2 3] [3 2 1]
18:16lazybot[clojure.core/rseq clojure.core/reverse]
18:16TEttingerwonder why it didn't find str
18:16amalloySgeo, Raynes: is Dynamic something that could be (or is) implemented in haskell, or does it have to be done in the bowels of the type system or compiler?
18:16amalloyTEttinger: because str isn't a solution
18:16doomlordshame it isn't printing the query here in the irc channel
18:16tomoj$findfn \a \b \c "abc"
18:16amalloy&(str [\a \b \c])
18:16lazybot⇒ "[\\a \\b \\c]"
18:16TEttingerohhh
18:17lazybot[clojure.core/str]
18:17technomancyRaynes: so Emacs mailer uses something like "phil@i-did-not-set-a-mail-host-please-tickle-me" for your From: field if you don't configure it
18:17TEttingerI didn't know the syntax that findfn needed
18:17technomancyRaynes: maybe lein-newnew could do something similar?
18:17Raynestechnomancy: I have no idea what we're talking about.
18:17Sgeoamalloy, I think it makes use of a typeclass called Typeable. I _think_ it exists in pure Haskell but actually making instances typically uses a language extension
18:17SgeoI may be wrong
18:17technomancyRaynes: the annoyance of *.core
18:17amalloytechnomancy: he's trying to get rid of foo.core
18:18amalloythough i can see how without twitter context you'd think he's looking for a tickle buddy
18:18Sgeobut for your own datatypes you'd typically use deriving Typeable with the appropriate language extension
18:18RaynesI'm lost.
18:19doomlordso do we just need some massive brute force datacentre and we submit "write-fn [.sample input,outputs pairs..] :suggest_name "foo" " and it generates the programs for us, and picks the empirically proven most popular names..
18:19amalloyjust tickle him like his email address suggests. the clojure fanfic boards would catch fire
18:19Sgeoamalloy, although it also relies on unsafeCoerce iirc, so partly depends on your opinion of whether that counts as Haskell
18:19technomancylol
18:19technomancyRaynes: cemerick tweeted about how he hates *.core and everyone chimed in with ideas of how to stem the tide of badly-named namespace
18:19RaynesOh!
18:19RaynesI'm so sick of the *.core arguments.
18:20Sgeoamalloy, http://hackage.haskell.org/packages/archive/base/4.2.0.1/doc/html/Data-Dynamic.html
18:20RaynesMaybe if it had ever caused me a problem I'd care *a little*, but...
18:20technomancyRaynes: think of all the poor saps who don't use uniquify
18:20Sgeouniquify?
18:20technomancyseventeen indistinguishable core.clj buffers open
18:20amalloyhah
18:21amalloyi remember those days
18:21Raynestechnomancy: Let's run up to the stage during Bodil's talk and be like "Yo, imma let you finish, but *.core is the best convention of ALL TIME!"
18:21technomancySgeo: http://www.emacswiki.org/emacs/uniquify
18:21amalloypersonally i'm more interested in getting clojure programmers to pick namespaces that are even a little bit globally unique
18:22doomlord$findfn [3 [1 2 3 4 5 6]] [[1 2 3][4 5 6]]
18:22lazybot[]
18:22SgeoAs in, being able to rename namespaces at the Clojure level, so something that was in foo.bar/baz is relocated to somethingelse/baz, not just aliased
18:23doomlord$findfn [2 [1 2 3 4 5 6]] [[1 2] [3 4] [5 6]]
18:23lazybot[]
18:23technomancySgeo: one of these days we're going to hack that up at seajure
18:23technomancycontent-addressable namespaces
18:23technomancya la nix
18:24SgeoAwesome
18:24amalloydoomlord: drop the []s
18:24doomlordhow does it distinguish input from output
18:24doomlord$findfn 2 [1 2 3 4 5 6] [[1 2] [3 4] [5 6]]
18:24amalloyoutput comes last
18:24lazybot[clojure.core/partition-all clojure.core/partition]
18:25doomlordthis is awesome
18:26ivan$findfn 0 1
18:26doomlord$findfn [1 2 3][4 5 6] [[1 4][2 5][3 6]]
18:26lazybot[clojure.core/unchecked-inc-int clojure.core/unchecked-inc clojure.core/inc clojure.core/inc']
18:26lazybot[]
18:26SgeoWait, it will pass its argument through unchecked-inc-int?
18:27Sgeohmm
18:27ivan$findfn '([1 2 3][4 5 6]) [[1 4][2 5][3 6]]
18:27doomlordfindfn cloud app could collect people's queries and list the most popular ones as function documentation
18:27lazybot[]
18:29doomlordfindfn (partial -) [3 2 1 4] 1
18:29ivan$findfn 9223372036854775807 -9223372036854775808
18:29lazybot[clojure.core/unchecked-inc clojure.core/bit-not]
18:30doomlord$findfn (partial count) ["foo" "bar "baaaz" "fo"] "baaaz"
18:30lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: core$partial
18:30doomlord$findfn #(count %) ["foo" "bar "baaaz" "fo"] "baaaz"
18:30lazybot[]
18:31doomlordthats one i was trying to write - given a 'score' function, find the element of a collection who has the largest 'score'
18:31TEttingerI am a little confused about leiningen mixed with maven
18:31amalloy&(doc max-key)
18:31clojurebotdefmulti doc is ugly
18:31lazybot⇒ "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."
18:31TEttingertechnomancy: http://nifty-gui.lessvoid.com/archives/459 lists how to have a maven project with these jars in it
18:32TEttingerbut how would I carry that over to clojure with lein?
18:34doomlord(apply max-key #(count %) ["foo" "baar" "bz"])
18:34doomlord,(apply max-key #(count %) ["foo" "baar" "bz"])
18:34clojurebot"baar"
18:34doomlordawesome, thats very useful
18:35doomlordany pther
18:35doomlordany other lanuages have a similar standard function?
18:35hyPiRion,(apply max-key count ["foo" "baar" "bz"])
18:35clojurebot"baar"
18:35hyPiRion(just fyi)
18:36doomlordneater ok.
18:37doomlord$findfn count ["foo" "baar" "bz"] ["bz" "foo" "baar"]
18:38lazybot[]
18:38doomlord(want: "sort-key")
18:38metellus,(apply sort-by count ["foo" "baar" "bz"])
18:38clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core$sort-by>
18:39metellus,(sort-by count ["foo" "baar" "bz"])
18:39clojurebot("bz" "foo" "baar")
18:39doomlordok cool.
18:39amalloynow that one, i don't know why lazybot didn't find
18:39metellus$findfn count ["foo" "baar" "bz"] ("bz" "foo" "baar")
18:39lazybotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
18:39doomlordmaybe it has a timeout (halting problem)
18:39metellus$findfn count ["foo" "baar" "bz"] '("bz" "foo" "baar")
18:39lazybot[]
18:41doomlorddoes haskell benefit from having immutability assumptions in its collector in ways that jvm languages can't.. or does the jvm pay more dividends from popularity and hence amount of attention its implmeentations have got
18:41doomlord(or maybe the jvm has enough to benefit from immutabiltiy asumptions)
18:44technomancydoomlord: not really; the main place JVM legacy messes you up vs haskell is when doing type inference
18:46technomancysupposedly the HM type inference algorithm is incompatible with subclassing or something
18:46technomancyTEttinger: site's down
18:46doomlordah that sucks, type inference is awesome
18:46SgeoWhat does Scala do?
18:46technomancyother types of inference are possible, but they're generally not as good
18:47SgeoOh, have limited inferencing?
18:47technomancySgeo: inference for locals and subclass methods only IIRC
18:47TEttingertechnomancy: which site, http://nifty-gui.lessvoid.com/archives/459 ?
18:47technomancyTEttingeryeah
18:47TEttingerjust loaded it from her
18:47TEttingere
18:47doomlorddoes clr handle it bbetter
18:48technomancydoomlord: F# does better than scala from what I understand, but I haven't looked at it in detail
18:48doomlordi'd assume immutability helps type inferencing quite a bit vs other lisps
18:49doomlordwant: power of lisp macros, clojures style of adhoc structures, *and* reliable type inferencing :)
19:01oskarthIf I am moving code from one ns to another and get "already refers to..." errors in nREPL, how do I get nREPL to lose the old definitions / force update?
19:03tomojone manual way is (ns-unmap *ns* 'the-var)
19:04oskarthns-unmap, thank you :)
19:07dgrnbrgHey clojure users, I just wrote a println/trace oriented debugging library for Clojure: https://github.com/dgrnbrg/spyscope
19:08dgrnbrgIt's thoroughly documented, and it provides a lot of filtering and tracing functionality in very few keystrokes
19:10dgrnbrgit supports many usage patterns in multithreaded debugging, such as including fragments of filtered stack traces and storing the interleaving of the traces.
19:11dgrnbrgit also is done with reader tags and extra metadata, which means you type as few characters as possible
19:11amalloydgrnbrg: i find that last claim highly dubious
19:12amalloyfor example, #spy/d x is already more typing than (? x), which is what i use
19:12dgrnbrgamalloy: you could alias it to #?, which would be fewer characters (and I think that's legal)...
19:13amalloywell (a) it's not actually fewer characters with paredit, and (b) you're not supposed to use non-namespaced reader tags, as i'm sure you know
19:13dgrnbrgamalloy: that's why it has a 3 letter namespace :)
19:13amalloyi know
19:14dgrnbrgmy paredit would require an extra keystroke to slurp the x
19:14amalloyno way. M-( ?
19:14dgrnbrgi use paredit.vim :)
19:14dgrnbrgand evil-paredit-compat.el
19:14wingy_with datomic free i dont get durability right?
19:15dgrnbrgbut, amalloy, does your library have the filtering/querying/understanding really messy logs functionality?
19:16amalloynot really. it just prints the expression and then the value. but i carefully objected only to the repeated claim of "as few characters as possible"
19:17rlbTimMc: so I suppose it might just be that incanter just doesn't work over ssh -X/Y right now.
19:17rlbs/just doesn't/doesn't/
19:18dgrnbrgamalloy: I'm just trying to get some eyeballs ;)
19:19dgrnbrgI think that what I wrote is very useful, and removes a lot of annoyance from long debugging sessions of multithreaded applications, where it's hard to see what's going on, and at some point you've got some many tracing statements it's like "wtf does :failed 323 mean in the stdout mess!?"
19:19tomojwingy_: you get durability with transactor-local storage
19:21wingy_tomoj: didnt know it writes to the disk
19:21wingy_cool
19:22hyPiRiondgrnbrg: So you're using reader tags to remove the amount of parens?
19:23dgrnbrghyPiRion: I often find that i first want to see what a value is, and then I realize over time that I need more and more information about it, especially as I start displaying related values as well
19:23dgrnbrgSo you can first just use the reader tag to get basic info
19:23dgrnbrgand then you can keep requesting more and more info and narrowing your search as you gain problem insight
19:23dgrnbrgand the printed lines have enough context to grep, filter, and detemine how to remove the traces
19:24hyPiRionHmm, interesting.
19:25tomojI wonder how much slower the free storage is than dynamodb
19:25dgrnbrgit's what I came up with when I tried to write a tool that followed my natural, lazy, least-effort-first debugging style
19:26dgrnbrgI'd like to add cross-thread data analysis, so that it could track data flowing through code and reference types, but even without that, just making coherent traces is a big improvement
19:27hyPiRionHmm, you should add some settable debug-flag which toggles debugging off and on.
19:27eflynnwow lot of people in here
19:27hyPiRionSince I'm lazy and wouldn't bother to remove my debugging stuff after a debugging session.
19:28dgrnbrghyPiRion: wouldn't you use git checkout/reset to clean up the code prior to commit/release?
19:28dgrnbrg
19:29dgrnbrghow would you imagine that working--a configurable regex that filters which namespaces have any effect at the moment?
19:31hyPiRiondgrnbrg: Well, it was just a random though I had after long nights with #define DEBUG in c.
19:31hyPiRions/though/thought/
19:31hyPiRionMaybe I should use a logging tool for that instead, and turn the logging off.
19:32dgrnbrgyeah, this is less for logging and more for debugging sessions
19:35hyPiRionanyway, it seems like something I'm doing quite a lot but haven't bothered to make a lib out of. I'll probably use it if I'm in need of debugging.
19:35dgrnbrgawesome! that was my thought exactly, but i got fed up with not having the lib, esp for mutlithreaded stuff
19:37SgeoI'm starting to see the benefit of Clojure's approach to namespacing symbols over Common Lisp's approach: It's why it's not terrible that Clojure is a Lisp-1 with CL-style macros, because the symbols that are used within, say, a let won't be the same as the symbols that are the result of quasiquoting
19:37Sgeo,`+
19:37clojurebotclojure.core/+
19:37tomojI wonder why symbols can't start with numbers
19:37SgeoUsing that in a let that let's + won't conflict
19:37Sgeo,(= '+ 'clojure.core/+)
19:37clojurebotfalse
19:38Sgeo,(let [+ 5] (clojure.core/+ 10 +))
19:38clojurebot15
19:41under_my_shoes:)
19:51TEttingertechnomancy, maybe in more general terms, can you use a maven repo (not sure of the exact terminology) from leiningen, in a lein-only project?
19:52TEttingerthe line that had me confused a bit, more than the rest,
19:52TEttingerFor Maven simply add our sf.net Nifty Maven Repo to your pom.xml:
19:52TEttingerand I have never added repos for leiningen before
19:59wingy_TEttinger: long time no see .. you were one of the LiveScript users?
19:59amalloy$google leiningen sample project.clj
19:59lazybot[leiningen/sample.project.clj at master · technomancy/leiningen ...] https://github.com/technomancy/leiningen/blob/master/sample.project.clj
19:59amalloyTEttinger: ^
20:00TEttingerwingy_, still considering it
20:00TEttingerthanks amalloy
20:01TEttingerwingy_, if I am not mistaken so is Sorella
20:02TEttingerand right now I am looking to develop something along the lines of "a nice GUI"
20:02wingy_TEttinger: i thought you were already using it for dev
20:02TEttingerno, I don't know enough JS to get by
20:03TEttingerI want to get Nifty GUI to work with Clojure for now, failing that I will try LiveScript with AppJS
20:18tomoj$findfn :foo :bar :foo
20:19lazybot[clojure.core/doto clojure.core/or]
20:19xeqiwere either of those what you were looking for?
20:19tomojneither of them are fns
20:20tomojI bet useful has this
20:20xeqi&((comp first list) :foo :bar)
20:20lazybot⇒ :foo
20:21tomojguess not
20:21tomojah, that'll work
20:25Sgeo,((const :foo) :bar)
20:25clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: const in this context, compiling:(NO_SOURCE_PATH:0)>
20:25Sgeo,((constantly :foo) :bar)
20:25clojurebot:foo
20:25SgeoSorry, too much Haskell ;)
20:25SgeoAlthough I guess that's not what you want
20:25tomojif it were curried
20:25Sgeo,(apply first :foo :bar)
20:25clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
20:26Sgeo,(apply first [:foo :bar])
20:26clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$first>
20:26Sgeo...derp
20:26devnherp
20:26muhoom'gerp
20:26devnermagerb
20:26tomojdevn: you know how to rebase?
20:27devntomoj: i knew someone was going to tell me "you fucking noob"
20:27tomojnah, rebase is scary
20:27devnnot that you're saying it that way, i just have always dealt in pull requests
20:27devnso the patch flow is a bit foreign to me
20:28devni did git am --keep-cr -s < patch.diff
20:28devnit failed to apply cleanly
20:28devni sort of expected a merge-esque situation but didn't see one
20:28devnso i ended up just redoing the patch, committing, generating the new patch
20:28tomojwell one option is to go to a spot where the patch applies fine, apply it, then do `git rebase origin/master` and fix the conflicts
20:28tomojthen add and commit
20:29devntomoj: gotcha. that makes sense.
20:29tomojdunno if that puts you as committer but it definitely will leave author alone
20:29devntomoj: how active are you on the dev jira?
20:29tomojand commit date
20:30tomojnot much on clj, somewhat on cljs
20:30devntomoj: i feel like im doing stuff wrong -- ive read through the guide for submitting patches with the workflow and what-not
20:30devnbut i can't shake the feeling im Doing It Wrong
20:32devntomoj: i just did a few things on there, so I suppose I'll find out the hard way whether I get it or not
20:33devntomoj: there's so much low-hanging fruit and tedious work that can be done. I'd like to help some people in the meetup I run to get comfortable helping out with some of that tedium, just want to make sure I don't make a mess
20:48doomlord$findfn [10 1 9 100 2] [1 100]
20:48lazybot[]
20:48doomlord$findfn [10 1 9 100 2] [1]
20:49lazybot[]
20:49doomlord$findfn 10 1 9 100 2 [1]
20:49lazybot[]
20:49doomlord$findfn 10 1 9 100 2 100
20:49lazybot[clojure.core/bit-xor clojure.core/max]
20:49doomlord$findfn 10 1 9 100 2 [1 100]
20:50lazybot[]
20:50amalloyhah. bit-xor. what a lovely accident
20:51tomoj&((juxt min max) 10 1 9 100 2)
20:51lazybot⇒ [1 100]
20:51doomlorddamn there was me trying to write that with maps /reduces
20:51doomlord(defn reduce-juxt..) (reduce-juxt min max [10 1 9 2])
20:52doomlord,(apply (juxt min max) [9 10 2 7 4])
20:52clojurebot[2 10]
21:04ivanany longbottom news?
21:08tomoj:(
21:08tomojthe tracing thing someone wrote above made me long for longbottom
21:53Frozenlo`Question for seesaw users: Whenever I use the 'dialog' function, it shows a dialog. However the dialog doesn't have a presence on the task bar, so if I put another window in front of it, I can forget it's there. Is there a way to add it to the taskbar?
22:09SgeoWould be nice if it was easy to make a macro that intercepts function calls
22:11tomojit intercepts every single function call?
22:12xeqiSgeo: similar to https://github.com/technomancy/robert-hooke ?
22:12yediis there a #clojure chat log?
22:12tomojlogs?
22:12clojurebotlogs is http://clojure-log.n01se.net/
22:12tomojclojurebot: botsnack
22:12clojurebotbotsnack is scoobysnack
22:14Sgeoxeqi, except adding a hook to all function calls, not just ones I know about
22:18gfredericksI think it's conceivable to redefine fn
22:19gfredericksbut probably a lot of clojure.core at least would get loaded before that happens
22:22amalloySgeo: i don't think you would enjoy the spooky action-at-a-distance strewn throughout your program
22:22Sgeoamalloy, well, just the function calls lexically contained within some macro
22:23tomojwhy redefine fn? just walk the body
22:23amalloy"just"
22:24SgeoYes, I know it can be done by walking the body, but it also requires understanding special forms. It's certainly doable, I think, but a library to make it easy would be nice
22:24amalloySgeo: so write that library. nobody else is going to
22:51Apage43oh man
22:51Apage43I may have caught myself overusing a pattern
23:14amalloyApage43: what pattern?
23:16Apage43(let [acc (transient [])] (walk/{pre/post}walk (fn [el] (when some-pred (conj! acc el)) el)) (persistent! acc))
23:16Apage43er, where the last arg to walk is some big ugly hierarchichal structure
23:17Apage43and I'm just searching it for pieces that match a predicate
23:17amalloyso...(filter some-pred (tree-seq coll))?
23:18amalloyor i guess tree-seq wants more args
23:19amalloy(filter some-pred (tree-seq coll? seq coll)) iirc
23:19Apage43seq? identity looks usable for most of the places I'd use that pattern with postwalk
23:19Apage43sometimes I use it with prewalk too though,
23:20Apage43hm
23:20Apage43but it's lazy, which is really nice
23:20amalloyApage43: your function is brutally wrong anyway
23:20amalloythat conj! is not guaranteed to do what you want; transients are not supposed to be bashed in place
23:21Apage43oh?
23:22amalloythey're permitted to mutate themselves, not guaranteed
23:22amalloyit so happens that in the current version of clojure, vectors always do (i think). but maps don't, and in a future version vectors may not
23:22Apage43ah. I'm just getting lucky then, oops.
23:22amalloyeven if it were guaranteed, there's no reason to introduce mutability here; using an atom would be less wrong but just as unpleasant
23:24amalloyafter all, you're computing the results of a pure function on a data structure. recursion is enough
23:25Apage43tree-seq is almost what I want
23:25Apage43I'll prolly write something based off it
23:28Apage43I need to also have the option to go breadth-first, but that's it really
23:30callen~(read-string "(+ 1 42)")
23:30clojurebotread-string |is| as unsafe as eval unless *read-eval* is bound to false.
23:30callenIllegalStateException Attempting to call unbound fn: #'clojure.core/unquote clojure.lang.Var$Unbound.throwArity (Var.java:43)
23:30callenkay, what did I do that is stupid?
23:31amalloyyou tried to unquote inside of a non-quoted context
23:32callenamalloy: it returns (+ 1 42), how do I force eval on that?
23:32amalloydon't
23:32amalloyor call eval, if you want
23:32callendon't say that, I'm just trying to learn.
23:32callenwhat exactly is it returning? a quoted form?
23:32amalloya list
23:32callenthis isn't production code, I'm following along with cemerick's book.
23:33amalloycontaining the symbol +, and the numbers 1 and 42
23:33callenthat makes sense just fine, but how do I do the equivalent of ()'ing it, if it's not quoted to begin with?
23:34amalloy()'ing it doesn't mean anything, so i don't know what the equivalent of that is
23:34callenamalloy: how do I get the returned list to evaluate and return its result?
23:34callenjust eval?
23:35amalloyeval. that's what eval is
23:35callenthat worked, but I was suspicious of it.
23:35callenamalloy: thank you.