<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 :: SolverConfig
defaultSolverConfig = SolverConfig {
  preferEasyGoalChoices = True,
  pStrategy             = PreferLatestForSelected, -- latest for goals only
  avoidReinstalls       = True
}

originalSolve :: SolverConfig ->   -- solver parameters
                 Index ->          -- all available packages as an index
                 Preferences ->    -- global preferences
                 Preferences ->    -- user preferences (override the global preferences)
                 [PN] ->           -- global goals
                 [Dep PN] ->       -- global constraints
                 P.GlobalFlags ->  -- global flag choices
                 P.LocalFlags ->   -- local flag choices
                 Log Message (Assignment, RevDepMap)
originalSolve sc idx globalPrefs userPrefs userGoals userDeps globalFlags localFlags =
  explorePhase     $
  heuristicsPhase  $
  preferencesPhase $
  pStrategyPhase   $
  validationPhase  $
  prunePhase       $
  buildPhase
  where
    explorePhase = exploreTreeLog
    heuristicsPhase = if preferEasyGoalChoices sc
                        then P.deferDefaultFlagChoices . P.preferEasyGoalChoices
                        else id
    preferencesPhase = P.preferPreferences   userPrefs .
                       P.preferPreferences globalPrefs
    pStrategyPhase = case pStrategy sc of
                       PreferAllLatest ->
                         P.preferLatest . P.preferInstalled
                       PreferLatestForSelected -><commit_msg>change avoidReinstalls default, to match old Cabal solver<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 :: SolverConfig
defaultSolverConfig = SolverConfig {
  preferEasyGoalChoices = True,
  pStrategy             = PreferLatestForSelected, -- latest for goals only
  avoidReinstalls       = False
}

originalSolve :: SolverConfig ->   -- solver parameters
                 Index ->          -- all available packages as an index
                 Preferences ->    -- global preferences
                 Preferences ->    -- user preferences (override the global preferences)
                 [PN] ->           -- global goals
                 [Dep PN] ->       -- global constraints
                 P.GlobalFlags ->  -- global flag choices
                 P.LocalFlags ->   -- local flag choices
                 Log Message (Assignment, RevDepMap)
originalSolve sc idx globalPrefs userPrefs userGoals userDeps globalFlags localFlags =
  explorePhase     $
  heuristicsPhase  $
  preferencesPhase $
  pStrategyPhase   $
  validationPhase  $
  prunePhase       $
  buildPhase
  where
    explorePhase = exploreTreeLog
    heuristicsPhase = if preferEasyGoalChoices sc
                        then P.deferDefaultFlagChoices . P.preferEasyGoalChoices
                        else id
    preferencesPhase = P.preferPreferences   userPrefs .
                       P.preferPreferences globalPrefs
    pStrategyPhase = case pStrategy sc of
                       PreferAllLatest ->
                         P.preferLatest . P.preferInstalled
                       PreferLatestForSelected ->
{'fraction_non_alphanumeric': 0.0601025641025641, 'fraction_numerical': 0.0, 'mean_word_length': 2.4828571428571427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1461819', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1162, 'n_words': 291}