Imports
To reduce the need for rewriting common definitions across specifications, tadpole allows importing other files.
Imports are included as if the file content were copied into the file at the point of the import statement. Files which are imported in multiple places are ignored after the first import statement.
Local Imports
Local imports use a file path relative to the importing file, written as a string.
with "imported.tp";This method is preferred when splitting specifications across multiple files without intending to reuse code in other specifications.
Library imports
Library imports specify the path as a series of path segments separated by periods. The .tp extension is omitted.
with std.util;This will search for a file named std/util.tp in the following paths, in order:
- The current working directory
- The path specified in the environment variable
TADPOLE_LIBS_DIR Within the user data directory:
- On Linux, in
$XDG_DATA_HOME/tadpole/lib/ - On Windows, in
{FOLDERID_RoamingAppData}/tadpole/lib/ - On MacOS, in
$HOME/Library/Application Support/tadpole/lib/
- On Linux, in
- In the built-in libraries included in the tadpole executable
The standard library is included in the tadpole binary and available alongside CLI releases. More details can be found in the chapter on the standard library.