@@ -431,19 +431,24 @@ addWeights toWeight paths =
431431
432432
433433bests :: [(Path, Int)] -> [Path]
434−bests ( (headPath, headWeight) : weightedPaths ) =
435− let
436− gatherMinimum acc@(minWeight, paths) (path, weight) =
437− if weight == minWeight then
438− (minWeight, path : paths)
434+bests allPaths =
435+ case allPaths of
436+ [] ->
437+ error "Cannot choose the best of zero paths. This should never happen."
439438
440− else if weight < minWeight then
441− (weight, [path])
439+ (headPath, headWeight) : weightedPaths ->
440+ let
441+ gatherMinimum acc@(minWeight, paths) (path, weight) =
442+ if weight == minWeight then
443+ (minWeight, path : paths)
442444
443− else
444− acc
445− in
446− snd (List.foldl' gatherMinimum (headWeight, [headPath]) weightedPaths)
445+ else if weight < minWeight then
446+ (weight, [path])
447+
448+ else
449+ acc
450+ in
451+ snd (List.foldl' gatherMinimum (headWeight, [headPath]) weightedPaths)
447452
448453
449454-- PATH PICKING HEURISTICS