interface-files.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .. _interface-files:
  2. ***************
  3. Interface files
  4. ***************
  5. .. note::
  6. This is a stub. Contributions, additions and corrections are greatly
  7. appreciated.
  8. When an ``.agda`` file is saved, another file with the same name and extension
  9. ``.agdai`` is automatically created. The latter file is what we call an
  10. **interface file**.
  11. Interface files store the results from the type-checking process. These
  12. results include:
  13. * A translation of pattern-matching definitions to case trees (this translation
  14. speeds up computation).
  15. * The resolution of all implicit arguments.
  16. (Note: under the flag ``--allow-unsolved-metas`` not **all** implicit arguments
  17. need to be resolved to create an interface file.)
  18. Storage
  19. -------
  20. In projects that do not use any Agda library, the ``.agdai`` files are
  21. stored alongside the ``.agda`` source file.
  22. If the ``.agda`` source file is part of a project with an *identifiable root*
  23. (i.e. if there is an ``.agda-lib`` file in any of the directories above it),
  24. then the interface file is stored in the ``_build/VERSION`` directory at the
  25. identified root. This prevents losing the interface file when switching between
  26. agda versions. You can revert this behaviour with the flag ``--no-project``.
  27. .. note::
  28. When an ``.agda`` file is renamed, the old ``.agdai`` file is kept, and a new
  29. ``.agdai`` file is created. This is the intended behavior, and the orphan
  30. files can be safely deleted from the user's file system if needed.
  31. The compression run to create ``.agdai`` files introduces sharing. Sharing
  32. improves the memory efficiency of the code loaded from interface files.
  33. The syntax represented in ``.agdai`` files differs significantly from the syntax
  34. of source files.
  35. Compilation
  36. -----------
  37. An external module is loaded by loading its interface file. Interface files are
  38. also intermediate points when compiling through a backend to e.g. Haskell.