[racket] weird behavior with in-range in typed racket

From: Alexander D. Knauth (alexander at knauth.org)
Date: Thu Feb 5 22:07:52 EST 2015

This program:
#lang typed/racket
(define n : Real 5)
(for/list ([i : Natural (in-range n)]) : (Listof Natural)
  i)
And this program:
#lang typed/racket
(define n : Real 5)
(for/list ([i : Natural (identity (in-range n))]) : (Listof Natural)
  i)
The first one produces an error:
. Type Checker: type mismatch
  expected: Nonnegative-Integer
  given: Integer in: (for/list ((i : Natural (in-range n))) : (Listof Natural) i)
The second one works fine:
'(0 1 2 3 4)
But why does the first one produce integer, but wrapping it in identity make it produce Nonnegative-Integer (Natural) ?




Posted on the users mailing list.