<div class="__aliyun_email_body_block"><div  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun"><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span >Inspired by typed-lambda in S7 Scheme stuff.scm</span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span ><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span >I just implemented typed-define. It is licensed in Apache License by the Goldfish Scheme authors and it is ok for the author to adopt it and re-distribute it in 0 clause BSD license.</span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span ><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span >Here is the code snippets ( it is based on define*, and predicates-based type checking is mandatory ):</span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span ><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span >(define-macro (typed-define name-and-params x . xs)</span><div  style="clear: both;">&nbsp; (let* ((name (car name-and-params))</div><div  style="clear: both;"> &nbsp; &nbsp; &nbsp; &nbsp; (params (cdr name-and-params)))</div><div  style="clear: both;">&nbsp; &nbsp; `(define* (,name ,@(map (lambda (param)</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (let ((param-name (car param))</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (type-pred (cadr param))</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (default-value (cddr param)))</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (if (null? default-value)</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; param-name</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `(,param-name ,(car default-value)))))</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params))</div><div  style="clear: both;"> &nbsp; &nbsp; &nbsp; ,@(map (lambda (param)</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (let ((param-name (car param))</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (type-pred (cadr param)))</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `(unless (,type-pred ,param-name)</div><div  style="clear: both;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (error 'type-error (string-append "Invalid type for " (symbol-&gt;string ',param-name))))))</div><div  style="clear: both;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params)</div><div  style="clear: both;"> &nbsp; &nbsp; &nbsp; ,x</div><div ><span > &nbsp; &nbsp; &nbsp; ,@xs)))</span></div><span ><br ></span></div></div></div>