Make the runtime reflection API for names, modules, locations more systematic
Currently in base we have
-
GHC.SrcLoc: the data typeSrcLoccontainssrcLocPackageandsrcLocModule -
Data.Typeable.Internals: the data typeTyConcontainstyConPackage,tyConModuleandtyConName. -
GHC.Generics: the data typeDatatypecontainsdataTypePackage,dataTypeModuleanddataTypeName -
Data.Data: the data typeDataType(yes the capitalisation differs!) contains a fieldtycon :: String, and there are functionstyconModule :: String -> String, andtyconUQname :: String -> String, for parsing that string and extracting the module name and tycon name. -
GHC.StaticPtr: the data typeStaticPtrInfocontainsspInfoPackageKey,spInfoModuleName,spInfoName(allStrings). Oh, andspInfoSrcLoc :: (Int,Int)too! -
GHC.Stack.ccSrcSpan :: Ptr CostCentre -> IO CStringstores a source location in a C structure, and returns it as aCString.
This is madness! Six different representations for the same information in one package!
Let's fix this by defining some shared data types, for
-
Module=ModuleName+ package -
Entity=Module+ unqualified name
There would be a tiresome changeover period; but Typeable and StaticPtr are in flux anyway.
Would anyone be willing to lead on this?
Edited by Simon Peyton Jones