9 Modules and Imports
A Shplait program that starts with #lang shplait is a module, and its definitions are all implicitly exported for use by other modules. Use import in a module to import definitions from other modules. The module form adds to a submodule, which is nested inside another module.
definition | ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
import | ||||||||||||||||||||
| ||||||||||||||||||||
| ||||||||||||||||||||
import | ||||||||||||||||||||
|
If open is not used, then the last component of module_path (not counting a file suffix, if any), is used to prefix all of the imported names. Use the prefix, then ., then a name exported from the module to use that name. If open is used for the module, then its exported names can be used directly, without a prefix.
The typed form is for importing functions from modules that are written in a language other than Shplait. The specific bindings named by the in_names are imported from the module_path, and each imported binding is assumed (without specific compile-time or run-time checking) to have the specified type. An in_name can use . to access nested exports from module_path, in which case the last id is used as the name of the import. If in_name includes ~as, then the id after ~as is the local name. See type for an example.
The relative_path_string form allows only characters in a file name that are especially portable: a-z, A-Z, 0-9, -, +, _, /, and .. Use the file(path_string) form when a more general, platform-specific path_string is needed.
Some operating systems, such as Windows or macOS, may hide file extensions when listing files. A relative_path_string or path_string must include a file’s extension, if any, which is typically ".rhm".
declaration | ||||||||
| ||||||||
| ||||||||
|