Closed frenchy64 closed 2 days ago
@ikitommi I took your idea and ran with it. Since you were unhappy with :function
, I added a new proxy schema :ifn
. LMK what you think.
[:function [:=> [:cat] :int] [:=> [:cat :int] :int]]
==
[:ifn [:-> :int] [:-> :int :int]]
Hey, finally had time to dig into this. I think the :ifn
~= :function
gives too many ways to do one thing:
[:function [:=> :cat :int]]
[:function [:-> :int]]
[:ifn [:=> :cat :int]]
[:ifn [:-> :int]]
also, :ifn
sound bit like ifn?
which is a different thing, e.g. a map gives true to that.
otherwise, looks good! I'll pick up this branch and play with it + add if something is missing or would like to have it differently.
I dropped the AritySchema
and moved the -function-info
into the Function
protocol + added some tests + renamed :fn
property as :guard
.
Few things I noticed:
I dropped :->
from the default registry and marked m/-->-schema
as experimental due to AST and explain results potentially being unstable. But, good to go to master.
Thanks!!
also,
:ifn
sound bit likeifn?
which is a different thing, e.g. a map gives true to that.
I don't see the problem, that's also true for :function
.
user=> (m/validate [:function [:=> [:cat [:enum 1]] [:enum 1]]] {1 1})
true
Introduce a flat syntax for function arguments.
:->
without children, looks like an infix op[:=> :a :-> :b]
.:fn
property:ifn
:->