Fork me on GitHub
#malli
<
2023-12-11
>
Sam09:12:06

In all function schema examples I find, like https://github.com/metosin/malli/blob/master/docs/function-schemas.md#function-schemas-1 , there's the keyword :cat . What is it? I tried to read a blogpost about seqexp which went way over my head. In the example below, it seems just fine to use [:=> :int :int] instead of [=> [:cat :int] :int] . Why is the :cat needed, what does it do?

(defn foo
  {:malli/schema [:=> :int :int]}
  [x]
  (inc x))

(defn foo2
  {:malli/schema [:=> [:cat :int] :int]}
  [x]
  (inc x))

(= (foo2 1) (foo 1)) ;; both work the same

delaguardo09:12:46

:cat is needed when there is more than one argument expected by the function. this is the way to say "function foo expects two integers"

Sam09:12:08

Oh, should have thought of that. Thank you!