<commit_before>module Distribution.Client.Dependency.Modular.Solver where

import Data.Map as M

import Distribution.Client.Dependency.Types

import Distribution.Client.Dependency.Modular.Assignment
import Distribution.Client.Dependency.Modular.Builder
import Distribution.Client.Dependency.Modular.Dependency
import Distribution.Client.Dependency.Modular.Explore
import Distribution.Client.Dependency.Modular.Index
import Distribution.Client.Dependency.Modular.Log
import Distribution.Client.Dependency.Modular.Message
import Distribution.Client.Dependency.Modular.Package
import qualified Distribution.Client.Dependency.Modular.Preference as P
import Distribution.Client.Dependency.Modular.Validate

-- Configurable interface to the solver.

data SolverConfig = SolverConfig {
  preferEasyGoalChoices :: Bool,
  pStrategy             :: PackagesPreferenceDefault,
  avoidReinstalls       :: Bool
}

defaultSolverConfig :: Bool -> SolverConfig
defaultSolverConfig ar = SolverConfig {
  preferEasyGoalChoices = True,
  pStrategy             = PreferLatestForSelected, -- latest for goals only
  avoidReinstalls       = ar
}

solve :: SolverConfig ->   -- solver parameters
         Index ->          -- all available packages as an index
         (PN -> PackagePreferences) -> -- preferences
         Map PN PackageConstraint ->   -- global constraints
         [PN] ->                       -- global goals<commit_msg>switch goal reordering off by default<commit_after>module Distribution.Client.Dependency.Modular.Solver where

import Data.Map as M

import Distribution.Client.Dependency.Types

import Distribution.Client.Dependency.Modular.Assignment
import Distribution.Client.Dependency.Modular.Builder
import Distribution.Client.Dependency.Modular.Dependency
import Distribution.Client.Dependency.Modular.Explore
import Distribution.Client.Dependency.Modular.Index
import Distribution.Client.Dependency.Modular.Log
import Distribution.Client.Dependency.Modular.Message
import Distribution.Client.Dependency.Modular.Package
import qualified Distribution.Client.Dependency.Modular.Preference as P
import Distribution.Client.Dependency.Modular.Validate

-- Configurable interface to the solver.

data SolverConfig = SolverConfig {
  preferEasyGoalChoices :: Bool,
  pStrategy             :: PackagesPreferenceDefault,
  avoidReinstalls       :: Bool
}

defaultSolverConfig :: Bool -> SolverConfig
defaultSolverConfig ar = SolverConfig {
  preferEasyGoalChoices = False,
  pStrategy             = PreferLatestForSelected, -- latest for goals only
  avoidReinstalls       = ar
}

solve :: SolverConfig ->   -- solver parameters
         Index ->          -- all available packages as an index
         (PN -> PackagePreferences) -> -- preferences
         Map PN PackageConstraint ->   -- global constraints
         [PN] ->                       -- global goals
{'fraction_non_alphanumeric': 0.07474676912329724, 'fraction_numerical': 0.0, 'mean_word_length': 3.6193548387096772, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2651732', 'n_tokens_mistral': 712, 'n_tokens_neox': 694, 'n_words': 172}