简体   繁体   中英

require/typed in typed racket… examples?

I'm trying to do use the science.plt module in a typed racket program, but I'm having a hard time understanding how to use the require/typed form properly. I've read the docs repeatedly, but I guess I don't quite understand what exactly I'm trying to produce with the form.

In the

[struct name ([f : t] ...)]

form, is the name a name I should expect to find in the module I want to require, or am I making it up for use within my own program?

Probably the most helpful thing for me would be an example or three of require/typed applied to untyped racket modules.

Or if I'm misunderstanding this real deeply and one cannot use untyped modules in a typed program, how should I go about structuring things? I really just need the random number and random distribution functionality from the science.plt module, and don't expect to have any other imports, at this point.

Did you have a look at the Typed Racket reference page for require/typed ? There are several examples there showing how to import from untyped modules.

The name expression in the [#:struct name ([f : t] ...) struct-option ...] clause is supposed to be the name of a structure type.

That is, if you have a struct like (struct point (xy) , the name is supposed to be point .

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