-- | Does a case-insensitive substring search by package name.
--
-- That is, all packages that contain the given string in their name.
--
searchByNameSubstring :: PackageIndex pkg
                      -> String -> [(PackageName, [pkg])]
searchByNameSubstring (PackageIndex m) searchterm =
    [ pkgs
    | pkgs@(PackageName name, _) <- Map.toList m
    , lsearchterm `isInfixOf` lowercase name ]
  where
    lsearchterm = lowercase searchterm
searchByNameSubstring :: PackageIndex pkg
                      -> String -> [(PackageName, [pkg])]
searchByNameSubstring (PackageIndex m) searchterm =
    [ pkgs
    | pkgs@(PackageName name, _) <- Map.toList m
    , lsearchterm `isInfixOf` lowercase name ]
  where
    lsearchterm = lowercase searchterm
searchByNameSubstring (PackageIndex m) searchterm =
    [ pkgs
    | pkgs@(PackageName name, _) <- Map.toList m
    , lsearchterm `isInfixOf` lowercase name ]
  where
    lsearchterm = lowercase searchterm