summaryrefslogtreecommitdiff
path: root/src/full/Agda/Interaction/Library.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/full/Agda/Interaction/Library.hs')
-rw-r--r--src/full/Agda/Interaction/Library.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/full/Agda/Interaction/Library.hs b/src/full/Agda/Interaction/Library.hs
index c2c1dce..209d5cf 100644
--- a/src/full/Agda/Interaction/Library.hs
+++ b/src/full/Agda/Interaction/Library.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE PatternGuards #-}
module Agda.Interaction.Library
( getDefaultLibraries
@@ -75,10 +73,12 @@ findAgdaLibFiles root = do
if up == root then return [] else findAgdaLibFiles up
files -> return files
-getDefaultLibraries :: FilePath -> LibM ([LibName], [FilePath])
-getDefaultLibraries root = mkLibM [] $ do
+getDefaultLibraries :: FilePath -> Bool -> LibM ([LibName], [FilePath])
+getDefaultLibraries root optDefaultLibs = mkLibM [] $ do
libs <- findAgdaLibFiles root
- if null libs then first (, []) <$> readDefaultsFile
+ if null libs
+ then
+ if optDefaultLibs then first (, []) <$> readDefaultsFile else return (([], []), [])
else first libsAndPaths <$> parseLibFiles Nothing (zip (repeat 0) libs)
where
libsAndPaths ls = (concatMap libDepends ls, concatMap libIncludes ls)
@@ -94,13 +94,14 @@ readDefaultsFile = do
`catchIO` \e -> return (["."], [OtherError $ "Failed to read defaults file.\n" ++ show e])
getLibrariesFile :: Maybe FilePath -> IO FilePath
-getLibrariesFile overrideLibFile = do
+getLibrariesFile (Just overrideLibFile) = return overrideLibFile
+getLibrariesFile Nothing = do
agdaDir <- getAgdaAppDir
- let override = maybe [] (:[]) overrideLibFile
- files <- (override ++) <$> filterM doesFileExist (map (agdaDir </>) defaultLibraryFiles)
+ let defaults = map (agdaDir </>) defaultLibraryFiles
+ files <- filterM doesFileExist defaults
case files of
file : _ -> return file
- [] -> return (agdaDir </> last defaultLibraryFiles) -- doesn't exist, but that's ok
+ [] -> return (last defaults) -- doesn't exist, but that's ok
getInstalledLibraries :: Maybe FilePath -> LibM [AgdaLibFile]
getInstalledLibraries overrideLibFile = mkLibM [] $ do
@@ -195,4 +196,3 @@ versionView s =
valid [] = False
valid vs = not $ any null vs
_ -> (s, [])
-