module-management 0.20.2.1 → 0.20.3
raw patch · 10 files changed
+199/−18 lines, 10 filesdep ~haskell-src-exts
Dependency ranges changed: haskell-src-exts
Files
- Language/Haskell/Modules/Imports.hs +57/−1
- Language/Haskell/Modules/Merge.hs +4/−0
- Language/Haskell/Modules/Params.hs +4/−1
- Language/Haskell/Modules/Split.hs +4/−1
- Language/Haskell/Modules/Util/SrcLoc.hs +16/−0
- Language/Haskell/Modules/Util/Symbols.hs +69/−0
- changelog +14/−0
- module-management.cabal +4/−4
- scripts/CLI.hs +10/−6
- scripts/CLI/Cabal/Instances.hs +17/−5
Language/Haskell/Modules/Imports.hs view
@@ -18,6 +18,9 @@ import Data.Set as Set (empty, fromList, member, Set, singleton, toList, union, unions) import Language.Haskell.Exts.Annotated.Simplify as S (sImportDecl, sImportSpec, sModuleName, sName) import qualified Language.Haskell.Exts.Annotated.Syntax as A (Decl(DerivDecl), ImportDecl(..), ImportSpec(..), ImportSpecList(ImportSpecList), InstHead(..), Module(..), ModuleHead(..), ModuleName(..), QName(..), Type(..))+#if MIN_VERSION_haskell_src_exts(1,16,0)+import qualified Language.Haskell.Exts.Annotated.Syntax as A (InstRule(..))+#endif import Language.Haskell.Exts.Pretty (defaultMode, PPHsMode(layout), PPLayout(PPInLine), prettyPrintWithMode) import Language.Haskell.Exts.SrcLoc (SrcLoc(..), SrcSpanInfo) import qualified Language.Haskell.Exts.Syntax as S (ImportDecl(importLoc, importModule, importSpecs), ModuleName(..), Name(..))@@ -246,19 +249,31 @@ else s where n = case s of+#if MIN_VERSION_haskell_src_exts(1,16,0)+ (A.IVar _ _ x) -> x+#else (A.IVar _ x) -> x+#endif (A.IAbs _ x) -> x (A.IThingAll _ x) -> x (A.IThingWith _ x _) -> x s' = case s of+#if MIN_VERSION_haskell_src_exts(1,16,0)+ (A.IVar l _ x) -> A.IThingAll l x+#else (A.IVar l x) -> A.IThingAll l x+#endif (A.IAbs l x) -> A.IThingAll l x (A.IThingWith l x _) -> A.IThingAll l x (A.IThingAll _ _) -> s -- Eliminate imports that became empty -- importPred :: ImportDecl -> Bool+#if MIN_VERSION_haskell_src_exts(1,16,0)+ importPred (A.ImportDecl _ mn _ _ _ _ _ (Just (A.ImportSpecList _ _ []))) =+#else importPred (A.ImportDecl _ mn _ _ _ _ (Just (A.ImportSpecList _ _ []))) =+#endif not remove || maybe False (isEmptyImport . A.importSpecs) (find ((== (unModuleName mn)) . unModuleName . A.importModule) oldImports) where isEmptyImport (Just (A.ImportSpecList _ _ [])) = True@@ -273,6 +288,46 @@ standaloneDerivingTypes (ModuleInfo (A.XmlHybrid _ _ _ _ _ _ _ _ _) _ _ _) = error "standaloneDerivingTypes A.XmlHybrid" standaloneDerivingTypes (ModuleInfo (A.Module _ _ _ _ decls) _ _ _) = unions (map derivDeclTypes decls)+#if MIN_VERSION_haskell_src_exts(1,16,0)++-- | Collect the declared types of a standalone deriving declaration.+class DerivDeclTypes a where+ derivDeclTypes :: a -> Set (Maybe S.ModuleName, S.Name)++instance DerivDeclTypes (A.Decl l) where+ derivDeclTypes (A.DerivDecl _ _ x) = derivDeclTypes x+ derivDeclTypes _ = empty++instance DerivDeclTypes (A.InstRule l) where+ derivDeclTypes (A.IRule _ _ _ x) = derivDeclTypes x+ derivDeclTypes (A.IParen _ x) = derivDeclTypes x++instance DerivDeclTypes (A.InstHead l) where+ derivDeclTypes (A.IHCon _ _) = empty+ derivDeclTypes (A.IHParen _ x) = derivDeclTypes x+ derivDeclTypes (A.IHInfix _ x _op) = derivDeclTypes x+ derivDeclTypes (A.IHApp _ x y) = union (derivDeclTypes x) (derivDeclTypes y)++instance DerivDeclTypes (A.Type l) where+ derivDeclTypes (A.TyForall _ _ _ x) = derivDeclTypes x -- qualified type+ derivDeclTypes (A.TyFun _ x y) = union (derivDeclTypes x) (derivDeclTypes y) -- function type+ derivDeclTypes (A.TyTuple _ _ xs) = unions (map derivDeclTypes xs) -- tuple type, possibly boxed+ derivDeclTypes (A.TyList _ x) = derivDeclTypes x -- list syntax, e.g. [a], as opposed to [] a+ derivDeclTypes (A.TyApp _ x y) = union (derivDeclTypes x) (derivDeclTypes y) -- application of a type constructor+ derivDeclTypes (A.TyVar _ _) = empty -- type variable+ derivDeclTypes (A.TyCon _ (A.Qual _ m n)) = singleton (Just (sModuleName m), sName n) -- named type or type constructor+ -- Unqualified names refer to imports without "qualified" or "as" values.+ derivDeclTypes (A.TyCon _ (A.UnQual _ n)) = singleton (Nothing, sName n)+ derivDeclTypes (A.TyCon _ _) = empty+ derivDeclTypes (A.TyParen _ x) = derivDeclTypes x -- type surrounded by parentheses+ derivDeclTypes (A.TyInfix _ x _op y) = union (derivDeclTypes x) (derivDeclTypes y) -- infix type constructor+ derivDeclTypes (A.TyKind _ x _) = derivDeclTypes x -- type with explicit kind signature+ derivDeclTypes (A.TyParArray _ x) = derivDeclTypes x+ derivDeclTypes (A.TyPromoted _ _) = empty+ derivDeclTypes (A.TyEquals _ _ _) = empty -- a ~ b, not clear how this related to standalone deriving+ derivDeclTypes (A.TySplice _ _) = empty+ derivDeclTypes (A.TyBang _ _ x) = derivDeclTypes x+#else where -- derivDeclTypes :: Decl -> Set (Maybe S.ModuleName, S.Name) derivDeclTypes (A.DerivDecl _ _ (A.IHead _ _ xs)) = unions (map derivDeclTypes' xs) -- Just (moduleName, sName x)@@ -287,12 +342,13 @@ derivDeclTypes' (A.TyApp _ x y) = union (derivDeclTypes' x) (derivDeclTypes' y) -- application of a type constructor derivDeclTypes' (A.TyVar _ _) = empty -- type variable derivDeclTypes' (A.TyCon _ (A.Qual _ m n)) = singleton (Just (sModuleName m), sName n) -- named type or type constructor- -- Unqualified names refer to imports without "qualified" or "as" values.+ -- Unqualified names refer to imports without "qualified" or "as" values. derivDeclTypes' (A.TyCon _ (A.UnQual _ n)) = singleton (Nothing, sName n) derivDeclTypes' (A.TyCon _ _) = empty derivDeclTypes' (A.TyParen _ x) = derivDeclTypes' x -- type surrounded by parentheses derivDeclTypes' (A.TyInfix _ x _op y) = union (derivDeclTypes' x) (derivDeclTypes' y) -- infix type constructor derivDeclTypes' (A.TyKind _ x _) = derivDeclTypes' x -- type with explicit kind signature+#endif -- | Compare the two import declarations ignoring the things that are -- actually being imported. Equality here indicates that the two
Language/Haskell/Modules/Merge.hs view
@@ -141,7 +141,11 @@ -- Looking at an import, augment the map with the "as" name of a -- qualified import. module and that module's info. qualifiedImportName :: A.ImportDecl l -> Maybe S.ModuleName+#if MIN_VERSION_haskell_src_exts(1,16,0)+ qualifiedImportName (A.ImportDecl _ m _ _ _ _ (Just a) _specs) =+#else qualifiedImportName (A.ImportDecl _ m _ _ _ (Just a) _specs) =+#endif case elem (sModuleName m) inNames of True -> Just (sModuleName a) _ -> Nothing
Language/Haskell/Modules/Params.hs view
@@ -1,5 +1,5 @@ -- | Functions to control the state variables of 'MonadClean'.-{-# LANGUAGE FlexibleContexts, FlexibleInstances, OverloadedStrings, PackageImports, ScopedTypeVariables, UndecidableInstances #-}+{-# LANGUAGE CPP, FlexibleContexts, FlexibleInstances, OverloadedStrings, PackageImports, ScopedTypeVariables, UndecidableInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Language.Haskell.Modules.Params ( Params(Params, dryRun, extraImports, hsFlags, junk, moduVerse,@@ -149,6 +149,9 @@ , importModule = i , importQualified = False , importSrc = False+#if MIN_VERSION_haskell_src_exts(1,16,0)+ , importSafe = False+#endif , importPkg = Nothing , importAs = Nothing , importSpecs = Just (False, []) }
Language/Haskell/Modules/Split.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ScopedTypeVariables, TupleSections #-}+{-# LANGUAGE CPP, ScopedTypeVariables, TupleSections #-} {-# OPTIONS_GHC -Wall -fno-warn-orphans #-} module Language.Haskell.Modules.Split ( splitModule@@ -366,6 +366,9 @@ S.importModule = S.ModuleName "Main", S.importQualified = False, S.importSrc = False,+#if MIN_VERSION_haskell_src_exts(1,16,0)+ S.importSafe = False, -- ?+#endif S.importPkg = Nothing, S.importAs = Nothing, S.importSpecs = Just (False, [])}
Language/Haskell/Modules/Util/SrcLoc.hs view
@@ -83,14 +83,22 @@ spanInfo (A.ExportSpecList x _) = x instance HasSpanInfo ExportSpec where+#if MIN_VERSION_haskell_src_exts(1,16,0)+ spanInfo (A.EVar x _ _) = x+#else spanInfo (A.EVar x _) = x+#endif spanInfo (A.EAbs x _) = x spanInfo (A.EThingAll x _) = x spanInfo (A.EThingWith x _ _) = x spanInfo (A.EModuleContents x _) = x instance HasSpanInfo ImportDecl where+#if MIN_VERSION_haskell_src_exts(1,16,0)+ spanInfo (A.ImportDecl x _ _ _ _ _ _ _) = x+#else spanInfo (A.ImportDecl x _ _ _ _ _ _) = x+#endif instance HasSpanInfo Decl where spanInfo (A.TypeDecl l _ _) = l@@ -109,7 +117,11 @@ spanInfo (A.SpliceDecl l _) = l spanInfo (A.TypeSig l _ _) = l spanInfo (A.FunBind l _) = l+#if MIN_VERSION_haskell_src_exts(1,16,0)+ spanInfo (A.PatBind l _ _ _) = l+#else spanInfo (A.PatBind l _ _ _ _) = l+#endif spanInfo (A.ForImp l _ _ _ _ _) = l spanInfo (A.ForExp l _ _ _ _) = l spanInfo (A.RulePragmaDecl l _) = l@@ -123,7 +135,11 @@ spanInfo (A.SpecSig l _ _) = l #endif spanInfo (A.SpecInlineSig l _ _ _ _) = l+#if MIN_VERSION_haskell_src_exts(1,16,0)+ spanInfo (A.InstSig l _) = l+#else spanInfo (A.InstSig l _ _) = l+#endif spanInfo (A.AnnPragma l _) = l instance HasSpanInfo SrcSpanInfo where
Language/Haskell/Modules/Util/Symbols.hs view
@@ -15,6 +15,10 @@ import Language.Haskell.Exts.Annotated.Simplify (sName) import qualified Language.Haskell.Exts.Annotated.Syntax as A (ClassDecl(..), ConDecl(..), Decl(..), DeclHead(..), ExportSpec(..), FieldDecl(..), GadtDecl(..), ImportSpec(..), InstHead(..), Match(..), Name, Pat(..), PatField(..), QName(..), QualConDecl(..), RPat(..)) import qualified Language.Haskell.Exts.Syntax as S (CName(..), ExportSpec(..), ImportSpec(..), Name(..), QName(..))+#if MIN_VERSION_haskell_src_exts(1,16,0)+import qualified Language.Haskell.Exts.Annotated.Syntax as A (InstRule(..))+import qualified Language.Haskell.Exts.Syntax as S (Namespace(..))+#endif -- | Do a fold over the names that are declared in a declaration (not -- every name that appears, just the ones that the declaration is@@ -25,6 +29,9 @@ instance FoldDeclared (A.Decl a) where foldDeclared f r (A.TypeDecl _ x _t) = foldDeclared f r x -- type x = ... foldDeclared f r (A.TypeFamDecl _ x _k) = foldDeclared f r x -- data family x = ...+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.ClosedTypeFamDecl _ x _k _ts) = foldDeclared f r x -- data family x = ...+#endif foldDeclared f r (A.DataDecl _ _ _ x _ _) = foldDeclared f r x -- data/newtype _ x = ... foldDeclared f r (A.GDataDecl _ _ _ x _ _ _) = foldDeclared f r x foldDeclared f r (A.DataFamDecl _ _ x _) = foldDeclared f r x@@ -39,7 +46,11 @@ foldDeclared f r (A.SpliceDecl _ _) = f Nothing r -- template haskell splice declaration foldDeclared f r (A.TypeSig _ xs _) = foldl (foldDeclared f) r xs foldDeclared f r (A.FunBind _ xs) = foldl (foldDeclared f) r xs+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.PatBind _ x _ _) = foldDeclared f r x+#else foldDeclared f r (A.PatBind _ x _ _ _) = foldDeclared f r x+#endif foldDeclared _f _r (A.ForImp _ _ _ _ _ _) = error "Unimplemented FoldDeclared instance: ForImp" foldDeclared _ _r (A.ForExp _ _ _ _ _) = error "Unimplemented FoldDeclared instance: ForExp" foldDeclared f r (A.RulePragmaDecl _ _) = f Nothing r@@ -53,22 +64,48 @@ foldDeclared f r (A.SpecSig _ x _) = foldDeclared f r x #endif foldDeclared f r (A.SpecInlineSig _ _ _ x _) = foldDeclared f r x+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.InstSig _ x) = foldDeclared f r x+ foldDeclared f r (A.MinimalPragma _ _) = f Nothing r+#else foldDeclared f r (A.InstSig _ _ x) = foldDeclared f r x+#endif foldDeclared f r (A.AnnPragma _ _) = f Nothing r instance FoldDeclared (A.DeclHead a) where+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.DHead _ x) = foldDeclared f r x+ foldDeclared f r (A.DHApp _ x _) = foldDeclared f r x+ foldDeclared f r (A.DHInfix _ _ x) = foldDeclared f r x+#else foldDeclared f r (A.DHead _ x _) = foldDeclared f r x foldDeclared f r (A.DHInfix _ _ x _) = foldDeclared f r x+#endif foldDeclared f r (A.DHParen _ x) = foldDeclared f r x instance FoldDeclared (A.ClassDecl a) where foldDeclared f r (A.ClsDecl _ x) = foldDeclared f r x -- ordinary declaration foldDeclared f r (A.ClsDataFam _ _ x _) = foldDeclared f r x -- declaration of an associated data type foldDeclared f r (A.ClsTyFam _ x _) = foldDeclared f r x -- declaration of an associated type synonym foldDeclared _ r (A.ClsTyDef _ _ _) = r -- default choice for an associated type synonym+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.ClsDefSig _ x _) = foldDeclared f r x -- default signature+#endif instance FoldDeclared (A.InstHead a) where+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.IHCon _ x) = foldDeclared f r x+ foldDeclared f r (A.IHApp _ x _) = foldDeclared f r x+ -- foldDeclared f r (A.IHead _ x _) = foldDeclared f r x+ foldDeclared f r (A.IHInfix _ _ x) = foldDeclared f r x+#else foldDeclared f r (A.IHead _ x _) = foldDeclared f r x foldDeclared f r (A.IHInfix _ _ x _) = foldDeclared f r x+#endif foldDeclared f r (A.IHParen _ x) = foldDeclared f r x+#if MIN_VERSION_haskell_src_exts(1,16,0)+instance FoldDeclared (A.InstRule a) where+ foldDeclared f r (A.IRule _ _ _ x) = foldDeclared f r x+ foldDeclared f r (A.IParen _ x) = foldDeclared f r x+#endif instance FoldDeclared (A.Match a) where foldDeclared f r (A.Match _ x _ _ _) = foldDeclared f r x foldDeclared f r (A.InfixMatch _ _ x _ _ _) = foldDeclared f r x@@ -79,8 +116,12 @@ foldDeclared _ r (A.Special _ _) = r instance FoldDeclared (A.Pat a) where foldDeclared f r (A.PVar _ x) = foldDeclared f r x -- variable+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared _ r (A.PLit _ _ _) = r -- literal constant+#else foldDeclared _ r (A.PLit _ _) = r -- literal constant foldDeclared f r (A.PNeg _ x) = foldDeclared f r x -- negated pattern+#endif foldDeclared f r (A.PNPlusK _ x _) = foldDeclared f r x -- n+k pattern foldDeclared f r (A.PInfixApp _ p1 _qn p2) = let r' = foldDeclared f r p1 in foldDeclared f r' p2 -- pattern with an infix data constructor foldDeclared f r (A.PApp _ _ ps) = foldl (foldDeclared f) r ps -- data constructor and argument patterns@@ -127,13 +168,21 @@ -- Something imported can be exported instance FoldDeclared (A.ImportSpec l) where+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.IVar _ _ name) = foldDeclared f r name+#else foldDeclared f r (A.IVar _ name) = foldDeclared f r name+#endif foldDeclared f r (A.IAbs _ name) = foldDeclared f r name foldDeclared f r (A.IThingAll _ name) = foldDeclared f r name foldDeclared f r (A.IThingWith _ name _) = foldDeclared f r name instance FoldDeclared (A.ExportSpec l) where+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.EVar _ _ name) = foldDeclared f r name+#else foldDeclared f r (A.EVar _ name) = foldDeclared f r name+#endif foldDeclared f r (A.EAbs _ name) = foldDeclared f r name foldDeclared f r (A.EThingAll _ name) = foldDeclared f r name foldDeclared f r (A.EThingWith _ name _) = foldDeclared f r name@@ -153,20 +202,36 @@ exports :: (FoldDeclared a, FoldMembers a) => a -> [S.ExportSpec] exports x = case (justs (symbols x), justs (members x)) of+#if MIN_VERSION_haskell_src_exts(1,16,0)+ ([n], []) -> [S.EVar S.NoNamespace (S.UnQual n)]+#else ([n], []) -> [S.EVar (S.UnQual n)]+#endif ([n], ms) -> [S.EThingWith (S.UnQual n) (sort (map S.VarName ms))] ([], []) -> [] ([], _) -> error "exports: members with no top level name"+#if MIN_VERSION_haskell_src_exts(1,16,0)+ (ns, []) -> map (S.EVar S.NoNamespace . S.UnQual) ns+#else (ns, []) -> map (S.EVar . S.UnQual) ns+#endif y -> error $ "exports: multiple top level names and member names: " ++ show y imports :: (FoldDeclared a, FoldMembers a) => a -> [S.ImportSpec] imports x = case (justs (symbols x), justs (members x)) of+#if MIN_VERSION_haskell_src_exts(1,16,0)+ ([n], []) -> [S.IVar S.NoNamespace n]+#else ([n], []) -> [S.IVar n]+#endif ([n], ms) -> [S.IThingWith n (sort (map S.VarName ms))] ([], []) -> [] ([], _ms) -> error "exports: members with no top level name"+#if MIN_VERSION_haskell_src_exts(1,16,0)+ (ns, []) -> map (S.IVar S.NoNamespace) ns+#else (ns, []) -> map S.IVar ns+#endif y -> error $ "imports: multiple top level names and member names: " ++ show y -- | Fold over the declared members - e.g. the method names of a class@@ -194,4 +259,8 @@ foldDeclared f r (A.FieldDecl _ xs _) = foldl (foldDeclared f) r xs instance FoldDeclared (A.GadtDecl l) where+#if MIN_VERSION_haskell_src_exts(1,16,0)+ foldDeclared f r (A.GadtDecl _ x xs _) = let r' = foldDeclared f r x in maybe r' (foldl (foldDeclared f) r') xs+#else foldDeclared f r (A.GadtDecl _ x _) = foldDeclared f r x+#endif
changelog view
@@ -1,3 +1,17 @@+haskell-module-management (0.20.3) unstable; urgency=low++ * Changes for haskell-src-exts-1.16++ -- David Fox <dsf@seereason.com> Tue, 21 Oct 2014 09:12:18 -0700++haskell-module-management (0.20.2) unstable; urgency=low++ * Fix hmm compile error+ * Update cabal file+ * Moved to github++ -- David Fox <dsf@seereason.com> Tue, 14 Oct 2014 06:21:04 -0700+ haskell-module-management (0.20.1) unstable; urgency=low * Evidently ExplicitNamespaces didn't make it into
module-management.cabal view
@@ -1,5 +1,5 @@ Name: module-management-Version: 0.20.2.1+Version: 0.20.3 Synopsis: Clean up module imports, split and merge modules Description: Clean up module imports, split and merge modules. Homepage: https://github.com/seereason/module-management@@ -521,7 +521,7 @@ data-default, directory, filepath,- haskell-src-exts,+ haskell-src-exts <= 1.17, HUnit, lifted-base, monad-control,@@ -562,7 +562,7 @@ -- To see detailed counts use -ddump-simpl-stats -- Total ticks: 1186241 -- In 7.8.1 increasing the context stack size from 20 to 60 seems necessary.- ghc-options: -O0 -fcontext-stack=60+ ghc-options: -O0 -fcontext-stack=120 Test-Suite module-management-tests Type: exitcode-stdio-1.0@@ -573,6 +573,6 @@ containers, filepath, HUnit,- haskell-src-exts,+ haskell-src-exts <= 1.17, module-management, process
scripts/CLI.hs view
@@ -1,5 +1,5 @@ {- # OPTIONS_GHC -Wall #-}-{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, PatternGuards, StandaloneDeriving, ViewPatterns #-}+{-# LANGUAGE CPP, DeriveDataTypeable, DeriveGeneric, PatternGuards, StandaloneDeriving, ViewPatterns #-} module Main where import System.Console.Haskeline@@ -15,7 +15,9 @@ import Data.Char (toLower) import qualified Data.Set as S (member, toList, map) import Data.Set.Extra as Set (Set, toList)-import Distribution.ModuleExport (ModuleExport(..))+#if MIN_VERSION_Cabal(1,21,0)+import Distribution.InstalledPackageInfo (ModuleReexport(..))+#endif import Distribution.Package (InstalledPackageId(..)) import GHC.Generics (Generic) import Language.Haskell.Modules (cleanImports, CleanT, findHsModules, mergeModules, modifyDirs, ModuleName(..), MonadClean, noisily, putDirs, putModule, runCleanT, splitModuleDecls)@@ -43,8 +45,9 @@ import System.Exit -deriving instance Generic (ModuleExport m)+#if !MIN_VERSION_Cabal(1,21,1) deriving instance Generic InstalledPackageId+#endif data HMM = CLI { verbosity :: Int,@@ -68,9 +71,10 @@ cabalFile = Nothing &= typFile &= name "f"- &= help ".cabal file to load. Modules listed there will be loaded\- \ and when modules are split the .cabal file will be updated\- \ when you quit or use the cabalWrite command",+ &= help (concat+ [".cabal file to load. Modules listed there will be loaded",+ " and when modules are split the .cabal file will be updated",+ " when you quit or use the cabalWrite command"]), otherFiles = [] &= typFile &= args }
scripts/CLI/Cabal/Instances.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE StandaloneDeriving #-}@@ -8,6 +9,7 @@ module CLI.Cabal.Instances () where import Data.List+import Data.Map import Data.Typeable import Data.Version import Distribution.Compiler@@ -22,6 +24,12 @@ import Language.Haskell.Extension deriving instance Generic a => Generic (Condition a)+#if MIN_VERSION_Cabal(1,21,1)+instance (Ord k, Generic k, Generic v) => Generic (Map k v) where+ type Rep (Map k v) = Rep [(k, v)]+ from = from . toList+ to = fromList . to+#else deriving instance Generic Arch deriving instance Generic Benchmark deriving instance Generic BenchmarkInterface@@ -29,13 +37,10 @@ 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@@ -50,8 +55,12 @@ deriving instance Generic TestSuite deriving instance Generic TestSuiteInterface deriving instance Generic TestType-deriving instance Generic Version deriving instance Generic VersionRange+#endif+deriving instance Generic ConfVar+deriving instance Generic Flag+deriving instance Generic GenericPackageDescription+deriving instance Generic Version deriving instance (Generic a, Generic b, Generic c) => Generic (CondTree a b c) @@ -62,6 +71,7 @@ deriving instance Typeable3 CondTree deriving instance Typeable1 Condition +#if !MIN_VERSION_Cabal(1,21,1) deriving instance Typeable Arch deriving instance Typeable Benchmark deriving instance Typeable BenchmarkInterface@@ -91,12 +101,14 @@ deriving instance Typeable TestSuiteInterface deriving instance Typeable TestType deriving instance Typeable VersionRange+#endif deriving instance Typeable ModuleName #endif -+#if !MIN_VERSION_Cabal(1,21,1) instance Generic ModuleName where type Rep ModuleName = Rep [String] from = from . components to = fromString . intercalate "." . to+#endif