r/Clojure • • Jul 24 '25

Good quality libraries

Hi all! I am learning Clojure as a part of experiment on myself. I really love FP and my favourite FP language is Haskell. Learning it made me really appreciate types. The reason I decided to learn Clojure is TDD; for last year or two I really came to love TDD, and I realised the more I use it, the less I rely on types, so I decided to learn some dynamic language and see if I really need types when I have TDD. What I found is that I am fine as long as I work with my own code that I know, but when I have to use external library I lack something else, it's not the safety, it's explorability. Even with little docs one can learn a lot about the library in Haskell. How do you guys work around that in Clojure? Is there some list of the industry standards or at least of the libraries with good uniformal documentation? Thanks

22 Upvotes

9 comments sorted by

View all comments

Show parent comment

2

u/imihnevich Jul 24 '25

By all means share everything that might be handy, thanks for the gist and tips

3

u/v4ss42 Jul 25 '25

Sorry for the delay - here's that ns-docs fn I mentioned: https://gist.github.com/pmonks/e2449584c4f519672460c3f5fe3dd730

2

u/v4ss42 Jul 24 '25 edited Jul 24 '25

I also found an old (and probably out of date) gist I wrote that gets the namespaces in a dep too: https://gist.github.com/pmonks/982ce90dac11a4cefe45378c0db3d555

In combination with the (to-be-created-shortly) ns-docs gist, this allows one to go from a dependency coordinate (which is usually one of the first things you’ll see listed in a GitHub project’s README) all the way to a list of vars+docstrings per namespace in that dep.

For completeness I should probably close the loop and write a dep-docs fn, that prints out the vars+docstrings from all namespaces in a given dep. It might be a bit unwieldy at the REPL, but with a bit of thought I could probably come up with a more ergonomic API (e.g. allowing the results to be filtered using core Clojure fns).

1

u/v4ss42 Jul 27 '25

Ok so while I came up with a short, quick & dirty dep-docs function, it has the side effects of both downloading the dep (not terrible) and adding it to the running classpath (which isn't great imvho, and won't work if different versions are introspected - it uses add-lib, which can't "replace" an existing dep in the classpath).

I assume there are clever ways to get the docstrings of a namespace and its public vars without adding the code to the classpath, but I also suspect that'll be a lot more complex, especially if macros are involved.