From 47368ddf9558ca1810e9ade58bde3cb6ede7cce6 Mon Sep 17 00:00:00 2001 From: davidaf3 Date: Thu, 14 Nov 2024 19:55:57 +0100 Subject: [PATCH] Allow mixing local with and without paths when generating --- src/Action/Generate.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Action/Generate.hs b/src/Action/Generate.hs index 0793f58a..8c33e733 100644 --- a/src/Action/Generate.hs +++ b/src/Action/Generate.hs @@ -238,11 +238,20 @@ actionGenerate g@Generate{..} = withTiming (if debug then Just $ replaceExtensio warnFlagIgnored "--haddock" "set" (local_ /= []) "--local" warnFlagIgnored "--haddock" "set" (isJust download) "--download" readHaskellHaddock timing settings dir - | [""] <- local_ -> do - warnFlagIgnored "--local" "used as flag (no paths)" (isJust download) "--download" - readHaskellGhcpkg timing settings | [] <- local_ -> do readHaskellOnline timing settings doDownload - | otherwise -> readHaskellDirs timing settings local_ + | otherwise -> do + let (localFlag, dirs) = partition (=="") local_ + (ghcPkgCbl, ghcPkgWant, ghcPkgSource) <- + if null localFlag + then pure (Map.empty, Set.empty, pure ()) + else do + warnFlagIgnored "--local" "used as flag (no paths)" (isJust download) "--download" + readHaskellGhcpkg timing settings + (dirsCbl, dirsWant, dirsSource) <- + if null dirs + then pure (Map.empty, Set.empty, pure ()) + else readHaskellDirs timing settings dirs + pure (Map.union dirsCbl ghcPkgCbl, Set.union dirsWant ghcPkgWant, ghcPkgSource >> dirsSource) Frege | [] <- local_ -> readFregeOnline timing doDownload | otherwise -> errorIO "No support for local Frege databases" (cblErrs, popularity) <- evaluate $ packagePopularity cbl