Get project root
ModuleAgda-2.8.0.2Haskell2010
Agda.Interaction.Library
Library management.
Sample use:
-- Get libraries as listed in .agda/libraries file.
libs <- getInstalledLibraries Nothing
-- Get the libraries (and immediate paths) relevant for projectRoot.
-- This involves locating and processing the .agda-lib file for the project.
(libNames, includePaths) <- getDefaultLibraries projectRoot True
-- Get include paths of depended-on libraries.
resolvedPaths <- libraryIncludePaths Nothing libs libNames
let allPaths = includePaths ++ resolvedPaths
- 8 types
- 16 values
- PackageAgda-2.8.0.2
- Exports24
- LanguageHaskell2010
- LicenceMIT
- SourceLibrary.hs
getDefaultLibraries Get dependencies and include paths for given project root:
Look for .agda-lib files according to findAgdaLibFiles.
If none are found, use default dependencies (according to defaults file)
and current directory (project root).
getInstalledLibraries :: Maybe FilePathOverride the default
librariesfile?-> LibM [AgdaLibFile]Content of library files. (Might have empty
LibNames.)
Parse the descriptions of the libraries Agda knows about.
Returns none if there is no libraries file.
Return the trusted executables Agda knows about.
Returns none if there is no executables file.
libraryIncludePaths Get all include pathes for a list of libraries to use.
Get the content of the .agda-lib file in the given project root.
Returns the absolute default lib dir. This directory is used to store the Primitive.agda file.
Determine whether the second absolute path refers to one of Agda's primitive modules. The first argument should be the result of getPrimitiveLibDir.
All builtin modules.
These builtins may use postulates, and are still considered --safe.
These builtins may not use postulates under --safe. They are not
automatically unsafe, but will be if they use an unsafe feature.
The very magical, auto-imported modules.
A symbolic library name.
Library names are structured into the base name and a suffix of version
numbers, e.g. mylib-1.2.3. The version suffix is optional.
Instances9Eq, Ord, Show, Generic, NFData, Hashable, …
Eq LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseOrd LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseIn comparisons, a missing version number is assumed to be infinity. E.g.
foo > foo-2.2 > foo-2.0.1 > foo-2 > foo-1.0.Show LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseGeneric LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseNFData LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseHashable LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BasePretty LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseNull LibNameDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Basetype Rep LibName = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Base"LibName"
"Agda.Interaction.Library.Base"
"Agda-2.8.0.2-IWATId8XtJVEb9GRZaI6YB"
'False) (C1 ('MetaCons"LibName"
'PrefixI 'True) (S1 ('MetaSel ('Just"libNameBase"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just"libNameVersion"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Integer])))
Split a library name into basename and a list of version numbers.
parseLibName "foo-1.2.3" == LibName "foo" [1, 2, 3]
parseLibName "foo-01.002.3" == LibName "foo" [1, 2, 3]Note that because of leading zeros, parseLibName is not injective.
(prettyShow . parseLibName would produce a normal form.)
The options from an OPTIONS pragma (or a .agda-lib file).
In the future it might be nice to switch to a more structured representation. Note that, currently, there is not a one-to-one correspondence between list elements and options.
Constructors
OptionsPragmapragmaStrings :: [String]The options.
pragmaRange :: RangeThe range of the options in the pragma (not including things like an
OPTIONSkeyword).
Instances5Show, Semigroup, Monoid, NFData, EmbPrj
Show OptionsPragmaDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseSemigroup OptionsPragmaDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseMonoid OptionsPragmaDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseNFData OptionsPragmaDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseRanges are not forced.
EmbPrj OptionsPragmaDefined in Agda-2.8.0.2 · Agda.TypeChecking.Serialise.Instances.Common · orphan
Content of a .agda-lib file.
Constructors
AgdaLibFile_libName :: LibNameThe symbolic name of the library.
_libFile :: FilePathPath to this
.agda-libfile (not content of the file)._libAbove :: !IntHow many directories above the Agda file is the
.agda-libfile located?_libIncludes :: [FilePath]Roots where to look for the modules of the library.
_libDepends :: [LibName]Dependencies.
_libPragmas :: OptionsPragmaDefault pragma options for all files in the library.
Instances4Show, Generic, NFData, Rep
Show AgdaLibFileDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseGeneric AgdaLibFileDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseNFData AgdaLibFileDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Basetype Rep AgdaLibFile = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Base"AgdaLibFile"
"Agda.Interaction.Library.Base"
"Agda-2.8.0.2-IWATId8XtJVEb9GRZaI6YB"
'False) (C1 ('MetaCons"AgdaLibFile"
'PrefixI 'True) ((S1 ('MetaSel ('Just"_libName"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LibName) :*: (S1 ('MetaSel ('Just"_libFile"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: S1 ('MetaSel ('Just"_libAbove"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Int))) :*: (S1 ('MetaSel ('Just"_libIncludes"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [FilePath]) :*: (S1 ('MetaSel ('Just"_libDepends"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [LibName]) :*: S1 ('MetaSel ('Just"_libPragmas"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OptionsPragma)))))
A symbolic executable name.
Throws LibErrors exceptions, still collects LibWarnings.
Raise collected LibErrors as exception.
Constructors
Instances6Show, Generic, NFData, Pretty, EmbPrj, Rep
Show LibWarningDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseGeneric LibWarningDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseNFData LibWarningDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BasePretty LibWarningDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseEmbPrj LibWarningDefined in Agda-2.8.0.2 · Agda.TypeChecking.Serialise.Instances.Errors · orphantype Rep LibWarning = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Base"LibWarning"
"Agda.Interaction.Library.Base"
"Agda-2.8.0.2-IWATId8XtJVEb9GRZaI6YB"
'False) (C1 ('MetaCons"LibWarning"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe LibPositionInfo)) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LibWarning')))
Information about which .agda-lib file we are reading
and from where in the libraries file it came from.
Constructors
LibPositionInfolibFilePos :: Maybe FilePathName of
librariesfile.lineNumPos :: LineNumberLine number in
librariesfile.filePos :: FilePathLibrary file.
Instances5Show, Generic, NFData, EmbPrj, Rep
Show LibPositionInfoDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseGeneric LibPositionInfoDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseNFData LibPositionInfoDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseEmbPrj LibPositionInfoDefined in Agda-2.8.0.2 · Agda.TypeChecking.Serialise.Instances.Errors · orphantype Rep LibPositionInfo = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Base"LibPositionInfo"
"Agda.Interaction.Library.Base"
"Agda-2.8.0.2-IWATId8XtJVEb9GRZaI6YB"
'False) (C1 ('MetaCons"LibPositionInfo"
'PrefixI 'True) (S1 ('MetaSel ('Just"libFilePos"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FilePath)) :*: (S1 ('MetaSel ('Just"lineNumPos"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LineNumber) :*: S1 ('MetaSel ('Just"filePos"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath))))
A file can either belong to a project located at a given root containing an .agda-lib file, or be part of the default project.
Constructors
ProjectConfigconfigRoot :: FilePathDirectory which contains the
.agda-libfile for the current project.configAgdaLibFile :: FilePath.agda-libfile relative to configRoot (filename only, no directory).configAbove :: !IntHow many directories above the Agda file is the
.agda-libfile located?
DefaultProjectConfig
Instances3Generic, NFData, Rep
Generic ProjectConfigDefined in Agda-2.8.0.2 · Agda.Interaction.Library.BaseNFData ProjectConfigDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Basetype Rep ProjectConfig = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Interaction.Library.Base"ProjectConfig"
"Agda.Interaction.Library.Base"
"Agda-2.8.0.2-IWATId8XtJVEb9GRZaI6YB"
'False) (C1 ('MetaCons"ProjectConfig"
'PrefixI 'True) (S1 ('MetaSel ('Just"configRoot"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just"configAgdaLibFile"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: S1 ('MetaSel ('Just"configAbove"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Int))) :+: C1 ('MetaCons"DefaultProjectConfig"
'PrefixI 'False) U1)
Exported for testing
1 declarationGeneralized version of findLib for testing.
findLib' id "a" [ "a-1", "a-02", "a-2", "b" ] == [ "a-02", "a-2" ]findLib' id "a" [ "a", "a-1", "a-01", "a-2", "b" ] == [ "a" ]
findLib' id "a-1" [ "a", "a-1", "a-01", "a-2", "b" ] == [ "a-1", "a-01" ]
findLib' id "a-2" [ "a", "a-1", "a-01", "a-2", "b" ] == [ "a-2" ]
findLib' id "c" [ "a", "a-1", "a-01", "a-2", "b" ] == []