#clojure logs

2012-07-21

00:00seancorfieldmonokai has holes that are affected by other themes... very annoying
00:01dubzM-x disable-theme works for me
00:09dubzseancorfield: if you open your init.el you could try typing (disable-theme 'monokai) then M-x eval-buffer
01:10dsrguruin a macro definition, what's the best way to determine if a parameter is an atom in the CL sense and can be used as a binding
01:13dsrguruI'm trying to write a macro such that (my-macro []) -> [], (my-macro foo) -> [foo], and (my-macro [a b]) -> {:keys [a b]}
01:14dsrguruand I'm wondering how to check to see if the argument is in the foo form
01:14dsrgurui.e. an unquoted symbol
01:15amalloy&(doc symbol?)
01:15lazybot⇒ "([x]); Return true if x is a Symbol"
01:16dsrguru,(symbol? foo)
01:16clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>
01:16dsrgurusee?
01:16amalloyirrelevant. your macro receives source-code forms
01:17amalloy(defmacro m [x] (symbol? x)) (macroexpand '(m foo)) => true
01:17dsrguru,(defmacro h [arg] (str (symbol? arg)))
01:17clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
01:17dsrguruhaha too bad
01:17dsrguruall right thanks
01:18amalloy&(clojure.tools.macro/macrolet [(h [arg] (str (symbol? arg)))] (h foo))
01:18lazybot⇒ "true"
01:18dsrguruoh macrolet is really useful, thanks again
01:19dsrguru what's the difference between clojurebot/. and lazybot/&
01:19amalloy~source
01:19clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
01:19amalloy$whatis source
01:19lazybotsource is http://github.com/flatland/lazybot
01:19amalloyno shorter answer is a very accurate representation of the differences. they just have entirely different codebases
01:22dsrguruinteresting
01:27TEttingerdon't forget HandyBot!
01:29TEttingerhttps://github.com/Wilfred/HandyBot
01:32dsrguruTEttinger: and you can execute code in a sandbox on HandyBot (which I found out you can't do with ClojureBot)
01:32dsrgurunice to know
01:35TEttingerdsrguru: nope!
01:36TEttingerthe main reason I worked with HandyBot was because it has one dependency: clojure
02:06dsrguruhttp://pastebin.com/EB0WF9i5
02:06dsrguruthe second condition throws an error
02:06dsrguruIllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol
02:07dsrgurureproducible by calling (gen-bindings 'foo)
02:07dsrguruyet ['foo] in a repl works fine
02:09dsrguruany thoughts?
02:11arohner_,(empty? 'foo)
02:11clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
02:12dsrguruyou're a genius
02:13dsrguruarohner: I've switched the order and it works perfectly, thanks
02:13dsrguruso empty can only be called on iseq, good to know
02:14dsrguru*seqs
02:14dsrguruoh that reminds me, are there any collections that aren't seqs?
02:14arohnervectors
02:15arohneryou can produce a seq from a vector, but the vector itself is not a seq
02:15arohner,(seq [1 2 3])
02:15dsrgurudo all the main library functions call seq on a vector automatically?
02:15clojurebot(1 2 3)
02:15arohner,(seq? [1 2 3])
02:15clojurebotfalse
02:15dsrguru,(seq? {:a 3, :b 1, :c 4})
02:15clojurebotfalse
02:16arohnereverything that treats a thing as a seq is responsible for calling seq on it
02:16dsrguruoh so are seqs really just what appear to be lists?
02:16arohnerin general, it's not something you need to worry about
02:16dsrgurubut vectors and maps are seq-able
02:16arohnerseqs are a "view" or an "interface"
02:16arohnerlists are not seqs though, because a list is a concrete datastructure
02:17dsrguru,(seq? '(a b c))
02:17clojurebottrue
02:17arohnerlists implement ISeq directly
02:17dsrguru,(seq? (list 1 2 3))
02:17clojurebottrue
02:17dsrguruarohner: oh ok
02:17arohneras proof you don't need to worry:
02:17arohner,(map inc [1 2 3])
02:17clojurebot(2 3 4)
02:17arohnermap works on seqs, but took a vector there
02:17dsrgururight
02:18dsrgurubut what do you mean by lists being a concrete data structure
02:18dsrguruthey're clearly not implemented as simple linked lists whose elements are cons pairs
02:18dsrguruso how do they differ from seqs?
02:19arohnerI'm reasonably sure they are simple linked lists
02:19arohnerhttp://bc.tech.coop/blog/081108.html
02:19dsrguruso it's just that the list function converts them to seqs before the user can interact with them directly?
02:20dsrguruarohner: list isn't anywhere there
02:20arohnerIPersistentList
02:20dsrguruoh nvm
02:20dsrgururight
02:20arohnerISeq is an interface. Anything implements ISeq "isa" seq
02:21dsrguruinteresting
02:22arohnerthink of list as "a real data structure in memory" whereas ISeq is "a view on data that implements ISeq"
02:25dsrgururight
02:25arohnerand also it helps to be clear on the difference between ISeq and LazySeq
02:25dsrguruok that's true
02:25dsrgurubut is there any benefit to viewing lists as physical linked lists rather than "the default implementation of ISeq"
02:25dsrguruif the list function automatically calls seq
02:26arohnerthere is no "default" implementation of ISeq. Maybe you're conflating them because they print the same?
02:26arohner,(list 1 2 3)
02:26clojurebot(1 2 3)
02:26arohner,(take 3 (range 0))
02:26clojurebot()
02:26arohner,(take 3 (range))
02:26clojurebot(0 1 2)
02:26arohnerthose are entirely different things, in memory
02:27dsrguruexactly, that's what I'm asking
02:27dsrguruso they are?
02:27arohneryes, (list 1 2 3) and (take 3 (range)) are different things in memory
02:27dsrguru,(type (take 3 (range)))
02:27clojurebotclojure.lang.LazySeq
02:28dsrguru,(take 3 (range))
02:28clojurebot(0 1 2)
02:28arohnerit's usually not relevant though
02:28arohnerunless you have side effects or something
02:28dsrguruah so there's no special print syntax for LazySeq
02:28arohnerright
02:28dsrguruso when parens are printed, that just means an instance of ISeq
02:29dsrguruand when I type '(...), I'm really creating a seq
02:29dsrgurunot a list, correct?
02:29dsrguruwait no
02:29dsrguru(seq? '(0 1 2))
02:30dsrguru,(seq? '(0 1 2))
02:30clojurebottrue
02:30dsrguruyet
02:30dsrguru,(type '(0 1 2))
02:30clojurebotclojure.lang.PersistentList
02:30dsrguruso PersistentLists are seqs
02:30dsrgurubut vectors aren't
02:30arohner,(list? '(0 1 2))
02:30clojurebottrue
02:30arohnercorrect
02:30arohnerPersistentLists implement ISeq. seq on a vector returns a thing that implements ISeq
02:31dsrgurulet's see what specifically
02:31dsrguru,(type (seq [1]))
02:31clojurebotclojure.lang.PersistentVector$ChunkedSeq
02:31dsrguru,(type [1])
02:31clojurebotclojure.lang.PersistentVector
02:31dsrguruI wonder if there's a difference between '(1) and (seq '(1))
02:31dsrguru,(type (seq '(1)))
02:31clojurebotclojure.lang.PersistentList
02:31dsrgurunope
02:32dsrguru,(type (seq (seq [1])))
02:32clojurebotclojure.lang.PersistentVector$ChunkedSeq
02:32dsrguruso seq does nothing if its arg is a seq
02:32arohnerpretty much
02:32arohnerthere's one (intentional) corner case though
02:32arohner(seq '())
02:33arohner,(seq '())
02:33clojurebotnil
02:33arohnerseq forces the evaluation of the first argument, and returns nil if it's the empty seq
02:36dsrguruto make conditionals more convenient?
02:36arohnerI think so
02:37arohnersorry, seq forces the evaluation of the first *element*, not the first argument
02:37arohner,(seq (range))
02:37clojurebot(0 1 2 3 4 ...)
02:37arohnerhrm, not the best example, because the repl forces more evaluation there
02:57seancorfielddubz: brilliant! (disable-theme 'whatever) in the *scratch* buffer worked! wonder why it didn't work via M-x disable-theme ?
03:35amalloyseancorfield: disable-theme is either not interactive (looks to me like it is though), or does a bad job of knowing what themes are available, preventing you from entering something "wrong"
03:35amalloyrather than using your *scratch* buffer (which i have configured to eval stuff as clojure, not elisp), you can hit M-: to get an elisp-eval-form prompt
03:37amalloyfor the curious: you can set *scratch* to clojure-mode with (setq initial-major-mode 'clojure-mode) in your .emacs
05:12visilaGoing through the Clojure koans, I have some trouble understanding the last two in the function koans. Can anybody explain them to me? http://pastie.org/4294283
05:27unlinkvisila: the ___ stands for something you are supposed to fill in?
05:28visilaunlink: indeed
05:30unlinkSo in the first one, you are given a blank in the first term of the form, meaning you need to supply a function. In particular, a function, when, which called with the function (fn [n] (* n n)), returns 25.
05:32unlinkSo it will look something like ((fn [square] ___) (fn [n] (* n n))).
05:33visilaunlink: I got that far, but as the `square` argument then just represents the function, I guess I need to call it?
05:34visilaunlink: since ((fn [square] square) (fn [n] (* n n))) doesn't work
05:34unlinkvisila: Well, you need to produce 25 somehow.
05:34visilaaah
05:35visilayeah got it
05:35unlinkLook at (fn [square] square) ... it's the identity function. Passing it (fn [n] (* n n)) just gets you the same back.
05:35visilayeah, makes sense, so ((fn [square] (square 5)) (fn [n] (* n n)))
05:35unlinkRight.
05:37unlinkAnother less interesting solution would be ((constantly 25) (fn [n] (* n n))).
05:38visilaunlink: and constantly is just a function that takes any arguments and returns whatever argument is given? (here 25)
05:38clojurebotRoger.
05:38visilaIs the bot that smart? :p
05:39unlinkYes.
05:39visilaunlink: cool. thanks for your help. suggestion for resource after doing the koans? (first thing I did)
05:41unlinkvisila: Build something to scratch a personal itch, fix a bug in a clojure open source library, and refer to clojuredocs, a book of your choosing (I used Programming Clojure) and stack overflow. No need to wait.
05:43visilaunlink: might be a good idea to dive right in, perhaps do some competition problems. what's the simple go-to web framework before diving into the clojure eqvl. of rails?
05:47unlinkvisila: Ring is the baseline HTTP abstraction comparable to Rack or WSGI. It's entirely possible to write entire web apps with just ring. Compojure, sandbar and noir are popular libraries/frameworks on top of ring.
05:49unlinkI have no experience with anything higher-level than compojure (I stopped generating HTML on the server side awhile ago)
05:52visilaunlink: Thanks. Coming from Ruby object-oriented programming has become second nature. Is this something executed in Clojure? (At a first glance it doesn't seem like it)
05:53tzarHi, I'm just starting out, I was wondering why I can (GL11/glBegin ...) but not (doto GL11 (. glBegin ...))?
05:53unlinkvisila: Is what something executed in Clojure?
05:53visilaunlink: Object-oriented programming
05:55unlinkvisila: No, Clojure maintains a philosophy of a wealth of operations of a few simple data types.
05:55unlink(That said, for efficiency's sake, Clojure does supply a mechanism for implementing low level data structures in an Object-Oriented fashion.)
06:04unlinkFor example, in Ruby, you might say posts.reject &:deleted to filter out rejected posts. The Clojure equivalent looks similar: (filter (complement :deleted) posts). However, Ruby's approach doesn't scale... supposed you wanted to filter by a different predicate than truthiness. Compare (filter (comp not zero? count :comments) posts) and posts.reject {|p| p.comments.length == 0}
06:06tzarposts.reject {|p| p.comments.empty?}
06:09unlinktzar: Right, my example was a bit labored. In Clojure (filter :comments posts) would do the same thing as well.
06:15tzarokay, I think I have mostly figured out my before question, it is to do with macro expansion and the let binding of doto
06:16tzarso, new question: is there a version of doto without a let
06:16tzar?
06:16tzarie a doto that does not evaluate x
06:21lysuhello,I have a empty vector nested in a map, like (def v {k: []}), how could I push a element into vector? 'assoc-in' seems not work..thx
06:23lysuuse map+conj seem seem work, but is there other better method?
06:33dhklHi guys, I'm having trouble with calling the delete method on an object in ClojureScript. For some reason, calling (.delete video) will generate the following error: "Parse error. missing name after . operator"
06:34Raynes&(update-in {:k []} [:k] conj 0)
06:34lazybot⇒ {:k [0]}
06:34Rayneslysu: ^
06:41lysuRaynes: thank u, update-in!
07:15Wizekhello
07:17WizekHow can I make clojure to print numbers from 1-10 with a loop?
07:18WizekI could write (print 1 2 3 4 '...) of course, but I'd like to learn about clojure loops
07:23Chousukeyou should focus on learning about sequences and working with them instead of explicit loops
07:24Chousukebut there is the loop construct. it basically works like a recursive function except that it doesn't create a function :P
07:26ChousukeI think the shortest way to do what you ask would be (apply print (range 1 11))
07:27Chousukebut in general if you want to go over a seq and do something with side-effects, you'd use doseq: (doseq [x (range 1 11)] (print x))
08:55duck1123Is there any middleware that'll pretty print my html output? I like the utra-compact output that hiccup puts out normally, but for dev it'd be nice to have the extra whitespace
08:55ToxicFrog"No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil"
08:55ToxicFrogWhat?
08:55clojurebotwhat is cells
08:56llasramToxicFrog: You called clojure.io/reader on `nil`
08:56llasramclojure.java.io/reader even
08:58ToxicFrogAah
08:59ToxicFrogAha, right, because I changed how the program handles arguments and forgot to change how lein invokes it
08:59ToxicFrogThanks
09:59duck1123Is it possible to write my cljs functions so they can take a js object or a cljs map? Ore is it pretty much one or the other?
10:27sw1nnhi
10:28sw1nnI'm trying to split a vector 20% (say) 80%
10:28sw1nnwhere it's random which 'partition' each element should go into
10:28sw1nnbut must get strictly 20% in one partition, 80% in the other.
10:29sw1nnany thoughts.
10:29sw1nnI think I want something like (defn partition-indexed [pred coll])
10:30sw1nnwhere pred gets passed the index and can determine whether we want it or not.
10:31sw1nnany suggestions? is there a core library function that does something close?
10:33jjidosome form of unzip
10:34duck1123hmm... there's a map-indexed and a partition-by
10:37sw1nnsomething like (shuffle (range (count c))) to get a randomised collection of the indexes. then partition by the first 20% indexes etc.
10:37sw1nnbut seems harder that I expect
10:40sw1nnthe 'real' problem is that I have a dataset that I'd like to split into a training and cross validation set. Maybe there's something specific to that problem that I'm missing?
10:42sw1nnamalloy has 'take-shuffled' here: https://github.com/amalloy/useful/blob/develop/src/useful/seq.clj
11:40TimMcYeah, shuffle and then split sounds like a good idea.
11:54jaydubshello
11:54duck1123greetings
11:55jaydubsusually this quite in here?
11:57duck1123it depends, it sometimes gets quiet on the weekends
11:57duck1123say something controversial and they'll come out of the woodwork
11:58jaydubs haha, yea i bet. have been playing w/ clojure fore a couple weeks now, read this guy's blog this morning and thought guess I need to check this channel out haha
11:58jaydubshttp://blog.raynes.me/
11:58duck1123welcome
11:58jaydubsthank you
11:59duck1123what kind of development have you been doing with Clojure?
11:59antoineBis tpye hint will avoid execution of a defn if type mismatch?
11:59antoineB*type
12:00jaydubsi started learning at webnoir, then realized i need some real lisp/clojure background first. so back tracked, got comfy, and am now back at webnoir
12:01duck1123antoineB: I'm not quite sure what you're asking
12:03jaydubsI am really intersted in producing web sites w/ clojure/noir. i kept runing into mr granger's stuff and its gorgeous looking/working so .. that plus knowing oo and functional seems like a well rounded belt, if you know what i'm saying
12:04duck1123Clojure is a great language to do webdev with. The Ring abstraction is a brilliant idea
12:05antoineB(defn test [^String name] ....)
12:05antoineB(test 12) => the code didn't enter the defn
12:05antoineB(test "abc") => the code enter the defn
12:07duck1123type hints exist to eliminate reflection, so they'll throw an exception if you're using interop and pass it to the right type, but if you don't run into any of those situations, it won't
12:07duck1123eg. (defn test [^String name] name) (test 42) => 42
12:08antoineBok
12:08antoineBcan i use clojure code from java?
12:08duck1123you're probably better off looking into contracts or similar if you really want to assert the type. (or a :pre condition)
12:09duck1123antoineB: absolutely. It's possible to generate clojure classes that can be used just like java classes, or you can load and run clojure code from java
12:09antoineBok
12:10duck1123http://stackoverflow.com/questions/2181774/calling-clojure-from-java
12:27antoineBthe thing i didn't understand in ring is how to dispatch, do i need a write my own handler to dispatch to other handlers?
12:34duck1123antoineB: Have you looked at Compojure? It gives you helpers for creating handlers
12:34duck1123and then things like Noir and Ciste (shameless plug) work at a higher abstraction.
12:35duck1123or am I misunderstanding your question?
12:36antoineBi am interesting in low level, my question is: Is there a beautifull way to organize different handler with ring?
12:37antoineBexample: using multimethod to dispatch the handler, using a "master" handler etc...
12:38duck1123so you want to match a handler then pass that request to a multimethod for further processing? you can do that
13:05antoineBis there a shorthand for (not (= ?? ??)) like (!= ?? ??)
13:05mduerksenantoineB: not=
13:06antoineBthansk
13:07pipelineso I want to call a protected method in a java class
13:08pipeline"proxy" doesn't want to do that for me directly; do I have to override the method and call proxy-super in the definition?
13:14arohnerpipeline: https://github.com/arohner/clj-wallhack
13:14arohnerit's also in old contrib
13:17pipelinearohner: ouch this is what I was afraid of
13:17pipelinearohner: thanks for confirming that I am barking up the wrong tree though
13:18arohnerhrm, I don't have much experience w/ proxy calling private methods. But the docstring says that proxy can call protected methods, but not protected fields
13:19pipelineyeah I think wallhack is actually needed in 1.3
13:19arohnerpipeline: you might also want to look at reify
13:22pipelinearohner: that is for making interfaces into proxy-type things
13:23arohneroh right, you can't inherit from concrete classes with that
13:23arohnerthere's also gen-class, though that's should be a last resort
13:25seancorfieldamalloy_: thanx for the hints on *scratch* and M-: last night
13:26pipelinearohner: I honestly thing gen-class is my best option, since the alternatives are to write a java class wrapper or use reflection
13:27pipelinearohner: but you saved me a bunch of time chasing my tail with proxy ...
14:17AtKaaZhi, could someone explain to me what am I missing here? ((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 5)
14:17AtKaaZwhy are they in reversed order?
14:18AtKaaZshouldn't they be '(1 2 3 4 5) ?
14:18AtKaaZThe conj function creates a new vector that contains an additional item added to the back.
14:20AtKaaZand why can't I use cons instead?
14:20AtKaaZIllegalArgumentException Don't know how to create ISeq from: java.lang.Long clojure.lang.RT.seqFrom (RT.java:487)
14:21metelluscons needs the arguments to be reversed
14:22AtKaaZoh
14:22AtKaaZlike this: ((fn foo [x] (when (> x 0) (cons x (foo (dec x)) ))) 5)
14:23AtKaaZbut this also returns '(5 4 3 2 1)
14:23AtKaaZI'm clearly missing something elementary:)
14:24amalloyAtKaaZ: conj doesn't create a new vector: it creates a new X, where X is whatever type you gave it; and it adds the new item wherever it's "convenient" for type X
14:24amalloyfor vectors that's the end; for lists and conses (and nil) that's the front
14:25AtKaaZalright then this article needs to correct this statment? "The conj function creates a new vector that contains an additional item added to the back." http://java.ociweb.com/mark/clojure/article.html
14:25AtKaaZhow do I know what type is X in the above ?
14:25amalloyvery first mention of conj in that article: The conj function, short for conjoin, adds one or more items to a collection. Where they are added depends on the type of the collection. This is explained in the information on specific collection types below.
14:26QtrDo you have defmacro in clojure?
14:26AtKaaZalright, I stand corrected :D
14:26amalloyyou're reading the documentation on how various functions behave when passed vectors
14:26AtKaaZQtr not me
14:27amalloyalso, i see you created a 4clojure issue. it is not the case that any problems "allow" multiple solutions
14:27amalloybut if you paste "9 9 9 9" into (= 9 __), that happens to work
14:27amalloyQtr: yes
14:28AtKaaZoh i see what you mean, I can do multiple solutions in one line
14:28AtKaaZthanks amalloy
14:28amalloyno, you can't do multiple solutions period. i mean, you can write whatever you want, but it's not like solution 1 gets tried against testcase 1 or anything. literally all the text you type is pasted in place of the __ in each case
14:29AtKaaZI understand
14:31duck1123AtKaaZ: in case you weren't aware, that fn won't use TCO, so you'll blow the stack if it's too high
14:32AtKaaZduck1123, well I'm new :) it's from here: http://www.4clojure.com/problem/57
14:32AtKaaZ Java doesn't currently support TCO and neither does Clojure. One way to avoid this issue in Clojure is to use the loop and recur special forms. Another way is to use the trampoline function. (I skimmed over this part)
14:33duck1123ok, I can see why they didn't get into recur yet. Just wanted to make sure you weren't trying to use that
14:33AtKaaZsweet, thanks
14:42AtKaaZamalloy I like the accuracy with which you troubleshooted the above down to the doc I was reading
14:43amalloyclick link, ctrl-f, problem solved :)
14:57AtKaaZI'm still trying to understand how did conj get a list as the first arg in: ((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 5)
14:58AtKaaZhow did the call to foo with the arg being 0 return a list ? and if it didn't why isn't (conj 1 2) working?
15:00AtKaaZbecause the way I understand it this part (foo (dec x)) returns as a list ie. '(1)
15:00AtKaaZbut how does that happen ? :)
15:00AtKaaZoh wait hmm
15:01AtKaaZohk: (conj nil 1)
15:01AtKaaZgot it=)
15:02AtKaaZvery clever I like it
15:04AtKaaZit's funny how I was stuck for like 15min and as soon as I wrote/asked the question out loud I was somehow able to find a path to its solution (happened before)
15:06AtKaaZit's almost as if, in the mind, we're skipping over some parts as if for speed-optimization but when we're writing it down we're forced to go over them and thus realize what we missed
15:24ToxicFrog,(conj nil 1)
15:24clojurebot(1)
15:24ToxicFrog,(conj 1 nil)
15:24clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentCollection>
15:24AtKaaZawesome
15:24ToxicFrogOh right, conj and cons take arguments in reverse order from each other.
15:24ToxicFrog,(cons 1 nil)
15:24clojurebot(1)
15:25AtKaaZ,(when-not nil 1)
15:25clojurebot1
15:25AtKaaZthat is some epic bot
15:38arrdemis it possible to use a variable-arity &more argument in conjunction with a keyword &{:keys [...]}?
15:40arohnerarrdem: how would that work?
15:40arohnerdestructuring can only create 'known' variable names. i.e. the local names have to be resolved at compile time
15:41arrdemarohner: from an implementation point of view I was expecting it not to be possible, and experiment at the REPL just confirmed such failure
15:45uvtcarrdem: Not sure if this is exactly what you're asking about, but I think that the idiomatic way to handle kwargs uses that. For example, to create a function that works like this `(foo :a 1 :b 2 :c 3)`, you can do `(defn foo [& {:keys [a b c]}] (println a b c))`.
15:46uvtcThat said, so far, I prefer the simpler `(defn foo [{:keys [a b c]}] (println a b c))` where you'd call it by passing a map: `(foo {:a 1 :b 2 :c 3})`.
16:13technomancyhttps://github.com/kingtim/nrepl.el/pull/21 <- anyone want to try an awesome new nrepl.el feature that even slime doesn't have?
16:14AtKaaZwhat is that exactly? in English :) I'm new
16:15technomancyAtKaaZ: have you used ido-mode in emacs?
16:15AtKaaZEmacs client for Clojure networked repl server ?
16:16AtKaaZnope but I've used emacs before (not with clojure)
16:16technomancyright; I just added a feature that lets you browse vars in namespaces much like ido lets you browse files in directories
16:16technomancyjust type enough chars to uniquely identify a given entry
16:16AtKaaZthat sounds cool
16:17technomancynrepl.el still needs a bit more polish before it's ready for widespread usage, but I thought I should add a feature that slime doesn't have to help convince people to make the switch =)
16:20carkdoes it work with clojure-mode too ? or is it standalone ?
16:21bprdoes anyone know what lamina is indicating when a channel is represented as "<== [?]" at the repl (as opposed to "<== [...]")
16:21technomancycark: it complements clojure-mode
16:21Raynestechnomancy: Thanks for reproducing that issue.
16:21bprapparently it's none of closed?, drained?, or transactional?
16:22carkoh i see it's requiring leni 2 :)
16:22carklein
16:27bprthe relevant print-method's body is: (.write writer (str "<== " (str ch)))
16:27bprwhich i don't find very helpful. (str ch) doesn't clarify much
16:32amalloybpr: so look in .toString for channels
16:32bpri am
16:37bpramalloy: at the bottom it seems to be printing persistentqueues
16:38bprbut that still leaves me with (str ?what) => "?"
16:40bpri certainly have not enqueued a "?" or a (symbol "?")
16:41bpranyway if i had print-method would yield: "<== [? ...]"
16:46technomancyoh man, 18 open issues on nrepl.el
16:46technomancyRaynes: can you try the ido-read-var branch?
16:46Raynestechnomancy: Can you explain what it does and how I can try it?
16:47technomancyRaynes: if you load my branch and jack in you should be able to do C-u M-. and bask in idoey goodness for finding a var
16:47technomancywould be much obliged
16:47Raynesk
16:48michhello
16:50Raynestechnomancy: Looks like you've finally found something that clashes with evil-mode.
16:51Raynestechnomancy: Not sure if that's the issue though, because nothing is working. I can't load my file. It's sitting there saying "Loading <file>…"
16:52RaynesBut anyways, when I did C-u M-., I got evil complaining about something.
16:56Raynestechnomancy: Looks like this is what kingtim was saying?
16:56RaynesI think this means we win?
16:56emezeske_Hey, people who use Clojars: You know that travis-ci.org image that some projects include in their README that says "build status: whatever" (friend has it: https://github.com/cemerick/friend/blob/master/README.md)?
16:57Raynesemezeske_: Yup.
16:57emezeske_If I created a similar widget that displayed the latest version of a project that's been uploaded to Clojars, would you use that?
16:57RaynesI would use the *shit* out of that.
16:57RaynesLike, I'd come to your house and give you a hug for it.
16:57emezeske_I noticed that a lot of READMEs have stale versions in their how-to-install docs
16:57emezeske_Raynes: haha
16:57RaynesPlease, for the love of God, just go do it.
16:58emezeske_Okay, it's officially on my TODO list. Not quite at the top, but close
16:58cemerickemezeske_: Once lein has a proper release plugin, there'll be no excuse to have stale readmes. But, this other idea is a good one regardless. :-)
16:58emezeske_cemerick: Yeah, that would be ideal
17:00Raynescemerick: I don't get the correlation.
17:01amalloyemezeske: you may have to hurry on that one; ninjudd was saying the other day he wants it
17:02emezeske_amalloy: Bah! What is it with good ideas never being original?
17:02amalloyideas don't count, it's execution. and i bet you'll beat him to it
17:02emezeske_Agreed on the first part, we'll see on the second :)
17:03augustlis it possible to tell exactly what went wrong from this error message from lein2? "Failed to collect dependencies for [#<Dependency ring:ring:jar:1.1.1 (compile)> #<Dependency clj-http:clj-http:jar:0.4.3 (compile)> #<Dependency org.clojure:clojure:jar:1.4.0 (compile)> #<Dependency compojure:compojure:jar:1.0.4 (compile)> #<Dependency cheshire:cheshire:jar:4.0.0 (compile)> #<Dependency myapp-clojure-utils:myapp-clojure-utils:jar:0.1.2 (co
17:03augustlsuch as which jar it couldn't find
17:04amalloywell, his new years resolution is to not start so many dang projects
17:05Raynesamalloy: Yeah, he needs more time to ask me what my progress is on project x and y.
17:05augustlthis is a project that works fine for lein 1 btw. Just changed :dev-dependencies to :profiles etc.
17:06Raynesaugustl: Could you refheap the whole project.clj file?
17:06duck1123travis fails my builds even though they pass normally
17:06augustlRaynes: sure thing
17:06Raynesduck1123: There are a lot of variables in that, believe it or not.
17:07augustlhttps://www.refheap.com/paste/3726
17:07duck1123Raynes: it's only the multi-threading part that's failing
17:07augustlRaynes: ^^
17:07duck1123I should take it as a sign that I need to define my test cases better. I just haven't done it yet
17:08Raynesaugustl: Now could you do the same for all of leiningen's output?
17:09technomancyRaynes: huh; if you can't load the file at all it's probably not due to my changes
17:09augustlCr8: https://www.refheap.com/paste/3727
17:09Raynestechnomancy: Well it certainly wasn't happening before your changes.
17:09augustlerr, Raynes, not Cr8
17:09technomancybleaugh
17:09augustlnot sure what happened there..
17:10technomancyRaynes: can you type "reduce" in the repl and hit M-. on that?
17:10augustlheh, "not authorized" might have got something to do it
17:10augustldid repo authentication change in lein 2?
17:10augustlI have it in ~/.lein/init.clj now, lein 1 style
17:11Raynesaugustl: The problem here is indeed that you don't have access to that repo.
17:12augustlthe error message was a bit obscure :)
17:12RaynesIt's pretty clear. :p
17:12Raynes"UNAUTHORIZED"
17:13augustlI looked at the error message though, not the full log of all the maven stuff
17:13augustlnot complaining, just saying
17:14augustlseems https://github.com/technomancy/leiningen/blob/preview/sample.project.clj is out of date, it mentions profile.clj which seems to be deprecated now
17:15augustlhmm, credentials.clj doesn't seem to be documented anywhere
17:16augustlleiningen seems to almost want to make it as hard as possible depend on non-public jars :)
17:18augustlI need to know how to use gpg it seems
17:19augustlis there a way to authenticate with a repository without using gpg in lein 2?
17:20Raynestechnomancy: That worked.
17:20Raynestechnomancy: Also, I C-u M-. seems to be working now.
17:20augustlI'm inclined to store the pasword in project.clj
17:21Raynestechnomancy: But evaluation stuff still wont work.
17:21Raynestechnomancy: C-x C-e doesn't work, nor does C-c C-k
17:35dnolen`cof
17:35dnolen`oops
17:53technomancyRaynes: there's something up with nrepl-buffer-ns
17:53technomancyI think you're seeing the same thing kingtim is
17:53clizzinis there a preferred lib in clojure for database migrations in web apps?
17:53technomancyall the places he uses nrepl-buffer-ns don't work on my machine, so I use (nrepl-current-ns) instead
17:54technomancyclizzin: here's what I use: https://github.com/heroku/buildkits/blob/master/src/buildkits/db/migrate.clj
17:54technomancythere's also ragtime, but it's a bit more complicated
17:54clizzintechnomancy: cool, thanks for the tip, i'll check it out
17:54technomancyRaynes: well thanks for trying it out
17:55clizzinso to add a migration, you just add a new function and then add it to -main?
17:55technomancyaugustl: you can use environment variables for credentials too
17:55technomancyand profiles.clj is definitely not deprecated
17:59technomancyclizzin: yeah, that's the idea. I might extract it into a lib at some point, but it's just a couple defns now, so feel free to copy/paste
18:07ziltiI want to turn a noir project into a usable war for use with Tomcat, but that seems to be very complicated. I'm using clojure 1.4, noir 1.3-beta3 and lein-ring 0.7.1. But lein-ring-uberwar results in a NullPointerException after having compiled the project, and I don't get a war file.
18:13technomancyhttp://nic.ferrier.me.uk/blog/2012_04/the_differences_between_the_lisps
20:29sandboxhey guys, can you do java annotations in clojure?
20:31hyPiRionHuh. Haven't heard about it, but it's probably stuffed in somewhere.
20:32hyPiRionhttps://groups.google.com/forum/?fromgroups#!topic/clojure/0hKOFQXAwRc
20:33sandboxthat's where i am right now too
20:33sandboxmust say i didn't click into the gist though
20:36hyPiRionFrom what I can read: People say that annotations are made up in Java due to some weakness in the language.
20:41sandboxthat's what i'm seeing too, anyways thanks for your help
22:07saurik(defn m [& a] (prn a)) (m 1) -> (1) ; makes sense, because I am destructuring an array into the rest parameter a, so I get a sequence back with the argument list, in this case "1"
22:08saurik(defprotocol Q (f [& d])) (deftype T [] Q (f [& d] (prn d))) (f (->T) 1) -> 1 ; highly confusing to me, as I am destructuring the arguments to the rest parameter d, but somehow am getting the singular value back inside of the function
22:09saurikam I fundamentally misunderstanding protocols? is this a bug in clojure? (I'm using 1.4.0 from clojars)
22:12amalloyno &args in protocols
22:12amalloythey're supposed to represent low-level pieces of functionality, not user-friendly stuff like sugared arglists
22:13saurikok, I'm somewhat surprised then that it does not simply fail, as opposed to working in such a weird way. I can deal with that: thanks.
22:13saurikhowever, one further question:
22:13saurik(defprotocol Q (f [d])) (deftype T [] Q (f [d] (prn d))) (f (->T) 1)
22:13saurikthere I am not using any special arguments: just something really simple with a single argument
22:14saurikNo single method: f of interface: Q found for function: f of protocol: Q
22:14saurikoh, I get that one
22:14saurikI need a this parameter
22:14amalloysaurik: & is a symbol, so [& q] in the context of a protocol is a two-arg function: & and q
22:15saurikah, ok, that makes sense
22:32tzarHow would I group a seq (:a :b :c :d :e) into ((:a :b) (:c :d) (:e)) ?
22:35eggsbytzar: partition-all 2
22:35eggsby&(partition-all 2 (list :a :b :c :d :e))
22:35lazybot⇒ ((:a :b) (:c :d) (:e))
22:36tzareggsby: thank you :)
23:03amalloy$findfn 2 [:a :b :c :d :e] [[:a :b] [:c :d] [:e]] ;; if you can guess what order the args go in, this often finds you the function you want
23:03lazybot[clojure.core/partition-all]
23:30Raynesamalloy: We could try every order of args and return the list with the fewest results.
23:30Raynesamalloy: It could be a new command $ihopeso
23:35amalloyRaynes: why the fewest?
23:35Raynesamalloy: I don't know. Most specific? *shrug*
23:35RaynesI didn't have a reason for picking between "the most" and "the fewest".
23:42mkwhat is a namespace? does it correspond to a package?
23:46RaynesMore or less.
23:46mkhow are functions put into a package with no class to contain them as methods?
23:54michaelr`good morning everybody!
23:54rlbmk: not sure what you mean -- like other languages, clojure has "normal" functions (i.e. not methods).
23:54rlbIn clojure's case, they're scoped within a namespace.
23:55mkrlb: java doesn't allow java.example.methodName()
23:55rlbmk: clojure's not java?
23:55rlb(just uses the jvm)
23:55rlb...as one of its platforms.
23:56mksure, or the js interpreter. I'm wondering how it compiles functions into a package
23:56rlboh, you mean the mechanism -- that I don't know.
23:56mknot the details, just what a function corresponds to - what it is on the jvm
23:57rlbnot sure what the JVM allows there (may or may not have anything to do with what java allows)
23:57rlbright -- don't know the jvm well enough to help you there
23:57mkok
23:57mkare namespaces mappings?