by ryanbrush · 13y ago · 0 comments
(ann my-inc [Number -> Number])
(defn my-inc [n] (let [internal-number (Integer/parseInt "1")] (+ n internal-number)))
one could write this:
(defn ^Number my-inc [^Number n] (let [internal-number (Integer/parseInt "1")] (+ n internal-number)))
...and then run a type checker that reads and analyzes the hints?
Of course, the core.typed annotations could preserve whatever information they need in the compiled output, whereas the type hints aren't preserved past the compile phase (as far as I can tell.) Is that the limitation that requires defining type information in separate annotations?
https://github.com/steveshogren/deft
Right now it only checks maps for a set of keys, the idea longer term is to add in other types of "type" checking.
I haven't yet tied into the built-in annotations, just because those didn't appear to check anything but valid Java types. If it is possible, I would be really interested in seeing how.