How can I redefine defintions in typed racket top level (repl)

Edit: I have realised, the details in my post is flawed (the example) and incomplete, please see my reply here in this samep post, for the additional details I have put in.

What version of Racket are you using?

Racket 8.5 [cs]

What program did you run?

(define (a x) x)
(define (a x) (+ 1 x))

What should have happened?

(a 1) would evaluate to 2 now.

If you got an error message, please include it here.

; :2593:14: Type Checker: No function domains matched in function application:
; Types: Number * -> Number
; Arguments: One Any
; Expected result: Any
;
; in: (+ 1 x)

The change in function signature cause a redefinition to fail, where as in untyped racket, this would succeed.

Thanks for your time :slight_smile:

1 Like

See my response at https://github.com/racket/typed-racket/issues/1266

In addition to what @sorawee described in his comment, Typed Racket currently does not support ML-style type inference. In this case, you need to give the parameter x a subtype of Number, either through the declarative form (which @sorawee has showed) or though an inlined type annotation

1 Like

@capfredf @sorawee
Thanks for the quick response and explanataions.
However, I want to apologize for the bad example that did not illustrate the issue I would like to raise and seek help on.

Which is to redefine definitions in typed racket, but perhaps this next snippet could do the job better, i.e.I would like to know how I can have something similar to this happen:

(: a (-> Number Number))
(define (a x) (1 + x))
(: a (-> Symbol Symbol))
(define (a x) x)

Many thanks again, in advance.

1 Like