Given the following Typed Racket program:

#lang typed/racket

(: greater-than-5? (Any -> Boolean))
(define (greater-than-5? x)
  (and (integer? x) (> x 5)))

(: equal-to-7? (Any -> Boolean))
(define (equal-to-7? x)
  (and (greater-than-5? x) (= x 7)))

I receive the error (highlighting the x in (= x 7)):

Type Checker: Expected Complex, but got Any in: x

Is there a way to tag greater-than-5? to mark that it only returns #t on integers? Marking its type as (Any -> Boolean : Integer) causes an error:

Type Checker: Expected result with filter ((Integer @ x) | (! Integer @ x)), got filter (((U Float Integer) @ x) | (OrFilter (! Integer @ x) ((U Float Integer) @ x))) in: (and (integer? x) (> x 5))

-- Jeremiah Willcock
_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/users

Reply via email to