[racket] prefix/rename for signatures in unit and define-signature forms

From: dfeltey at ccs.neu.edu (dfeltey at ccs.neu.edu)
Date: Thu May 8 16:56:52 EDT 2014

I'm trying to make sense of how prefix/rename work for signatures, but in trying to run some examples the actual implementation doesn't seem to match either my intuition or the documentation. 

For example I have the following simple signature:

(define-signature a^ (a))

I then try to build a new signature from a^ with a combination of open and prefix/rename.

(define-signature b-bad^
  ((open (prefix x: (rename (prefix y: a^) (q y:a))))))

This example, however, gives the error: 
"open: listed identifier not present in signature specification in: x:y:a"

I'm not sure I understand this since it appears as though prefixing x: comes before the renaming, but I would have though that first y: is prefixed to a, so that y:a is in the signature which can then be renamed q. So in the end the only variable in the signature should be x:q.

Attempting the same in a unit form gives a similar error:

(define u-bad 
  (unit (import (prefix x: (rename (prefix y: a^) (q y:a)))) 
        (export)
        x:q))
"unit: listed identifier not present in signature specification in: x:y:a"


If I change the prefix x: to y: things seem to work for some reason.

(define-signature b-good^
  ((open (prefix y: (rename (prefix y: a^) (q y:a))))))

In this case, I still expect the variable in the signature to be something like y:q, but trying a similar renaming in a unit form fails:

(define u-bad2 
  (unit (import (prefix y: (rename (prefix y: a^) (q y:a)))) 
        (export)
        y:q))

With the error:
"y:q: unbound identifier in module in: y:q"

 while the following does work

(define u-good 
  (unit (import (prefix y: (rename (prefix y: a^) (q y:a)))) 
        (export)
        q))


Am I misunderstanding something obvious about the way that the renaming/prefixing should be taking place on the level of a signature or unit import/export clause? The results I'm seeing are completely unintuitive to me and the documentation doesn't seem to clarify this for me.

Thanks
Dan

Posted on the users mailing list.