<commit_before>module Settings.Packages (
    module Settings.Default,
    packages, getPackages, knownPackages
    ) where

import Package
import Switches
import Expression
import Oracles.Setting
import Settings.User
import Settings.Default

-- Combining default list of packages with user modifications
packages :: Packages
packages = defaultPackages <> userPackages

getPackages :: Expr [Package]
getPackages = fromDiffExpr packages

-- These are the packages we build by default
defaultPackages :: Packages
defaultPackages = mconcat
    [ stage0 ? packagesStage0
    , stage1 ? packagesStage1 ]

packagesStage0 :: Packages
packagesStage0 = mconcat
    [ append [binPackageDb, binary, cabal, compiler, hoopl, hpc, transformers]
    , notWindowsHost ? notTargetOs "ios" ? append [terminfo] ]

packagesStage1 :: Packages
packagesStage1 = mconcat
    [ packagesStage0
    , append [ array, base, bytestring, containers, deepseq, directory
             , filepath, ghcPrim, haskeline, integerLibrary, parallel
             , pretty, primitive, process, stm, templateHaskell, time ]
    , windowsHost    ? append [win32]
    , notWindowsHost ? append [unix]
    , buildHaddock   ? append [xhtml] ]

knownPackages :: [Package]
knownPackages = defaultKnownPackages ++ userKnownPackages<commit_msg>Add findKnownPackage for finding packages by name.<commit_after>module Settings.Packages (
    module Settings.Default,
    packages, getPackages, knownPackages, findKnownPackage
    ) where

import Package
import Switches
import Expression
import Oracles.Setting
import Settings.User
import Settings.Default
import Data.List

-- Combining default list of packages with user modifications
packages :: Packages
packages = defaultPackages <> userPackages

getPackages :: Expr [Package]
getPackages = fromDiffExpr packages

-- These are the packages we build by default
defaultPackages :: Packages
defaultPackages = mconcat
    [ stage0 ? packagesStage0
    , stage1 ? packagesStage1 ]

packagesStage0 :: Packages
packagesStage0 = mconcat
    [ append [binPackageDb, binary, cabal, compiler, hoopl, hpc, transformers]
    , notWindowsHost ? notTargetOs "ios" ? append [terminfo] ]

packagesStage1 :: Packages
packagesStage1 = mconcat
    [ packagesStage0
    , append [ array, base, bytestring, containers, deepseq, directory
             , filepath, ghcPrim, haskeline, integerLibrary, parallel
             , pretty, primitive, process, stm, templateHaskell, time ]
    , windowsHost    ? append [win32]
    , notWindowsHost ? append [unix]
    , buildHaddock   ? append [xhtml] ]

knownPackages :: [Package]
knownPackages = defaultKnownPackages ++ userKnownPackages

-- Note: this is slow but we keep it simple as there not too many packages (30)
-- We handle integerLibrary in a special way, because packages integerGmp and
-- integerGmp2 have the same package name -- we return the user-selected one.
findKnownPackage :: PackageName -> Maybe Package
findKnownPackage name
    | name == pkgName integerLibrary = Just integerLibrary
    | otherwise = find (\pkg -> pkgName pkg == name) knownPackages
{'fraction_non_alphanumeric': 0.07438551099611902, 'fraction_numerical': 0.008085381630012937, 'mean_word_length': 4.233502538071066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5252935', 'n_tokens_mistral': 845, 'n_tokens_neox': 822, 'n_words': 282}