[Template-haskell] RE: Question regarding template Haskell

Simon Peyton-Jones simonpj at microsoft.com
Thu Sep 18 09:28:31 EDT 2003


| typeOf :: a -> TypeRep
| 
| rType :: a -> Typ (or :: a -> Type in the new THSyntax definitions).
| 
| The two are conceptually the same, but they return you different data
| types... 
| Come to think of it, now that we have a concrete syntax, perhaps it'd
| be worth merging the definitions of THSyntax's Type and Data.Dynamic's
| TypeRep?  They're conceptually the same thing, but with different data
| representations ...

That would make perfect sense.  The only tricky bit is that TypeRep is
hash-cons'd so that we can guaranteed to compare TypeReps in constant
time.   It would probably do no harm to hash-cons Typ's too, I guess.

With Ralf Laemmel I've been working on a sort of extension to the
Typeable class that gives more info for algebraic data types.  The
module signature is below.  We're working on a paper. 

Let's muse on this.

Simon


module Data.Generics.Basics ( 

	-- * The Data class for processing constructor applications
	Data( 
		gfoldl,		-- :: ... -> a -> c a
		toConstr, 	-- :: a -> Constr
		fromConstr,	-- :: Constr -> a
		dataTypeOf	-- :: a -> DataType
		
            ),

	-- * Constructor representations
	Constr,		-- abstract, instance of: Eq, Show
	ConIndex,	-- alias for Int, start at 1
	Fixity(..),	-- instance of: Eq, Show
	DataType,	-- abstract, instance of: Show

	-- * Constructing constructor representations
	mkConstr,   	-- :: ConIndex -> String -> Fixity -> Constr
	mkDataType,	-- :: [Constr] -> DataType

	-- * Observing constructor representations
	conString,	-- :: Constr -> String
	conFixity,	-- :: Constr -> Fixity
	conIndex,	-- :: Constr -> ConIndex
	stringCon,	-- :: DataType -> String -> Maybe Constr
	indexCon,	-- :: DataType -> ConIndex -> Constr
	maxConIndex,	-- :: DataType -> ConIndex
	dataTypeCons, 	-- :: DataType -> [Constr]



More information about the template-haskell mailing list