{-# 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 { ProjectParseError -> Maybe String projectParseSnippet :: Maybe String , ProjectParseError -> Maybe ProjectConfigPath projectParseSource :: Maybe ProjectConfigPath , ProjectParseError -> PError projectParseError :: Pkg.PError } deriving (Int -> ProjectParseError -> ShowS [ProjectParseError] -> ShowS ProjectParseError -> String (Int -> ProjectParseError -> ShowS) -> (ProjectParseError -> String) -> ([ProjectParseError] -> ShowS) -> Show ProjectParseError forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ProjectParseError -> ShowS showsPrec :: Int -> ProjectParseError -> ShowS $cshow :: ProjectParseError -> String show :: ProjectParseError -> String $cshowList :: [ProjectParseError] -> ShowS showList :: [ProjectParseError] -> ShowS Show) data ProjectParseResult a = ProjectParseFailed ProjectParseError | ProjectParseOk [ProjectParseWarning] a deriving (Int -> ProjectParseResult a -> ShowS [ProjectParseResult a] -> ShowS ProjectParseResult a -> String (Int -> ProjectParseResult a -> ShowS) -> (ProjectParseResult a -> String) -> ([ProjectParseResult a] -> ShowS) -> Show (ProjectParseResult a) forall a. Show a => Int -> ProjectParseResult a -> ShowS forall a. Show a => [ProjectParseResult a] -> ShowS forall a. Show a => ProjectParseResult a -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: forall a. Show a => Int -> ProjectParseResult a -> ShowS showsPrec :: Int -> ProjectParseResult a -> ShowS $cshow :: forall a. Show a => ProjectParseResult a -> String show :: ProjectParseResult a -> String $cshowList :: forall a. Show a => [ProjectParseResult a] -> ShowS showList :: [ProjectParseResult a] -> ShowS Show) projectParse :: Maybe String -> ProjectConfigPath -> Pkg.ParseResult a -> ProjectParseResult a projectParse :: forall a. Maybe String -> ProjectConfigPath -> ParseResult a -> ProjectParseResult a projectParse Maybe String s ProjectConfigPath path (Pkg.ParseFailed PError err) = ProjectParseError -> ProjectParseResult a forall a. ProjectParseError -> ProjectParseResult a ProjectParseFailed (ProjectParseError -> ProjectParseResult a) -> ProjectParseError -> ProjectParseResult a forall a b. (a -> b) -> a -> b $ Maybe String -> Maybe ProjectConfigPath -> PError -> ProjectParseError ProjectParseError Maybe String s (ProjectConfigPath -> Maybe ProjectConfigPath forall a. a -> Maybe a Just ProjectConfigPath path) PError err projectParse Maybe String _ ProjectConfigPath path (Pkg.ParseOk [PWarning] ws a x) = [ProjectParseWarning] -> a -> ProjectParseResult a forall a. [ProjectParseWarning] -> a -> ProjectParseResult a ProjectParseOk [(ProjectConfigPath path, PWarning w) | PWarning w <- [PWarning] ws] a x instance Functor ProjectParseResult where fmap :: forall a b. (a -> b) -> ProjectParseResult a -> ProjectParseResult b fmap a -> b _ (ProjectParseFailed ProjectParseError err) = ProjectParseError -> ProjectParseResult b forall a. ProjectParseError -> ProjectParseResult a ProjectParseFailed ProjectParseError err fmap a -> b f (ProjectParseOk [ProjectParseWarning] ws a x) = [ProjectParseWarning] -> b -> ProjectParseResult b forall a. [ProjectParseWarning] -> a -> ProjectParseResult a ProjectParseOk [ProjectParseWarning] ws (b -> ProjectParseResult b) -> b -> ProjectParseResult b forall a b. (a -> b) -> a -> b $ a -> b f a x instance Applicative ProjectParseResult where pure :: forall a. a -> ProjectParseResult a pure = [ProjectParseWarning] -> a -> ProjectParseResult a forall a. [ProjectParseWarning] -> a -> ProjectParseResult a ProjectParseOk [] <*> :: forall a b. ProjectParseResult (a -> b) -> ProjectParseResult a -> ProjectParseResult b (<*>) = ProjectParseResult (a -> b) -> ProjectParseResult a -> ProjectParseResult b forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b ap instance Monad ProjectParseResult where return :: forall a. a -> ProjectParseResult a return = a -> ProjectParseResult a forall a. a -> ProjectParseResult a forall (f :: * -> *) a. Applicative f => a -> f a pure ProjectParseFailed ProjectParseError err >>= :: forall a b. ProjectParseResult a -> (a -> ProjectParseResult b) -> ProjectParseResult b >>= a -> ProjectParseResult b _ = ProjectParseError -> ProjectParseResult b forall a. ProjectParseError -> ProjectParseResult a ProjectParseFailed ProjectParseError err ProjectParseOk [ProjectParseWarning] ws a x >>= a -> ProjectParseResult b f = case a -> ProjectParseResult b f a x of ProjectParseFailed ProjectParseError err -> ProjectParseError -> ProjectParseResult b forall a. ProjectParseError -> ProjectParseResult a ProjectParseFailed ProjectParseError err ProjectParseOk [ProjectParseWarning] ws' b x' -> [ProjectParseWarning] -> b -> ProjectParseResult b forall a. [ProjectParseWarning] -> a -> ProjectParseResult a ProjectParseOk ([ProjectParseWarning] ws' [ProjectParseWarning] -> [ProjectParseWarning] -> [ProjectParseWarning] forall a. [a] -> [a] -> [a] ++ [ProjectParseWarning] ws) b x' projectParseFail :: Maybe String -> Maybe ProjectConfigPath -> Pkg.PError -> ProjectParseResult a projectParseFail :: forall a. Maybe String -> Maybe ProjectConfigPath -> PError -> ProjectParseResult a projectParseFail Maybe String s Maybe ProjectConfigPath p PError e = ProjectParseError -> ProjectParseResult a forall a. ProjectParseError -> ProjectParseResult a ProjectParseFailed (ProjectParseError -> ProjectParseResult a) -> ProjectParseError -> ProjectParseResult a forall a b. (a -> b) -> a -> b $ Maybe String -> Maybe ProjectConfigPath -> PError -> ProjectParseError ProjectParseError Maybe String s Maybe ProjectConfigPath p PError e