Polymorphic Data.Dynamic
At some point in the compilation process an expression acquires a fully-specified, possibly polymorphic, type. If we add an operation that join that type and that expresssion, say TypedAny
, then we can implement the part of #4316 requested by mitar.
In GHCi we can evaluate HValue
s and also string them together with bind
statements.
The function
applyDynamic :: TypedAny -> TypedAny -> Maybe TypedAny
includes in its implementation a dictionary lookup and possible dynamic object linking for class methods.
the function
fromDynamic :: TypedAny -> Maybe a
like applyDynamic
, runs the typechecker at runtime to unify (and possibly link) the dynamic type (!TypedAny) and the static type (a).
*Conjecture * Since we already have typecase
(classes), with type families, this feature provides/simulates dependent types.