[commit: ghc] wip/nfs-locking: Add findKnownPackage for finding packages by name. (b51e6d9)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:04:52 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/b51e6d97b5f930963687dca5eb64983324baa8b1/ghc

>---------------------------------------------------------------

commit b51e6d97b5f930963687dca5eb64983324baa8b1
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Wed Aug 19 02:42:15 2015 +0100

    Add findKnownPackage for finding packages by name.


>---------------------------------------------------------------

b51e6d97b5f930963687dca5eb64983324baa8b1
 src/Settings/Packages.hs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/Settings/Packages.hs b/src/Settings/Packages.hs
index 6e236c9..369879c 100644
--- a/src/Settings/Packages.hs
+++ b/src/Settings/Packages.hs
@@ -1,6 +1,6 @@
 module Settings.Packages (
     module Settings.Default,
-    packages, getPackages, knownPackages
+    packages, getPackages, knownPackages, findKnownPackage
     ) where
 
 import Package
@@ -9,6 +9,7 @@ import Expression
 import Oracles.Setting
 import Settings.User
 import Settings.Default
+import Data.List
 
 -- Combining default list of packages with user modifications
 packages :: Packages
@@ -40,3 +41,11 @@ packagesStage1 = mconcat
 
 knownPackages :: [Package]
 knownPackages = defaultKnownPackages ++ userKnownPackages
+
+-- Note: this is slow but we keep it simple as there not too many packages (30)
+-- We handle integerLibrary in a special way, because packages integerGmp and
+-- integerGmp2 have the same package name -- we return the user-selected one.
+findKnownPackage :: PackageName -> Maybe Package
+findKnownPackage name
+    | name == pkgName integerLibrary = Just integerLibrary
+    | otherwise = find (\pkg -> pkgName pkg == name) knownPackages



More information about the ghc-commits mailing list