moduleAgda.TypeChecking.Monad.ImportswhereimportControl.Monad.StateimportControl.Monad.ReaderimportData.MaybeimportData.Map(Map)importData.Set(Set)importqualifiedData.MapasMapimportqualifiedData.ListasListimportqualifiedData.SetasSetimportSystem.TimeimportAgda.Syntax.Abstract.NameimportqualifiedAgda.Syntax.Concrete.NameasCimportAgda.TypeChecking.Monad.BaseimportAgda.Utils.MonadaddImport::ModuleName->TCM()addImportm=modify$\s->s{stImportedModules=Set.insertm$stImportedModuless}addImportCycleCheck::C.TopLevelModuleName->TCMa->TCMaaddImportCycleCheckm=local$\e->e{envImportPath=m:envImportPathe}getImports::TCM(SetModuleName)getImports=getsstImportedModulesisImported::ModuleName->TCMBoolisImportedm=Set.memberm<$>getImportsgetImportPath::TCM[C.TopLevelModuleName]getImportPath=asksenvImportPathvisitModule::ModuleInfo->TCM()visitModulemi=modify$\s->s{stVisitedModules=Map.insert(toTopLevelModuleName$iModuleName$miInterfacemi)mi$stVisitedModuless}setVisitedModules::VisitedModules->TCM()setVisitedModulesms=modify$\s->s{stVisitedModules=ms}getVisitedModules::TCMVisitedModulesgetVisitedModules=getsstVisitedModulesisVisited::C.TopLevelModuleName->TCMBoolisVisitedx=gets$Map.memberx.stVisitedModulesgetVisitedModule::C.TopLevelModuleName->TCM(MaybeModuleInfo)getVisitedModulex=gets$Map.lookupx.stVisitedModulesgetDecodedModules::TCMDecodedModulesgetDecodedModules=getsstDecodedModulessetDecodedModules::DecodedModules->TCM()setDecodedModulesms=modify$\s->s{stDecodedModules=ms}preserveDecodedModules::TCMa->TCMapreserveDecodedModulestcm=doms<-getDecodedModulesa<-tcmsetDecodedModulesmsreturnagetDecodedModule::C.TopLevelModuleName->TCM(Maybe(Interface,ClockTime))getDecodedModulex=gets$Map.lookupx.stDecodedModulesstoreDecodedModule::Interface->ClockTime->TCM()storeDecodedModuleit=modify$\s->s{stDecodedModules=Map.insert(toTopLevelModuleName$iModuleNamei)(i,t)$stDecodedModuless}dropDecodedModule::C.TopLevelModuleName->TCM()dropDecodedModulex=modify$\s->s{stDecodedModules=Map.deletex$stDecodedModuless}withImportPath::[C.TopLevelModuleName]->TCMa->TCMawithImportPathpath=local$\e->e{envImportPath=path}-- | Assumes that the first module in the import path is the module we are-- worried about.checkForImportCycle::TCM()checkForImportCycle=dom:ms<-getImportPathwhen(m`elem`ms)$typeError$CyclicModuleDependency$dropWhile(/=m)$reverse(m:ms)