Types.hs 4.67 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-----------------------------------------------------------------------------
-- |
-- Module      :  Network.Hackage.CabalInstall.Types
-- Copyright   :  (c) David Himmelstrup 2005
-- License     :  BSD-like
--
-- Maintainer  :  lemmih@gmail.com
-- Stability   :  provisional
-- Portability :  portable
--
-- All data types for the entire cabal-install system gathered here to avoid some .hs-boot files.
-----------------------------------------------------------------------------
module Network.Hackage.CabalInstall.Types where

15
import Distribution.Simple.Compiler (CompilerFlavor(..),Compiler)
16
import Distribution.Simple.Program  (ProgramConfiguration)
17
18
import Distribution.Package (PackageIdentifier)
import Distribution.Version (Dependency)
mnislaih's avatar
mnislaih committed
19
import Distribution.Verbosity
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

import System.IO (Handle)

data PkgInfo = PkgInfo
    { infoId        :: PackageIdentifier
    , infoDeps      :: [Dependency]
    , infoSynopsis  :: String
    , infoURL       :: String
    }
    deriving (Show, Read, Eq)

data Action
    = FetchCmd
    | InstallCmd
    | BuildDepCmd
    | CleanCmd
    | UpdateCmd
    | InfoCmd
    | HelpCmd
    | ListCmd
 deriving (Eq)

data TempFlags = TempFlags {
        tempHcFlavor    :: Maybe CompilerFlavor,
        tempHcPath      :: Maybe FilePath, -- ^given compiler location
        tempConfDir     :: Maybe FilePath,
        tempCacheDir    :: Maybe FilePath,
        tempPkgListDir  :: Maybe FilePath,
        tempHcPkg       :: Maybe FilePath, -- ^given hc-pkg location
        tempPrefix      :: Maybe FilePath,
        tempServers     :: [String],       -- ^Available Hackage servers.
        tempTarPath     :: Maybe FilePath,
        tempRunHc       :: Maybe FilePath,
mnislaih's avatar
mnislaih committed
53
        tempVerbose     :: Verbosity,            -- ^verbosity level
54
--        tempUpgradeDeps :: Bool,
55
56
        tempUserIns     :: Bool,           -- ^--user-install flag
        tempHelp        :: Bool
57
58
59
60
   }

data ConfigFlags = ConfigFlags {
        configCompiler    :: Compiler,
61
	configPrograms    :: ProgramConfiguration,
62
63
64
65
66
67
68
69
        configConfDir     :: FilePath,
        configCacheDir    :: FilePath,
        configPkgListDir  :: FilePath,
        configPrefix      :: Maybe FilePath,
        configServers     :: [String],       -- ^Available Hackage servers.
        configTarPath     :: FilePath,
        configRunHc       :: FilePath,
        configOutputGen   :: OutputGen,
mnislaih's avatar
mnislaih committed
70
        configVerbose     :: Verbosity,
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--        configUpgradeDeps :: Bool,
        configUserIns     :: Bool            -- ^--user-install flag
   }

data OutputGen
    = OutputGen
      { prepareInstall :: [(PackageIdentifier,[String],String)] -> IO ()
      , pkgIsPresent   :: PackageIdentifier -> IO ()
      , downloadingPkg :: PackageIdentifier -> IO ()
      , executingCmd   :: String -> [String] -> IO ()
      , cmdFailed      :: String -> [String] -> Int -> IO () -- cmd, flags and errno.
      , buildingPkg    :: PackageIdentifier -> IO () -- Package is fetched and unpacked. Starting installation.
      , stepConfigPkg  :: PackageIdentifier -> IO ()
      , stepBuildPkg   :: PackageIdentifier -> IO ()
      , stepInstallPkg :: PackageIdentifier -> IO ()
      , stepFinishedPkg:: PackageIdentifier -> IO ()
      , noSetupScript  :: PackageIdentifier -> IO ()
      , noCabalFile    :: PackageIdentifier -> IO ()
      , gettingPkgList :: String -> IO () -- Server.
      , showPackageInfo :: Maybe FilePath -- pkg file if fetched.
                        -> Bool -- is installed
                        -> [String] -- Options
                        -> Dependency -- Which dependency is this package supposed to fill
                        -> (PackageIdentifier,String,[ResolvedPackage])
                        -> IO ()
      , showOtherPackageInfo :: Maybe PackageIdentifier -- package if installed.
                             -> Dependency
                             -> IO () -- Show package which isn't available from any server.
      , cmdStdout      :: Maybe Handle
      , cmdStderr      :: Maybe Handle
      , -- | Output a message.
mnislaih's avatar
mnislaih committed
102
        message :: Verbosity -- ^ minimum verbosity needed to output this message
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
                -> String -> IO ()
      }



data ResolvedPackage
    = ResolvedPackage
    { fulfilling :: Dependency
    , resolvedData :: Maybe ( PackageIdentifier -- pkg id
                            , String            -- pkg location
                            , [ResolvedPackage] -- pkg dependencies
                            )
    , pkgOptions :: [String]
    } deriving Eq

data UnresolvedDependency
    = UnresolvedDependency
    { dependency :: Dependency
    , depOptions :: [String]
    }

data ResolvedDependency
    = ResolvedDependency PackageIdentifier String [(Dependency,Maybe ResolvedDependency)]
      deriving (Eq,Show)