sR      !"#$%&'()*+,-./01234567 8 9 : ; < = > ? @ A B C D E F G H I J KLMNOPQ Safe-Inferred Adapted from  $ to work in MonadCatchIO instances. *Temp directory to create the directory in Directory name template. See  openTempFile. $Callback that can use the directory RR Safe-Inferred BReplace the file at path with the given text, moving the original C to the location returned by passing path to backup. If backup is  the identity function you're going to have a bad time.        Safe-InferredS(Convert a compare function into an (==) Combine sortBy and groupBy %Construct the base of a module path. SSNoneT?A version of lines that preserves the presence or absence of a  terminating newline <Update a SrcLoc to move it from l past the string argument. Build a tree of SrcSpanInfo )UVWXYZ[\T]^_`abcdefghijklmnopq  (UVWXYZ[\T]^_`abcdefghijklmnopqNonewFold over the declared members - e.g. the method names of a class declaration, the constructors of a data declaration. ADo a fold over the names that are declared in a declaration (not @ every name that appears, just the ones that the declaration is  causing to exist - what's the word for that?. Reify!)  !rs"#$tuvwxyz{|}~ !"#$ !"#$ !rs"#$tuvwxyz{|}~ Safe-Inferred()Like diff, but ignores extra files in b. *4Find the paths of all the files below the directory top. +>Convenience function for building the moduVerse, searches for = modules in a directory hierarchy. FIXME: This should be in D MonadClean and use the value of sourceDirs to remove prefixes from B the module paths. And then it should look at the module text to % see what the module name really is. %&'()*+%&'()*+%&'()+*%&'()*+ Safe-Inferred ,-./01234 ,-./01234 ,-./01234,-./01234NoneBThis contains the information required to run the state monad for $ import cleaning and module spliting/ mergeing. 4Location of the temporary directory for ghc output. =None of the operations that modify the modules will actually  be performed if this is ture. 7Increase or decrease the amount of progress reporting. >Supply compiler extensions. These are provided to the module < parser and to GHC when it does the minimal import dumping. Extra flags to pass to GHC. 5Top level directories to search for source files and < imports. These directories would be the value used in the = hs-source-dirs parameter of a cabal file, and passed to ghc  via the -i option. 9The set of modules that splitModules and catModules will * check for imports of symbols that moved. 8Paths added to this list are removed as the state monad  finishes. 8If true, remove any import that became empty due to the ; clean. THe import might still be required because of the ? instances it contains, but usually it is not. Note that this ; option does not affect imports that started empty and end  empty. ;For testing, do not run cleanImports on the results of the ( splitModule and catModules operations. 6ACreate the environment required to do import cleaning and module  splitting/5merging. This environment, StateT Params m a, is an  instance of MonadClean. Run * with the extensions stored in the state. Run * with the extensions stored in the state. FSearch the path directory list for a source file that already exists. ISearch the path directory list, preferring an already existing file, but O if there is none construct one using the first element of the directory list. AIt is tempting to put import cleaning into these operations, but C that needs to be done after all of these operations are completed D so that all the compiles required for import cleaning succeed. On B the other hand, we might be able to maintain the moduVerse here. =Modify the set of modules whose imports will be updated when A modules are split or merged. No default, it is an error to run 8 splitModules or catModules without first setting this. 56565 6 None <The spans returned by haskell-src-exts may put comments and C whitespace in the suffix string of a declaration, we want them in @ the prefix string of the following declaration where possible. 9=Given the result of parseModuleWithComments and the original @ module text, this does a fold over the parsed module contents, B calling the seven argument functions in order. Each function is E passed the AST value, the text of the space and comments leading up > to the element, and the text for the element. Note that not  everything passed to the pre# argument of the functions will be ' comments and space - for example, the module keyword will be 8 passed in the pre argument to the ModuleName function. :Do just the header portion of 9. ;Do just the exports portion of 9. <Do just the imports portion of 9. =$Do just the declarations portion of 9. >LThis can be passed to foldModule to include the original text in the result ? Similar to >4, but used for the two argument separator functions @LThis can be passed to foldModule to omit the original text from the result. A Similar to @4, but used for the two argument separator functions '789 ,Receives the space before the first pragma. jCalled once for each pragma. In this and the similar arguments below, the three string arguments contain g the comments and space preceding the construct, the text of the construct and the space following it. Called with the module name. ACalled with the warning text between module name and export list 'Called with the export list open paren "Called with each export specifier ,Called with the export list close paren and where keyword #Called with each import declarator 'Called with each top level declaration 4Called with comments following the last declaration Parsed module Fold initialization value Result :;<=>?@A 789:;<=>?@A 879:;<=>?@A!789:;<=>?@A NoneB'Clean up the imports of a source file. MRun ghc with -ddump-minimal-imports and capture the resulting .imports file. BParse the import list generated by GHC, parse the original source @ file, and if all goes well insert the new imports into the old ? source file. We also need to modify the imports of any names B that are types that appear in standalone instance derivations so ! their members are imported too. AIf all the parsing went well and the new imports differ from the 3 old, update the source file with the new imports. @Compare the old and new import sets and if they differ clip out : the imports from the sourceText and insert the new ones. 2Final touch-ups - sort and merge similar imports. ACompare the two import declarations ignoring the things that are @ actually being imported. Equality here indicates that the two  imports could be merged. CBe careful not to try to compare objects with embeded SrcSpanInfo. B<If true, imports that turn into empty lists will be removed BB B NoneC>Merge the declarations from several modules into a single new > one, updating the imports of the modules in the moduVerse to B reflect the change. It *is* permissable to use one of the input B modules as the output module. Note that circular imports can be  created by this operation. 8Create the output module, the destination of the merge. >Update a module that does not participate in the merge - this : involves changing imports and exports of merged modules.  (Shouldn'$t this also fix qualified symbols?) 6Grab the declarations out of the old modules, fix any 6 qualified symbol references, prettyprint and return. CBug: If we cat two modules A and B, and A imported a symbol from B 5 and referenced that symbol with a qualifier from an as import, the 7 as qualifier needs to be changed to a full qualifier. AIn terms of what is going on right here, if m imports any of the  modules in oldmap with an as" qualifier, identifiers using the  module name in the as! qualifier must use new instead. Change any ModuleName in old to new. Note that this will > probably mess up the location information, so the result (if ; different from the original) should be prettyprinted, not  exactPrinted. CCC CNone NoneI8Do splitModuleBy with a custom symbol to module mapping JMDo splitModuleBy with the default symbol to module mapping (was splitModule) Split each of a module'*s declarations into a new module. Update G the imports of all the modules in the moduVerse to reflect the split. ( For example, if you have a module like   " module Start (a, b, (.+.)) where  import  a = 1 + a  b = 2  c = 3  c' = 4  (.+.) = b + c After running  splitModule the Start module will be gone. The  a and b& symbols will be in new modules named Start.A and  Start.B%. Because they were not exported by Start, the c and  c', symbols will both be in a new module named Start.Internal.C.  And the .+." symbol will be in a module named  Start.OtherSymbols-. Note that this module needs to import new  Start.A and Start.Internal.C modules. CIf we had imported and then re-exported a symbol in Start it would  go into a module named Start.ReExported. Any instance declarations  would go into Start.Instances. 8Create the set of module results implied by the split - D creations, removals, and modifications. This includes the changes > to the imports in modules that imported the original module. JUpdate the imports to reflect the changed module names in symbolToModule. ,What module should this symbol be moved to? 9Build an import of the symbols created by a declaration. DEFGHIJDEFGHIJDHGFEIJDHGFEIJNone  NoneK=Modify the set of modules whose imports will be updated when A modules are split or merged. No default, it is an error to run 8 splitModules or catModules without first setting this. L<If this flag is set, imports that become empty are removed. C Sometimes this will lead to errors, specifically when an instance D in the removed import that was required is no longer be available. . (Note that this reflects a limitation of the  -ddump-minimal-imports, option of GHC.) If this happens this flag @ should be set. Note that an import that is already empty when   cleanImports4 runs will never be removed, on the assumption that A it was placed there only to import instances. Default is True. M@Modify the list of directories that will be searched for source @ files, in a similar way to the Hs-Source-Dirs field in a cabal  file. Default is ["."]. N;Modify the extra extensions passed to the compiler and the ' parser. Default value is the list in  . O:Modify the list of extra flags passed to GHC. Default is []. P:Controls whether file updates will actually be performed. C Default is False. (I recommend running in a directory controlled ' by a version control system so you don't have to worry about this.) Q?If TestMode is turned on no import cleaning will occur after a " split or cat. Default is False. KLMNOPQ 56KLMNOPQ 56KLMNOPQKLMNOPQNoneJCan we handle a Main module in a file named something other than Main.hs? Preserve imports with a hiding clause ;Preserve imports used by a standalone deriving declaration Comment at EOF NoneNone*+0169:;<=>?@ABCIJKLMNOPQBIJC+*  !"#$%&'()*+,-./0123456789/:;<=>?@ABCDEFGHIJK L M N O P Q R S T U V W X Y Z [ \ ] ^ _`abcdefghijklmnopqrstuvwxyz{|}~rstu`    j k l n o p  /rst /rtvutuv/rs/module-management-0.11"Language.Haskell.Modules.Util.Temp#Language.Haskell.Modules.Util.DryIOLanguage.Haskell.Modules.Common$Language.Haskell.Modules.Util.SrcLoc%Language.Haskell.Modules.Util.Symbols"Language.Haskell.Modules.Util.Test!Language.Haskell.Modules.Util.QIOLanguage.Haskell.Modules.ParamsLanguage.Haskell.Modules.Fold Language.Haskell.Modules.ImportsLanguage.Haskell.Modules.MergeLanguage.Haskell.Modules.SplitSystem.IO.TempwithTempDirectory!Language.Haskell.Modules.Internal Tests.Merge Tests.FoldLanguage.Haskell.Exts.ParserdefaultParseMode Tests.Imports Tests.SplitLanguage.Haskell.Modules MonadDryRundryputDry tildeBackupnoBackup readFileMayberemoveFileIfPresentreplaceFileIfDifferent replaceFilecreateDirectoryIfMissing writeFiledryIOdryIO'groupBy'mapNamesmodulePathBasewithCurrentDirectory HasSpanInfospanInfosrcSpansrcLocendLoc textEndLocincreaseSrcLocteststextSpan srcPairTextmakeTree FoldMembers foldMembers FoldDeclared foldDeclaredsymbolsexportsimports repoModules logicModulesdiffdiff'rsync findPaths findModulesMonadVerbosity getVerbosity putVerbositymodifyVerbosityquietlynoisilyqIOqPutStr qLnPutStr MonadClean runMonadClean ModuleMap ModuleInfo foldModule foldHeader foldExports foldImports foldDeclsechoecho2ignoreignore2 cleanImports mergeModulesDeclNameInstance ReExportedInternalExported splitModulesplitModuleDeclsmodifyModuVersemodifyRemoveEmptyImportsmodifySourceDirsmodifyExtensions modifyHsFlags modifyDryRunmodifyTestModeignoringIOErrorstoEqlines'Decl ImportDecl ExportSpecExportSpecList WarningText ModuleName ModulePragma ModuleHeadtest1test2test3test4test5covers coveredBy$fDefaultSrcSpan$fDefaultSrcSpanInfo$fDefaultSrcLoc$fHasSpanInfoSrcSpanInfo$fHasSpanInfoDecl$fHasSpanInfoImportDecl$fHasSpanInfoExportSpec$fHasSpanInfoExportSpecList$fHasSpanInfoWarningText$fHasSpanInfoModulePragma$fHasSpanInfoModuleName$fHasSpanInfoModuleHead$fHasSpanInfoTree$fHasSpanInfoSrcSpanmembersjusts$fFoldDeclaredGadtDecl$fFoldDeclaredFieldDecl$fFoldDeclaredConDecl$fFoldDeclaredQualConDecl$fFoldMembersDecl$fFoldDeclaredExportSpec$fFoldDeclaredImportSpec$fFoldDeclaredName$fFoldDeclaredRPat$fFoldDeclaredPatField$fFoldDeclaredPat$fFoldDeclaredQName$fFoldDeclaredMatch$fFoldDeclaredInstHead$fFoldDeclaredClassDecl$fFoldDeclaredDeclHead$fFoldDeclaredDecl qPutStrLnParams scratchDirdryRun verbosity extensionshsFlags sourceDirs moduVersejunkremoveEmptyImportstestModeparseFileWithCommentshaskell-src-exts-1.13.5Language.Haskell.Exts.Annotated parseFileparseFileWithModefindSourcePath modulePathdoResult ModuleResultCreatedModifiedRemoved Unchanged getParams putParams modifyParams markForDelete$fMonadDryRunm$fMonadVerbositym$fMonadCleanStateT adjustSpansStloc_text_comms_sps_SpansspansModulefixSpan setSpanEnd setSpanStart$fSpansWarningText$fSpansModuleName $fSpansDecl$fSpansImportDecl$fSpansModulePragma$fSpansExportSpec$fSpansExportSpecList$fSpansModuleHead $fSpansModule dumpImports checkImports updateSourcereplaceImports fixNewImportsimportMergable unModuleNamestandaloneDerivingTypes compareSpecs equalSpecs nameStringdoOutputdoOther moduleDecls fixReferencesdoModulefixModuleExportfixModuleImport mergeExportsupdateModuleContentsExports moduleImports loadModules loadModule splitModuleBydoSplit updateImportsdefaultSymbolToModule toImportDecl isReExported parseModuledeclaredexportednewModuleNames declName'doSepssymbolToModuleMapsetAny setMapMaybesetMapM_test1binttest5btest6test7split1split2asplit2bsplit4split4b