h2. Problem
If two functions take similar keyword arguments, we have to write them out twice.
(ann make-contract [& :optional {:name (U Symbol String)
:first-order [Any :-> Any]
:projection [Blame :-> [Any :-> Any]]
:flat? Boolean}
:-> Contract])
(ann make-flat-contract [& :optional {:name (U Symbol String)
:first-order [Any :-> Any]
:projection [Blame :-> [Any :-> Any]]
:flat? Boolean}
:-> Contract])
Since HMap syntax is very similar *and* keyword arguments often flow into HMap types, it would be great to just specify these as HMap types.
(defalias KW
(HMap :optional {:name (U Symbol String)
:first-order [Any :-> Any]
:projection [Blame :-> [Any :-> Any]]
:flat? Boolean}))
(ann make-contract [& :HMap KW :-> Contract])
(ann make-flat-contract [& :HMap KW :-> Contract])
h2. Questions
What does a union of HMap's mean?
eg.
(defalias KW
(U '{:a Int}
'{:b Int}))
(ann make-contract [& :HMap KW :-> Contract])
What does nil mean?
(defalias KW
(U '{:a Int}
nil))
(ann make-contract [& :HMap KW :-> Contract])