Make the runtime reflection API for names, modules, locations more systematic
Currently in base
we have
-
GHC.SrcLoc
: the data typeSrcLoc
containssrcLocPackage
andsrcLocModule
-
Data.Typeable.Internals
: the data typeTyCon
containstyConPackage
,tyConModule
andtyConName
. -
GHC.Generics
: the data typeDatatype
containsdataTypePackage
,dataTypeModule
anddataTypeName
-
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 typeStaticPtrInfo
containsspInfoPackageKey
,spInfoModuleName
,spInfoName
(allString
s). Oh, andspInfoSrcLoc :: (Int,Int)
too! -
GHC.Stack.ccSrcSpan :: Ptr CostCentre -> IO CString
stores 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?