[plt-scheme] Type scheme annotations and macros

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Wed Oct 22 10:05:23 EDT 2008

A couple quick questions on Typed Scheme:

1) Why does the first type-check while the latter does not?

#lang typed-scheme
(if #f
     (add1 "dog")
     'ok)

#;
(if (ann #f #f)
     (add1 "dog")
     'ok)

2) How can I write a `bif' macro that works like Typed Scheme's if (ie. 
types its branches with occurrence typing), but forces the conditional 
value to be a Boolean and nothing but a Boolean?

(define-syntax bif
   (syntax-rules ()
     [(bif e0 e1 e2)
      (if (ann e0 Boolean)
          e1
          e2)]))

This enforces a Boolean type on e0, but seems to destroy the occurrence 
typing of e1 and e2.

Thanks,
David


Posted on the users mailing list.