Fork me on GitHub
#core-typed
<
2020-06-03
>
ambrosebs21:06:41

@paulll yeah, you could also use HMaps:

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

ambrosebs21:06:22

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

ambrosebs21:06:04

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

ambrosebs21:06:40

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

ambrosebs21:06:15

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