#clojure log - Jul 21 2012

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:00 seancorfield: monokai has holes that are affected by other themes... very annoying

0:01 dubz: M-x disable-theme works for me

0:09 seancorfield: if you open your init.el you could try typing (disable-theme 'monokai) then M-x eval-buffer

1:10 dsrguru: in 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

1:13 I'm trying to write a macro such that (my-macro []) -> [], (my-macro foo) -> [foo], and (my-macro [a b]) -> {:keys [a b]}

1:14 and I'm wondering how to check to see if the argument is in the foo form

1:14 i.e. an unquoted symbol

1:15 amalloy: &(doc symbol?)

1:15 lazybot: ⇒ "([x]); Return true if x is a Symbol"

1:16 dsrguru: ,(symbol? foo)

1:16 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>

1:16 dsrguru: see?

1:16 amalloy: irrelevant. your macro receives source-code forms

1:17 (defmacro m [x] (symbol? x)) (macroexpand '(m foo)) => true

1:17 dsrguru: ,(defmacro h [arg] (str (symbol? arg)))

1:17 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

1:17 dsrguru: haha too bad

1:17 all right thanks

1:18 amalloy: &(clojure.tools.macro/macrolet [(h [arg] (str (symbol? arg)))] (h foo))

1:18 lazybot: ⇒ "true"

1:18 dsrguru: oh macrolet is really useful, thanks again

1:19 what's the difference between clojurebot/. and lazybot/&

1:19 amalloy: ~source

1:19 clojurebot: source is http://github.com/hiredman/clojurebot/tree/master

1:19 amalloy: $whatis source

1:19 lazybot: source is http://github.com/flatland/lazybot

1:19 amalloy: no shorter answer is a very accurate representation of the differences. they just have entirely different codebases

1:22 dsrguru: interesting

1:27 TEttinger: don't forget HandyBot!

1:29 https://github.com/Wilfred/HandyBot

1:32 dsrguru: TEttinger: and you can execute code in a sandbox on HandyBot (which I found out you can't do with ClojureBot)

1:32 nice to know

1:35 TEttinger: dsrguru: nope!

1:36 the main reason I worked with HandyBot was because it has one dependency: clojure

2:06 dsrguru: http://pastebin.com/EB0WF9i5

2:06 the second condition throws an error

2:06 IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol

2:07 reproducible by calling (gen-bindings 'foo)

2:07 yet ['foo] in a repl works fine

2:09 any thoughts?

2:11 arohner_: ,(empty? 'foo)

2:11 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>

2:12 dsrguru: you're a genius

2:13 arohner: I've switched the order and it works perfectly, thanks

2:13 so empty can only be called on iseq, good to know

2:14 *seqs

2:14 oh that reminds me, are there any collections that aren't seqs?

2:14 arohner: vectors

2:15 you can produce a seq from a vector, but the vector itself is not a seq

2:15 ,(seq [1 2 3])

2:15 dsrguru: do all the main library functions call seq on a vector automatically?

2:15 clojurebot: (1 2 3)

2:15 arohner: ,(seq? [1 2 3])

2:15 clojurebot: false

2:15 dsrguru: ,(seq? {:a 3, :b 1, :c 4})

2:15 clojurebot: false

2:16 arohner: everything that treats a thing as a seq is responsible for calling seq on it

2:16 dsrguru: oh so are seqs really just what appear to be lists?

2:16 arohner: in general, it's not something you need to worry about

2:16 dsrguru: but vectors and maps are seq-able

2:16 arohner: seqs are a "view" or an "interface"

2:16 lists are not seqs though, because a list is a concrete datastructure

2:17 dsrguru: ,(seq? '(a b c))

2:17 clojurebot: true

2:17 arohner: lists implement ISeq directly

2:17 dsrguru: ,(seq? (list 1 2 3))

2:17 clojurebot: true

2:17 dsrguru: arohner: oh ok

2:17 arohner: as proof you don't need to worry:

2:17 ,(map inc [1 2 3])

2:17 clojurebot: (2 3 4)

2:17 arohner: map works on seqs, but took a vector there

2:17 dsrguru: right

2:18 but what do you mean by lists being a concrete data structure

2:18 they're clearly not implemented as simple linked lists whose elements are cons pairs

2:18 so how do they differ from seqs?

2:19 arohner: I'm reasonably sure they are simple linked lists

2:19 http://bc.tech.coop/blog/081108.html

2:19 dsrguru: so it's just that the list function converts them to seqs before the user can interact with them directly?

2:20 arohner: list isn't anywhere there

2:20 arohner: IPersistentList

2:20 dsrguru: oh nvm

2:20 right

2:20 arohner: ISeq is an interface. Anything implements ISeq "isa" seq

2:21 dsrguru: interesting

2:22 arohner: think of list as "a real data structure in memory" whereas ISeq is "a view on data that implements ISeq"

2:25 dsrguru: right

2:25 arohner: and also it helps to be clear on the difference between ISeq and LazySeq

2:25 dsrguru: ok that's true

2:25 but is there any benefit to viewing lists as physical linked lists rather than "the default implementation of ISeq"

2:25 if the list function automatically calls seq

2:26 arohner: there is no "default" implementation of ISeq. Maybe you're conflating them because they print the same?

2:26 ,(list 1 2 3)

2:26 clojurebot: (1 2 3)

2:26 arohner: ,(take 3 (range 0))

2:26 clojurebot: ()

2:26 arohner: ,(take 3 (range))

2:26 clojurebot: (0 1 2)

2:26 arohner: those are entirely different things, in memory

2:27 dsrguru: exactly, that's what I'm asking

2:27 so they are?

2:27 arohner: yes, (list 1 2 3) and (take 3 (range)) are different things in memory

2:27 dsrguru: ,(type (take 3 (range)))

2:27 clojurebot: clojure.lang.LazySeq

2:28 dsrguru: ,(take 3 (range))

2:28 clojurebot: (0 1 2)

2:28 arohner: it's usually not relevant though

2:28 unless you have side effects or something

2:28 dsrguru: ah so there's no special print syntax for LazySeq

2:28 arohner: right

2:28 dsrguru: so when parens are printed, that just means an instance of ISeq

2:29 and when I type '(...), I'm really creating a seq

2:29 not a list, correct?

2:29 wait no

2:29 (seq? '(0 1 2))

2:30 ,(seq? '(0 1 2))

2:30 clojurebot: true

2:30 dsrguru: yet

2:30 ,(type '(0 1 2))

2:30 clojurebot: clojure.lang.PersistentList

2:30 dsrguru: so PersistentLists are seqs

2:30 but vectors aren't

2:30 arohner: ,(list? '(0 1 2))

2:30 clojurebot: true

2:30 arohner: correct

2:30 PersistentLists implement ISeq. seq on a vector returns a thing that implements ISeq

2:31 dsrguru: let's see what specifically

2:31 ,(type (seq [1]))

2:31 clojurebot: clojure.lang.PersistentVector$ChunkedSeq

2:31 dsrguru: ,(type [1])

2:31 clojurebot: clojure.lang.PersistentVector

2:31 dsrguru: I wonder if there's a difference between '(1) and (seq '(1))

2:31 ,(type (seq '(1)))

2:31 clojurebot: clojure.lang.PersistentList

2:31 dsrguru: nope

2:32 ,(type (seq (seq [1])))

2:32 clojurebot: clojure.lang.PersistentVector$ChunkedSeq

2:32 dsrguru: so seq does nothing if its arg is a seq

2:32 arohner: pretty much

2:32 there's one (intentional) corner case though

2:32 (seq '())

2:33 ,(seq '())

2:33 clojurebot: nil

2:33 arohner: seq forces the evaluation of the first argument, and returns nil if it's the empty seq

2:36 dsrguru: to make conditionals more convenient?

2:36 arohner: I think so

2:37 sorry, seq forces the evaluation of the first *element*, not the first argument

2:37 ,(seq (range))

2:37 clojurebot: (0 1 2 3 4 ...)

2:37 arohner: hrm, not the best example, because the repl forces more evaluation there

2:57 seancorfield: dubz: brilliant! (disable-theme 'whatever) in the *scratch* buffer worked! wonder why it didn't work via M-x disable-theme ?

3:35 amalloy: seancorfield: 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"

3:35 rather 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

3:37 for the curious: you can set *scratch* to clojure-mode with (setq initial-major-mode 'clojure-mode) in your .emacs

5:12 visila: Going 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

5:27 unlink: visila: the ___ stands for something you are supposed to fill in?

5:28 visila: unlink: indeed

5:30 unlink: So 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.

5:32 So it will look something like ((fn [square] ___) (fn [n] (* n n))).

5:33 visila: unlink: I got that far, but as the `square` argument then just represents the function, I guess I need to call it?

5:34 unlink: since ((fn [square] square) (fn [n] (* n n))) doesn't work

5:34 unlink: visila: Well, you need to produce 25 somehow.

5:34 visila: aah

5:35 yeah got it

5:35 unlink: Look at (fn [square] square) ... it's the identity function. Passing it (fn [n] (* n n)) just gets you the same back.

5:35 visila: yeah, makes sense, so ((fn [square] (square 5)) (fn [n] (* n n)))

5:35 unlink: Right.

5:37 Another less interesting solution would be ((constantly 25) (fn [n] (* n n))).

5:38 visila: unlink: and constantly is just a function that takes any arguments and returns whatever argument is given? (here 25)

5:38 clojurebot: Roger.

5:38 visila: Is the bot that smart? :p

5:39 unlink: Yes.

5:39 visila: unlink: cool. thanks for your help. suggestion for resource after doing the koans? (first thing I did)

5:41 unlink: visila: 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.

5:43 visila: unlink: 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?

5:47 unlink: visila: 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.

5:49 I have no experience with anything higher-level than compojure (I stopped generating HTML on the server side awhile ago)

5:52 visila: unlink: 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)

5:53 tzar: Hi, I'm just starting out, I was wondering why I can (GL11/glBegin ...) but not (doto GL11 (. glBegin ...))?

5:53 unlink: visila: Is what something executed in Clojure?

5:53 visila: unlink: Object-oriented programming

5:55 unlink: visila: No, Clojure maintains a philosophy of a wealth of operations of a few simple data types.

5:55 (That said, for efficiency's sake, Clojure does supply a mechanism for implementing low level data structures in an Object-Oriented fashion.)

6:04 For 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}

6:06 tzar: posts.reject {|p| p.comments.empty?}

6:09 unlink: tzar: Right, my example was a bit labored. In Clojure (filter :comments posts) would do the same thing as well.

6:15 tzar: okay, I think I have mostly figured out my before question, it is to do with macro expansion and the let binding of doto

6:16 so, new question: is there a version of doto without a let

6:16 ?

6:16 ie a doto that does not evaluate x

6:21 lysu: hello,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

6:23 use map+conj seem seem work, but is there other better method?

6:33 dhkl: Hi 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"

6:34 Raynes: &(update-in {:k []} [:k] conj 0)

6:34 lazybot: ⇒ {:k [0]}

6:34 Raynes: lysu: ^

6:41 lysu: Raynes: thank u, update-in!

7:15 Wizek: hello

7:17 How can I make clojure to print numbers from 1-10 with a loop?

7:18 I could write (print 1 2 3 4 '...) of course, but I'd like to learn about clojure loops

7:23 Chousuke: you should focus on learning about sequences and working with them instead of explicit loops

7:24 but there is the loop construct. it basically works like a recursive function except that it doesn't create a function :P

7:26 I think the shortest way to do what you ask would be (apply print (range 1 11))

7:27 but 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))

8:55 duck1123: Is 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

8:55 ToxicFrog: "No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil"

8:55 What?

8:55 clojurebot: what is cells

8:56 llasram: ToxicFrog: You called clojure.io/reader on `nil`

8:56 clojure.java.io/reader even

8:58 ToxicFrog: Aah

8:59 Aha, right, because I changed how the program handles arguments and forgot to change how lein invokes it

8:59 Thanks

9:59 duck1123: Is 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:27 sw1nn: hi

10:28 I'm trying to split a vector 20% (say) 80%

10:28 where it's random which 'partition' each element should go into

10:28 but must get strictly 20% in one partition, 80% in the other.

10:29 any thoughts.

10:29 I think I want something like (defn partition-indexed [pred coll])

10:30 where pred gets passed the index and can determine whether we want it or not.

10:31 any suggestions? is there a core library function that does something close?

10:33 jjido: some form of unzip

10:34 duck1123: hmm... there's a map-indexed and a partition-by

10:37 sw1nn: something like (shuffle (range (count c))) to get a randomised collection of the indexes. then partition by the first 20% indexes etc.

10:37 but seems harder that I expect

10:40 the '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:42 amalloy has 'take-shuffled' here: https://github.com/amalloy/useful/blob/develop/src/useful/seq.clj

11:40 TimMc: Yeah, shuffle and then split sounds like a good idea.

11:54 jaydubs: hello

11:54 duck1123: greetings

11:55 jaydubs: usually this quite in here?

11:57 duck1123: it depends, it sometimes gets quiet on the weekends

11:57 say something controversial and they'll come out of the woodwork

11:58 jaydubs: 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:58 http://blog.raynes.me/

11:58 duck1123: welcome

11:58 jaydubs: thank you

11:59 duck1123: what kind of development have you been doing with Clojure?

11:59 antoineB: is tpye hint will avoid execution of a defn if type mismatch?

11:59 *type

12:00 jaydubs: i 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:01 duck1123: antoineB: I'm not quite sure what you're asking

12:03 jaydubs: I 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:04 duck1123: Clojure is a great language to do webdev with. The Ring abstraction is a brilliant idea

12:05 antoineB: (defn test [^String name] ....)

12:05 (test 12) => the code didn't enter the defn

12:05 (test "abc") => the code enter the defn

12:07 duck1123: type 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:07 eg. (defn test [^String name] name) (test 42) => 42

12:08 antoineB: ok

12:08 can i use clojure code from java?

12:08 duck1123: you're probably better off looking into contracts or similar if you really want to assert the type. (or a :pre condition)

12:09 antoineB: 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:09 antoineB: ok

12:10 duck1123: http://stackoverflow.com/questions/2181774/calling-clojure-from-java

12:27 antoineB: the 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:34 duck1123: antoineB: Have you looked at Compojure? It gives you helpers for creating handlers

12:34 and then things like Noir and Ciste (shameless plug) work at a higher abstraction.

12:35 or am I misunderstanding your question?

12:36 antoineB: i am interesting in low level, my question is: Is there a beautifull way to organize different handler with ring?

12:37 example: using multimethod to dispatch the handler, using a "master" handler etc...

12:38 duck1123: so you want to match a handler then pass that request to a multimethod for further processing? you can do that

13:05 antoineB: is there a shorthand for (not (= ?? ??)) like (!= ?? ??)

13:05 mduerksen: antoineB: not=

13:06 antoineB: thansk

13:07 pipeline: so I want to call a protected method in a java class

13:08 "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:14 arohner: pipeline: https://github.com/arohner/clj-wallhack

13:14 it's also in old contrib

13:17 pipeline: arohner: ouch this is what I was afraid of

13:17 arohner: thanks for confirming that I am barking up the wrong tree though

13:18 arohner: hrm, 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:19 pipeline: yeah I think wallhack is actually needed in 1.3

13:19 arohner: pipeline: you might also want to look at reify

13:22 pipeline: arohner: that is for making interfaces into proxy-type things

13:23 arohner: oh right, you can't inherit from concrete classes with that

13:23 there's also gen-class, though that's should be a last resort

13:25 seancorfield: amalloy_: thanx for the hints on *scratch* and M-: last night

13:26 pipeline: arohner: I honestly thing gen-class is my best option, since the alternatives are to write a java class wrapper or use reflection

13:27 arohner: but you saved me a bunch of time chasing my tail with proxy ...

14:17 AtKaaZ: hi, could someone explain to me what am I missing here? ((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 5)

14:17 why are they in reversed order?

14:18 shouldn't they be '(1 2 3 4 5) ?

14:18 The conj function creates a new vector that contains an additional item added to the back.

14:20 and why can't I use cons instead?

14:20 IllegalArgumentException Don't know how to create ISeq from: java.lang.Long clojure.lang.RT.seqFrom (RT.java:487)

14:21 metellus: cons needs the arguments to be reversed

14:22 AtKaaZ: oh

14:22 like this: ((fn foo [x] (when (> x 0) (cons x (foo (dec x)) ))) 5)

14:23 but this also returns '(5 4 3 2 1)

14:23 I'm clearly missing something elementary:)

14:24 amalloy: AtKaaZ: 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:24 for vectors that's the end; for lists and conses (and nil) that's the front

14:25 AtKaaZ: alright 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:25 how do I know what type is X in the above ?

14:25 amalloy: very 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:26 Qtr: Do you have defmacro in clojure?

14:26 AtKaaZ: alright, I stand corrected :D

14:26 amalloy: you're reading the documentation on how various functions behave when passed vectors

14:26 AtKaaZ: Qtr not me

14:27 amalloy: also, i see you created a 4clojure issue. it is not the case that any problems "allow" multiple solutions

14:27 but if you paste "9 9 9 9" into (= 9 __), that happens to work

14:27 Qtr: yes

14:28 AtKaaZ: oh i see what you mean, I can do multiple solutions in one line

14:28 thanks amalloy

14:28 amalloy: no, 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:29 AtKaaZ: I understand

14:31 duck1123: AtKaaZ: in case you weren't aware, that fn won't use TCO, so you'll blow the stack if it's too high

14:32 AtKaaZ: duck1123, well I'm new :) it's from here: http://www.4clojure.com/problem/57

14:32 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:33 duck1123: ok, I can see why they didn't get into recur yet. Just wanted to make sure you weren't trying to use that

14:33 AtKaaZ: sweet, thanks

14:42 amalloy I like the accuracy with which you troubleshooted the above down to the doc I was reading

14:43 amalloy: click link, ctrl-f, problem solved :)

14:57 AtKaaZ: I'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:58 how 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:00 because the way I understand it this part (foo (dec x)) returns as a list ie. '(1)

15:00 but how does that happen ? :)

15:00 oh wait hmm

15:01 ohk: (conj nil 1)

15:01 got it=)

15:02 very clever I like it

15:04 it'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:06 it'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:24 ToxicFrog: ,(conj nil 1)

15:24 clojurebot: (1)

15:24 ToxicFrog: ,(conj 1 nil)

15:24 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentCollection>

15:24 AtKaaZ: awesome

15:24 ToxicFrog: Oh right, conj and cons take arguments in reverse order from each other.

15:24 ,(cons 1 nil)

15:24 clojurebot: (1)

15:25 AtKaaZ: ,(when-not nil 1)

15:25 clojurebot: 1

15:25 AtKaaZ: that is some epic bot

15:38 arrdem: is it possible to use a variable-arity &more argument in conjunction with a keyword &{:keys [...]}?

15:40 arohner: arrdem: how would that work?

15:40 destructuring can only create 'known' variable names. i.e. the local names have to be resolved at compile time

15:41 arrdem: arohner: from an implementation point of view I was expecting it not to be possible, and experiment at the REPL just confirmed such failure

15:45 uvtc: arrdem: 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:46 That 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:13 technomancy: https://github.com/kingtim/nrepl.el/pull/21 <- anyone want to try an awesome new nrepl.el feature that even slime doesn't have?

16:14 AtKaaZ: what is that exactly? in English :) I'm new

16:15 technomancy: AtKaaZ: have you used ido-mode in emacs?

16:15 AtKaaZ: Emacs client for Clojure networked repl server ?

16:16 nope but I've used emacs before (not with clojure)

16:16 technomancy: right; I just added a feature that lets you browse vars in namespaces much like ido lets you browse files in directories

16:16 just type enough chars to uniquely identify a given entry

16:16 AtKaaZ: that sounds cool

16:17 technomancy: nrepl.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:20 cark: does it work with clojure-mode too ? or is it standalone ?

16:21 bpr: does anyone know what lamina is indicating when a channel is represented as "<== [?]" at the repl (as opposed to "<== [...]")

16:21 technomancy: cark: it complements clojure-mode

16:21 Raynes: technomancy: Thanks for reproducing that issue.

16:21 bpr: apparently it's none of closed?, drained?, or transactional?

16:22 cark: oh i see it's requiring leni 2 :)

16:22 lein

16:27 bpr: the relevant print-method's body is: (.write writer (str "<== " (str ch)))

16:27 which i don't find very helpful. (str ch) doesn't clarify much

16:32 amalloy: bpr: so look in .toString for channels

16:32 bpr: i am

16:37 amalloy: at the bottom it seems to be printing persistentqueues

16:38 but that still leaves me with (str ?what) => "?"

16:40 i certainly have not enqueued a "?" or a (symbol "?")

16:41 anyway if i had print-method would yield: "<== [? ...]"

16:46 technomancy: oh man, 18 open issues on nrepl.el

16:46 Raynes: can you try the ido-read-var branch?

16:46 Raynes: technomancy: Can you explain what it does and how I can try it?

16:47 technomancy: Raynes: 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:47 would be much obliged

16:47 Raynes: k

16:48 mich: hello

16:50 Raynes: technomancy: Looks like you've finally found something that clashes with evil-mode.

16:51 technomancy: 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:52 But anyways, when I did C-u M-., I got evil complaining about something.

16:56 technomancy: Looks like this is what kingtim was saying?

16:56 I think this means we win?

16:56 emezeske_: 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:57 Raynes: emezeske_: Yup.

16:57 emezeske_: 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:57 Raynes: I would use the *shit* out of that.

16:57 Like, I'd come to your house and give you a hug for it.

16:57 emezeske_: I noticed that a lot of READMEs have stale versions in their how-to-install docs

16:57 Raynes: haha

16:57 Raynes: Please, for the love of God, just go do it.

16:58 emezeske_: Okay, it's officially on my TODO list. Not quite at the top, but close

16:58 cemerick: emezeske_: 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:58 emezeske_: cemerick: Yeah, that would be ideal

17:00 Raynes: cemerick: I don't get the correlation.

17:01 amalloy: emezeske: you may have to hurry on that one; ninjudd was saying the other day he wants it

17:02 emezeske_: amalloy: Bah! What is it with good ideas never being original?

17:02 amalloy: ideas don't count, it's execution. and i bet you'll beat him to it

17:02 emezeske_: Agreed on the first part, we'll see on the second :)

17:03 augustl: is 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:03 such as which jar it couldn't find

17:04 amalloy: well, his new years resolution is to not start so many dang projects

17:05 Raynes: amalloy: Yeah, he needs more time to ask me what my progress is on project x and y.

17:05 augustl: this is a project that works fine for lein 1 btw. Just changed :dev-dependencies to :profiles etc.

17:06 Raynes: augustl: Could you refheap the whole project.clj file?

17:06 duck1123: travis fails my builds even though they pass normally

17:06 augustl: Raynes: sure thing

17:06 Raynes: duck1123: There are a lot of variables in that, believe it or not.

17:07 augustl: https://www.refheap.com/paste/3726

17:07 duck1123: Raynes: it's only the multi-threading part that's failing

17:07 augustl: Raynes: ^^

17:07 duck1123: I should take it as a sign that I need to define my test cases better. I just haven't done it yet

17:08 Raynes: augustl: Now could you do the same for all of leiningen's output?

17:09 technomancy: Raynes: huh; if you can't load the file at all it's probably not due to my changes

17:09 augustl: Cr8: https://www.refheap.com/paste/3727

17:09 Raynes: technomancy: Well it certainly wasn't happening before your changes.

17:09 augustl: err, Raynes, not Cr8

17:09 technomancy: bleaugh

17:09 augustl: not sure what happened there..

17:10 technomancy: Raynes: can you type "reduce" in the repl and hit M-. on that?

17:10 augustl: heh, "not authorized" might have got something to do it

17:10 did repo authentication change in lein 2?

17:10 I have it in ~/.lein/init.clj now, lein 1 style

17:11 Raynes: augustl: The problem here is indeed that you don't have access to that repo.

17:12 augustl: the error message was a bit obscure :)

17:12 Raynes: It's pretty clear. :p


17:13 augustl: I looked at the error message though, not the full log of all the maven stuff

17:13 not complaining, just saying

17:14 seems 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:15 hmm, credentials.clj doesn't seem to be documented anywhere

17:16 leiningen seems to almost want to make it as hard as possible depend on non-public jars :)

17:18 I need to know how to use gpg it seems

17:19 is there a way to authenticate with a repository without using gpg in lein 2?

17:20 Raynes: technomancy: That worked.

17:20 technomancy: Also, I C-u M-. seems to be working now.

17:20 augustl: I'm inclined to store the pasword in project.clj

17:21 Raynes: technomancy: But evaluation stuff still wont work.

17:21 technomancy: C-x C-e doesn't work, nor does C-c C-k

17:35 dnolen`: cof

17:35 oops

17:53 technomancy: Raynes: there's something up with nrepl-buffer-ns

17:53 I think you're seeing the same thing kingtim is

17:53 clizzin: is there a preferred lib in clojure for database migrations in web apps?

17:53 technomancy: all the places he uses nrepl-buffer-ns don't work on my machine, so I use (nrepl-current-ns) instead

17:54 clizzin: here's what I use: https://github.com/heroku/buildkits/blob/master/src/buildkits/db/migrate.clj

17:54 there's also ragtime, but it's a bit more complicated

17:54 clizzin: technomancy: cool, thanks for the tip, i'll check it out

17:54 technomancy: Raynes: well thanks for trying it out

17:55 clizzin: so to add a migration, you just add a new function and then add it to -main?

17:55 technomancy: augustl: you can use environment variables for credentials too

17:55 and profiles.clj is definitely not deprecated

17:59 clizzin: 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:07 zilti: I 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:13 technomancy: http://nic.ferrier.me.uk/blog/2012_04/the_differences_between_the_lisps

20:29 sandbox: hey guys, can you do java annotations in clojure?

20:31 hyPiRion: Huh. Haven't heard about it, but it's probably stuffed in somewhere.

20:32 https://groups.google.com/forum/?fromgroups#!topic/clojure/0hKOFQXAwRc

20:33 sandbox: that's where i am right now too

20:33 must say i didn't click into the gist though

20:36 hyPiRion: From what I can read: People say that annotations are made up in Java due to some weakness in the language.

20:41 sandbox: that's what i'm seeing too, anyways thanks for your help

22:07 saurik: (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:08 (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:09 am I fundamentally misunderstanding protocols? is this a bug in clojure? (I'm using 1.4.0 from clojars)

22:12 amalloy: no &args in protocols

22:12 they're supposed to represent low-level pieces of functionality, not user-friendly stuff like sugared arglists

22:13 saurik: ok, 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:13 however, one further question:

22:13 (defprotocol Q (f [d])) (deftype T [] Q (f [d] (prn d))) (f (->T) 1)

22:13 there I am not using any special arguments: just something really simple with a single argument

22:14 No single method: f of interface: Q found for function: f of protocol: Q

22:14 oh, I get that one

22:14 I need a this parameter

22:14 amalloy: saurik: & is a symbol, so [& q] in the context of a protocol is a two-arg function: & and q

22:15 saurik: ah, ok, that makes sense

22:32 tzar: How would I group a seq (:a :b :c :d :e) into ((:a :b) (:c :d) (:e)) ?

22:35 eggsby: tzar: partition-all 2

22:35 &(partition-all 2 (list :a :b :c :d :e))

22:35 lazybot: ⇒ ((:a :b) (:c :d) (:e))

22:36 tzar: eggsby: thank you :)

23:03 amalloy: $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:03 lazybot: [clojure.core/partition-all]

23:30 Raynes: amalloy: We could try every order of args and return the list with the fewest results.

23:30 * Raynes dances

23:30 Raynes: amalloy: It could be a new command $ihopeso

23:35 amalloy: Raynes: why the fewest?

23:35 Raynes: amalloy: I don't know. Most specific? *shrug*

23:35 I didn't have a reason for picking between "the most" and "the fewest".

23:42 mk: what is a namespace? does it correspond to a package?

23:46 Raynes: More or less.

23:46 mk: how are functions put into a package with no class to contain them as methods?

23:54 michaelr`: good morning everybody!

23:54 rlb: mk: not sure what you mean -- like other languages, clojure has "normal" functions (i.e. not methods).

23:54 In clojure's case, they're scoped within a namespace.

23:55 mk: rlb: java doesn't allow java.example.methodName()

23:55 rlb: mk: clojure's not java?

23:55 (just uses the jvm)

23:55 ...as one of its platforms.

23:56 mk: sure, or the js interpreter. I'm wondering how it compiles functions into a package

23:56 rlb: oh, you mean the mechanism -- that I don't know.

23:56 mk: not the details, just what a function corresponds to - what it is on the jvm

23:57 rlb: not sure what the JVM allows there (may or may not have anything to do with what java allows)

23:57 right -- don't know the jvm well enough to help you there

23:57 mk: ok

23:57 are namespaces mappings?

Logging service provided by n01se.net