packages feed

module-management 0.16 → 0.16.1

raw patch · 7 files changed

+210/−2 lines, 7 files

Files

debian/changelog view
@@ -1,3 +1,9 @@+haskell-module-management (0.16.1) unstable; urgency=low++  * Add missing CLI files to extra-source-files list++ -- David Fox <dsf@seereason.com>  Fri, 16 Aug 2013 11:17:34 -0700+ haskell-module-management (0.16) unstable; urgency=low    * Use haskeline in the hmm program (Adam Vogt)
module-management.cabal view
@@ -1,5 +1,5 @@ Name:               module-management-Version:            0.16+Version:            0.16.1 Synopsis:           Clean up module imports, split and merge modules Description:        Clean up module imports, split and merge modules. Homepage:           http://src.seereason.com/module-management@@ -10,7 +10,7 @@ Stability:          experimental Build-type:         Simple Cabal-version:      >=1.8-Extra-Source-Files: testdata.tar.gz, debian/changelog+Extra-Source-Files: testdata.tar.gz, debian/changelog, scripts/CleanModules.hs, scripts/CLI/Cabal.hs, scripts/CLI/Cabal/Instances.hs, scripts/CLI/HaskelineTransAdapter.hs  Flag build-tests   Description: build the test executable
+ scripts/CLI/Cabal.hs view
@@ -0,0 +1,71 @@+{-# LANGUAGE ViewPatterns #-}+-- | Adjust contents of a cabal file to follow+-- rearrangements of the underlying modules+module CLI.Cabal (++    module CLI.Cabal,++    readPackageDescription,+    writeGenericPackageDescription,+    showGenericPackageDescription,+    ) where++import CLI.Cabal.Instances++import Control.Lens+import Distribution.PackageDescription+import Distribution.PackageDescription.Parse+import Distribution.PackageDescription.PrettyPrint+import GHC.Generics (Generic)+import GHC.Generics.Lens++import Distribution.ModuleName+++import qualified Language.Haskell.Modules+import Data.List+import Data.Maybe++import Language.Haskell.Modules.Common++import qualified Data.Set as S+++toMN = Language.Haskell.Modules.ModuleName . intercalate "." . components++fromMN (Language.Haskell.Modules.ModuleName x) =  fromString x++getModules pkgDesc = map toMN $ toListOf tinplate pkgDesc+getSrcDirs pkgDesc = hsSourceDirs =<< toListOf tinplate pkgDesc++-- merge :: Generic a => [ModuleName] -> ModuleName -> a -> a+merge (map fromMN -> old) (fromMN -> new) pkgDesc = pkgDesc & over tinplate  f+    where f ms = let n | any (`elem` old) ms = [new::ModuleName]+                        | otherwise = []+                 in n ++ filter (`notElem` old) ms++split (fromMN -> old) (map fromMN -> news) pkgDesc = pkgDesc & over tinplate f+    where f ms = concatMap (\m -> if (m::ModuleName) == old then news else [m]) ms++update moduleResults pkgDesc = pkgDesc & over tinplate (\x -> fn x (S.fromList x))+    where+    r = removals moduleResults+    a = additions moduleResults+    fn modules ms+        | S.size (ms `S.intersection` r) > 0 = filter (`S.notMember` r) modules+                                            ++ S.toList (a S.\\ ms)+        | otherwise = modules :: [ModuleName]++removals rs = S.fromList $ mapMaybe remove rs+    where+    remove (ToBeRemoved m _) = Just (fromMN m)+    remove (JustRemoved m _) = Just (fromMN m)+    remove _ = Nothing++additions rs = S.fromList $ mapMaybe add rs+    where+    add (ToBeCreated m _) = Just (fromMN m)+    add (JustCreated m _) = Just (fromMN m)+    add _ = Nothing++
+ scripts/CLI/Cabal/Instances.hs view
@@ -0,0 +1,94 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE DeriveGeneric #-}++module CLI.Cabal.Instances () where++import Data.List+import Data.Typeable+import Data.Version+import Distribution.Compiler+import Distribution.License+import Distribution.ModuleName+import Distribution.Package+import Distribution.Package+import Distribution.PackageDescription+import Distribution.System+import Distribution.Version+import GHC.Generics+import Language.Haskell.Extension++deriving instance Generic a => Generic (Condition a)+deriving instance Generic Arch+deriving instance Generic Benchmark+deriving instance Generic BenchmarkInterface+deriving instance Generic BenchmarkType+deriving instance Generic BuildInfo+deriving instance Generic BuildType+deriving instance Generic CompilerFlavor+deriving instance Generic ConfVar+deriving instance Generic Dependency+deriving instance Generic Executable+deriving instance Generic Extension+deriving instance Generic Flag+deriving instance Generic FlagName+deriving instance Generic GenericPackageDescription+deriving instance Generic KnownExtension+deriving instance Generic Language+deriving instance Generic Library+deriving instance Generic License+deriving instance Generic OS+deriving instance Generic PackageDescription+deriving instance Generic PackageIdentifier+deriving instance Generic PackageName+deriving instance Generic RepoKind+deriving instance Generic RepoType+deriving instance Generic SourceRepo+deriving instance Generic TestSuite+deriving instance Generic TestSuiteInterface+deriving instance Generic TestType+deriving instance Generic Version+deriving instance Generic VersionRange++deriving instance (Generic a, Generic b, Generic c) => Generic (CondTree a b c)++deriving instance Typeable3 CondTree+deriving instance Typeable1 Condition++deriving instance Typeable Arch+deriving instance Typeable Benchmark+deriving instance Typeable BenchmarkInterface+deriving instance Typeable BenchmarkType+deriving instance Typeable BuildInfo+deriving instance Typeable BuildType+deriving instance Typeable CompilerFlavor+deriving instance Typeable ConfVar+deriving instance Typeable Dependency+deriving instance Typeable Executable+deriving instance Typeable Extension+deriving instance Typeable Flag+deriving instance Typeable FlagName+deriving instance Typeable GenericPackageDescription+deriving instance Typeable KnownExtension+deriving instance Typeable Language+deriving instance Typeable Library+deriving instance Typeable License+deriving instance Typeable OS+deriving instance Typeable PackageDescription+deriving instance Typeable PackageIdentifier+deriving instance Typeable PackageName+deriving instance Typeable RepoKind+deriving instance Typeable RepoType+deriving instance Typeable SourceRepo+deriving instance Typeable TestSuite+deriving instance Typeable TestSuiteInterface+deriving instance Typeable TestType+deriving instance Typeable VersionRange++deriving instance Typeable ModuleName+instance Generic ModuleName where+    type Rep ModuleName = Rep [String]+    from = from . components+    to = fromString . intercalate "." . to
+ scripts/CLI/HaskelineTransAdapter.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE FlexibleInstances, FlexibleContexts, UndecidableInstances, RankNTypes #-}+-- | note clear if this is the right way to be able to use an+-- InputT (CleanT IO)@+module CLI.HaskelineTransAdapter () where+import System.Console.Haskeline.MonadException+import Control.Monad.Trans.Control+import Control.Monad+import Control.Monad.State+import Control.Monad.Base+import Control.Monad.Trans++instance (MonadBaseControl IO m, MonadIO m) => MonadException m where+   controlIO f = join $ liftBaseWith (\x -> (f (toRunIO x)))++toRunIO :: (MonadBaseControl b0 m) => RunInBase m IO -> RunIO m+toRunIO rb = RunIO (\a -> liftM restoreM (rb a))
+ scripts/CleanModules.hs view
@@ -0,0 +1,21 @@+#!/usr/bin/env runghc++module Main where++import Options.Applicative+import Control.Monad.Trans (MonadIO(liftIO))+import Language.Haskell.Modules (cleanImports, runCleanT)+import System.Directory (getDirectoryContents)+import System.Environment (getArgs)+import System.FilePath (takeExtension)++main = do+  args <- getArgs+  fs <- if null args then sourceFiles "." else return args+  cs <- runCleanT $ mapM cleanImports' fs+  print cs++cleanImports' fp = do (liftIO $ putStr "cleaning: " >> print fp) >> cleanImports fp++sourceFiles :: FilePath -> IO [FilePath]+sourceFiles fp = getDirectoryContents fp >>= return . filter ((".hs" ==) . takeExtension)
testdata.tar.gz view

binary file changed (534129 → 534129 bytes)