标签: haskell dynamic types casting
使用Data.Typeable,我可以重新定义值的类型 -
Data.Typeable
typeOf :: Typeable a => a -> TypeRep
但是,给定TypeRep,似乎无法将值“设置”为该类型。
TypeRep
例如 -
maybeIntType :: TypeRep maybeIntType = typeOf (Just 100 :: Maybe Int)
但是如何使用maybeIntType创建(Nothing :: Maybe Int)?
maybeIntType
(Nothing :: Maybe Int)