This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-03
Channels
- # arachne (31)
- # aws (9)
- # bangalore-clj (7)
- # beginners (46)
- # boot (18)
- # cider (21)
- # cljs-dev (8)
- # clojure (154)
- # clojure-dusseldorf (5)
- # clojure-filipino (3)
- # clojure-ireland (4)
- # clojure-italy (9)
- # clojure-russia (6)
- # clojure-spec (6)
- # clojure-uk (52)
- # clojureremote (3)
- # clojurescript (173)
- # clojurewest (14)
- # cursive (24)
- # data-science (2)
- # datomic (18)
- # defnpodcast (1)
- # devcards (1)
- # hoplon (4)
- # instaparse (29)
- # jobs (2)
- # juxt (1)
- # leiningen (3)
- # lumo (78)
- # off-topic (46)
- # om (9)
- # onyx (42)
- # pedestal (33)
- # perun (3)
- # re-frame (9)
- # reagent (6)
- # slack-help (5)
- # spacemacs (2)
- # specter (6)
- # unrepl (157)
- # untangled (99)
- # yada (32)
Question: How do people set up spec.check to run automatically? Like through lein test?
@didibus The simple answer is that generally folks don’t. Generative testing should be considered separate from regular xUnit-style testing, so you’d normally have your generative testing handled separately from lein test
.
At Clojure/West, Alex Miller talked briefly about an experimental test runner that Cognitect are working on that would run continuously, invoking check
as needed on functions that either have changed or which are dependent on other functions that changed.
(BTW, there’s a #clojure-spec channel for more in depth discussion if you want)
Oh, that sounds really nice. Ya, that's true, if nothing in the path of a function has changed, checking it again is just expensive for nothing.
All that said, if you have only a few functions to check
and you know they don’t take long, you could always write a deftest
that called check
on them.
I didn't get much luck with answers over there, I don't think a lot of people look at it actively.
People who use clojure.spec
probably pay more attention there than here 🙂
Bear in mind that a) most US folks are probably not around much on Sunday b) it was Clojure/West this past week and a lot of those folks were traveling Saturday — you are likely to get more eyes on channels weekdays, during US office hours.
I was wondering if there were anything like reductions
from core except for transducers. Something like transductions
maybe.
is there a 'best of cljoure west' list somewhere? I know that all talks were great; but given limited time, one can only watch so many
@qqq I can recommend my favs: Synthesis and Verification for All. Clojure Java 9 and You, Why Clojure?, Core.Async in use. I did not watch all 25 talks though, but out of the 10 or so I did, those were my highlights.
@qqq Yeah, that was a good talk. She has done work with Prof Dan Grossman. I'm one of the mentors for the online version of his Programming Languages course.
Her talk was particularly interesting to me because many years ago I did work on compilers to verification languages (MALPAS) so it was awesome to see how far that field has gone -- her recent work on Rosette is incredible!
And, yeah, I'll second the other recommendations from @didibus -- Toby's talk about Java 9, and Tim's talk about core.async.
Elizabeth's talk about Datomic finally helped me understood how it actually worked -- I downloaded Datomic that morning and have been playing with it ever since.
Racket is a programmable language. You can easily create completely new dialects on top of the Racket engine.
It's also great for teaching since you can create subset and simple languages and let people build up to full Racket.
Hard to explain -- you'd have to go learn it.
How To Design Programs is a good book that focuses on the teaching language aspect of Racket
Written by Matthias Fellesien (sp?).
Felleisen
I have to develop in C++, but I wonder if there is any possibility to use Clojure to implement some of form of test for C++ code, treating the C++ code as data? I feel hopeful of the possibility after Watching the talk of Magic: Boom. Symbolic Assembly: Using Clojure to Meta-program Bytecode by @ra https://t.co/wzMBdKEvn6 Any pointer or comment is appreciated. I hope that the approach would increase productivity and rigor othe tests.
((juxt f g h) x) ==> [(f x) (g x) (h x)] is there a FOO where ((FOO f g h) [x y z]) ==> [(f x) (g y) (h z)]
I could use keywords but dispatch would be a slightly slower and I want the str for debugging purpose
hrm i'm having difficulty trying to conceptualize how i would make a transducible process that performs the job of reductions
In our project tests, we are depending on a little bit of an upstream java project's test infrastructure. We are able to pull it in using this line in lein
[org.apache.kafka/kafka-streams "0.10.1.0" :classifier "test"]
Now I'm trying to download the sources for this dependency but I think because it has a non-standard classifier, mvn dependency:sources
does not find it. Anyone know the correct incantation to get the sources for this?
I’d like to know peoples’ opinion on implementing Go’s idiomatic error handling style in Clojure: https://blog.golang.org/error-handling-and-go In Clojure it might look something like:
(let [[res err] (db/query ...)]
(if err
... handle error...
... handle result...))
Personally I find it to be a clean way of propagating errors throughout larger apps without littering the code with try/catch (which i.m.o. is a fundamentally flawed way of control flow) but I’d like to know your opinions on the pattern.@looveh I like it too, Clojure has some libs for that, like https://github.com/adambard/failjure
I hate Go's method of it. After every line of work, there's at least three lines of if err != nil {
@lsenjov The concept itself is sound, it's just the boilerplate around it and the lack of variant types that makes it ugly
I prefer exceptions over go's method, because (usually) the work of a function is all in one place
I'm not saying they don't have their own problems, I just hate reading golang code because of this problem
The problem is that you don't get one without the other, if you have exceptions but handle them incorrectly you get weird control flow
I'm more saying that exceptions are generally used in two cases: abort or self-heal (from my experience, if it's used differently feel free to correct)
If it's abort, and multiple functions abort, why not have the abort code in one section?
Short circuiting serves the same purpose, and it doesn't need something that is essentially a goto
Check the former discussion in this channel - starting 6:10 UTC: https://clojurians.slack.com/archives/C03S1KBA2/p1491199837737261
The time travelling NES emulator by @angusiguess was super cool
I try to refactor a core.async function with transduce. I have a async caller, which returns a vector of numbers, now I use doseq to go over this numbers and put them in a channel. On this channel is a map transducer, which uses the async caller again with the id. This returns a channel, containing a map. Now I have a channel with a channel inside which contains the map an I have to use (<! (<! chan))
to get the value. Is there a way to return this maps in the containing channel?
(defn async-caller
[args]
(let [out (chan 1 xf)]
(call-fn args {:success (fn [res]
(async/put! chan res)
(async/close! chan))})))
(defn foo
[arg]
(let [xf (map (fn [id] (async-caller id))
channel (chan 1 xf)
response-chan (async-caller arg))]
(go-loop [] (let [response (<! response-chan)]
(doseq [id response]
(>! channel id))
channel))))
This looks pretty weird, where does the chan above come from, why is "out" unused in async-caller... I might be able to help you with a more complete example
(defn async-caller
"Calls a remote function on a server, which returns a value on success
in the future. The uri is the route to the function."
[uri args]
(let [out (chan 1 xf)]
;this calls another function which handles the connection
;the returned values are put into the out channel
(call-fn uri args {:success (fn [res]
(async/put! out res)
(async/close! out))}
out)))
(defn foo
"Receives the ids on the first call and then calls the function again with the result values"
[arg]
(let [xf (map (fn [id] (async-caller "path.getinfo" id)))
channel (chan 1 xf)
response-chan (async-caller "path.getids" arg)]
(go-loop []
(let [response (<! response-chan)]
(doseq [id response]
(>! channel id))
channel))))
I reworked it a little. Maybe its now better to understand.
It is 🙂 Do you really have to use a channel of channels? I feel like a flat channel would be simpler here. I'll try to rewrite it a little
I would recommend something along these lines
(defn foo
"Receives the ids on the first call and then calls the function again with the result values"
[arg]
(let [xf (map (fn [id] (async-caller "path.getinfo" id)))
channel (chan 1 xf)
id-chan (async-caller "path.getids" arg)]
(go
(onto-chan channel (<! id-chan)))
channel))
It looks like your call-fn will only ever return one result, so you don't really need a go-loop
Thank you for the tips. The problem is, that I have to make the two calls, as they go to a different uri.
is it a known issue that you can do (keyword “namespace” “1”)
but you cannot do :test/1
?
"1" is not a valid keyword, even tho it might allow you to create it via keyword
: garbage in->out
user> (source keyword)
(defn keyword
"Returns a Keyword with the given namespace and name. Do not use :
in the keyword strings, it will be added automatically."
{:tag clojure.lang.Keyword
:added "1.0"
:static true}
([name] (cond (keyword? name) name
(symbol? name) (clojure.lang.Keyword/intern ^clojure.lang.Symbol name)
(string? name) (clojure.lang.Keyword/intern ^String name)))
([ns name] (clojure.lang.Keyword/intern ns name)))
nil
user>
https://clojure.org/reference/reader has the "spec" if we can call it that way
A socket to do what?
i have to make a tcp cliente, i have to connect two terminals that i receive and send messages
@jsdiaz19 - Seems like a pretty straightforward assignment. You're either going to end up using Java interop, or this: https://github.com/atroche/clj-sockets
Personally I would just use Java interop, since your assignment won't require much in the way of code.
the code for the clj bot has a sockets implementation if you want to look at it https://github.com/verma/clj-slackbot
@qqq @seancorfield If you want to understand how Racket helps you build languages, you need to check out the online book "Beautiful Racket" at http://beautifulracket.com
If we really want to make Clojure a great experience for students, ideally, we need someone (summer of code?) to make a "Racket language" that is a subset of Clojure that can be used to work through the entirety of How to Design Programs curriculum in DrRacket using Clojure syntax and semantics. That way, we get interop with the functional graphics/animation libraries and integration with the pedagogical IDE (stack illustrations, etc.) for free.
@puzzler: how is racket support for (1) react/js [whalesong looks not as well done as cljs] and (2) persistent datastrcutresu?
I know there's some kind of compiler from Racket to javascript that is used to power http://wescheme.org. I'm not aware of react support. There is a student-written library of persistent data structures, not integrated into the language the way it is with Clojure. But I'm not arguing that people should be switching to Racket. I'm arguing that a Clojure implementation in Racket would be the best way to on-ramp beginners to Clojure. It wouldn't even have to be a full implementation of Clojure, just a rich enough subset to work through a textbook.
If it's truly that much beter than clojure for writing new languages, I want to learn it, and if I need to learn it, having decent js supposrt would be n ice.
there's other things that are less-than-nice in Racket though....like I think they only recently got a GC that didn't require restarting the interpreter every so often.
yeah - racket is awesome for learning, but I don't see much case for using it in prod
yes, and slashdot is php
Tell me about best practices exposing a REPL from production systems. I'm thinking binding to localhost and ssh tunneling.
eraserhd instead of using nrepl, us the clojure built in socket server
it's available as a jvm flag without changing your code
and yes, ssh in
And rely on external tools (tmux in my case, emacs in other peoples' cases) for editing expressions and history and stuff?
or just rlwrap
with rlwrap, there's a shared history that ends up in a dot file by default
that's exactly what I do, yes - well I use telnet but close enough
in extreme cases I've even hot-patched code this way. It's possible but not something I recommend...
or, a more benign example, change timbre's logging level without a restart
Heh. Well the next thing I need to figure out is that I'm using component, and the system that's running doesn't have a global reference anywhere. 🙂
I mostly need to run a few queries, maybe transact some data, kick a component that gets stuck.
hey all. off topic but what is your favourite way to clean up a strng with HTML tags in it?
Does it have to be in Clojure? From the command line, links -dump foo.html > foo.txt
with enlive you can take an html string and extract eg. the content of each node
with enlive I think you'll want the [:body :> text-node]
selector
but it might be a bulldozer where you need a spoon
@triss oh, and I just found this mailing list thread that might be informative https://groups.google.com/forum/#!msg/enlive-clj/rrY08JdI4Tc/FmDuNjc6w_oJ
in a ring app, need to redirect in the route handler and it's not obeying the site base-url. Has anyone run into this in the past?
there's all these libraries for extenral database ot use -- but the jvm seems ot ahve everything else, and I'm wondering if there's builtin dbs I can just use directly from clojure
h2 can be used directly as a library that runs without external processes
I guess it depends on what you mean by "builtin"; if you mean it runs in memory without external processes, h2 works for that (and so does sqlite, if you specify in memory?). If you mean available without having to include a dependency, then none that I'm aware of.