[project @ 2003-11-23 12:23:49 by ralf]
authorralf <unknown>
Sun, 23 Nov 2003 12:23:49 +0000 (12:23 +0000)
committerralf <unknown>
Sun, 23 Nov 2003 12:23:49 +0000 (12:23 +0000)
Added some trivial observers for type representations.

Data/Typeable.hs

index 2be2ae1..4c8050a 100644 (file)
@@ -39,7 +39,13 @@ module Data.Typeable
        mkTyCon,        -- :: String  -> TyCon
        mkAppTy,        -- :: TyCon   -> [TypeRep] -> TypeRep
        mkFunTy,        -- :: TypeRep -> TypeRep   -> TypeRep
-       applyTy         -- :: TypeRep -> TypeRep   -> Maybe TypeRep
+       applyTy,        -- :: TypeRep -> TypeRep   -> Maybe TypeRep
+
+       -- * Observation of type representations
+       typerepTyCon,   -- :: TypeRep -> TyCon
+       typerepArgs,    -- :: TypeRep -> [TypeRep]
+       tyconString     -- :: TyCon   -> String
+
 
   ) where
 
@@ -171,6 +177,24 @@ mkTyCon str = TyCon (mkTyConKey str) str
 
 
 
+----------------- Observation ---------------------
+
+
+-- | Observe the type constructor of a type representation
+typerepTyCon :: TypeRep -> TyCon
+typerepTyCon (TypeRep _ tc _) = tc
+
+
+-- | Observe the argument types of a type representation
+typerepArgs :: TypeRep -> [TypeRep]
+typerepArgs (TypeRep _ _ args) = args
+
+
+-- | Observe string encoding of a type representation
+tyconString :: TyCon   -> String
+tyconString  (TyCon _ str) = str
+
+
 ----------------- Showing TypeReps --------------------
 
 instance Show TypeRep where