module Development.Shake.Cabal ( getCabalDeps
                               , getCabalDepsV
                               , getCabalDepsA
                               , shakeVerbosityToCabalVerbosity
                               -- * Oracles
                               , hsOracle
                               , cabalOracle
                               -- * Types
                               , HsCompiler (..)
                               -- * Oracle dummy types
                               , CabalVersion (..)
                               -- * Helper functions
                               , platform
                               , hsCompiler
                               -- * Reëxports from "Distribution.Version"
                               , prettyShow
                               ) where

import           Control.Applicative
import           Control.Arrow
import           Control.Composition
import           Control.Monad
import           Data.Foldable                          (fold, toList)
import           Data.Maybe                             (catMaybes)
import           Development.Shake                      hiding (doesFileExist)
import qualified Development.Shake                      as Shake
import           Development.Shake.Cabal.Oracles
import           Distribution.ModuleName
import           Distribution.PackageDescription
import           Distribution.PackageDescription.Parsec
import           Distribution.Pretty
import           Distribution.Utils.Path                (getSymbolicPath)
import           Distribution.Verbosity                 as Distribution
import           Distribution.Version
import           System.Directory                       (doesFileExist)
import           System.FilePath                        (pathSeparator)
import           System.Info                            (arch, os)

hsCompiler :: HsCompiler -> String
hsCompiler :: HsCompiler -> String
hsCompiler (GHC Maybe String
Nothing Maybe String
Nothing)       = String
"ghc"
hsCompiler (GHC Maybe String
Nothing (Just String
v))      = String
"ghc-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
v
hsCompiler (GHC (Just String
arch') (Just String
v)) = String
arch' String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-ghc-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
v
hsCompiler (GHC (Just String
arch') Maybe String
Nothing)  = String
arch' String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-ghc"
hsCompiler (GHCJS Maybe String
Nothing)             = String
"ghcjs"
hsCompiler (GHCJS (Just String
v))            = String
"ghcjs-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
v

-- | E.g. @x86_64-linux@
platform :: String
platform :: String
platform = String
arch String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
processOS String
os
    where processOS :: String -> String
processOS String
"darwin" = String
"osx"
          processOS String
x        = String
x

-- FIXME: should also work with .x, .cpphs, .y, .c2hs files
libraryToFiles :: Library -> [FilePath]
libraryToFiles :: Library -> [String]
libraryToFiles Library
lib = [[String]] -> [String]
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold [[String]
cs, [String]
is, [String]
hs]
    where ([String]
cs, [String]
is) = (BuildInfo -> [String]
cSources (BuildInfo -> [String])
-> (BuildInfo -> [String]) -> BuildInfo -> ([String], [String])
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& BuildInfo -> [String]
includes) (BuildInfo -> ([String], [String]))
-> BuildInfo -> ([String], [String])
forall a b. (a -> b) -> a -> b
$ Library -> BuildInfo
libBuildInfo Library
lib
          hs :: [String]
hs = (String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
".hs") (String -> String)
-> (ModuleName -> String) -> ModuleName -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> String
toFilePath (ModuleName -> String) -> [ModuleName] -> [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Library -> [ModuleName]
explicitLibModules Library
lib

fileHelper :: (a -> [ModuleName]) -> a -> [FilePath]
fileHelper :: (a -> [ModuleName]) -> a -> [String]
fileHelper = ((ModuleName -> String) -> [ModuleName] -> [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
".hs") (String -> String)
-> (ModuleName -> String) -> ModuleName -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> String
toFilePath) ([ModuleName] -> [String]) -> (a -> [ModuleName]) -> a -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.)

exeToFiles :: Executable -> [FilePath]
exeToFiles :: Executable -> [String]
exeToFiles = (String -> [String] -> [String])
-> (Executable -> String)
-> (Executable -> [String])
-> Executable
-> [String]
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (:) Executable -> String
modulePath ((Executable -> [ModuleName]) -> Executable -> [String]
forall a. (a -> [ModuleName]) -> a -> [String]
fileHelper Executable -> [ModuleName]
exeModules)

testToFiles :: TestSuite -> [FilePath]
testToFiles :: TestSuite -> [String]
testToFiles = (TestSuite -> [ModuleName]) -> TestSuite -> [String]
forall a. (a -> [ModuleName]) -> a -> [String]
fileHelper TestSuite -> [ModuleName]
testModules

benchToFiles :: Benchmark -> [FilePath]
benchToFiles :: Benchmark -> [String]
benchToFiles = (Benchmark -> [ModuleName]) -> Benchmark -> [String]
forall a. (a -> [ModuleName]) -> a -> [String]
fileHelper Benchmark -> [ModuleName]
benchmarkModules

foreignToFiles :: ForeignLib -> [FilePath]
foreignToFiles :: ForeignLib -> [String]
foreignToFiles = (ForeignLib -> [ModuleName]) -> ForeignLib -> [String]
forall a. (a -> [ModuleName]) -> a -> [String]
fileHelper ForeignLib -> [ModuleName]
foreignLibModules

extract :: CondTree a b c -> [c]
extract :: CondTree a b c -> [c]
extract (CondNode c
d b
_ []) = [c
d]
extract (CondNode c
d b
_ [CondBranch a b c]
bs) = c
d c -> [c] -> [c]
forall a. a -> [a] -> [a]
: (CondBranch a b c -> [c]
forall a b a. CondBranch a b a -> [a]
g (CondBranch a b c -> [c]) -> [CondBranch a b c] -> [c]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [CondBranch a b c]
bs)
    where g :: CondBranch a b a -> [a]
g (CondBranch Condition a
_ CondTree a b a
tb Maybe (CondTree a b a)
fb) = [[a]] -> [a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[a]] -> [a]) -> [[a]] -> [a]
forall a b. (a -> b) -> a -> b
$ [Maybe [a]] -> [[a]]
forall a. [Maybe a] -> [a]
catMaybes [[a] -> Maybe [a]
forall a. a -> Maybe a
Just ([a] -> Maybe [a]) -> [a] -> Maybe [a]
forall a b. (a -> b) -> a -> b
$ CondTree a b a -> [a]
forall a b c. CondTree a b c -> [c]
extract CondTree a b a
tb, CondTree a b a -> [a]
forall a b c. CondTree a b c -> [c]
extract (CondTree a b a -> [a]) -> Maybe (CondTree a b a) -> Maybe [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (CondTree a b a)
fb]

-- | Assign each shake @Verbosity@ level to a Cabal @Verbosity@ level.
shakeVerbosityToCabalVerbosity :: Shake.Verbosity -> Distribution.Verbosity
shakeVerbosityToCabalVerbosity :: Verbosity -> Verbosity
shakeVerbosityToCabalVerbosity Verbosity
Silent     = Verbosity
silent
shakeVerbosityToCabalVerbosity Verbosity
Error      = Verbosity
normal
shakeVerbosityToCabalVerbosity Verbosity
Warn       = Verbosity
normal
shakeVerbosityToCabalVerbosity Verbosity
Info       = Verbosity
verbose
shakeVerbosityToCabalVerbosity Verbosity
Verbose    = Verbosity
verbose
shakeVerbosityToCabalVerbosity Verbosity
Diagnostic = Verbosity
deafening

-- | Get cabal dependencies, respecting verbosity level given to
-- [shake](http://shakebuild.com/).
getCabalDepsA :: FilePath -> Action (Version, [FilePath])
getCabalDepsA :: String -> Action (Version, [String])
getCabalDepsA = Action (Action (Version, [String])) -> Action (Version, [String])
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Action (Action (Version, [String])) -> Action (Version, [String]))
-> (String -> Action (Action (Version, [String])))
-> String
-> Action (Version, [String])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Verbosity -> String -> Action (Version, [String])
g (Verbosity -> String -> Action (Version, [String]))
-> Action Verbosity
-> Action (String -> Action (Version, [String]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Verbosity -> Verbosity) -> Action Verbosity -> Action Verbosity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Verbosity -> Verbosity
shakeVerbosityToCabalVerbosity Action Verbosity
getVerbosity Action (String -> Action (Version, [String]))
-> Action String -> Action (Action (Version, [String]))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>) (Action String -> Action (Action (Version, [String])))
-> (String -> Action String)
-> String
-> Action (Action (Version, [String]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Action String
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    where g :: Verbosity -> String -> Action (Version, [String])
g = IO (Version, [String]) -> Action (Version, [String])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Version, [String]) -> Action (Version, [String]))
-> (Verbosity -> String -> IO (Version, [String]))
-> Verbosity
-> String
-> Action (Version, [String])
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.* Verbosity -> String -> IO (Version, [String])
getCabalDepsV

-- | Get library dependencies from a @.cabal@ file. This will only work for
-- @.hs@ files; module signatures are not supported.
getCabalDeps :: FilePath -> IO (Version, [FilePath])
getCabalDeps :: String -> IO (Version, [String])
getCabalDeps = Verbosity -> String -> IO (Version, [String])
getCabalDepsV Verbosity
normal

getCabalDepsV :: Distribution.Verbosity -> FilePath -> IO (Version, [FilePath])
getCabalDepsV :: Verbosity -> String -> IO (Version, [String])
getCabalDepsV Verbosity
v String
p = do
    GenericPackageDescription
pkg <- Verbosity -> String -> IO GenericPackageDescription
readGenericPackageDescription Verbosity
v String
p
    let descr :: PackageDescription
descr = GenericPackageDescription -> PackageDescription
packageDescription GenericPackageDescription
pkg
        extraSrc :: [String]
extraSrc = PackageDescription -> [String]
extraSrcFiles PackageDescription
descr
        vers :: Version
vers = PackageIdentifier -> Version
pkgVersion (PackageDescription -> PackageIdentifier
package PackageDescription
descr)

        mkHelper :: (GenericPackageDescription -> t (a, a)) -> [a]
mkHelper GenericPackageDescription -> t (a, a)
f = (t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (t a -> [a])
-> (GenericPackageDescription -> t a)
-> GenericPackageDescription
-> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, a) -> a) -> t (a, a) -> t a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, a) -> a
forall a b. (a, b) -> b
snd (t (a, a) -> t a)
-> (GenericPackageDescription -> t (a, a))
-> GenericPackageDescription
-> t a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenericPackageDescription -> t (a, a)
f) GenericPackageDescription
pkg

        libs :: [CondTree ConfVar [Dependency] Library]
libs = Maybe (CondTree ConfVar [Dependency] Library)
-> [CondTree ConfVar [Dependency] Library]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (GenericPackageDescription
-> Maybe (CondTree ConfVar [Dependency] Library)
condLibrary GenericPackageDescription
pkg)
        exes :: [CondTree ConfVar [Dependency] Executable]
exes = (GenericPackageDescription
 -> [(UnqualComponentName,
      CondTree ConfVar [Dependency] Executable)])
-> [CondTree ConfVar [Dependency] Executable]
forall (t :: * -> *) a a.
(Foldable t, Functor t) =>
(GenericPackageDescription -> t (a, a)) -> [a]
mkHelper GenericPackageDescription
-> [(UnqualComponentName,
     CondTree ConfVar [Dependency] Executable)]
condExecutables
        subLibs :: [CondTree ConfVar [Dependency] Library]
subLibs = (GenericPackageDescription
 -> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)])
-> [CondTree ConfVar [Dependency] Library]
forall (t :: * -> *) a a.
(Foldable t, Functor t) =>
(GenericPackageDescription -> t (a, a)) -> [a]
mkHelper GenericPackageDescription
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries
        tests :: [CondTree ConfVar [Dependency] TestSuite]
tests = (GenericPackageDescription
 -> [(UnqualComponentName,
      CondTree ConfVar [Dependency] TestSuite)])
-> [CondTree ConfVar [Dependency] TestSuite]
forall (t :: * -> *) a a.
(Foldable t, Functor t) =>
(GenericPackageDescription -> t (a, a)) -> [a]
mkHelper GenericPackageDescription
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
condTestSuites
        benches :: [CondTree ConfVar [Dependency] Benchmark]
benches = (GenericPackageDescription
 -> [(UnqualComponentName,
      CondTree ConfVar [Dependency] Benchmark)])
-> [CondTree ConfVar [Dependency] Benchmark]
forall (t :: * -> *) a a.
(Foldable t, Functor t) =>
(GenericPackageDescription -> t (a, a)) -> [a]
mkHelper GenericPackageDescription
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
condBenchmarks
        foreigns :: [CondTree ConfVar [Dependency] ForeignLib]
foreigns = (GenericPackageDescription
 -> [(UnqualComponentName,
      CondTree ConfVar [Dependency] ForeignLib)])
-> [CondTree ConfVar [Dependency] ForeignLib]
forall (t :: * -> *) a a.
(Foldable t, Functor t) =>
(GenericPackageDescription -> t (a, a)) -> [a]
mkHelper GenericPackageDescription
-> [(UnqualComponentName,
     CondTree ConfVar [Dependency] ForeignLib)]
condForeignLibs

        extractHelper :: (b -> [b]) -> [CondTree a b b] -> [b]
extractHelper b -> [b]
f [CondTree a b b]
xs = (b -> [b]
f (b -> [b]) -> (CondTree a b b -> [b]) -> CondTree a b b -> [b]
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< CondTree a b b -> [b]
forall a b c. CondTree a b c -> [c]
extract) (CondTree a b b -> [b]) -> [CondTree a b b] -> [b]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [CondTree a b b]
xs

        normalSrc :: [String]
normalSrc = (Library -> [String])
-> [CondTree ConfVar [Dependency] Library] -> [String]
forall b b a b. (b -> [b]) -> [CondTree a b b] -> [b]
extractHelper Library -> [String]
libraryToFiles [CondTree ConfVar [Dependency] Library]
libs
        exeSrc :: [String]
exeSrc = (Executable -> [String])
-> [CondTree ConfVar [Dependency] Executable] -> [String]
forall b b a b. (b -> [b]) -> [CondTree a b b] -> [b]
extractHelper Executable -> [String]
exeToFiles [CondTree ConfVar [Dependency] Executable]
exes
        subSrc :: [String]
subSrc = (Library -> [String])
-> [CondTree ConfVar [Dependency] Library] -> [String]
forall b b a b. (b -> [b]) -> [CondTree a b b] -> [b]
extractHelper Library -> [String]
libraryToFiles [CondTree ConfVar [Dependency] Library]
subLibs
        testSrc :: [String]
testSrc = (TestSuite -> [String])
-> [CondTree ConfVar [Dependency] TestSuite] -> [String]
forall b b a b. (b -> [b]) -> [CondTree a b b] -> [b]
extractHelper TestSuite -> [String]
testToFiles [CondTree ConfVar [Dependency] TestSuite]
tests
        benchSrc :: [String]
benchSrc = (Benchmark -> [String])
-> [CondTree ConfVar [Dependency] Benchmark] -> [String]
forall b b a b. (b -> [b]) -> [CondTree a b b] -> [b]
extractHelper Benchmark -> [String]
benchToFiles [CondTree ConfVar [Dependency] Benchmark]
benches
        foreignSrc :: [String]
foreignSrc = (ForeignLib -> [String])
-> [CondTree ConfVar [Dependency] ForeignLib] -> [String]
forall b b a b. (b -> [b]) -> [CondTree a b b] -> [b]
extractHelper ForeignLib -> [String]
foreignToFiles [CondTree ConfVar [Dependency] ForeignLib]
foreigns

        dirHelper :: (a -> BuildInfo) -> [CondTree a b a] -> [String]
dirHelper a -> BuildInfo
f [CondTree a b a]
xs = ((SymbolicPath PackageDir SourceDir -> String)
-> [SymbolicPath PackageDir SourceDir] -> [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((String -> String -> String
forall a. [a] -> [a] -> [a]
++ [Char
pathSeparator]) (String -> String)
-> (SymbolicPath PackageDir SourceDir -> String)
-> SymbolicPath PackageDir SourceDir
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SymbolicPath PackageDir SourceDir -> String
forall from to. SymbolicPath from to -> String
getSymbolicPath) ([SymbolicPath PackageDir SourceDir] -> [String])
-> (a -> [SymbolicPath PackageDir SourceDir]) -> a -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuildInfo -> [SymbolicPath PackageDir SourceDir]
hsSourceDirs (BuildInfo -> [SymbolicPath PackageDir SourceDir])
-> (a -> BuildInfo) -> a -> [SymbolicPath PackageDir SourceDir]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> BuildInfo
f (a -> [String])
-> (CondTree a b a -> [a]) -> CondTree a b a -> [String]
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< CondTree a b a -> [a]
forall a b c. CondTree a b c -> [c]
extract) (CondTree a b a -> [String]) -> [CondTree a b a] -> [String]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [CondTree a b a]
xs

        dir :: [String]
dir = (Library -> BuildInfo)
-> [CondTree ConfVar [Dependency] Library] -> [String]
forall a a b. (a -> BuildInfo) -> [CondTree a b a] -> [String]
dirHelper Library -> BuildInfo
libBuildInfo [CondTree ConfVar [Dependency] Library]
libs
        exeDir :: [String]
exeDir = (Executable -> BuildInfo)
-> [CondTree ConfVar [Dependency] Executable] -> [String]
forall a a b. (a -> BuildInfo) -> [CondTree a b a] -> [String]
dirHelper Executable -> BuildInfo
buildInfo [CondTree ConfVar [Dependency] Executable]
exes
        subDirs :: [String]
subDirs = (Library -> BuildInfo)
-> [CondTree ConfVar [Dependency] Library] -> [String]
forall a a b. (a -> BuildInfo) -> [CondTree a b a] -> [String]
dirHelper Library -> BuildInfo
libBuildInfo [CondTree ConfVar [Dependency] Library]
subLibs
        testDirs :: [String]
testDirs = (TestSuite -> BuildInfo)
-> [CondTree ConfVar [Dependency] TestSuite] -> [String]
forall a a b. (a -> BuildInfo) -> [CondTree a b a] -> [String]
dirHelper TestSuite -> BuildInfo
testBuildInfo [CondTree ConfVar [Dependency] TestSuite]
tests
        benchDirs :: [String]
benchDirs = (Benchmark -> BuildInfo)
-> [CondTree ConfVar [Dependency] Benchmark] -> [String]
forall a a b. (a -> BuildInfo) -> [CondTree a b a] -> [String]
dirHelper Benchmark -> BuildInfo
benchmarkBuildInfo [CondTree ConfVar [Dependency] Benchmark]
benches
        foreignDirs :: [String]
foreignDirs = (ForeignLib -> BuildInfo)
-> [CondTree ConfVar [Dependency] ForeignLib] -> [String]
forall a a b. (a -> BuildInfo) -> [CondTree a b a] -> [String]
dirHelper ForeignLib -> BuildInfo
foreignLibBuildInfo [CondTree ConfVar [Dependency] ForeignLib]
foreigns

        dirgeHelper :: f [a] -> f [a] -> f [a]
dirgeHelper f [a]
d = ([a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
(++) ([a] -> [a] -> [a]) -> f [a] -> f ([a] -> [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f [a]
d f ([a] -> [a]) -> f [a] -> f [a]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>)

        dirge :: [String] -> [String]
dirge = [String] -> [String] -> [String]
forall (f :: * -> *) a. Applicative f => f [a] -> f [a] -> f [a]
dirgeHelper [String]
dir
        dirgeExe :: [String] -> [String]
dirgeExe = [String] -> [String] -> [String]
forall (f :: * -> *) a. Applicative f => f [a] -> f [a] -> f [a]
dirgeHelper [String]
exeDir
        dirgeSub :: [String] -> [String]
dirgeSub = [String] -> [String] -> [String]
forall (f :: * -> *) a. Applicative f => f [a] -> f [a] -> f [a]
dirgeHelper [String]
subDirs
        dirgeTest :: [String] -> [String]
dirgeTest = [String] -> [String] -> [String]
forall (f :: * -> *) a. Applicative f => f [a] -> f [a] -> f [a]
dirgeHelper [String]
testDirs
        dirgeBench :: [String] -> [String]
dirgeBench = [String] -> [String] -> [String]
forall (f :: * -> *) a. Applicative f => f [a] -> f [a] -> f [a]
dirgeHelper [String]
benchDirs
        dirgeForeign :: [String] -> [String]
dirgeForeign = [String] -> [String] -> [String]
forall (f :: * -> *) a. Applicative f => f [a] -> f [a] -> f [a]
dirgeHelper [String]
foreignDirs

        h :: [String] -> IO [String]
h = (String -> IO Bool) -> [String] -> IO [String]
forall (m :: * -> *) a.
Applicative m =>
(a -> m Bool) -> [a] -> m [a]
filterM String -> IO Bool
doesFileExist

    [String]
norms <- [String] -> IO [String]
h ([String] -> [String]
dirge [String]
normalSrc)
    [String]
exeFiles <- [String] -> IO [String]
h ([String] -> [String]
dirgeExe [String]
exeSrc)
    [String]
subFiles <- [String] -> IO [String]
h ([String] -> [String]
dirgeSub [String]
subSrc)
    [String]
testFiles <- [String] -> IO [String]
h ([String] -> [String]
dirgeTest [String]
testSrc)
    [String]
benchFiles <- [String] -> IO [String]
h ([String] -> [String]
dirgeBench [String]
benchSrc)
    [String]
foreignFiles <- [String] -> IO [String]
h ([String] -> [String]
dirgeForeign [String]
foreignSrc)

    (Version, [String]) -> IO (Version, [String])
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Version
vers, String
p String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [String]
extraSrc [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
norms [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
exeFiles [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
subFiles [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
testFiles [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
benchFiles [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
foreignFiles)