on master help sign in
Get rid of warning, throw specific error in impossible case
f63020aEvan Czaplicki
src/Optimize/DecisionTree.hs+16−11
@@ -431,19 +431,24 @@ addWeights toWeight paths =
431
431
432
432
433bests :: [(Path, Int)] -> [Path]
433bests :: [(Path, Int)] -> [Path]
434−bests ( (headPath, headWeight) : weightedPaths ) =
434+bests allPaths =
435− let
435+ case allPaths of
436− gatherMinimum acc@(minWeight, paths) (path, weight) =
436+ [] ->
437− if weight == minWeight then
437+ error "Cannot choose the best of zero paths. This should never happen."
438− (minWeight, path : paths)
439
438
439+ (headPath, headWeight) : weightedPaths ->
440+ let
441+ gatherMinimum acc@(minWeight, paths) (path, weight) =
440− else if weight < minWeight then
442+ if weight == minWeight then
441− (weight, [path])
443+ (minWeight, path : paths)
442
444
445+ else if weight < minWeight then
446+ (weight, [path])
447+
443− else
448+ else
444− acc
449+ acc
445− in
450+ in
446− snd (List.foldl' gatherMinimum (headWeight, [headPath]) weightedPaths)
451+ snd (List.foldl' gatherMinimum (headWeight, [headPath]) weightedPaths)
447
452
448
453
449-- PATH PICKING HEURISTICS
454-- PATH PICKING HEURISTICS