3 ms·
Author of core.typed here. I will challenge that schemas are "significantly" better for documentation than core.typed types. With unions, intersections, heter
by ambrosebs 13y ago
Author of core.typed here.
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 https://github.com/clojure/core.typed/wiki/Types
And some declarative types in action: https://github.com/frenchy64/core.typed-example/blob/master/src/fire/simulate.clj#L42 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.
- w01fe 13y agoSorry, that didn't come across the way I wanted -- it certainly wasn't meant as a dig on the expressiveness or power of core.typed, which is a project I'm really excited about. 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.
- ambrosebs 13y agoNo problem, just was eager to clarify :) 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.