module Distribution.Simple.Program.Types (
Program(..),
internalProgram,
simpleProgram,
ConfiguredProgram(..),
programPath,
ProgArg,
ProgramLocation(..),
) where
import Data.List (nub)
import System.FilePath ((</>))
import Distribution.Simple.Utils
( findProgramLocation, findFirstFile )
import Distribution.Version
( Version )
import Distribution.Verbosity
( Verbosity )
data programFindVersion :: Verbosity -> FilePath -> IO (Maybe Version)Program = Program {
programName :: String,
programFindLocation :: Verbosity -> IO (Maybe FilePath),
programFindVersion :: Verbosity -> FilePath -> IO (Maybe Version),
programPostConf :: Verbosity -> ConfiguredProgram -> IO [ProgArg]
}
type ProgArg = String
data programLocation :: ProgramLocationConfiguredProgram = ConfiguredProgram {
programId :: String,
programVersion :: Maybe Version,
programDefaultArgs :: [String],
programOverrideArgs :: [String],
programLocation :: ProgramLocation
} deriving (D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) :: ConfiguredProgram -> ConfiguredProgram -> BoolEq)
data locationPath :: FilePathProgramLocation
= UserSpecified { locationPath :: FilePath }
| FoundOnSystem { locationPath :: FilePath }
deriving (D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, ($c==) :: ConfiguredProgram -> ConfiguredProgram -> BoolEq)
programPath :: ConfiguredProgram -> FilePath
programPath = locationPath :: ProgramLocation -> FilePathlocationPath (.) :: (b -> c) -> (a -> b) -> a -> c. programLocation :: ConfiguredProgram -> ProgramLocationprogramLocation
simpleProgram :: String -> Program
simpleProgram name = Program {
programName = name :: Stringname,
programFindLocation = \v -> findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath)findProgramLocation v :: Verbosityv name :: Stringname,
programFindVersion = \_ _ -> return :: Monad m => forall a. a -> m areturn Nothing :: Maybe aNothing,
programPostConf = \_ _ -> return :: Monad m => forall a. a -> m areturn [] :: [a][]
}
internalProgram :: [FilePath] -> String -> Program
internalProgram paths name = Program {
programName = name :: Stringname,
programFindLocation = \_v ->
findFirstFile :: (a -> FilePath) -> [a] -> IO (Maybe a)findFirstFile id :: a -> aid [ path :: FilePathpath (</>) :: FilePath -> FilePath -> FilePath</> name :: Stringname | path <- nub :: Eq a => [a] -> [a]nub paths :: [FilePath]paths ],
programFindVersion = \_ _ -> return :: Monad m => forall a. a -> m areturn Nothing :: Maybe aNothing,
programPostConf = \_ _ -> return :: Monad m => forall a. a -> m areturn [] :: [a][]
}