From: ralf Date: Sun, 23 Nov 2003 12:23:49 +0000 (+0000) Subject: [project @ 2003-11-23 12:23:49 by ralf] X-Git-Tag: nhc98-1-18-release~440 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=db57e8fc131e5f1507474bb1b38fa7179e494aa0;p=ghc-base.git [project @ 2003-11-23 12:23:49 by ralf] Added some trivial observers for type representations. --- diff --git a/Data/Typeable.hs b/Data/Typeable.hs index 2be2ae1..4c8050a 100644 --- a/Data/Typeable.hs +++ b/Data/Typeable.hs @@ -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