From 191ae58b730022a7b0ea198a47fd590f7e03b68d Mon Sep 17 00:00:00 2001 From: Ryan Trinkle Date: Tue, 4 Jul 2023 13:00:12 -0400 Subject: [PATCH] Remove unused file --- dep/reexportsToStubs.hs | 58 ----------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 dep/reexportsToStubs.hs diff --git a/dep/reexportsToStubs.hs b/dep/reexportsToStubs.hs deleted file mode 100644 index dff9971..0000000 --- a/dep/reexportsToStubs.hs +++ /dev/null @@ -1,58 +0,0 @@ -{-# LANGUAGE RecordWildCards #-} - -import Distribution.PackageDescription.Parsec -import Distribution.PackageDescription -import Distribution.Types.Library -import Distribution.Types.ModuleReexport -import Distribution.Verbosity -import Distribution.ModuleName (components) -import System.Environment (getArgs) -import System.Directory (createDirectoryIfMissing) -import System.FilePath ((), (<.>), joinPath, takeDirectory) -import Data.List.Split (splitOn) -import Data.List (intercalate) - --- Helper function to convert a module name to a file path -convertModuleToPath :: String -> FilePath -convertModuleToPath moduleName = "src" joinPath (splitOn "." moduleName) <.> "hs" - --- Function to write a file with the given module structure -writeModuleFile :: (String, String) -> IO () -writeModuleFile (originalModule, newModule) = do - let content = unlines - [ "module " ++ newModule ++ " (module X) where" - , "" - , "import " ++ originalModule ++ " as X" - ] - filePath = convertModuleToPath newModule - createDirectoryIfMissing True (takeDirectory filePath) - writeFile filePath content - -main :: IO () -main = do - args <- getArgs - case args of - [fileName] -> do - result <- parseCabalFile fileName - case result of - Left err -> putStrLn $ "Error: " ++ err - Right reexports -> mapM_ writeModuleFile reexports - _ -> putStrLn "Usage: cabal-file-parser " - -parseCabalFile :: FilePath -> IO (Either String [(String, String)]) -parseCabalFile filePath = do - result <- readGenericPackageDescription silent filePath - let maybeMainLib = case condLibrary result of - Just (CondNode lib _ _) -> Just lib - Nothing -> Nothing - subLibs = [lib | (_, CondNode lib _ _) <- condSubLibraries result] - libs = maybe subLibs (:subLibs) maybeMainLib - return $ case libs of - (lib:_) -> Right (extractReexportedModules lib) - [] -> Left "No library found in .cabal file." - -extractReexportedModules :: Library -> [(String, String)] -extractReexportedModules lib = - map (\ModuleReexport{..} -> (moduleNameString moduleReexportOriginalName, moduleNameString moduleReexportName)) (reexportedModules lib) - -moduleNameString = intercalate "." . components