definition:
|
searchPackages :: Repository -> Bool -> Bool -> String -> [[Package]]
searchPackages (Repository ps) searchmod searchexec searchterm =
map sortedByVersion (groupBy (\a b -> name a == name b) allResults)
where
allResults = let s = lowerS searchterm
in if searchmod
then filter (\p -> searchterm `elem` exportedModules p) ps
else if searchexec
then filter (\p -> s `isInfixOf`
(lowerS $ execOfPackage p)) ps
else filter (matches s) ps
matches q p = q `isInfixOf` (lowerS $ name p) ||
q `isInfixOf` (lowerS $ synopsis p) ||
q `isInfixOf` (lowerS $ unwords (exportedModules p))
sortedByVersion = sortBy (\a b -> version a `vgt` version b)
lowerS = map toLower
|
demand:
|
arguments 1 2
|
deterministic:
|
deterministic operation
|
documentation:
|
--- Search the names and synopses of all compiler-compatbile packages
--- in the repository for a particular term.
--- Lower/upercase is ignored for the search.
--- Returns all matching versions (newest first) of each package.
---
--- @param repo - the repository
--- @param searchmod - search for some module?
--- @param searchexec - search for some executable?
--- @param searchterm - the term to search for
|
failfree:
|
(_, _, _, _)
|
indeterministic:
|
referentially transparent operation
|
infix:
|
no fixity defined
|
iotype:
|
{({Repository},_,_,_) |-> {:,[]}}
|
name:
|
searchPackages
|
precedence:
|
no precedence defined
|
result-values:
|
{:,[]}
|
signature:
|
Repository -> Prelude.Bool -> Prelude.Bool -> String -> [[CPM.Package.Package]]
|
solution-complete:
|
operation might suspend on free variables
|
terminating:
|
possibly non-terminating
|
totally-defined:
|
possibly non-reducible on same data term
|