[plt-scheme] units and macros (unit/lang ?)

From: Daniel Mahler (mahler at cyc.com)
Date: Thu Nov 20 21:29:42 EST 2003

The problem is that I want pluggable components, not harwired ones.
I am thinking of dsomething like a monad transformer framework,
with a pttern like:

(module
 Monad mzscheme
 (require (lib "unitsig.ss" "mzlib"))

 (define-signature monad^ (^ bind))

 (define-signature monad-transformer^ ((open monad^) lift))

 (define id@
   (unit/sig
    monad^
    (import)

    (define-syntax bind
      (syntax-rules ()
	((bind (var exp) body)
	 (let ((var exp))
	   body))))
    ...
    ))

 (define env-trans@
   (unit/sig
    monad-transformer^
    (import (T : monad^))
 
    (define-syntax bind
      (syntax-rules ()
	((bind (var exp) body)
	 (lambda (env)
	   (T:bind (var (exp env))
	      (body env))))))
    ...
    ))
 ...
)

and dynamically assembling layered monads using compound units.
Of course bind can be implemented as a function that takes a one
argument function as the body argument, but that introduces amny
superfluous lambdas into the code,
ie you end up always writing (bind exp (lambda (var) body))
in place of (bind (var exp) body).

thanks
D

    
Shriram Krishnamurthi writes:
 >   For list-related administrative tasks:
 >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
 > 
 > PLT Scheme's `module' mechanism does just this!  You can read Matthew
 > Flatt's ICFP 2002 paper for the full details, or begin here for a
 > quick and programmer-friendly introduction:
 > 
 >   http://www.htus.org/Book/Staging/how-to-use-modules/
 > 
 > Shriram



Posted on the users mailing list.