by ambrosebs · 13y ago · 0 comments
I will challenge that schemas are "significantly" better for documentation than core.typed types.
With unions, intersections, heterogeneous maps, parameterised classes, recursive types we can be very expressive.
Here's some examples of the syntax for types: https://github.com/clojure/core.typed/wiki/Types
And some declarative types in action: https://github.com/frenchy64/core.typed-example/blob/master/...
I think core.typed is restrictive enough to allow annotations like the one above, while being opinionated enough to guide the programmer to write clear, comprehensible types.
The main driver for Schema was to make annotating function inputs and outputs as simple and readable as possible. Personally, I find annotations directly on the function arguments easier to parse than separate function type declarations, but I suppose that's a matter of preference.
FWIW there are macros like fn> that allow you to write (fn> :- Number [a :- Symbol] 1), but you lose the ability to write ordered function types with multiple cases, so I don't use it very much.