core-typed

hifumi123 2024-05-14T22:07:59.632709Z

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?

2024-05-14T22:25:12.025859Z

yes, and very little is hard coded

2024-05-14T22:25:32.659109Z

the main reason is that most values are immutable in clojure

👍 1
2024-05-14T22:25:51.819929Z

so there's no need to support sophisticated control flow involving mutable objects

2024-05-14T22:31:11.981019Z

Typed Clojure's approach is straight from https://www2.ccs.neu.edu/racket/pubs/icfp10-thf.pdf

👀 1
hifumi123 2024-05-14T23:16:46.104749Z

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.

❤️ 1
2024-05-14T23:20:27.390799Z

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

👍 2