-
Notifications
You must be signed in to change notification settings - Fork 75
Accurate downcasting
frenchy64 edited this page Apr 25, 2013
·
2 revisions
We can combine type information to infer more accurate types, but it's not obvious how to achieve this.
eg. if we know a binding is of type (Seqable Number)
and (IPersistentVector Any)
, we should infer it to be
(IPersistentVector Number)
.
We want to infer similar results where possible.
Maintain a database of safe downcasts, provided by the user.
(alter-class IPersistentVector [[a :variance :covariant]]
:downcast {Seqable (TFn [x] (IPersistentVector x))})
;need to pattern match (Seqable (IMapEntry x y)) ?
(alter-class IPersistentMap [[a :variance :covariant]]
:downcast {Seqable ?})