racket/collects/syntax/modcollapse.rkt
Matthew Flatt 9ba663aa77 preserve submoduleness in module path index for expanded submodules
The preserved path is exposed by a new `module-path-index-submodule'
function, and `module-path-index-join' now accepts an optional
submodule path.

Also, fixed a problem with `collapse-module-path-index' when
a module path indx is built on a resolved module path that
is a submodule path.

In addition to the main repair, `collapse-module-path[-index]' is
correctly documented to allow '(quote <sym>) rel-to paths.

Finally, `collapse-module-path-index' changed to use a symbolic
resolved module path that appears as the base of a module path
index, rather than falling back to the given rel-to path. It's
possble that the old beavior was intentional, but it wasn't tested,
and it seems more likely to have been a bug.

Closes PR 12724
2012-04-24 21:10:28 -06:00

36 lines
1.2 KiB
Racket

#lang racket/base
(require racket/contract/base
"private/modcollapse-noctc.rkt")
(define simple-rel-to-module-path-v/c
(and/c module-path?
(or/c
path?
(cons/c 'lib any/c)
(cons/c 'file any/c)
(cons/c 'planet any/c)
(cons/c 'quote any/c)
(cons/c 'submod
(cons/c (or/c
path?
(cons/c 'lib any/c)
(cons/c 'file any/c)
(cons/c 'planet any/c)
(cons/c 'quote any/c))
(cons/c symbol? (listof symbol?)))))))
(define rel-to-module-path-v/c
(or/c simple-rel-to-module-path-v/c
path?
symbol? ;; why do we allow symbols (which are non-normalized) as a `relto' value?
(-> simple-rel-to-module-path-v/c)))
(provide/contract
[collapse-module-path (module-path?
rel-to-module-path-v/c
. -> . simple-rel-to-module-path-v/c)]
[collapse-module-path-index ((or/c symbol? module-path-index?)
rel-to-module-path-v/c
. -> . simple-rel-to-module-path-v/c)])