-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: :->
#1027
base: master
Are you sure you want to change the base?
WIP: :->
#1027
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I also too a stab at this earlier. Looking at my stash, the idea was:
- move the
malli.util/-util-schema
asmalli.core/-proxy-schema
- implement
:->
using that (you canm/deref
to get the underlaying:=>
of this) - there are few places where one needs to check "if the schema is a function schema". There could be a new
FunctionSchema
protocol or some other & simpler way to tag both variants as valid. - I just listed both e.g. in
:function
schema (oh, the crappy name of that!)
- (when-not (every? #(= :=> (type %)) children)
+ (when-not (every? #(= #{:=> :->} (type %)) children)
the actual :->
impl was:
(defn -->-schema []
(-proxy-schema {:type :->
:fn (fn [p c o] (let [c (map #(schema % o) c), cc [(into [:cat] (butlast c)) (last c)]]
[c (map -form c) (into-schema :=> p cc o)]))}))
not sure if that worked in all possible places, was a quick test, see https://clojurians.slack.com/archives/CLDK6MFMK/p1706446416126059
I think having a new Schema would be simpler here. WDYT?
src/malli/core.cljc
Outdated
@@ -1760,9 +1760,28 @@ | |||
(-type [_] :=>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be changed too
src/malli/core.cljc
Outdated
@@ -1749,7 +1749,7 @@ | |||
{:min 1 :max 1} | |||
(-regex-min-max child nested?))))))))) | |||
|
|||
(defn -=>-schema [] | |||
(defn -=>-schema [{:keys [flat-arrow?]}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keys with ?
in the end should be predicate functions, so flat-arrow
would suffice here. https://github.com/bbatsov/clojure-style-guide?tab=readme-ov-file#naming-predicates
@ikitommi I took your idea and ran with it. Since you were unhappy with [:function [:=> [:cat] :int] [:=> [:cat :int] :int]]
==
[:ifn [:-> :int] [:-> :int :int]] |
Introduce a flat syntax for function arguments.
:->
without children, looks like an infix op[:=> :a :-> :b]
.:fn
property:ifn
:->