On Nov 21, 2012, at 11:34 AM, Pierpaolo Bernardi wrote:

> #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))))


I believe nobody responded. On occasion the type checker needs help narrowing 
down a type, as in your example. Specifically, the type checker on occasion 
guesses (fancy word is: "locally infers") a type and to make programming 
convenient, it guesses a little larger than good for things like your example. 
The easy fix is

#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)
    (: f sex)
    (define f -1)
    (define m 1)
    (define s sexomino)
    (list (s n m n n) (s f f n n))))

This is a compromise to accommodate code from an untyped basis mostly as is and 
helping programmers find even narrower types when they wish to make sharp 
invariants explicit. 

Think of TR as a wide-spectrum typed programming experience 

-- Matthias



Attachment: smime.p7s
Description: S/MIME cryptographic signature

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to