malli

Kovas Palunas 2025-06-19T18:16:49.951579Z

I'm working on a cljs app and am using a global registry to define schemas. I have some code like this:

(register! ::target-transformer
  [:=> [:cat ::character ::transformer-params] ::character])

(defn do-damage
  {:malli/schema ::target-transformer}
  [character {:keys [damage]}]
  (update character :vigor #(- % damage)))
but it leads to an error: Error: Schema error when instrumenting function: app.interface.characters/get-single-melee-target - :malli.core/instrument-requires-function-schema I tried wrapping the schema like
{:malli/schema (m/deref ::target-transformer)}
but since my schema depends on other stuff that is not yet defined (e.g. ::character), this does not work. Is there a way to tell malli to deref all function schemas when I call malli-dev/start? Or is there another idiomatic way to do this. Posts I made leading up to this latest issue with more context: https://www.reddit.com/r/Clojure/comments/1l11nbg/best_way_to_resolve_circular_dependencies_in/ https://www.reddit.com/r/Clojure/comments/1le87io/debugging_invalid_malli_schemas_in_cljs/

Kovas Palunas 2025-07-01T03:23:04.002049Z

do you mean make my own fork of malli with those changes?

2025-07-01T03:30:48.831949Z

Yes, and if it helps then propose it upstream.

2025-06-23T20:28:57.251409Z

You might want to try an experimental malli branch to make it aware of aliases. Change https://github.com/metosin/malli/blob/6b0862135ea58ef2ac92bda9ae605994a5fb20d6/src/malli/core.cljc#L108C1-L112C1 to:

(-function-schema? [this] (if (-ref-schema? this) (-function-schema? (-deref this)) false))
  (-function-info [this] (when (-ref-schema? this) (-function-info (-deref this))))
  (-function-schema-arities [this] (when (-ref-schema? this) (-function-schema-arities (-deref this))))
  (-instrument-f [this a b c] (when (-ref-schema? this) (-instrument-f (-deref this) a b c)))