简体   繁体   中英

How to use `eval` in typed racket?

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.

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM