moduleHint.Reflection(ModuleElem(..),Id,name,children,getModuleExports,)whereimportData.ListimportData.MaybeimportControl.Monad.TransimportHint.BaseimportqualifiedGHCimportqualifiedOutputableasGHC.O-- | An Id for a class, a type constructor, a data constructor, a binding, etctypeId=StringdataModuleElem=FunId|ClassId[Id]|DataId[Id]deriving(Read,Show,Eq)name::ModuleElem->Idname(Funf)=fname(Classc_)=cname(Datad_)=dchildren::ModuleElem->[Id]children(Fun_)=[]children(Class_ms)=mschildren(Data_dcs)=dcs-- | Gets an abstract representation of all the entities exported by the module.-- It is similar to the @:browse@ command in GHCi.getModuleExports::ModuleName->Interpreter[ModuleElem]getModuleExportsmn=doghc_session<-fromSessionStateghcSession--module_<-findModulemnmod_info<-mayFail$GHC.getModuleInfoghc_sessionmodule_exports<-liftIO$mapM(GHC.lookupNameghc_session)(GHC.modInfoExportsmod_info)--return(asModElemList$catMaybesexports)asModElemList::[GHC.TyThing]->[ModuleElem]asModElemListxs=concat[cs',ts',ds\\(concatMap(mapFun.children)ts'),fs\\(concatMap(mapFun.children)cs')]where(cs,ts,ds,fs)=([asModElemc|c@GHC.AClass{}<-xs],[asModElemt|t@GHC.ATyCon{}<-xs],[asModElemd|d@GHC.ADataCon{}<-xs],[asModElemf|f@GHC.AnId{}<-xs])cs'=[Classn$filter(alsoInfs)ms|Classnms<-cs]ts'=[Datat$filter(alsoInds)dcs|Datatdcs<-ts]alsoInes=(`elem`(mapnamees))asModElem::GHC.TyThing->ModuleElemasModElem(GHC.AnIdf)=Fun$getUnqualNamefasModElem(GHC.ADataCondc)=Fun$getUnqualNamedcasModElem(GHC.ATyContc)=Data(getUnqualNametc)(mapgetUnqualName$GHC.tyConDataConstc)asModElem(GHC.AClassc)=Class(getUnqualNamec)(mapgetUnqualName$GHC.classMethodsc)getUnqualName::GHC.NamedThinga=>a->StringgetUnqualName=GHC.O.showSDocUnqual.GHC.pprParenSymName