On this page:

6.12 API for Collection Searches🔗

 (require setup/collection-search) package: base

Added in version 6.3 of package base.


(collection-search mod-path 
  [#:init result 
  #:combine combine 
  #:break? break? 
  #:all-possible-roots? all-possible-roots?]) 
  mod-path : normalized-lib-module-path?
  result : any/c = #f
  combine : (any/c (and/c path? complete-path?) . -> . any/c)
   = (lambda (r v) v)
  break? : (any/c . -> . any/c) = (lambda (r) #f)
  all-possible-roots? : any/c = #f
Generalizes collection-file-path to support folding over all possible locations of a collection-based file in the current configuration. Unlike collection-file-path, collection-search takes the file to location in module-path form, but always as a 'lib path.

Each possible path for the file (not counting a ".ss" to/from ".rkt" conversion) is provided as a second argument to the combine function, where the first argument is the current result, and the value produced by combine becomes the new result. The #:init argument provides the initial result.

The break? function short-circuits a search based on the current value. For example, it could be used to short-circuit a search after a suitable path is found.

If all-possible-roots? is #f, then combine is called only on paths within "collects"-like directories (for the current configuration) where at least a matching collection directory exists.


(normalized-lib-module-path? v)  boolean?

  v : any/c
Returns #t if v is a module path (in the sense of module-path?) of the form '(lib str) where str contains at least one slash. The collapse-module-path function produces such module paths for collection-based module references.