[plt-scheme] Help making a unit from a module

From: Kyle Smith (airfoil at bellsouth.net)
Date: Tue Dec 19 21:29:29 EST 2006

The following works as I would expect:

(require (lib "unit.ss"))

(define-signature pp^ (data))

(define pp@
  (unit
    (import pp^)
    (export)
    
    (define (pp x)
      (printf "~a~n" x))
    
    (pp data)
    ))

(define data 'success)
(invoke-unit pp@ (import pp^))
(let ((data 'inside))
  (invoke-unit pp@ (import pp^))
  (let ()
    (define data 'deep-inside)
    (invoke-unit pp@ (import pp^))))
(define data 'another-time)
(invoke-unit pp@ (import pp^))
=>
success
inside
deep-inside
another-time
__________________________________________________________________

However, my attempts at getting the unit in a module have been frustrating.
This what I have, which does not work:

(module pp-sig mzscheme
  
  (provide pp^)
  
  (require (lib "unit.ss"))
  (define data #f)
  (define-signature pp^ (data)))

(module pp (lib "a-unit.ss")  

  (require pp-sig)
  
  (import pp^)
  (export)
  
  (define (pp x)
    (display x))
  
  (pp data))

(require pp)

(define data 'success)
(invoke-unit pp@ (import pp^))
=>
 invoke-unit: result of unit expression was not a unit: (make-unit ...)

Does someone know the magic sequence in order to make this work.  I know it's
possible, because that's what a-unit.ss is all about.  I'm just missing
something in the implementation.

Thanks,

--kyle
airfoil at bellsouth dot net
schemekeys.blogspot.com 




Posted on the users mailing list.