malli 2025-09-02

I received funding to work on Malli this quarter. Here's my proposal, first I'll finish the constraint work I almost finished earlier this year. https://www.clojuriststogether.org/news/q3-2025-funding-announcement/#ambrose-bonnaire-sergeant-malli

👏 8
đź‘€ 1
🔥 3
2
3
🎉 5

@ben.sless Good question, tbh I haven't thought about this in 6 months. I didn't expect it to be picked up for funding. I'm ramping myself back on, I'll keep you posted.

There's code somewhere which I will share.

I'll leave comments there

👌 1

comments left

🔥 2

Using this opportunity to discuss - how do you plan to achieve a canonical representation and simplification algorithm that given different shaped schemas will reach the same ground form? Reminds me of some problems from LC expression reduction

note to self: I should look into this and offer my comments as well

Thanks. It'll be a while until I get started, I intend to work on my open PR's first.

Say, I’ve an fn declared in a defprotocol:

(defprotocol MyProtocol
  (do-this [x] "blah blah"))
I wanted to add a schema for this do-this fn, to ensure the implementers do the right thing:
(m/=> do-this [:=> [:cat :string] :string])

(defprotocol MyProtocol
  (do-this [x] "blah blah"))
I have the instrumentation enabled and all other fns seem to be handled fine, but this doesn’t seem to be applied to fns implemented as part of a protocol… how do I define a schema for a protocol fn?

that's been a recommended way to do protocols for a while! ben vandergrift and alex miller wrote about that in their book Clojure Applied 10 years ago

🙏 1

Did a bit of research and it seems it’s not supposed to work as per https://github.com/metosin/malli/issues/555

Are there possible workarounds?

I ended up creating a schemed wrapper function that calls the protocol method:

(defprotocol MyProtocol
  (-do-this [x] "internal implementation"))

(m/=> do-this [:=> [:cat :string] :string])
(defn do-this [x]
  (-do-this x))

(defrecord MyRecord [data]
  MyProtocol
  (-do-this [x] (str "processed: " (:data x))))