core-typed

Typed Clojure, an optional type system for Clojure
2020-06-03T21:08:41.013Z

@paulll yeah, you could also use HMaps:

(defalias T (U '{:A Float} '{:B String} '{:C '[Int Int]})

2020-06-03T21:09:22.013700Z

in practice, you'd probably want a dispatch key so you can distinguish the cases

2020-06-03T21:10:04.014300Z

(defalias T (U '{:op :A, :A Float} '{:op :B, :B String} '{:op :C, :C '[Int Int]})

2020-06-03T21:10:40.014900Z

then (when (= :A (:op x)) ...) would update the type of x to '{:op :A, :A Float}

2020-06-03T21:11:15.015600Z

your example would also work fine, you'd just use (when (instance? A x) ...) instead