-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Track which file has errors and which has warnings - Add test for import parse warnings - Remove added type sigs, use e for error type - Move ProjectParseResult into its own module - Import qualified from Deprecated.ParseUtils - Reverse warnings so they are in line number order - Report parse result error in imported config - Split project test into warning and error tests - Add type synonyms for project parse - Extract function reportProjectParseWarnings - Show the snippet that doesn't parse - Add if, elif and else test projects - Fix else for elif typo - Show provenance if not root - Rerun expected output with provenance - Redo ParseWarningProvenence with ordered output - Add ProjectParseError record - Reword badly formed comment lines - Satisfy fix-whitespace - Add changelog entry - Updated - indented expectation - No snippet when modifying compiler under condition - Only show custom message with snippet - Rerun expected output with source - Use a Doc for the ReportParseResult message - Update expected .out files - Use normalized path when recursing - Consistent projectParse ... source - Consistent projectParse ... normSource - Use normalizeWindowsOutput - Use .md extension on changelog entry - Satisfy HLint - Revert elif to else, see that this is wrong and undo
- Loading branch information
1 parent
54d364d
commit 8ba44d3
Showing
26 changed files
with
727 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
cabal-install/src/Distribution/Deprecated/ProjectParseUtils.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{-# OPTIONS_HADDOCK hide #-} | ||
|
||
module Distribution.Deprecated.ProjectParseUtils | ||
( ProjectParseError (..) | ||
, ProjectParseWarning | ||
, ProjectParseResult (..) | ||
, projectParseFail | ||
, projectParse | ||
) where | ||
|
||
import Distribution.Client.Compat.Prelude hiding (get) | ||
import Prelude () | ||
|
||
import qualified Distribution.Deprecated.ParseUtils as Pkg (PError, PWarning, ParseResult (..)) | ||
import Distribution.Solver.Types.ProjectConfigPath (ProjectConfigPath) | ||
|
||
type ProjectParseWarning = (ProjectConfigPath, Pkg.PWarning) | ||
|
||
data ProjectParseError = ProjectParseError | ||
{ projectParseSnippet :: Maybe String | ||
, projectParseSource :: Maybe ProjectConfigPath | ||
, projectParseError :: Pkg.PError | ||
} | ||
deriving (Show) | ||
|
||
data ProjectParseResult a | ||
= ProjectParseFailed ProjectParseError | ||
| ProjectParseOk [ProjectParseWarning] a | ||
deriving (Show) | ||
|
||
projectParse :: Maybe String -> ProjectConfigPath -> Pkg.ParseResult a -> ProjectParseResult a | ||
projectParse s path (Pkg.ParseFailed err) = ProjectParseFailed $ ProjectParseError s (Just path) err | ||
projectParse _ path (Pkg.ParseOk ws x) = ProjectParseOk [(path, w) | w <- ws] x | ||
|
||
instance Functor ProjectParseResult where | ||
fmap _ (ProjectParseFailed err) = ProjectParseFailed err | ||
fmap f (ProjectParseOk ws x) = ProjectParseOk ws $ f x | ||
|
||
instance Applicative ProjectParseResult where | ||
pure = ProjectParseOk [] | ||
(<*>) = ap | ||
|
||
instance Monad ProjectParseResult where | ||
return = pure | ||
ProjectParseFailed err >>= _ = ProjectParseFailed err | ||
ProjectParseOk ws x >>= f = case f x of | ||
ProjectParseFailed err -> ProjectParseFailed err | ||
ProjectParseOk ws' x' -> ProjectParseOk (ws' ++ ws) x' | ||
|
||
projectParseFail :: Maybe String -> Maybe ProjectConfigPath -> Pkg.PError -> ProjectParseResult a | ||
projectParseFail s p e = ProjectParseFailed $ ProjectParseError s p e |
Oops, something went wrong.