@paulll yeah, you could also use HMaps:
(defalias T (U '{:A Float} '{:B String} '{:C '[Int Int]})
in practice, you'd probably want a dispatch key so you can distinguish the cases
(defalias T (U '{:op :A, :A Float} '{:op :B, :B String} '{:op :C, :C '[Int Int]})
then (when (= :A (:op x)) ...)
would update the type of x
to '{:op :A, :A Float}
your example would also work fine, you'd just use (when (instance? A x) ...)
instead