How to use `eval` in typed racket?

35 Views Asked by At

I evaluated an expression in the form of (time (eval ......)) in the repl (with -I typed/racket on the startup), and there occurred an error:

string:1:0: Type Checker: Polymorphic function `time-apply' could not be applied to arguments:
Domains: (-> a ... a b) (List a ... a) 
         (-> b) Null 
Arguments: (-> AnyValues) Null
  in: (time (eval ......))
 [,bt for context]

How can I specify the number and type of eval's results?

I've tried using cast and assert, which produced new errors.

1

There are 1 best solutions below

0
John Clements On

The issue here is with the exceedingly unusual type of 'eval'.

Two possible fixes:

#lang typed/racket

(time (call-with-values (λ () (eval (+ 3 4))) (inst list Any)))

or, if you don't need to capture the result, you can do something much simpler like

#lang typed/racket

(time (begin (eval (+ 3 4)) #f))