[commit: ghc] master: Respect the ordering of -package directives (574ccfa)

Simon Peyton-Jones simonpj at microsoft.com
Mon Dec 2 10:28:29 UTC 2013


Patrick

Thanks!  

When you do something subtle like change 'foldM' to 'foldrM', could you add a comment to point out the subtlety?  After all, by definition this was something that someone else missed.

Simon

| -----Original Message-----
| From: ghc-commits [mailto:ghc-commits-bounces at haskell.org] On Behalf Of
| git at git.haskell.org
| Sent: 02 December 2013 02:39
| To: ghc-commits at haskell.org
| Subject: [commit: ghc] master: Respect the ordering of -package
| directives (574ccfa)
| 
| Repository : ssh://git@git.haskell.org/ghc
| 
| On branch  : master
| Link       :
| http://ghc.haskell.org/trac/ghc/changeset/574ccfa231ca05d03d1da9d31e5bc
| 81e74cc5e1e/ghc
| 
| >---------------------------------------------------------------
| 
| commit 574ccfa231ca05d03d1da9d31e5bc81e74cc5e1e
| Author: Patrick Palka <patrick at parcs.ath.cx>
| Date:   Tue Nov 26 11:46:59 2013 -0500
| 
|     Respect the ordering of -package directives
| 
| 
| >---------------------------------------------------------------
| 
| 574ccfa231ca05d03d1da9d31e5bc81e74cc5e1e
|  compiler/main/Packages.lhs |   15 ++++++++-------
|  1 file changed, 8 insertions(+), 7 deletions(-)
| 
| diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs
| index aefb536..df5eddb 100644
| --- a/compiler/main/Packages.lhs
| +++ b/compiler/main/Packages.lhs
| @@ -59,6 +59,7 @@ import System.FilePath as FilePath
|  import qualified System.FilePath.Posix as FilePath.Posix
|  import Control.Monad
|  import Data.Char (isSpace)
| +import Data.Foldable (foldrM)
|  import Data.List as List
|  import Data.Map (Map)
|  import qualified Data.Map as Map
| @@ -980,7 +981,7 @@ getPreloadPackagesAnd dflags pkgids =
|        preload = preloadPackages state
|        pairs = zip pkgids (repeat Nothing)
|    in do
| -  all_pkgs <- throwErr dflags (foldM (add_package pkg_map ipid_map)
| preload pairs)
| +  all_pkgs <- throwErr dflags (foldrM (add_package pkg_map ipid_map)
| preload pairs)
|    return (map (getPackageDetails state) all_pkgs)
| 
|  -- Takes a list of packages, and returns the list with dependencies
| included,
| @@ -1003,15 +1004,15 @@ closeDepsErr :: PackageConfigMap
|               -> Map InstalledPackageId PackageId
|               -> [(PackageId,Maybe PackageId)]
|               -> MaybeErr MsgDoc [PackageId]
| -closeDepsErr pkg_map ipid_map ps = foldM (add_package pkg_map
| ipid_map) [] ps
| +closeDepsErr pkg_map ipid_map ps = foldrM (add_package pkg_map
| ipid_map) [] ps
| 
|  -- internal helper
|  add_package :: PackageConfigMap
|              -> Map InstalledPackageId PackageId
| -            -> [PackageId]
|              -> (PackageId,Maybe PackageId)
| +            -> [PackageId]
|              -> MaybeErr MsgDoc [PackageId]
| -add_package pkg_db ipid_map ps (p, mb_parent)
| +add_package pkg_db ipid_map (p, mb_parent) ps
|    | p `elem` ps = return ps     -- Check if we've already added this
| package
|    | otherwise =
|        case lookupPackage pkg_db p of
| @@ -1019,12 +1020,12 @@ add_package pkg_db ipid_map ps (p, mb_parent)
|                             missingDependencyMsg mb_parent)
|          Just pkg -> do
|             -- Add the package's dependents also
| -           ps' <- foldM add_package_ipid ps (depends pkg)
| +           ps' <- foldrM add_package_ipid ps (depends pkg)
|             return (p : ps')
|            where
| -            add_package_ipid ps ipid@(InstalledPackageId str)
| +            add_package_ipid ipid@(InstalledPackageId str) ps
|                | Just pid <- Map.lookup ipid ipid_map
| -              = add_package pkg_db ipid_map ps (pid, Just p)
| +              = add_package pkg_db ipid_map (pid, Just p) ps
|                | otherwise
|                = Failed (missingPackageMsg str <> missingDependencyMsg
| mb_parent)
| 
| 
| _______________________________________________
| ghc-commits mailing list
| ghc-commits at haskell.org
| http://www.haskell.org/mailman/listinfo/ghc-commits


More information about the ghc-commits mailing list