Fork me on GitHub
#malli
<
2024-01-27
>
ikitommi08:01:09

ok, better to change the guard from function into Schema object. Bit more wrapping, but supports custom error messages etc out-of-the-box:

👏 2
ikitommi08:01:54

spec uses single map as argument with :ret and :args keys, I think it’s more clear to use positional args instead, e.g. the guard function is of type args ret -> boolean.

ikitommi08:01:02

why? less things to remember (the keys in the map) + easier to destructure:

;; spec
(fn [{:keys [args ret]})
  (< (first args) ret))

;; proposal for malli
(fn [[arg] ret]
  (< arg ret)

ikitommi09:01:58

ok, it needs to be arity1, so:

;; spec
(fn [{:keys [args ret]})
  (< (first args) ret))

;; proposal for malli
(fn [[[arg] ret]]
  (< arg ret)