From db57e8fc131e5f1507474bb1b38fa7179e494aa0 Mon Sep 17 00:00:00 2001 From: ralf Date: Sun, 23 Nov 2003 12:23:49 +0000 Subject: [PATCH] [project @ 2003-11-23 12:23:49 by ralf] Added some trivial observers for type representations. --- Data/Typeable.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 -- 1.7.10.4