This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-27
Channels
- # beginners (80)
- # boot (5)
- # cider (4)
- # cljsrn (3)
- # clojure (83)
- # clojure-russia (1)
- # clojure-spec (15)
- # clojurescript (20)
- # community-development (8)
- # cursive (6)
- # emacs (5)
- # fulcro (14)
- # hoplon (71)
- # off-topic (6)
- # om (2)
- # onyx (33)
- # parinfer (3)
- # re-frame (21)
- # reagent (20)
- # spacemacs (2)
- # specter (4)
- # vim (8)
Is there a way to crowd fund @stuarthalloway so he can take a leave of absence from datomic customer support, and build all the cool stuff he talked about in https://vimeo.com/223309989 ? Just imagine the overall increase in clojure productivity!
1. better integration with seesaw / gorilla repl 2. better "clojure inspector" for looking at data 3. alternative structure to nrepl // how cool would it be if clj/cljs repls were easy to hack on 4. better documentation, defining a new repl as should be as easy as defining a new function / macro -- I want repls to be easily programmable
re 4: not sure there's that high of a use-case for them really? :thinking_face: Unless there's a use case missing?
1&2 can be summarized as "show me data graphically, not as text" -- I'm currently working on something similar myself, called blast! where if I pass it a hiccup form, it'll display it in a browser for me
so it's not as nice as doing this to native clojure data structures, but if I have a large clojure data and I want to viaualize it, I transform it to hiccup, then I blast! it and view it in the browser
https://clojure.github.io/clojure/clojure.test-api.html <-- is there a way to clear all the tests in a given namespace ? the problem I'm running into is: 1. I'm doing repl mode development. 2. I defined an incorrect test 3. now, my run-tests always has atleast one failure because one of the tests is bad. 4. without restarting the jvm/repl, is therea wa yto "clear all the tests in a namespace" ?
ns-unmap
?
@seancorfield : ns-unmap, I believe, does it one symbol at a time // I want to nuke all existing tests, which I guess is doable via getting symbols, checking their name, and removing on some conditional
@dominicm : interesting, I did not consider that (mainly due to emacs key bindings using cider eval buffer instead of refresh namespace)
is there any reason to use -> ->> instead of using as-> everywhere ? I feel like every time I see -> ->>, I'm spending brain cycles mentally substituting exprs into sexps
When reading if I see ->>
I usually know collections are being threaded, as the collection is always the last argument by convention.
When you see ->
you usually know you’re dealing with a single value or a map.
once you realise that you don’t need to think about the threading so much. Usually you don’t oscillate between 1st/last arg, except when the first arg is also the last arg… in which case it doesn’t matter
@qqq i think its just a style preference. Using as-> adds a little bit more clutter which can be avoided
I’m using manifold to put collections onto a stream, now in one place I’d like to have a stream that gets each item in these collections individually - manifold provides a transform
function that lets me use a transducer to transform the stream but I’m not sure if that actually helps.
An example:
(manifold.stream/put! s [:a :b :c])
;; now instead of printing "[:a :b :c]" I want the below to print each kw individually
(manifold.stream/consume #(prn %) s)
@martinklepsch something like derived stream + s/mapcat?
@martinklepsch i think this is what you want: https://github.com/ztellman/manifold/blob/master/src/manifold/stream.clj#L799
(let [s (manifold.stream/stream)]
(manifold.stream/put! s [:a :b :c])
(->> s
(manifold.stream/transform cat)
(manifold.stream/consume println)))
Hi! I’m hoping to include Spec, Datomic and Records in a project I’ve been thinking about for a long time, because I believe these technologies would actually enable me to realise it, but right now I’m stumbling a bit in the planning phase because of the fact that Records don’t support namespace qualified keywords. I guess I could use some custom to and from Record functions that transforms keys, but I fear that it would add a lot of complexity and making it way harder to reason about the code and flow of data. Any general recommendations, blog posts or material covering this? BTW: The reason I consider Records is that the code played out so nicely when I introduced Records and Protocols in my latest project.
IMHO — Generally: don’t use records. Use functions and basic data structures. The language was designed for this, as is Datomic and Spec. I think spec can provide the benefits of “typed” records (minus maybe IDE autosuggest). I would go so far as to recommend not using defprotocol too 😕. This is a weak opinion though: I have little OO experience and most of it has been hair pulling. If I understood it better, my opinion may be different. That said, the functional idiom in Clojure seems very, very hard to beat in terms of simplicity. There is data, there are functions that work on that data, and that’s more or less it. You want a type? {:type :my-type ...}
. Inheritence is a must? Check out the`derive` function. You might just toy around with the idea of doing things this way. Ultimately, don’t listen to us. Pick what you think makes the most sense. 🙂 Sounds like a cool project, best of luck.
@stijn that does the trick, never used cat
before 😱
Thank you very much
@martinklepsch you're welcome 🙂
I guess @lerouxrgd 🙂 trying to see if it's stable/usable in prod
@mokr you can put namespaced keywords in a record, you just can't define them as mandatory keys, if that helps
Anybody here use Vim Fireplace?
Tried using it when starting with Clojure but ended up going with IntelliJ/Cursive and Vim mode in IntelliJ because it was easier for me 😕
#vim-fireplace
Is there no :as
equivalent for import
?
no, there's no way to rename imports
Yikes. Didn’t realize that. Hm.
For writing new (Clojure) code guess it wouldn’t hurt but think it would if you had two Java imports by the same name. In which case Java has no more ability to alias than Clojure
import is never needed though
it's a convenience, classes are hot loaded when referenced, even if you don't import
I have this code that creates a function but first it loads a file from resources. Is it ok to defn
inside let
that will load that resource?
(ns validator.core
(:require [ :as io]
[scjsv.core :as v]))
(let [schema (slurp (io/resource "schema.json"))]
(def validate (v/validator schema)))
what you do need is the proper class path (which you should be letting lein or boot do for you)
@yonatanel why not (def validate (v/validator (slurp (io/resource "schema.json"))))
or just put the let inside the def
for a defn, I'd use (def schema ...)
(defn validator ...)
it's more flexible, you can now redefine the schema independently of the validator in your repl
data hiding is usually a bad idea in clojure
I modify a function; I call (clojure.tools.namespace.repl/refresh)
; I see the namespace (and parent namespaces) refreshed; I call (source refreshed.namespace/modified-function)
; I see the old unmodified code. Any ideas?
hey guys, I heard lein repl
will write a .nrepl-port
file but I've never seen it before, any ideas? (I'm using lein 2,7,1)
@qqq as->
is designed to be used inside ->
, not outside it or instead of it.
Could you elaborate a bit on this please? My (newbie) understand is that I could use it as a substitute
(-> expr (f b c) (g y z) (as-> n (q m n o)) (h s t))
That's why it's as->
expr symbol, rather than symbol expr
@seancorfield Oh neat. what is the argument against using it by itself though?
Because it would be more idiomatic to use (let [symbol expr] ...)
as->
was introduced specifically to address the use case of expressions in the middle of a ->
pipeline that didn't conform to first-arg or last-arg threading.
@seancorfield : first time I am hearing of this; thanks!
Other useful threading macros: some->
, some->>
, cond->
, and cond->>
.
At work we have condp->
and condp->>
which are like cond->
(and cond->>
) except they also thread the expression through the condition/predicate since that seemed to be such a common pattern.
@seancorfield why does as->
allow multiple forms to be passed, and binds the result to name
at each step then?
So you don't have to have multiple, separate as->
forms in the middle of a pipeline if you have several functions that need a non-first, non-last argument threaded.
Hi! I am trying to define a function which returns :clojure.spec.alpha/invalid
but getting a (ironically) spec validation error. https://gist.github.com/hmaurer/4d893f633fdc8826db430b4d8401c260 (gisted to avoid spamming channel)
Hi guys! I am trying to learn cider via spacemacs. How do I eval the namespaces that i am :requiring. If I try to eval the ns declarations I get “namespace not found” errors, but after I go to the ns that was not found and eval it “by hand” go back and now i can eval that ns declaration.
require is transitive, this shouldn't be an issue - require on a namespace also requires everything that ns requires
@noisesmith , that’s what I thought. But I don’t know why I have to eval all the namespaces before I eval the ns that requires those namespaces.
one reason could be if you put the ns in the wrong place
or spelled the name wrong
anyway, none of this is cider, this is all core clojure stuff
remember that the relative path to the namespace has to match it's full name, and any -
has to be translated to _
@noisesmith , please check this repo https://github.com/smnplk/clj-bencode
@noisesmith ahh, I see where I made a mistake. Actually , the namespace wans’t able to compile because inside namespace I used a function before declaring it.
oh - if you edit, then use the :reload
argument to require and try again, that lets you recover
or you can load from the file as you fix it
@noisesmith , thanks, I’ll do that.