Out of curiosity, does typed clojure have a notion of "flow-sensitive typing" similar to TypeScript? Concretely, is the following behavior present?
;; assume x has type (U T nil)
(when (some? x)
;; type of x is inferred as T, rather than (U T nil)
(do something with x))
In the case of TypeScript, I've heard that the type checker has a bunch of common JavaScript code patterns hard-coded, and this makes the implementation of the language pretty complicated. Does Typed Clojure face similar issues?yes, and very little is hard coded
the main reason is that most values are immutable in clojure
so there's no need to support sophisticated control flow involving mutable objects
some examples of hardcoding is instance? and satisfies? https://github.com/typedclojure/typedclojure/blob/bc0a3644b2fe88a0840a2aa278ee0fbeb6f232eb/typed/clj.checker/src/typed/clj/checker/check.clj#L1567-L1592
OTOH some? int? etc are fully composable https://github.com/typedclojure/typedclojure/blob/bc0a3644b2fe88a0840a2aa278ee0fbeb6f232eb/typed/lib.clojure/src/typed/ann/clojure.cljc#L1550-L1551
Typed Clojure's approach is straight from https://www2.ccs.neu.edu/racket/pubs/icfp10-thf.pdf
Cool! I appreciate the detailed response. At the moment I am thinking of making a little "typed clojure playground" so its easier for me to experiment with this stuff.
you might want to base it on this example project, which shows you how to write passing/failing unit tests for type checking expressions https://github.com/typedclojure/typedclojure/blob/main/example-projects/symbolic-guide/test/typed_example/symbolic_guide.clj