This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-14
Channels
- # admin-announcements (5)
- # aws (3)
- # beginners (35)
- # boot (96)
- # cider (1)
- # clara (6)
- # cljs-dev (12)
- # cljsrn (34)
- # clojure (151)
- # clojure-boston (3)
- # clojure-brasil (4)
- # clojure-canada (1)
- # clojure-czech (8)
- # clojure-dusseldorf (11)
- # clojure-japan (5)
- # clojure-russia (120)
- # clojure-taiwan (1)
- # clojure-uk (3)
- # clojurescript (7)
- # component (27)
- # cursive (13)
- # data-science (45)
- # datomic (1)
- # devcards (5)
- # emacs (3)
- # funcool (65)
- # hoplon (103)
- # instaparse (3)
- # jobs (14)
- # jobs-discuss (1)
- # juxt (2)
- # lein-figwheel (2)
- # off-topic (16)
- # om (20)
- # onyx (49)
- # parinfer (17)
- # perun (1)
- # planck (5)
- # proton (4)
- # re-frame (14)
- # ring-swagger (4)
- # spacemacs (4)
- # untangled (110)
- # yada (14)
Very unlikely. But videos of the sessions will get posted to ClojureTV on YouTube pretty quickly.
@mobileink: I've added boot-fails to the community tasks. (I like it a lot).
are there any plans to support protocols with varargs fns? (i.e. declined in 2013: http://dev.clojure.org/jira/browse/CLJ-1024)
@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)
@escherize: no, but videos will be available usually within 24 h on the ClojureTV channel
@tolitius: I don't know of any reason it wouldn't be considered again
@alexmiller: thx. that would be a great thing to have to keep protocol fns as expressive as regular fns
Would be considered, or wouldn't be considered?
afaik, would be
@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)
yeah, I ran out of time for that and realized afterwards
it was ugly :)
I'll post a gist for you, hang on
https://gist.github.com/puredanger/f6b09089f50321fca30a7928045bc845
two specific problems I had were 1) sorting by a comparator on a function of the values and 2) zipmap
there are multiple solutions to both but I had hard a time finding something actually nice for either
there are some custom spliterator versions of #2 and some 3rd party libs that provide better versions
#1 is well supported if you want to sort by either keys or values, but a function of the values was just ugly
thx. sure, definitely can be cleaned up, but still a cool comparison to 4 clj lines (the streams/transducer part)
I find Java streams quite nice, hope they'll get only better/cleaner/more composable with inferred generics. thanks for the example
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 ?
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
@loganmhb: see my message - that's what I can't quote!
'(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)
I'm guessing it's because I'm evaluating it in Clojure REPL on the JVM
oh sorry
well, read my question, yes!
(something #js [1 2 3])
I thought a reader macro was like ^{:my-meta-thing 7}
or #{1 2 3}
#js is a tagged literal, but not one that has a reader defined in Clojure
@alexmiller got it - thanks!
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)
@alexmiller: out of interest, is there any way I can turn such an expression into a Clojure list so I can manipulate it ?
I'm trying to write a macro to convert Om code into Hiccup
oh I guess it will work if I evaluate it in the browser right ?
ah but no, because those #js bits won't be read into Clojure data structures
they'll be Javascript objects
it is possible to supply a default data reader that produces tagged literal objects
to do so, you can bind default-data-reader-fn to a function
sorry, that has around it
*default-data-reader-fn*
that's a fn of tag and value that returns an instance
I think if you just bind that to the existing clojure.core/tagged-literal fn that will preserve it
(binding [*default-data-reader-fn* clojure.core/tagged-literal]
(read-string "'(something #js[1 2 3])"))
I guess you don't need the quote in this case because you are invoking the reader directly
(binding [*default-data-reader-fn* clojure.core/tagged-literal]
(read-string "(something #js[1 2 3])"))
@alexmiller: fantastic 😀
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)
(clojure.lang.Symbol clojure.lang.TaggedLiteral)
(let [[x y] (binding [*default-data-reader-fn* clojure.core/tagged-literal]
(read-string "(something #js[1 2 3])"))]
[(:tag y) (:form y)])
((comp :form last last) (binding [default-data-reader-fn clojure.core/tagged-literal] (read-string "'(something #js [1 2 3])"))) => [1 2 3]
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
i think I'll just slurp the files, read-string them as you described and convert them to hiccup from there
it's converting Om (div #js {}) style code to hiccup [:div {}] style code
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
I think you'd need just ISeq, not IPersistentCollection
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
ISeq extends IPersistentCollection (weirdly, both define cons())
what's the error you're getting?
and what types do you currently implement?
I might have a big gap in my understanding, i've tried narrowing it down to the simplest thing
I'm expecting that to be 1, but I get 'Don't know how to create ISeq from: java.lang.Long
presumably because the default cons expects a seq in second place
actually you've got the arg order switched when you invoke cons don't you?
the cons function order is opposite the Java method order
i thought so but i wasn't sure how it should match the signature i implemented on the type
switching the order, I get Unhandled java.lang.AbstractMethodError
it should be (cons 1 (MyType.))
but MyType is then expected to be an ISeq or something seqable
IPC extends Seqable, but you haven't implemented seq()
which yields the AbstractMethodError
understood, thanks @alexmiller
it leads to more errors but i think i can follow the trail
looking for some more real world manifold usage — someone any pointers?
actually, all i need it seq() as you said (and make sure it returns an ISeq
is there some reference or documentation good for understanding how all the protocols fit together or you just have to look through the source?
ah @bronsa, that explains why im still not seeing anything other than default behaviour of cons
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?
@jtackett: you could try https://github.com/mjul/docjure
@codonnell: Thank you!
for example, if I have the following:
(defn notched-slider [] *)
*
is where my cursor is. And I want to paste two lines right there.
If I hit P
I get this:
[question-label "How stressed are you feeling?"]
[next-button]
(defn notched-slider [] )
If it hit p
I get this:
(defn notched-slider [] )
[question-label "How stressed are you feeling?"]
[next-button]
@seanhess: What did you do to copy the two lines?
If you select full lines, vim will paste them below (or above) your cursor.
no problem
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"]
)
It’s my understanding that it is considered better to have it look like this: (defn notched-slider [] [text {} "hello"])
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
You can use J
to join lines
If I hit I
while over one of the leading spaces on the last line, it deletes my function?
I'm not 100% sure and actually need to step away right now.
Best of luck, though.
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'
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
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
@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:
you can also use =
on a visual selection to indent according to whatever rules you have loaded
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?
https://gist.github.com/martinklepsch/71b1c91d796fa2033609638451d5527a#file-sqs-clj-L40
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
@hiredman: what makes you think it returns a lazy seq?
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
@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.
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))))
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
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