From a67218bf005d292e618f549f4de42133f6fdec59 Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Sat, 26 Nov 2016 23:58:09 +0000 Subject: [PATCH] A few minor BuildTarget code tweaks Comments, error messages and updated example inputs. --- .../Distribution/Client/BuildTarget.hs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cabal-install/Distribution/Client/BuildTarget.hs b/cabal-install/Distribution/Client/BuildTarget.hs index 16bf9eb3947..5b0e4978fc9 100644 --- a/cabal-install/Distribution/Client/BuildTarget.hs +++ b/cabal-install/Distribution/Client/BuildTarget.hs @@ -631,11 +631,11 @@ reportBuildTargetProblems problems = do ((target, originalMatch, renderingsAndMatches):_) -> die $ "Internal error in build target matching. It should always be " ++ "possible to find a syntax that's sufficiently qualified to " - ++ "give an unambigious match. However when matching '" + ++ "give an unambiguous match. However when matching '" ++ showUserBuildTarget target ++ "' we found " ++ showBuildTarget originalMatch ++ " (" ++ showBuildTargetKind originalMatch ++ ") which does not " - ++ "have an unambigious syntax. The possible syntax and the " + ++ "have an unambiguous syntax. The possible syntax and the " ++ "targets they match are as follows:\n" ++ unlines [ "'" ++ showUserBuildTarget rendering ++ "' which matches " @@ -662,6 +662,8 @@ reportBuildTargetProblems problems = do [ "Unknown build target '" ++ showUserBuildTarget target ++ "'.\n" ++ unlines [ (case inside of + Just (kind, "") + -> "The " ++ kind ++ " has no " Just (kind, thing) -> "The " ++ kind ++ " " ++ thing ++ " has no " Nothing -> "There is no ") @@ -1648,6 +1650,8 @@ forceInexact m = m -- but if we have multiple exact, or inexact then the we collect all the -- ambiguous matches. -- +-- This operator is associative, has unit 'mzero' and is also commutative. +-- matchPlus :: Match a -> Match a -> Match a matchPlus (ExactMatch d1 xs) (ExactMatch d2 xs') = ExactMatch (max d1 d2) (xs ++ xs') @@ -1668,6 +1672,8 @@ matchPlus a@(NoMatch d1 ms) b@(NoMatch d2 ms') -- difference that an exact match from the left matcher shadows any exact -- match on the right. Inexact matches are still collected however. -- +-- This operator is associative, has unit 'mzero' and is not commutative. +-- matchPlusShadowing :: Match a -> Match a -> Match a matchPlusShadowing a@(ExactMatch _ _) _ = a matchPlusShadowing a b = matchPlus a b @@ -1797,7 +1803,8 @@ caseFold = lowercase {- ex1pinfo :: [PackageInfo] ex1pinfo = - [ PackageInfo { + [ addComponent (CExeName (mkUnqualComponentName "foo-exe")) [] ["Data.Foo"] $ + PackageInfo { pinfoId = PackageIdentifier (mkPackageName "foo") (mkVersion [1]), pinfoLocation = LocalUnpackedPackage "/the/foo", pinfoDirectory = Just ("/the/foo", "foo"), @@ -1812,6 +1819,18 @@ ex1pinfo = pinfoComponents = [] } ] + where + addComponent n ds ms p = + p { + pinfoComponents = + ComponentInfo n (componentStringName (pinfoId p) n) + p ds (map mkMn ms) + [] [] [] + : pinfoComponents p + } + + mkMn :: String -> ModuleName + mkMn = ModuleName.fromString -} {- stargets =