如何使用特定的TypeRep创建值

时间:2015-10-02 22:27:51

标签: haskell dynamic types casting

使用Data.Typeable,我可以重新定义值的类型 -

typeOf :: Typeable a => a -> TypeRep

但是,给定TypeRep,似乎无法将值“设置”为该类型。

例如 -

maybeIntType :: TypeRep
maybeIntType = typeOf (Just 100 :: Maybe Int)

但是如何使用maybeIntType创建(Nothing :: Maybe Int)

0 个答案:

没有答案
相关问题