This works though:

  #lang typed/racket

  (require mzlib/etc)

  (define-type NDigit (U 0 1 2 3 4 5 6 7 8 9))
  (define-type SDigit (U 'one 'two 'three 'four 'five 'six 'seven 'eight 'nine))

  (: f (-> NDigit SDigit))
  (define (f i)
    (evcase i
      [(ann 0 0) (displayln i) 'two]
      [(ann 1 1) (displayln i) 'two]
      [(ann 2 2) (displayln i) 'two]
      [(ann 3 3) (displayln i) 'two]
      [else 'one]))

This is because the original version didn't annotate the numeric literals,
which typecheck as Positive-Byte (except for 0 and 1 which are special).

Using = here won't work because the typechecking rule that considers filters
for equality doesn't work for =. The comment in the code says

  ;; `=' is not included. Its type is more useful than this typing rule.

Could we get the benefits of both approaches somehow?

Cheers,
Asumu

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to