<commit_before>module Settings (
    module Settings.Packages,
    module Settings.TargetDirectory,
    module Settings.User,
    module Settings.Ways,
    getPkgData, getPkgDataList,
    getPackagePath, getTargetDirectory, getTargetPath, getPackageSources,
    ) where

import Expression
import Oracles
import Settings.Packages
import Settings.TargetDirectory
import Settings.User
import Settings.Ways

getPackagePath :: Expr FilePath
getPackagePath = liftM pkgPath getPackage

getTargetDirectory :: Expr FilePath
getTargetDirectory = liftM2 targetDirectory getStage getPackage

getTargetPath :: Expr FilePath
getTargetPath = liftM2 targetPath getStage getPackage

getPkgData :: (FilePath -> PackageData) -> Expr String
getPkgData key = lift . pkgData . key =<< getTargetPath

getPkgDataList :: (FilePath -> PackageDataList) -> Expr [String]
getPkgDataList key = lift . pkgDataList . key =<< getTargetPath

-- Find all Haskell source files for the current target. TODO: simplify.
getPackageSources :: Expr [FilePath]
getPackageSources = do
    path        <- getTargetPath
    packagePath <- getPackagePath
    srcDirs     <- getPkgDataList SrcDirs

    let buildPath = path -/- "build"
        dirs      = (buildPath -/- "autogen") : map (packagePath -/-) srcDirs

    (foundSources, missingSources) <- findModuleFiles dirs "*hs"

    -- Generated source files live in buildPath and have extension "hs"
    let generatedSources = [ buildPath -/- s <.> "hs" | s <- missingSources ]

    return $ foundSources ++ generatedSources

-- findModuleFiles scans a list of given directories and finds files matching a<commit_msg>Fix GhcPrim path in getPackageSources.<commit_after>module Settings (
    module Settings.Packages,
    module Settings.TargetDirectory,
    module Settings.User,
    module Settings.Ways,
    getPkgData, getPkgDataList,
    getPackagePath, getTargetDirectory, getTargetPath, getPackageSources,
    ) where

import Expression
import Oracles
import Settings.Packages
import Settings.TargetDirectory
import Settings.User
import Settings.Ways

getPackagePath :: Expr FilePath
getPackagePath = liftM pkgPath getPackage

getTargetDirectory :: Expr FilePath
getTargetDirectory = liftM2 targetDirectory getStage getPackage

getTargetPath :: Expr FilePath
getTargetPath = liftM2 targetPath getStage getPackage

getPkgData :: (FilePath -> PackageData) -> Expr String
getPkgData key = lift . pkgData . key =<< getTargetPath

getPkgDataList :: (FilePath -> PackageDataList) -> Expr [String]
getPkgDataList key = lift . pkgDataList . key =<< getTargetPath

-- Find all Haskell source files for the current target. TODO: simplify.
getPackageSources :: Expr [FilePath]
getPackageSources = do
    path        <- getTargetPath
    packagePath <- getPackagePath
    srcDirs     <- getPkgDataList SrcDirs

    let buildPath = path -/- "build"
        autogen   = buildPath -/- "autogen"
        dirs      = autogen : map (packagePath -/-) srcDirs

    (foundSources, missingSources) <- findModuleFiles dirs "*hs"

    -- Generated source files live in buildPath and have extension "hs"...
    let generatedSources = [ buildPath -/- s <.> "hs" | s <- missingSources ]
    -- ...except that GHC/Prim.hs lives in autogen. TODO: fix?
        fixGhcPrim = replaceEq (buildPath -/- "GHC/Prim.hs") (autogen -/- "GHC/Prim.hs")

    return $ foundSources ++ fixGhcPrim generatedSources

-- findModuleFiles scans a list of given directories and finds files matching a
{'fraction_non_alphanumeric': 0.08379081190407396, 'fraction_numerical': 0.0011557353366079169, 'mean_word_length': 3.7751724137931033, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4844254', 'n_tokens_mistral': 1001, 'n_tokens_neox': 955, 'n_words': 308}