[racket] typing a function

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Wed Nov 21 12:41:03 EST 2012

Type inference here does not want to annoy users by assigning a singleton type to the f binding, since this can cause more problems. You'll need to change (define f -1) to (define: f : -1 -1) if you really want this to type.
----- Original Message -----
From: "Pierpaolo Bernardi" <olopierpa at gmail.com>
To: users at racket-lang.org
Sent: Wednesday, November 21, 2012 12:34:29 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket] typing a function

Another puzzle.  Why the following, as written, does not type:

#lang typed/racket

(define-type sex (U -1 0 1))

(struct: sexomino
  ((n : sex)
   (e : sex)
   (s : sex)
   (o : sex)))

(: sexomini (Listof sexomino))
(define sexomini
  (let ()
    (define n 0)
    (define f -1)
    (define m 1)
    (define s sexomino)
    (list (s n m n n) (s f f n n))))

while it works if I change the last line to:

 (list (s n m n n) (s -1 -1 n n))))


  Racket Users list:

Posted on the users mailing list.