[plt-scheme] typed teaching languages

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Sun Aug 9 18:35:55 EDT 2009


The following program should work:

#lang typed-scheme
(: positive-real? (Any -> Boolean))
(define (positive-real? v)
  (and (number? v) (real? v) (>= v 0)))

Currently >= expects inputs of type Number, and number? is the
predicate for the Number type.  I do not believe there is a Real type,
and real? is not recognized as a type predicate.

Carl Eastlund

On Sun, Aug 9, 2009 at 6:28 PM, Todd O'Bryan<toddobryan at gmail.com> wrote:
> Thank you. I'm now making progress...
> However, I've hit a Typed Scheme hiccup.
> (define (positive-real? v)
>  (and (real? v) (>= v 0)))
> won't type check because it thinks the second v is just an Any.
> I tried adding a type annotation (ann v Number) with a begin around
> the second part of the and, but that didn't help.
> Anybody know how to give Typed Scheme the hint it needs here?
> Todd

Posted on the users mailing list.