How to deal with `let/cc` in typed racket?

(: foo : -> Integer)
(define (foo)
  (let/cc r
    (r 1)))

The above program will report

Type Checker: Cannot apply expression of type Any, since it is not a function type in: (r 1)

How to let type checker knows the type of r?

1 Like

You need to annotate the binding of r:

#lang typed/racket

(: foo : -> Integer)
(define (foo)
  (let/cc r : Integer
    (r 1)))
2 Likes

Oh! I was trying something like r : (-> Integer Integer)

1 Like

A regular continuation returns nothing, so the type of r is actually (-> Integer Nothing). However, since we know r is always a function and it always returns nothing, you just need to give the input type.

4 Likes