Data.Typeable
利用 Data.Typeable,可以打印动态类型信息。
class Typeable (a :: k) where
typeRep# :: TypeRep a
typeRep :: Typeable a => TypeRep a
typeRep = typeRep#
typeOf :: Typeable a => a -> TypeRep a
typeOf _ = typeRep
typeOf 函数可以返回某个值的类型信息。
Prelude> :m +Data.Typeable
Prelude Data.Typeable> :t typeOf 'a'
typeOf 'a' :: TypeRep
Prelude Data.Typeable> typeOf 'a'
Char