Agda-2.3.2: A dependently typed functional programming language and proof assistant

Safe Haskell | None

Agda.Interaction.FindFile

Description

Functions which map between module names and file names.

Note that file name lookups are cached in the `TCState`. The code assumes that no Agda source files are added or removed from the include directories while the code is being type checked.

Synopsis

- toIFile :: AbsolutePath -> AbsolutePath
- data FindError
  - = NotFound [AbsolutePath]
  - | Ambiguous [AbsolutePath]
- findErrorToTypeError :: TopLevelModuleName -> FindError -> TypeError
- findFile :: TopLevelModuleName -> TCM AbsolutePath
- findFile' :: TopLevelModuleName -> TCM (Either FindError AbsolutePath)
- findFile'' :: [AbsolutePath] -> TopLevelModuleName -> ModuleToSource -> IO (Either FindError AbsolutePath, ModuleToSource)
- findInterfaceFile :: TopLevelModuleName -> TCM (Maybe AbsolutePath)
- checkModuleName :: TopLevelModuleName -> AbsolutePath -> TCM ()
- moduleName' :: AbsolutePath -> TCM TopLevelModuleName
- moduleName :: AbsolutePath -> TCM TopLevelModuleName
- type ModuleToSource = Map TopLevelModuleName AbsolutePath
- type SourceToModule = Map AbsolutePath TopLevelModuleName
- sourceToModule :: TCM SourceToModule
- tests :: IO Bool

# Documentation

toIFile :: AbsolutePath -> AbsolutePath

Converts an Agda file name to the corresponding interface file name.

data FindError

Errors which can arise when trying to find a source file.

Invariant: All paths are absolute.

Constructors

NotFound [AbsolutePath] | The file was not found. It should have had one of the given file names.
Ambiguous [AbsolutePath] | Several matching files were found. Invariant: The list of matching files has at least two elements.

findErrorToTypeError :: TopLevelModuleName -> FindError -> TypeError

Given the module name which the error applies to this function converts a `FindError` to a `TypeError`.

findFile :: TopLevelModuleName -> TCM AbsolutePath

Finds the source file corresponding to a given top-level module name. The returned paths are absolute.

Raises an error if the file cannot be found.

findFile' :: TopLevelModuleName -> TCM (Either FindError AbsolutePath)

Tries to find the source file corresponding to a given top-level module name. The returned paths are absolute.

findFile''

Arguments

:: [AbsolutePath] | Include paths.
-> TopLevelModuleName |
-> ModuleToSource | Cached invocations of `findFile''`. An updated copy is returned.
-> IO (Either FindError AbsolutePath, ModuleToSource) |

A variant of `findFile'` which does not require `TCM`.

findInterfaceFile :: TopLevelModuleName -> TCM (Maybe AbsolutePath)

Finds the interface file corresponding to a given top-level module name. The returned paths are absolute.

Raises an error if the source file cannot be found, and returns `Nothing` if the source file can be found but not the interface file.

checkModuleName

Arguments

:: TopLevelModuleName | The name of the module.
-> AbsolutePath | The file from which it was loaded.
-> TCM () |

Ensures that the module name matches the file name. The file corresponding to the module name (according to the include path) has to be the same as the given file name.

moduleName' :: AbsolutePath -> TCM TopLevelModuleName

Computes the module name of the top-level module in the given file.

moduleName :: AbsolutePath -> TCM TopLevelModuleName

A variant of `moduleName'` which raises an error if the file name does not match the module name.

The file name is interpreted relative to the current working directory (unless it is absolute).

type ModuleToSource = Map TopLevelModuleName AbsolutePath

Maps top-level module names to the corresponding source file names.

type SourceToModule = Map AbsolutePath TopLevelModuleName

Maps source file names to the corresponding top-level module names.

sourceToModule :: TCM SourceToModule

Creates a `SourceToModule` map based on `stModuleToSource`.

tests :: IO Bool