[racket-dev] A function for checking if a library path exists

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Wed Apr 23 17:41:19 EDT 2014

I'd like to have a function that takes a collection path, as can be
given to `lib`, and gives me back the file name.  What's the best way
to do this?

It would seem like `collection-file-path` is the obvious solution, but
that requires me to parse `racket/list` into "racket" and "list.rkt".
The other alternative is, I think:

(define (f x)
  (define rmp ((current-module-name-resolver) x #f #f #f))
  (define p (resolved-module-path-name rmp))
  (and (file-exists? p) p))

Is this correct? Is there a simpler way to write it?

Sam

Posted on the dev mailing list.