[plt-scheme] check underlying type when composing units

From: Pinku Surana (suranap at gmail.com)
Date: Wed Dec 8 18:24:08 EST 2004

In the snippet below, how do I enforce that A@ and B@ have the same
underlying implementation of ordered^ when I run instantiate-B? I want
to prevent the following:

(instantiate-B B@ string@ (instantiate-A A@ integer@))

I'd prefer to keep A and B separate because their implementation might
change, though the underlying ordered^ must be the same.


Thanks.


;; code 

(define-signature ordered^ (elm= elm< elm<=))
(define-signature A^ ((open ordered^) x y z))
(define-signature B^ ((open ordered^) a b c))

(define A@
  (unit/sig A^ (import (o : ordered^))
    ;; define elm=,elm<,elm<= in terms of the imported ordered^
  ))

(define B@
  (unit/sig B^ (import (o : ordered^) (a : A^))
    ;; define elm=,elm<,elm<= in terms of the imported ordered^
    ;; these are different from A@
  ))

(define (instantiate-A impl-A@ order@)
  (compound-unit/sig
    (import)
    (link (O : ordered^ (order@))
          (A : A^ (impl-A@ O)))
    (export (open A))))

(define (instantiate-B impl-B@ order@ impl-A@)
  (compound-unit/sig
    (import)
    (link (O : ordered^ (order@))
          (A : A^ (impl-A@))
          (B : B^ (impl-B@ O A)))
    (export (open A))))


Posted on the users mailing list.