Fork me on GitHub
#announcements
<
2022-10-06
>
Matthew Davidson (kingmob)08:10:32

https://github.com/clj-commons/potemkin has been released. There are no changes to functionality. Everything should work as before. The major change is improved support for clj-kondo. While not comprehensive, it should cut down on false positives. Note that import-vars was already handled specially by clj-kondo, so if that’s the only potemkin macro you use, you shouldn’t see any differences. Minor changes include doc improvements, the minimum Java version is now 8, and the fast-bound-fn and fast-memoize fns are deprecated (they’re almost never faster than modern Clojure).

🎉 10
clj-commons 7
clj-kondo 3
ericdallo10:10:34

That's awesome!

Ivar Refsdal08:10:23

https://github.com/ivarref/clj-paginate, fast pagination of vectors and maps with Clojure for GraphQL, has been released. This release adds support for multiple sort criteria (ascending or descending), e.g. you may specify sort-attrs as [[:date :desc] [:id :desc]]. It also adds support for the named parameter :inclusive? that allows a user to refresh a page based only on an old pageInfo/connection. It introduces the named parameter :sort? that defaults to true. clj-paginate will now (by default) sort the data for you. Power users, people who already cache the (sorted) data to be paginated, can disable that feature.

🎉 7
borkdude14:10:17

The first public release of gh-release-artifact : Upload artifacts to Github releases idempotently This is small library that I've been using in projects like babashka, clj-kondo, and others, for a few years now, to automatically upload files to Github releases. This library is especially handy when your project is built from different CIs and releases for those files have to be created idempotently (babashka currently uses 4 different CIs to build releases on). Repo: https://github.com/borkdude/gh-release-artifact The main API function is here: https://github.com/borkdude/gh-release-artifact/blob/main/API.md#borkdude.gh-release-artifact/release-artifact

💯 13
🎉 12
Cam Saul20:10:54

Methodical 0.15.0 is out! https://github.com/camsaul/methodical/releases/tag/0.15.0.1 Methodical is a library that acts like a drop-in replacement for Clojure multimethods, with tons of extra features, support for functionally/non-destructively composing multimethods, better error checking, and debugging tooling. The last few releases have focused on improving the developer experience with better error checking, documentation generation, and tooling, and 0.15.0 continues this theme. The marquee feature of 0.15.0 is support for macroexpansion-time defmethod arglist arity validation. If you have a three-arg multimethod and try to write a defmethod for it that takes only two args, get an error message right away!

(m/defmulti ^:private mf
  {:arglists '([x]), :defmethod-arities #{1}}
  keyword)

(m/defmethod mf :x [x] x)
;; => ok

(m/defmethod mf :x ([x] x) ([x y] x y))
;; => error: {:arities {:disallowed #{2}}}

(m/defmethod mf :x [x y] x y)
;; => error: {:required #{1}, :disallowed #{2}}
(Yes, this works with rest-argument & arities as well!) 0.15.0 also includes improved error messages, a bug fix, and ten new utility functions.

👀 5
🎉 6
😲 3
Noah Bogart20:10:34

That's sick! How does it work? Just checking the :arglists of the metadata?

Cam Saul20:10:34

I considered doing that at first but decided that was ultimately too fragile, especially if you have "fancy" :arglists metadata like [x y z?] (meaning [x y] [x y z]) So instead you can attach a set of :defmethod-arities metadata that is a set of allowed arities; each arity is represented by either an integer or by a [:>= n] form for an arity with & rest arguments. The example above demonstrates using a plain integer arity. Here's an example that includes a 3-or-more-args arity:

;; methods must both a 1-arity and a 3+-arity
(m/defmulti ^:private mf
  {:arglists '([x] [x y z & more]), :defmethod-arities #{1 [:>= 3]}}
  keyword)

(m/defmethod mf :x ([x] x) ([x y z & more] x))
;; => ok

(m/defmethod mf :x [x y] x)
;; => error: {:arities {:required #{1 [:>= 3]}, :disallowed #{2}}}

Cam Saul20:10:27

it's smart enough to figure out if you cover your bases with other arities that aren't exactly the same as what was asked too:

(m/defmulti ^:private mf
  {:arglists '([x y z & more]), :defmethod-arities #{[:>= 3]}}
  keyword)

(m/defmethod mf :x
  ([a b c] x)
  ([a b c d] x)
  ([a b c d & more] x))
;; => ok, because everything required by [:>= 3] is covered, and everything present is allowed by [:>= 3]

Noah Bogart21:10:59

Oh I see. Okay, that makes sense. Very cool