From 3f968cb1c021228f1bed9f958b47d2611c889941 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 22 Sep 2022 00:03:26 +0800 Subject: [PATCH] WIP --- lib/GHCup/Errors.hs | 9 +++++++-- lib/GHCup/Requirements.hs | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/GHCup/Errors.hs b/lib/GHCup/Errors.hs index 0ce4a01..e4f33c5 100644 --- a/lib/GHCup/Errors.hs +++ b/lib/GHCup/Errors.hs @@ -360,13 +360,18 @@ deriving instance Show InstallSetError -- | A build failed. -data BuildFailed = forall es . (ToVariantMaybe BuildFailed es, PopVariant BuildFailed es, Pretty (V es), Show (V es)) => BuildFailed FilePath (V es) +data BuildFailed = forall es . (ToVariantMaybe BuildFailed es, PopVariant BuildFailed es, Pretty (V es), Show (V es)) => BuildFailed FilePath (V es) (Just Requirements) instance Pretty BuildFailed where - pPrint (BuildFailed path reason) = + pPrint (BuildFailed path reason req) = case reason of VMaybe (_ :: BuildFailed) -> pPrint reason _ -> text "BuildFailed failed in dir" <+> text (path <> ":") <+> pPrint reason + <+> printToolReq' + where + printToolReq' = case req of + Nothing -> T.pack "" + Just req' -> prettyRequirementsError req' deriving instance Show BuildFailed diff --git a/lib/GHCup/Requirements.hs b/lib/GHCup/Requirements.hs index 27bb87a..826e117 100644 --- a/lib/GHCup/Requirements.hs +++ b/lib/GHCup/Requirements.hs @@ -68,6 +68,17 @@ prettyRequirements Requirements {..} = n = if not . T.null $ _notes then "\n Note: " <> _notes else "" in "System requirements " <> d <> n + +prettyRequirementsError :: Requirements -> T.Text +prettyRequirementsError Requirements {..} = + let d = if not . null $ _distroPKGs + then "\nMake sure the following distro packages " + <> "are installed: " + <> T.intercalate " " _distroPKGs + else "" + n = if not . T.null $ _notes then "\nMake sure the following requirements are met: " <> _notes else "" + in d <> n + rawRequirements :: Requirements -> T.Text rawRequirements Requirements {..} = if not . null $ _distroPKGs