Fork me on GitHub
#tools-deps
<
2021-01-07
>
pinkfrog14:01:20

I am using belman, so the dep setup is:

{:aliases
   :rebel
     {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.4"}}
      :main-opts  ["-m" "rebel-readline.main"]}
} ;

pinkfrog14:01:47

I want in every ns, I can access doc, and dir (which are from the namespace repl)

Alex Miller (Clojure team)15:01:59

there isn't really any way to do this without making a customized repl

Alex Miller (Clojure team)15:01:13

(which is not really that hard, but might be more than you want to do)

borkdude15:01:29

Maybe evaluating things from within user is an alternative approach?

borkdude15:01:00

(I typically just require 'clojure.repl if I need it)

pinkfrog15:01:03

thought the repl should support such a feature.

Alex Miller (Clojure team)15:01:15

yeah, I just use if I'm working at the repl

Alex Miller (Clojure team)15:01:09

but I'm usually working in an editor-connected repl and leave the repl window in user, while sending expressions from whatever namespace I'm working in

Alex Miller (Clojure team)15:01:33

and using editor tools for doc support etc

pinkfrog15:01:20

You don’t drop in the repl window and switch to the current active buffer namespace for adhoc editting?

Alex Miller (Clojure team)15:01:27

no, I write code in my editor and eval it

👌 3
Alex Miller (Clojure team)15:01:05

the main thing I usually use the repl window for is just (pst *e) :)

Alex Miller (Clojure team)15:01:47

I dropped an example of making a repl to do this somewhere

pinkfrog15:01:08

It is about clojure.main, so might not applicable to rebel

borkdude15:01:28

@alexmiller hah, I just tried this with bb and it also works there:

$ bb -e "(require '[clojure.main :as m]) \
        (m/repl :init #(apply require m/repl-requires) \
        :eval (fn [form] (do (require '[clojure.pprint :refer [pprint]]) \
        (eval form))))"
user=> (ns foo)
nil
foo=> (pprint {:a 1})
{:a 1}
nil
(only pp isn't available yet)

borkdude15:01:17

@i You should probably read the README of rebel read-line: https://github.com/bhauman/rebel-readline#quick-usage > The main way to utilize this readline editor is to replace the clojure.main/repl-read behavior in clojure.main/repl.

borkdude15:01:43

It seems to offer integration with clojure.main

pinkfrog15:01:04

which part are you referring to ?

borkdude15:01:43

under quick usage

practicalli-johnny16:01:58

@i I think I have missed something. If using rebel readline, you have docs and eldoc (function signatures) in every namespace as part of the default Rebel readline UI. Its easy to run other commands from the repl namespace by using the fully qualified name, which rebel readline keeps in its history so you only have to type once and even then TAB will auto-complete the name of namespaces and functions, so you dont even need to type it in full once. Eg. (clojure.repl/dir clojure.string)

practicalli-johnny16:01:11

I did a short video of using REBL for a very simple project, showing eldoc and docs and tab completion of namespaces and function names http://practicalli.github.io/clojure/clojure-tools/repl/

Alex Miller (Clojure team)21:01:43

for any of you toolsmiths looking for a project, it would be cool to see a tool that compared the APIs from two versions of a Clojure lib at the source level (like https://abi-laboratory.pro/?view=timeline&amp;lang=java&amp;l=clojure does for Java compatibility)

Alex Miller (Clojure team)21:01:56

even knowing surface level add/remove/modify functions and add/modify arities would be a big help in detecting things (deeper level that understood keys in maps or coll types or whatever would be a harder task)

borkdude21:01:29

This is very easy to make using clj-kondo analysis. @lee didn't you make this kind of tools once for clj-doc?

lread21:01:28

We were talking about such a thing for cljdoc but never got to it. I did hack together something to compare rewrite-clj/rewrite-cljs/rewrite-cljc. It serves this purpose and but I am certainly not proud of its quality https://github.com/lread/diff-apis

borkdude21:01:20

I can whip up something in an hour or so

lread21:01:26

@borkdude, I think you might live in a different space/time continuum than me. simple_smile Or there are several of you “We are borkdude, resistance is futile”.

lread21:01:09

Will your clj-kondo solution pick up potemkin and potemkin-like imports?

borkdude21:01:10

@lee clj-kondo knows how to handle potemkin itself, but not sure about potemkin-likes

👍 3
vlaaad22:01:00

Isn't it something Rich worked on? Codeq?

Alex Miller (Clojure team)22:01:46

codeq is actually in this ballpark, but is actually more fine-grained

Alex Miller (Clojure team)22:01:12

I think it's both more and less than what I'm saying although it could be a good substrate

borkdude22:01:16

invokable as JVM script

borkdude22:01:45

Usage: api_diff.clj lib1.jar lib2.jar (or api_diff.clj foo/src bar/src)

borkdude22:01:31

There is also :private information in this analysis, I didn't take that into account, but small change.

borkdude22:01:33

There might be other diffing libs out there that give a format that's better suited for what you want, this is just a start

Alex Miller (Clojure team)22:01:16

pretty cool. would love to see something like this integrated that also used tools.deps so you could tell it a lib and two versions to compare

Alex Miller (Clojure team)22:01:54

ultimately I wonder if you could say that a version has a breaking api change

borkdude22:01:05

@alexmiller tda returns this for lib-location: {:base "/Users/borkdude/.m2/repository", :path "org/clojure/clojure/1.8.0", :classifier nil, :type :mvn}, is there anything I could use to resolve the full path to the jar?

Alex Miller (Clojure team)22:01:18

I wouldn't use lib-location at all

Alex Miller (Clojure team)22:01:37

better to resolve-deps or calc-basis and get the paths out of the result

borkdude22:01:45

I just want the location for this one thing, that's why I thought lib-location would be fitting

Alex Miller (Clojure team)22:01:41

lib-location won't actually download it

borkdude22:01:43

Ah I see:

#:org.clojure{clojure {:paths ["/Users/borkdude/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar"], :deps/manifest :mvn, :mvn/version "1.8.0", :parents #{[]}}}
I can work with that

borkdude22:01:53

yeah, I did the downloading with resolve-deps already

Alex Miller (Clojure team)22:01:14

for a maven dep, :paths should always have a single entry

Alex Miller (Clojure team)22:01:36

(at least for now, maybe some future case to consider)

Alex Miller (Clojure team)22:01:40

alternately, you could call org.clojure.tools.deps.alpha.extensions/coord-paths directly I guess

Alex Miller (Clojure team)22:01:36

(ext/coord-paths 'org.clojure/clojure {:mvn/version "1.10.0"} :mvn {:mvn/repos maven/standard-repos})

Alex Miller (Clojure team)22:01:08

probably the most direct but still most generic call you can make in the public api

borkdude22:01:35

Gist updated, works for mvn deps:

api_diff.clj org.clojure/clojure "1.8.0" "1.10.1" > /tmp/diff.txt

borkdude22:01:53

Detecting breaking changes is not something I will include today, it's getting too late ;)

borkdude22:01:42

I guess the algorithm should look at things that were in v1 but were removed in v2, or arities that were removed in v2

borkdude22:01:45

afk now, sleep

Alex Miller (Clojure team)22:01:38

pretty sweet, nice hack

Alex Miller (Clojure team)22:01:11

@borkdude there is one bug there - need to provide the standard maven repos if you don't have stuff locally

Alex Miller (Clojure team)22:01:23

(require '[clojure.tools.deps.alpha.util.maven :as mvn])

Alex Miller (Clojure team)22:01:33

then

(-> (tda/resolve-deps `{:deps {~lib {:mvn/version ~v}} :mvn/repos ~mvn/standard-repos} {})

borkdude23:01:52

@alexmiller Thanks, updated. Also swapped out deep-diff with editscript, this prints things like:

[[[clojure.core into] :fixed-arities 0] :+ 0]
 [[[clojure.core into] :fixed-arities 1] :+ 1]
This makes it pretty easy to grep for :- for things that have disappeared.

borkdude23:01:54

My grep for 1.8.0 ~ 1.10.1:

[[[clojure.pprint format-simple-number] :fixed-arities] :-]
 [[[clojure.core emit-method-builder] :fixed-arities 4] :-]
 [[[clojure.core.reducers compile-if]] :-]

borkdude23:01:12

(some of these could be due to subpar analysis by clj-kondo)

borkdude23:01:49

ah for emit-method-builder it correctly detected an API change: https://github.com/clojure/clojure/commit/2cc37bb56a9125a1829c73c505e32995e663059a but this function is private, so no problem

borkdude23:01:05

and indeed, compile-if disappeared (also private)

borkdude23:01:20

so the only false positive seems to be the one in pprint

Alex Miller (Clojure team)23:01:32

just trying to help here man - you're already a week into the new year without publishing any new tools

24
parrot 3