Fork me on GitHub
#clojure
<
2017-08-27
>
qqq03:08:40

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!

dominicm07:08:39

What things of note are not built?

qqq08:08:14

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

dominicm08:08:26

re 3: unrepl might be of interest

dominicm08:08:46

re 4: not sure there's that high of a use-case for them really? :thinking_face: Unless there's a use case missing?

dominicm08:08:59

1/2 are somewhat related. Agree these could do with some serious work.

qqq09:08:45

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

qqq09:08:09

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

qqq05:08:07

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" ?

qqq05:08:31

I'm okay if it nukes all tests (in all namespaces) too

qqq06:08:31

current best solution = remove-ns + cider eval current buffer

dominicm07:08:37

Does tools.namepsace's refresh not handle this scenario?

qqq09:08:14

@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

qqq09:08:52

@dominicm : interesting, I did not consider that (mainly due to emacs key bindings using cider eval buffer instead of refresh namespace)

dominicm09:08:06

cider-refresh exists

qqq09:08:53

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

rickmoynihan09:08:35

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.

rickmoynihan09:08:28

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

alpox09:08:45

@qqq i think its just a style preference. Using as-> adds a little bit more clutter which can be avoided

martinklepsch10:08:07

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.

martinklepsch10:08:31

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) 

misha10:08:36

@martinklepsch something like derived stream + s/mapcat?

stijn11:08:07

tranfsorm with cat should do this, no?

stijn11:08:14

(let [s (manifold.stream/stream)] 
  (manifold.stream/put! s [:a :b :c])
  (->> s
       (manifold.stream/transform cat)
       (manifold.stream/consume println)))

mokr11:08:54

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.

alex-dixon16:08:21

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.

qqq11:08:29

What is Records ?

mokr11:08:14

Correct, I’m referring to Records as created by defrecord.

martinklepsch11:08:04

@stijn that does the trick, never used cat before 😱

martinklepsch11:08:13

Thank you very much

stijn11:08:36

@martinklepsch you're welcome 🙂

mpenet12:08:27

anyone using celtuce?

mpenet12:08:13

I guess @lerouxrgd 🙂 trying to see if it's stable/usable in prod

noisesmith13:08:22

@mokr you can put namespaced keywords in a record, you just can't define them as mandatory keys, if that helps

captainlexington14:08:07

Anybody here use Vim Fireplace?

alex-dixon16:08:32

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 😕

reefersleep20:08:01

#vim-fireplace

alex-dixon16:08:19

Is there no :as equivalent for import?

noisesmith16:08:49

no, there's no way to rename imports

alex-dixon16:08:15

Yikes. Didn’t realize that. Hm.

alex-dixon16:08:29

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

noisesmith16:08:01

import is never needed though

noisesmith16:08:17

it's a convenience, classes are hot loaded when referenced, even if you don't import

yonatanel16:08:46

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)))

noisesmith16:08:50

what you do need is the proper class path (which you should be letting lein or boot do for you)

noisesmith16:08:55

@yonatanel why not (def validate (v/validator (slurp (io/resource "schema.json"))))

noisesmith16:08:04

or just put the let inside the def

yonatanel16:08:45

Oh, right. I asked about defn but used def

noisesmith16:08:35

for a defn, I'd use (def schema ...) (defn validator ...)

noisesmith16:08:52

it's more flexible, you can now redefine the schema independently of the validator in your repl

noisesmith16:08:22

data hiding is usually a bad idea in clojure

yonatanel16:08:47

nice. Thanks!

Garrett Hopper18:08:51

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?

akiroz19:08:30

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)

seancorfield21:08:53

@qqq as-> is designed to be used inside ->, not outside it or instead of it.

hmaurer22:08:22

Could you elaborate a bit on this please? My (newbie) understand is that I could use it as a substitute

seancorfield22:08:03

(-> expr (f b c) (g y z) (as-> n (q m n o)) (h s t))

seancorfield22:08:01

That's why it's as-> expr symbol, rather than symbol expr

hmaurer22:08:02

@seancorfield Oh neat. what is the argument against using it by itself though?

seancorfield22:08:12

Because it would be more idiomatic to use (let [symbol expr] ...)

seancorfield22:08:21

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.

qqq01:08:54

@seancorfield : first time I am hearing of this; thanks!

seancorfield01:08:32

Other useful threading macros: some->, some->>, cond->, and cond->>.

seancorfield01:08:25

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.

hmaurer18:08:40

@seancorfield why does as-> allow multiple forms to be passed, and binds the result to name at each step then?

seancorfield18:08:49

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.

hmaurer22:08:20

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)

smnplk22:08:14

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.

noisesmith22:08:50

require is transitive, this shouldn't be an issue - require on a namespace also requires everything that ns requires

smnplk22:08:52

@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.

noisesmith22:08:49

one reason could be if you put the ns in the wrong place

noisesmith22:08:56

or spelled the name wrong

noisesmith22:08:23

anyway, none of this is cider, this is all core clojure stuff

noisesmith22:08:22

remember that the relative path to the namespace has to match it's full name, and any - has to be translated to _

smnplk22:08:26

@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.

smnplk22:08:53

I called a function before it’s declaration

noisesmith22:08:56

oh - if you edit, then use the :reload argument to require and try again, that lets you recover

noisesmith22:08:02

or you can load from the file as you fix it

smnplk22:08:33

@noisesmith , thanks, I’ll do that.