Skip to content

Commit

Permalink
Update world file entries ignoring version constraints
Browse files Browse the repository at this point in the history
Otherwise it is easy to add impossible constraints to the world file.
cabal install 'foo > 1' && cabal install 'foo < 1'
Would give us a world file with both constraints.
  • Loading branch information
dcoutts committed May 10, 2010
1 parent 64e4690 commit 3a96d4f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Distribution/Client/World.hs
Expand Up @@ -48,10 +48,9 @@ import System.IO.Error( isDoesNotExistError, )
import qualified Data.ByteString.Lazy.Char8 as B
import Prelude hiding ( getContents )


-- | Adds packages to the world file; creates the file if it doesn't
-- exist yet. Flag assignments for a package are updated if already
-- present. IO errors are non-fatal.
-- | Adds packages to the world file; creates the file if it doesn't
-- exist yet. Version constraints and flag assignments for a package are
-- updated if already present. IO errors are non-fatal.
insert :: Verbosity -> Bool -> FilePath -> [UnresolvedDependency] -> IO ()
insert = modifyWorld $ unionBy equalUDep

Expand All @@ -64,7 +63,8 @@ delete = modifyWorld $ flip (deleteFirstsBy equalUDep)
-- | UnresolvedDependency values are considered equal if they refer to
-- the same package, i.e., we don't care about differing versions or flags.
equalUDep :: UnresolvedDependency -> UnresolvedDependency -> Bool
equalUDep u1 u2 = dependency u1 == dependency u2
equalUDep (UnresolvedDependency (Dependency pkg1 _) _)
(UnresolvedDependency (Dependency pkg2 _) _) = pkg1 == pkg2

-- | Modifies the world file by applying an update-function ('unionBy'
-- for 'insert', 'deleteFirstsBy' for 'delete') to the given list of
Expand Down

0 comments on commit 3a96d4f

Please sign in to comment.