Fork me on GitHub
#clojure
<
2016-04-14
>
escherize00:04:26

Is there going to be a livestream of clojure west?

escherize00:04:38

(like on twitch or something)

seancorfield01:04:48

Very unlikely. But videos of the sessions will get posted to ClojureTV on YouTube pretty quickly.

danielsz02:04:06

@mobileink: I've added boot-fails to the community tasks. (I like it a lot).

tolitius03:04:39

are there any plans to support protocols with varargs fns? (i.e. declined in 2013: http://dev.clojure.org/jira/browse/CLJ-1024)

Alex Miller (Clojure team)04:04:11

@kingmob: for this case, you'll need to require those files prior to when you expect them to be used (to force them to be loaded)

Alex Miller (Clojure team)04:04:32

@escherize: no, but videos will be available usually within 24 h on the ClojureTV channel

Alex Miller (Clojure team)04:04:07

@tolitius: I don't know of any reason it wouldn't be considered again

tolitius04:04:55

@alexmiller: thx. that would be a great thing to have to keep protocol fns as expressive as regular fns

seancorfield04:04:13

Would be considered, or wouldn't be considered?

tolitius04:04:22

I read it as "no reason why not", maybe it's just the way I wanted to read it simple_smile

tolitius04:04:03

@alexmiller: btw, in your phillyete talk you did not get to the Java streams example, was it on par with transducers, or was it still creating intermediate sequences? (we did talk about cases when to not use transducers, but I forgot to ask you about the Java example)

Alex Miller (Clojure team)04:04:42

yeah, I ran out of time for that and realized afterwards

Alex Miller (Clojure team)04:04:58

I'll post a gist for you, hang on

tolitius04:04:41

intentionally ugly? simple_smile

Alex Miller (Clojure team)04:04:15

two specific problems I had were 1) sorting by a comparator on a function of the values and 2) zipmap

Alex Miller (Clojure team)04:04:33

there are multiple solutions to both but I had hard a time finding something actually nice for either

Alex Miller (Clojure team)04:04:05

there are some custom spliterator versions of #2 and some 3rd party libs that provide better versions

Alex Miller (Clojure team)04:04:33

#1 is well supported if you want to sort by either keys or values, but a function of the values was just ugly

tolitius04:04:18

thx. sure, definitely can be cleaned up, but still a cool comparison to 4 clj lines (the streams/transducer part)

tolitius04:04:20

I find Java streams quite nice, hope they'll get only better/cleaner/more composable with inferred generics. thanks for the example

octahedrion12:04:31

i need to manipulate a Clojure list that includes tagged literals, like (something #js [1 2 3]), but I can't quote that so what can be done ?

loganmhb12:04:25

@octo221: what can’t you quote?

loganmhb12:04:31

quoting lists containing tagged literals seems to work for me:

boot.user=> (java.util.UUID/randomUUID)
#uuid "3ceeb855-2014-4006-89ee-9ded67180130"
boot.user=> (list *1)
(#uuid "3ceeb855-2014-4006-89ee-9ded67180130")
boot.user=> '(#uuid "3ceeb855-2014-4006-89ee-9ded67180130")
(#uuid "3ceeb855-2014-4006-89ee-9ded67180130")
boot.user=> (count '(#uuid "3ceeb855-2014-4006-89ee-9ded67180130"))
1

octahedrion12:04:54

@loganmhb: see my message - that's what I can't quote!

octahedrion12:04:00

'(something #js [1 2 3]) RuntimeException No reader function for tag js clojure.lang.LispReader$CtorReader.readTagged (LispReader.java:1245) RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:221)

octahedrion12:04:00

I'm guessing it's because I'm evaluating it in Clojure REPL on the JVM

loganmhb12:04:04

Are trying to quote a clojurescript list in clojure?

octahedrion12:04:16

well, read my question, yes!

octahedrion12:04:43

(something #js [1 2 3])

octahedrion12:04:26

I thought a reader macro was like ^{:my-meta-thing 7}

Alex Miller (Clojure team)12:04:20

#js is a tagged literal, but not one that has a reader defined in Clojure

loganmhb12:04:48

Is it possible to avoid the #js tag and use something like (clj->js [1 2 3])?

Alex Miller (Clojure team)12:04:33

you can define a data reader for it or you can use reader conditionals to read but ignore it (not really sure what your actual use case is)

octahedrion12:04:46

@alexmiller: out of interest, is there any way I can turn such an expression into a Clojure list so I can manipulate it ?

octahedrion13:04:14

I'm trying to write a macro to convert Om code into Hiccup

octahedrion13:04:02

oh I guess it will work if I evaluate it in the browser right ?

octahedrion13:04:42

ah but no, because those #js bits won't be read into Clojure data structures

octahedrion13:04:52

they'll be Javascript objects

Alex Miller (Clojure team)13:04:26

it is possible to supply a default data reader that produces tagged literal objects

Alex Miller (Clojure team)13:04:54

to do so, you can bind default-data-reader-fn to a function

Alex Miller (Clojure team)13:04:07

sorry, that has around it

Alex Miller (Clojure team)13:04:16

*default-data-reader-fn*

Alex Miller (Clojure team)13:04:22

that's a fn of tag and value that returns an instance

Alex Miller (Clojure team)13:04:38

I think if you just bind that to the existing clojure.core/tagged-literal fn that will preserve it

Alex Miller (Clojure team)13:04:36

(binding [*default-data-reader-fn* clojure.core/tagged-literal]
  (read-string "'(something #js[1 2 3])"))

Alex Miller (Clojure team)13:04:07

I guess you don't need the quote in this case because you are invoking the reader directly

Alex Miller (Clojure team)13:04:24

(binding [*default-data-reader-fn* clojure.core/tagged-literal]
  (read-string "(something #js[1 2 3])"))

Alex Miller (Clojure team)13:04:57

that should return you a list containing a symbol and a "TaggedLiteral" object (that implements the map interface and has keyword attributes :tag and :form)

octahedrion13:04:05

(clojure.lang.Symbol clojure.lang.TaggedLiteral)

Alex Miller (Clojure team)13:04:46

(let [[x y] (binding [*default-data-reader-fn* clojure.core/tagged-literal]
              (read-string "(something #js[1 2 3])"))]
  [(:tag y) (:form y)])

octahedrion13:04:03

((comp :form last last) (binding [default-data-reader-fn clojure.core/tagged-literal] (read-string "'(something #js [1 2 3])"))) => [1 2 3]

Alex Miller (Clojure team)13:04:27

now if you're doing this in clojurescript, I don't recall how compatible this is, it might not be - not sure cljs has *default-data-reader-fn* or tagged-literal

octahedrion13:04:30

i think I'll just slurp the files, read-string them as you described and convert them to hiccup from there

octahedrion13:04:01

it's converting Om (div #js {}) style code to hiccup [:div {}] style code

danielstockton13:04:35

what protocols/methods do i need to implement to override cons on a custom type (deftype)? i tried clojure.lang.IPersistentCollection and cons but it blows up in seqFrom

Alex Miller (Clojure team)13:04:07

I think you'd need just ISeq, not IPersistentCollection

danielstockton13:04:50

I'm trying to implement a B tree, need to override cons. Been looking at datascript for inspiration, I don't see it implementing ISeq: https://github.com/tonsky/datascript/blob/master/src/datascript/btset.cljc#L514

Alex Miller (Clojure team)13:04:49

ISeq extends IPersistentCollection (weirdly, both define cons())

Alex Miller (Clojure team)13:04:57

what's the error you're getting?

Alex Miller (Clojure team)13:04:35

and what types do you currently implement?

danielstockton13:04:49

I might have a big gap in my understanding, i've tried narrowing it down to the simplest thing

danielstockton13:04:27

I'm expecting that to be 1, but I get 'Don't know how to create ISeq from: java.lang.Long

danielstockton13:04:09

presumably because the default cons expects a seq in second place

Alex Miller (Clojure team)14:04:26

actually you've got the arg order switched when you invoke cons don't you?

Alex Miller (Clojure team)14:04:08

the cons function order is opposite the Java method order

danielstockton14:04:40

i thought so but i wasn't sure how it should match the signature i implemented on the type

danielstockton14:04:07

switching the order, I get Unhandled java.lang.AbstractMethodError

Alex Miller (Clojure team)14:04:10

it should be (cons 1 (MyType.))

Alex Miller (Clojure team)14:04:28

but MyType is then expected to be an ISeq or something seqable

Alex Miller (Clojure team)14:04:42

IPC extends Seqable, but you haven't implemented seq()

Alex Miller (Clojure team)14:04:52

which yields the AbstractMethodError

jtackett14:04:22

Anyone know the best library to read emails and email attachments?

danielstockton14:04:06

it leads to more errors but i think i can follow the trail

martinklepsch14:04:36

looking for some more real world manifold usage — someone any pointers? simple_smile

danielstockton14:04:03

actually, all i need it seq() as you said (and make sure it returns an ISeq

danielstockton14:04:23

is there some reference or documentation good for understanding how all the protocols fit together or you just have to look through the source?

bronsa14:04:48

IPC cons maps to conj, not cons

bronsa14:04:20

cons will just invoke new c.l.Cons(x, my-coll)

danielstockton14:04:05

ah @bronsa, that explains why im still not seeing anything other than default behaviour of cons

bronsa14:04:37

as to why both IPC and ISeq implement cons -- they have covariant return types

jtackett14:04:55

Hey I am trying to read a buffered input stream from an email attachment that is an excel file. I’ve tried slurp and a bunch of java methods. Anyone know how to read these?

payal17:04:27

what is the exact use of task i.e. (deftask foo )

adamfrey17:04:28

@payal: deftask is a boot thing, you might want to ask in #C053K90BR

seanhess17:04:19

I’m new to clojure, and struggling with my editor experience (vim, with paredit).

seanhess17:04:40

for example, if I have the following: (defn notched-slider [] *) * is where my cursor is. And I want to paste two lines right there.

seanhess17:04:00

If I hit P I get this: [question-label "How stressed are you feeling?"] [next-button] (defn notched-slider [] )

seanhess17:04:23

If it hit p I get this: (defn notched-slider [] ) [question-label "How stressed are you feeling?"] [next-button]

seanhess17:04:26

What am I missing here?

seanhess17:04:12

Oh… it’s because my code would be unbalanced?

Chris O’Donnell17:04:44

@seanhess: What did you do to copy the two lines?

seanhess17:04:12

Vjy to visually select two lines then yank

Chris O’Donnell17:04:36

If you select full lines, vim will paste them below (or above) your cursor.

seanhess17:04:19

Oh dear, you’re right… Thanks!

seanhess17:04:16

if you don’t mind if I ask you another question: I’m writing a function and want it to look nice when I’m done. So I start with (defn notched-slider [] ) and I want to type a function body. My cursor is before ). If I hit return, and type a body, it comes out looking like this: (defn notched-slider [] [text {} "hello"] )

seanhess17:04:40

It’s my understanding that it is considered better to have it look like this: (defn notched-slider [] [text {} "hello"])

seanhess17:04:41

normally to fix that, I would go the last line, type I to get my cursor before the ), and hit backspace until it looks good. But when I hit I over the ), paredit removes the line of whitespace after my function (?) and moves my cursor to the beginning of the function

Chris O’Donnell17:04:05

You can use J to join lines

seanhess17:04:08

If I hit I while over one of the leading spaces on the last line, it deletes my function?

seanhess17:04:25

That works way better, thanks!

seanhess17:04:31

Do you have any idea what I is donig?

Chris O’Donnell17:04:11

I'm not 100% sure and actually need to step away right now.

Chris O’Donnell17:04:18

Best of luck, though.

seanhess17:04:28

Ok, thank you!

seanhess17:04:38

Yes. I chose these without any real knowledge, but here’s what I have: " Clojure Plug 'guns/vim-clojure-static' Plug 'tpope/vim-fireplace' Plug 'kien/rainbow_parentheses.vim' Plug 'guns/vim-clojure-highlight' Plug 'tpope/vim-unimpaired' Plug 'venantius/vim-cljfmt' Plug 'paredit.vim'

seanhess17:04:37

Also the w movement has a huge amount of lag

seanhess17:04:07

Just the first one. If I hit it again, it moves one word, then about 1s after I stop hitting it, it does the first w movement very late

seanhess17:04:30

Am I using the wrong plugin?

pbostrom17:04:42

I don't know, it's been a while since I used vim, but I though that plugin would handle indentation and formatting for you

nberger17:04:05

@seanhess: try removing stuff until you find what makes w to lag. I have the following and w works fine, and I does what you usually expect:

ckarlsen18:04:12

any http clients that are capable of consuming server-sent events?

bja18:04:23

you can also use = on a visual selection to indent according to whatever rules you have loaded

bja18:04:23

(which should be clojure-specific rules if you have vim-clojure-static installed)

martinklepsch18:04:44

I've written a bit of ztellman/manifold code today interfacing with SQS and while it works I'm not sure if "I'm doing it right": https://gist.github.com/martinklepsch/71b1c91d796fa2033609638451d5527a particularly I'm wondering about the use of manifold.time/every to fetch messages from SQS and the deferred usage when handling these messages. Does this seem right to you?

hiredman19:04:18

hard to tell, because there aren't a lot of docs for amazonicas sqs api, put it sort of looks like it expects you to cal lthe receive-message function, and then consume from the lazy seq, not call receive-message every time you want a message

martinklepsch19:04:34

@hiredman: what makes you think it returns a lazy seq?

hiredman19:04:39

just because the few examples of use I see have people calling first on it, which uh, I guess it could be returning a single message wrapped in a collection, but why would thye do that

hiredman19:04:32

but if you have used the api and it isn't, then it isn't

martinklepsch19:04:24

@hiredman: the return value of receive-message looks like this {:messages [...]} so I guess it's not lazy. You can specify a number of messages you'd like to receive so it'll always be a sequence, maybe that's why people call first on it.

hlolli21:04:56

As I'm guessing the book "Clojure Applied" was written for an earlier Clojure version. I'm wondering if anyone can tell me why this snippet return an error(or a possible workaround): java.lang.IllegalArgumentException: Can't define method not in interfaces: compareTo

(declare validate-same-currency)
(defrecord Currency [divisor sym desc])
(defrecord Money [amount ^Currency currency]
  java.lang.Comparable
  (compareTo [m1] [m2]
             (validate-same-currency m1 m2)
             (compare (:amount m1) (:amount m2))))

hiredman21:04:30

the argument list is wrong

hiredman21:04:10

that is a method that takes 1 paramter (including this) creates a vector (which would be kicked out by the compiler if the defrecord macro wasn't failing) because the contents of the vector are a symbol that isn't bound (m2) then does some other stuff

hlolli21:04:07

ahh shit, I only have a lamp here, oops, [m1 m2] should that have been.

hlolli21:04:32

I will turn on the light before asking a obvious question simple_smile

seanhess22:04:44

@nberger: thanks for your help!

seanhess22:04:57

It was definitely paredit.vim that was causing trouble. Disabling it got rid of the strange behavior. Disabling every other plugin but that one I still had it. The only thing that fixed was switching to this mirror: https://github.com/kovisoft/paredit

mrg23:04:31

So I'm reading "Clojure Applied" and there is this code snippet:

mrg23:04:48

... that wouldn't actually work, right?

mrg23:04:53

Because of the missing arguments to recur?

mrg23:04:13

Thank you, just wanted to make sure I wasn't going crazy