Haskell has Data.Dynamic
:
a method of hiding types in such a way that they may be conditionally resolved at run-time in a type-safe manner.
Here's the implementation in Haskell:
data Dynamic where
Dynamic :: forall a. TypeRep a -> a -> Dynamic