modular/expansion/tags.scm
(module tags scheme

  (require ;;(lib "contract.ss")
           ;;(lib "plt-match.ss")
           "syntax-errors.scm"
           "idmap.scm"
           "../../private/planet.ss")
  (require-cce/scheme)

  (provide/contract

   [tag-id (-> identifier? identifier? identifier?)]
   [retag (-> idmap? identifier? identifier?)])

  (define (tag-id tag id)
    (text->identifier tag "." id #:stx id))

  (define (retag tags id)
    (match (regexp-match "^([^.]+)[.]([^.]+)$" (text->string id))
      [#f id]
      [(list full prefix suffix)
       (let* ([tag (idmap-get tags
                              (text->identifier prefix #:stx id)
                              (lambda () #f))])
         (if tag (tag-id tag (text->identifier suffix #:stx id)) id))]))

  )