This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-18
Channels
- # admin-announcements (3)
- # arachne (8)
- # beginners (55)
- # boot (51)
- # cbus (1)
- # cider (15)
- # cljs-dev (5)
- # cljsrn (8)
- # clojure (203)
- # clojure-austin (2)
- # clojure-belgium (12)
- # clojure-boston (6)
- # clojure-czech (47)
- # clojure-dusseldorf (14)
- # clojure-estonia (1)
- # clojure-greece (42)
- # clojure-japan (2)
- # clojure-poland (4)
- # clojure-russia (97)
- # clojure-sg (5)
- # clojure-uk (41)
- # clojurescript (122)
- # code-reviews (4)
- # component (3)
- # core-matrix (19)
- # cursive (25)
- # datomic (16)
- # devcards (24)
- # editors (6)
- # euroclojure (1)
- # hoplon (88)
- # immutant (3)
- # incanter (4)
- # jobs (5)
- # keechma (1)
- # luminus (1)
- # om (44)
- # onyx (22)
- # parinfer (3)
- # planck (1)
- # proton (3)
- # re-frame (5)
- # reagent (30)
- # ring (2)
- # spacemacs (1)
- # untangled (92)
- # yada (1)
An inauspicious start to my emacs trail š - I had to edit the .emacs file and add variables of package archive sites.
@jeff-ster: that's not inauspicious, that's the first step
now I get " CIDER's version (0.12.0) does not match cider-nrepl's version (nil). Things will break!"
@jeff-ster: I'm running into the same issue on OS-X lol.
you have to insert this in your project.clj :plugins [[cider/cider-nrepl "x0.12.0"]]
@jeff-ster: that you think emacs is going to work is the inauspicious thing
gotta calibrate your expectations such that when it does work, you're pleasantly surprised
@jeff-ster: afaik latest cider injects dependencies for you if you're doing a cider-jack-in
({:number 15, :name "Flowers"},{:number 16, :name "Books"}) Hi, guys! Which is the best way (Clojure way) to add 1000 to each number in this collection? I think that the solution that I have is a bit verbose... (map #(hash-map :number (+ 1000 (:number %)) :name (:name %)))
@lucelios: (map #(update % :number (partial + 1000)) foo)
note: update
was added in 1.7
use update-in
if youāre using < 1.7
thanks a lot @conormcd @bostonaholic !!!
if you do a lot of nested operations like this, take a look at https://github.com/nathanmarz/specter
iām curious if anyone is familiar with ring/compojure and middlewares ā iām wondering if itās possible to write a proxy middleware?
@lwhorton: You could see how ring-proxy does it and go based of that: https://github.com/tailrecursion/ring-proxy/blob/master/src/tailrecursion/ring_proxy.clj
well, I was digging around in there and the problem Iām having is perhaps conceptual
when passing the merged http-opts to clj-http.client/request
is that a blocking operation?
Hey guys. Just curious everytime I try to hit an https endpoint in my ring clojure application, I see the :ssl-client-cert field as nil even thought I have the ring service setup to handle https. (I can hit the https endpoint, but the client cert is always nil)
because it seems to me that thereās some issue with the sync/async nature ā if I do a GET, it is successfully proxied, but the response is always 404.. even though logging after the request happens shows the correct proxy result.
almost like ring says āoh no immediate response iām going to use a 404 middleware"
disregard that whole thing⦠I had a misplaced paren that was causing a bad if-let block to return too soon.
Does anyone have example of to do an https call using clj-http. I want to pass an actual client certificate and not just the :insecure option
Thanks for the pointer
https://github.com/dakrone/clj-http/blob/master/test/clj_http/test/conn_mgr_test.clj#L49
Thanks
what's the consensus on parinfer?
i'm a big fan of paredit. but i haven't looked too far into parinfer. I also really liked lispy, but haven't used it much recently as sometimes it gets into an invalid state with a mismatched paren
parinfer is just really new, and anyone who has spent time using paredit has had their brain so thoroughly warped by it that they usually aren't looking for anything else
there is actually some other emacs mode that is sort of like paredit, which I tried for about a day before my paredit addled mind rejected all the slight differences from paredit as wrong
iām actually using atom text editor right now, not emacs
Actually, I had my brain so warped by paredit with Emacs that I was institutionalized in a Vim rehab facility. Gave up on using Emacs for Clojure (and lisp) until parinfer came along.
non-emacs text editors are where there is a lot of new people picking up clojure, and many of them are javascript based, so parinfer drops in well, and if you are new to clojure you likely are not so accustomed to paredit that you don't want to use anything else
I started with Emacs and Common Lisp many, many years ago, long before Clojure came along. I got along fine with just parenthesis matching. Then people told me that I just had to start using this new paredit thing, and it was all downhill from there. On the other hand, parentheses were never my biggest issue in writing lisp-y code. I know some people just love it.
funny thing is, i used emacs up until around 2 years ago
but now iām starting clojure, maybe i should look at emacs again
is emacs still the best when it comes to having a repl built-in?
I was using vim up until I got my first clojure job about six years ago, that job wanted everyone with a similar setup for the sake of pairing, and I cannot imagine switching back to vim
there are jobs where you HAVE TO use emacs? š
i can't imagine using an emacs mode on a lisp that didn't have some notion of structured editing, like slurp
My point with parinfer is basically, it is a new and interesting looking thing, but you'll find many (but not all) people who have been writing clojure for a long period of time (many using emacs) who are not all that interested, not because of anything problematic with parinfer, but because they have already made their peace with some other bit of tooling
when I used vim, I would use vim for writing code, but now I use emacs, I use it for so much stuff, I want to say everything even though it isn't really. at one time I had some patches that embedded a webkit view in an emacs buffer (and it sort of kind of worked). org-mode is amazing
i think the biggest drawback of emacs is that itās still centered solely around text
UIs have changed so much
atom, by being a browser under the hood, and exposing js and css, can house some really powerful plugins that you could never implement in emacs
its crazy that you need a patch to bundle a half-working webkit view in a buffer
@amonks: look up activate-power-mode š š
do you have a favorite case where that kind of ui control is used for something more useful?
rendering your application in a buffer sounds good already, graphical tools for building UIs ala Netbeans for java etc.
custom buttons etc.
thereās a toolbar plugin for atom that iām using too, it makes using proto-repl easier
I need help with writing a macros
I have a macro like this:
that displays an expression and its evaluation
(disp (map inc [1 2 3]))
returns (map inc [1 2 3]) => (2 3 4)
no, the code you pasted isn't valid, it will throw an error when the reader tries to read it
Iāve fixed the code of the macro
I had a typo
now I want to be able to pass several expressions to my macro and to get the expressions and their evaluations one by one
for me, (disp (map inc [1 2 3]))
returns "(map inc [1 2 3]) => clojure.lang.LazySeq@7c42ā
treat the expressions as data by making them quoted forms, and call eval on them when you want to see what they eval too
I donāt want to use eval
I know but I feel that macro is more elegant in this case
if you use that macro, and don't treat forms as data, you can't even have a collection of forms
what do u mean by treating form as data?
when you quote a form, you get the datastructure of the form, instead of the evaluated result
user=> (for [form ['(map inc (range 10)) '(map dec (range 10))]] [(pr-str form) (pr-str (eval form))])
(["(map inc (range 10))" "(1 2 3 4 5 6 7 8 9 10)"] ["(map dec (range 10))" "(-1 0 1 2 3 4 5 6 7 8)"])
user=>
you could call it like this (disp ['(map inc [1 2 3]) '(map inc [3 2 1])])
I have modified my macro to use print
instead of str
like this
and now it returns the evaluated result instead of the datastructure of the form
why print
and str
donāt behave in a similar way?
e.g. maybe you have some function in which the macro is called and didn't realod the function after changing the macro
Iām testing in the REPL
yeah, so you said it returns the evaluated result, to me that means it returns the result of evaluating the form (talking about return values of macros is problematic for reasons), what did that mean to you?
in that repl I see it evaluating to a string of the form and the result of evaluating the form
to me, the form is (map inc [1 2 3])
and the evaluation is (2 3 4)
which is exactly what I wanted
which is exactly what I wanted
but with str
I got
(map inc [1 2 3]) => clojure.lang.LazySeq@7c42
so again, why my macro -with pr-str - is wrong?
are you asking because it is doing something you don't want it to do? or are you asking for a general critique of the endeavor?
This is what Iām trying to do
But with no sucess
The problem with eval
is that I want my code to be portable and to run on clojurescript
and I donāt want to use self-host cljs for this case
clojurescript is self-hosted now, so it should have no problem eval'ing
yeah, you want it to run in a text area where people can type forms in to the browser and see the results, right?
not really. I want to handle this kind of cases: (disp (map inc [1 2 3]) (map dec [4 5 6]))
but you want (map inc 1 2 3) to be something someone can type in to a text area in a webpage, right?
The whole (disp (map inc [1 2 3]) (map dec [4 5 6]))
is going to be typed by the user
if you have requirements, where any part is "given a clojure expression, get its value" that is eval
I know, Iām one of the authors of klipse
But I donāt want to use self-host inside the self-host code of klipse
I still cannot understand why I couldnāt be able to evaluate (disp (map inc [1 2 3]) (map dec [4 5 6]))
with a macro
if you want to have a text box a user can type a form in to, and evaluate it, that form isn't known at compile time, so a macro won't know what to do with it
I think that in my use case, it works
the proof is that with one expression everything works fine
I just canāt find the proper way to make it work for several expressions
trying...
I am able to get the form but not its evaluation
(disp (map inc [1 2 3]) (map dec [4 5 6])
=> ("form => (map inc [1 2 3])" "form => (map dec [4 5 6])ā)
Now I get ("(quote (map inc [1 2])) \" => \" (map inc [1 2])ā)
macroexoand
didnāt help
I cannot find the way to evaluate an expression inside a macro
;; hiredman ą² _ą²
(defmacro disp [& forms]
(cons `list (for [form forms] (str (pr-str (list 'quote form)) " => " (pr-str form)))))
@hiredman: it doesnāt work.
suppose I am writing a library to implement a protocol which is built on http. Are there good ways to allow my user to choose their own http client library? e.g. they may want to use clj-http or aleph or ...
(defmacro disp [& forms] (cons `list (for [form forms] `(str (pr-str '~form) " => " (pr-str ~form)))))
;; something like this with the thing-that-does-http passed in on each request
(my-library/query #(http/post " "
{:content-type %1
:accept %2
:body %3})
"SELECT ?p ?o WHERE { </foo/2> ?p ?o }")
@telent I would abstract calls into a http library with set of well-defined functions, and provide one default implementation for clj-http or what is your favourite one, this way you allow user to swap them for their own implementation
I pretty much don't use anything besides clj-http, what are libraries are you trying to support, and how closely do their models of http match?
aleph is an awful lot like clj-http (it says) but returns deferred objects that need dereffing
actual swapping mechanism is not that important IMO, Clojure protocols would work, multimethods is also an option, or plain map would work as well
re: disp, generating literal calls to list
can result in some oddess http://dev.clojure.org/jira/browse/CLJS-1617
a very dirty solution would be to declare the methods as ^:dynamic and let user swap them in the namespace
so maybe just provide an async and a sync option built in to the library instead of arbitrary http client plugability
of course option (c) is Just Use clj-http because the chance in any production stack of it not being a dependency of something else the client already uses is tending to zero quite rapidy
in one of my libraries, I simply keep pluggable methods in a config map, and provide one default imlementation:
If a library extends a protocol to Throwable
, and I extend the same protocol to clojure.lang.ExceptionInfo
, which implementation will win?
Anyone know a solid mqtt broker library?
Most that I find look to be abandoned