{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE DataKinds               #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators           #-}
{-# LANGUAGE FlexibleInstances           #-}
{-# LANGUAGE RankNTypes           #-}

{-|
Module      : GHCup.Errors
Description : GHCup error types
Copyright   : (c) Julian Ospald, 2020
License     : LGPL-3.0
Maintainer  : hasufell@hasufell.de
Stability   : experimental
Portability : portable
-}
module GHCup.Errors where

import           GHCup.Types

import           Codec.Archive
import           Control.Exception.Safe
import           Data.ByteString                ( ByteString )
import           Data.CaseInsensitive           ( CI )
import           Data.Text                      ( Text )
import           Data.Versions
import           Haskus.Utils.Variant
import           System.FilePath
import           Text.PrettyPrint               hiding ( (<>) )
import           Text.PrettyPrint.HughesPJClass hiding ( (<>) )
import           URI.ByteString

import qualified Data.Map.Strict               as M
import qualified Data.Text                     as T
import qualified Data.Text.Encoding            as E
import qualified Data.Text.Encoding.Error      as E
import           Data.Data (Proxy(..))
import Data.Time (Day)



allHFError :: String
allHFError :: FilePath
allHFError = [FilePath] -> FilePath
unlines [FilePath]
allErrors
 where
  format :: Proxy a -> FilePath
format Proxy a
p = FilePath
"GHCup-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show (forall a. HFErrorProject a => Proxy a -> Int
eBase Proxy a
p) forall a. Semigroup a => a -> a -> a
<> FilePath
" " forall a. Semigroup a => a -> a -> a
<>  forall a. HFErrorProject a => Proxy a -> FilePath
eDesc Proxy a
p
  format'' :: a -> Proxy a -> FilePath
format'' a
e Proxy a
p = FilePath
"GHCup-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show (forall a. HFErrorProject a => a -> Int
eNum a
e) forall a. Semigroup a => a -> a -> a
<> FilePath
" " forall a. Semigroup a => a -> a -> a
<>  forall a. HFErrorProject a => Proxy a -> FilePath
eDesc Proxy a
p
  format' :: a -> p -> FilePath
format' a
e  p
_ = FilePath
"GHCup-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show (forall a. HFErrorProject a => a -> Int
eNum a
e) forall a. Semigroup a => a -> a -> a
<> FilePath
" " forall a. Semigroup a => a -> a -> a
<>  forall a. Pretty a => a -> FilePath
prettyShow a
e
  format''' :: a -> p -> FilePath -> FilePath
format''' a
e  p
_ FilePath
str' = FilePath
"GHCup-" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show (forall a. HFErrorProject a => a -> Int
eNum a
e) forall a. Semigroup a => a -> a -> a
<> FilePath
" " forall a. Semigroup a => a -> a -> a
<>  FilePath
str'
  allErrors :: [FilePath]
allErrors =
    [ FilePath
"# low level errors (1 to 500)"
    , let proxy :: Proxy NoCompatiblePlatform
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoCompatiblePlatform in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoCompatiblePlatform
proxy
    , let proxy :: Proxy NoDownload
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoDownload in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoDownload
proxy
    , let proxy :: Proxy NoUpdate
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoUpdate in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoUpdate
proxy
    , let proxy :: Proxy DistroNotFound
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy DistroNotFound in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DistroNotFound
proxy
    , let proxy :: Proxy UnknownArchive
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy UnknownArchive in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UnknownArchive
proxy
    , let proxy :: Proxy UnsupportedScheme
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy UnsupportedScheme in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UnsupportedScheme
proxy
    , let proxy :: Proxy CopyError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy CopyError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy CopyError
proxy
    , let proxy :: Proxy MergeFileTreeError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy MergeFileTreeError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy MergeFileTreeError
proxy
    , let proxy :: Proxy TagNotFound
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy TagNotFound in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TagNotFound
proxy
    , let proxy :: Proxy DayNotFound
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy DayNotFound in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DayNotFound
proxy
    , let proxy :: Proxy NextVerNotFound
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NextVerNotFound in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NextVerNotFound
proxy
    , let proxy :: Proxy AlreadyInstalled
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy AlreadyInstalled in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy AlreadyInstalled
proxy
    , let proxy :: Proxy DirNotEmpty
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy DirNotEmpty in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DirNotEmpty
proxy
    , let proxy :: Proxy NotInstalled
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NotInstalled in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NotInstalled
proxy
    , let proxy :: Proxy UninstallFailed
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy UninstallFailed in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UninstallFailed
proxy
    , let proxy :: Proxy NotFoundInPATH
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NotFoundInPATH in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NotFoundInPATH
proxy
    , let proxy :: Proxy JSONError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy JSONError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy JSONError
proxy
    , let proxy :: Proxy FileDoesNotExistError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy FileDoesNotExistError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy FileDoesNotExistError
proxy
    , let proxy :: Proxy FileAlreadyExistsError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy FileAlreadyExistsError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy FileAlreadyExistsError
proxy
    , let proxy :: Proxy TarDirDoesNotExist
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy TarDirDoesNotExist in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TarDirDoesNotExist
proxy
    , let proxy :: Proxy DigestError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy DigestError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DigestError
proxy
    , let proxy :: Proxy GPGError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy GPGError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy GPGError
proxy
    , let proxy :: Proxy HTTPStatusError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy HTTPStatusError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy HTTPStatusError
proxy
    , let proxy :: Proxy MalformedHeaders
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy MalformedHeaders in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy MalformedHeaders
proxy
    , let proxy :: Proxy HTTPNotModified
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy HTTPNotModified in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy HTTPNotModified
proxy
    , let proxy :: Proxy NoLocationHeader
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoLocationHeader in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoLocationHeader
proxy
    , let proxy :: Proxy TooManyRedirs
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy TooManyRedirs in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TooManyRedirs
proxy
    , let proxy :: Proxy PatchFailed
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy PatchFailed in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy PatchFailed
proxy
    , let proxy :: Proxy NoToolRequirements
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoToolRequirements in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoToolRequirements
proxy
    , let proxy :: Proxy InvalidBuildConfig
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy InvalidBuildConfig in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy InvalidBuildConfig
proxy
    , let proxy :: Proxy NoToolVersionSet
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoToolVersionSet in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoToolVersionSet
proxy
    , let proxy :: Proxy NoNetwork
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoNetwork in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoNetwork
proxy
    , let proxy :: Proxy HadrianNotFound
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy HadrianNotFound in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy HadrianNotFound
proxy
    , let proxy :: Proxy ToolShadowed
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ToolShadowed in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ToolShadowed
proxy
    , let proxy :: Proxy ContentLengthError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ContentLengthError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ContentLengthError
proxy
    , let proxy :: Proxy DuplicateReleaseChannel
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy DuplicateReleaseChannel in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DuplicateReleaseChannel
proxy
    , FilePath
""
    , FilePath
"# high level errors (4000+)"
    , let proxy :: Proxy DownloadFailed
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy DownloadFailed in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy DownloadFailed
proxy
    , let proxy :: Proxy InstallSetError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy InstallSetError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy InstallSetError
proxy
    , let proxy :: Proxy TestFailed
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy TestFailed in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy TestFailed
proxy
    , let proxy :: Proxy BuildFailed
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy BuildFailed in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy BuildFailed
proxy
    , let proxy :: Proxy GHCupSetError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy GHCupSetError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy GHCupSetError
proxy
    , FilePath
""
    , FilePath
"# true exceptions (500+)"
    , let proxy :: Proxy ParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ParseError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ParseError
proxy
    , let proxy :: Proxy UnexpectedListLength
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy UnexpectedListLength in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy UnexpectedListLength
proxy
    , let proxy :: Proxy NoUrlBase
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy NoUrlBase in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy NoUrlBase
proxy
    , FilePath
""
    , FilePath
"# orphans (800+)"
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = SchemaError -> URIParseError
MalformedScheme SchemaError
MissingColon
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedUserInfo
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedQuery
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedFragment
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedHost
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedPort
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = URIParseError
MalformedPath
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy URIParseError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy URIParseError
          e :: URIParseError
e     = FilePath -> URIParseError
OtherError FilePath
""
      in forall {a} {a}.
(HFErrorProject a, HFErrorProject a) =>
a -> Proxy a -> FilePath
format'' URIParseError
e Proxy URIParseError
proxy
    , let proxy :: Proxy ArchiveResult
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveFatal
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveFailed
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveWarn
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveRetry
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveOk
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy
    , let proxy :: Proxy ArchiveResult
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ArchiveResult
          e :: ArchiveResult
e     = ArchiveResult
ArchiveEOF
      in forall {a} {p}. (HFErrorProject a, Pretty a) => a -> p -> FilePath
format' ArchiveResult
e Proxy ArchiveResult
proxy

    , let proxy :: Proxy ProcessError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError in forall a. HFErrorProject a => Proxy a -> FilePath
format Proxy ProcessError
proxy
    , let proxy :: Proxy ProcessError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = Int -> FilePath -> [FilePath] -> ProcessError
NonZeroExit Int
0 FilePath
"" []
      in forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"A process returned a non-zero exit code."
    , let proxy :: Proxy ProcessError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = FilePath -> [FilePath] -> ProcessError
PTerminated FilePath
"" []
      in forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"A process terminated prematurely."
    , let proxy :: Proxy ProcessError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = FilePath -> [FilePath] -> ProcessError
PStopped FilePath
"" []
      in forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"A process stopped prematurely."
    , let proxy :: Proxy ProcessError
proxy = forall {k} (t :: k). Proxy t
Proxy :: Proxy ProcessError
          e :: ProcessError
e     = FilePath -> [FilePath] -> ProcessError
NoSuchPid FilePath
"" []
      in forall {a} {p}. HFErrorProject a => a -> p -> FilePath -> FilePath
format''' ProcessError
e Proxy ProcessError
proxy FilePath
"Could not find PID for this process."
    ]


prettyHFError :: (Pretty e, HFErrorProject e) => e -> String
prettyHFError :: forall e. (Pretty e, HFErrorProject e) => e -> FilePath
prettyHFError e
e =
  let errorCode :: FilePath
errorCode = FilePath
"GHCup-" forall a. Semigroup a => a -> a -> a
<> forall {a}. (Ord a, Num a, Show a) => a -> FilePath
padIntAndShow (forall a. HFErrorProject a => a -> Int
eNum e
e)
  in (FilePath
"[" forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath -> FilePath
linkEscapeCode FilePath
errorCode  (FilePath -> FilePath
hfErrorLink FilePath
errorCode) forall a. Semigroup a => a -> a -> a
<> FilePath
"] ") forall a. Semigroup a => a -> a -> a
<> forall a. Pretty a => a -> FilePath
prettyShow e
e
 where
  hfErrorLink :: FilePath -> FilePath
hfErrorLink FilePath
errorCode = FilePath
"https://errors.haskell.org/messages/" forall a. Semigroup a => a -> a -> a
<> FilePath
errorCode
  padIntAndShow :: a -> FilePath
padIntAndShow a
i
    | a
i forall a. Ord a => a -> a -> Bool
< a
10    = FilePath
"0000" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show a
i
    | a
i forall a. Ord a => a -> a -> Bool
< a
100   = FilePath
"000"  forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show a
i
    | a
i forall a. Ord a => a -> a -> Bool
< a
1000  = FilePath
"00"   forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show a
i
    | a
i forall a. Ord a => a -> a -> Bool
< a
10000 = FilePath
"0"    forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> FilePath
show a
i
    | Bool
otherwise =           forall a. Show a => a -> FilePath
show a
i

class HFErrorProject a where
  eNum :: a -> Int
  eNum a
_ = forall a. HFErrorProject a => Proxy a -> Int
eBase (forall {k} (t :: k). Proxy t
Proxy :: Proxy a)

  eBase :: Proxy a -> Int

  eDesc :: Proxy a -> String

linkEscapeCode :: String -> String -> String
linkEscapeCode :: FilePath -> FilePath -> FilePath
linkEscapeCode FilePath
linkText FilePath
link = FilePath
"\ESC]8;;" forall a. Semigroup a => a -> a -> a
<> FilePath
link forall a. Semigroup a => a -> a -> a
<> FilePath
"\ESC\\" forall a. Semigroup a => a -> a -> a
<> FilePath
linkText forall a. Semigroup a => a -> a -> a
<> FilePath
"\ESC]8;;\ESC\\"


    ------------------------
    --[ Low-level errors ]--
    ------------------------



-- | A compatible platform could not be found.
data NoCompatiblePlatform = NoCompatiblePlatform String -- the platform we got
  deriving Int -> NoCompatiblePlatform -> FilePath -> FilePath
[NoCompatiblePlatform] -> FilePath -> FilePath
NoCompatiblePlatform -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoCompatiblePlatform] -> FilePath -> FilePath
$cshowList :: [NoCompatiblePlatform] -> FilePath -> FilePath
show :: NoCompatiblePlatform -> FilePath
$cshow :: NoCompatiblePlatform -> FilePath
showsPrec :: Int -> NoCompatiblePlatform -> FilePath -> FilePath
$cshowsPrec :: Int -> NoCompatiblePlatform -> FilePath -> FilePath
Show

instance Pretty NoCompatiblePlatform where
  pPrint :: NoCompatiblePlatform -> Doc
pPrint (NoCompatiblePlatform FilePath
str') =
    FilePath -> Doc
text (FilePath
"Could not find a compatible platform. Got: " forall a. [a] -> [a] -> [a]
++ FilePath
str')

instance HFErrorProject NoCompatiblePlatform where
  eBase :: Proxy NoCompatiblePlatform -> Int
eBase Proxy NoCompatiblePlatform
_ = Int
1
  eDesc :: Proxy NoCompatiblePlatform -> FilePath
eDesc Proxy NoCompatiblePlatform
_ = FilePath
"No compatible platform could be found"

-- | Unable to find a download for the requested version/distro.
data NoDownload = NoDownload
  deriving Int -> NoDownload -> FilePath -> FilePath
[NoDownload] -> FilePath -> FilePath
NoDownload -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoDownload] -> FilePath -> FilePath
$cshowList :: [NoDownload] -> FilePath -> FilePath
show :: NoDownload -> FilePath
$cshow :: NoDownload -> FilePath
showsPrec :: Int -> NoDownload -> FilePath -> FilePath
$cshowsPrec :: Int -> NoDownload -> FilePath -> FilePath
Show

instance Pretty NoDownload where
  pPrint :: NoDownload -> Doc
pPrint NoDownload
NoDownload =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy NoDownload))

instance HFErrorProject NoDownload where
  eBase :: Proxy NoDownload -> Int
eBase Proxy NoDownload
_ = Int
10
  eDesc :: Proxy NoDownload -> FilePath
eDesc Proxy NoDownload
_ = FilePath
"Unable to find a download for the requested version/distro."

-- | No update available or necessary.
data NoUpdate = NoUpdate
  deriving Int -> NoUpdate -> FilePath -> FilePath
[NoUpdate] -> FilePath -> FilePath
NoUpdate -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoUpdate] -> FilePath -> FilePath
$cshowList :: [NoUpdate] -> FilePath -> FilePath
show :: NoUpdate -> FilePath
$cshow :: NoUpdate -> FilePath
showsPrec :: Int -> NoUpdate -> FilePath -> FilePath
$cshowsPrec :: Int -> NoUpdate -> FilePath -> FilePath
Show

instance Pretty NoUpdate where
  pPrint :: NoUpdate -> Doc
pPrint NoUpdate
NoUpdate = FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy NoUpdate))

instance HFErrorProject NoUpdate where
  eBase :: Proxy NoUpdate -> Int
eBase Proxy NoUpdate
_ = Int
20
  eDesc :: Proxy NoUpdate -> FilePath
eDesc Proxy NoUpdate
_ = FilePath
"No update available or necessary."

-- | The Architecture is unknown and unsupported.
data NoCompatibleArch = NoCompatibleArch String
  deriving Int -> NoCompatibleArch -> FilePath -> FilePath
[NoCompatibleArch] -> FilePath -> FilePath
NoCompatibleArch -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoCompatibleArch] -> FilePath -> FilePath
$cshowList :: [NoCompatibleArch] -> FilePath -> FilePath
show :: NoCompatibleArch -> FilePath
$cshow :: NoCompatibleArch -> FilePath
showsPrec :: Int -> NoCompatibleArch -> FilePath -> FilePath
$cshowsPrec :: Int -> NoCompatibleArch -> FilePath -> FilePath
Show

instance Pretty NoCompatibleArch where
  pPrint :: NoCompatibleArch -> Doc
pPrint (NoCompatibleArch FilePath
arch) =
    FilePath -> Doc
text (FilePath
"The Architecture is unknown or unsupported. Got: " forall a. [a] -> [a] -> [a]
++ FilePath
arch)

instance HFErrorProject NoCompatibleArch where
  eBase :: Proxy NoCompatibleArch -> Int
eBase Proxy NoCompatibleArch
_ = Int
30
  eDesc :: Proxy NoCompatibleArch -> FilePath
eDesc Proxy NoCompatibleArch
_ = FilePath
"The Architecture is unknown and unsupported"

-- | Unable to figure out the distribution of the host.
data DistroNotFound = DistroNotFound
  deriving Int -> DistroNotFound -> FilePath -> FilePath
[DistroNotFound] -> FilePath -> FilePath
DistroNotFound -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [DistroNotFound] -> FilePath -> FilePath
$cshowList :: [DistroNotFound] -> FilePath -> FilePath
show :: DistroNotFound -> FilePath
$cshow :: DistroNotFound -> FilePath
showsPrec :: Int -> DistroNotFound -> FilePath -> FilePath
$cshowsPrec :: Int -> DistroNotFound -> FilePath -> FilePath
Show

instance Pretty DistroNotFound where
  pPrint :: DistroNotFound -> Doc
pPrint DistroNotFound
DistroNotFound =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy DistroNotFound))

instance HFErrorProject DistroNotFound where
  eBase :: Proxy DistroNotFound -> Int
eBase Proxy DistroNotFound
_ = Int
40
  eDesc :: Proxy DistroNotFound -> FilePath
eDesc Proxy DistroNotFound
_ = FilePath
"Unable to figure out the distribution of the host"

-- | The archive format is unknown. We don't know how to extract it.
data UnknownArchive = UnknownArchive FilePath
  deriving Int -> UnknownArchive -> FilePath -> FilePath
[UnknownArchive] -> FilePath -> FilePath
UnknownArchive -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [UnknownArchive] -> FilePath -> FilePath
$cshowList :: [UnknownArchive] -> FilePath -> FilePath
show :: UnknownArchive -> FilePath
$cshow :: UnknownArchive -> FilePath
showsPrec :: Int -> UnknownArchive -> FilePath -> FilePath
$cshowsPrec :: Int -> UnknownArchive -> FilePath -> FilePath
Show

instance Pretty UnknownArchive where
  pPrint :: UnknownArchive -> Doc
pPrint (UnknownArchive FilePath
file) =
    FilePath -> Doc
text forall a b. (a -> b) -> a -> b
$ FilePath
"The archive format is unknown. We don't know how to extract the file " forall a. Semigroup a => a -> a -> a
<> FilePath
file

instance HFErrorProject UnknownArchive where
  eBase :: Proxy UnknownArchive -> Int
eBase Proxy UnknownArchive
_ = Int
50
  eDesc :: Proxy UnknownArchive -> FilePath
eDesc Proxy UnknownArchive
_ = FilePath
"The archive format is unknown. We don't know how to extract it."

-- | The scheme is not supported (such as ftp).
data UnsupportedScheme = UnsupportedScheme
  deriving Int -> UnsupportedScheme -> FilePath -> FilePath
[UnsupportedScheme] -> FilePath -> FilePath
UnsupportedScheme -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [UnsupportedScheme] -> FilePath -> FilePath
$cshowList :: [UnsupportedScheme] -> FilePath -> FilePath
show :: UnsupportedScheme -> FilePath
$cshow :: UnsupportedScheme -> FilePath
showsPrec :: Int -> UnsupportedScheme -> FilePath -> FilePath
$cshowsPrec :: Int -> UnsupportedScheme -> FilePath -> FilePath
Show

instance Pretty UnsupportedScheme where
  pPrint :: UnsupportedScheme -> Doc
pPrint UnsupportedScheme
UnsupportedScheme =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy UnsupportedScheme))

instance HFErrorProject UnsupportedScheme where
  eBase :: Proxy UnsupportedScheme -> Int
eBase Proxy UnsupportedScheme
_ = Int
60
  eDesc :: Proxy UnsupportedScheme -> FilePath
eDesc Proxy UnsupportedScheme
_ = FilePath
"The scheme is not supported (such as ftp)."

-- | Unable to copy a file.
data CopyError = CopyError String
  deriving Int -> CopyError -> FilePath -> FilePath
[CopyError] -> FilePath -> FilePath
CopyError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [CopyError] -> FilePath -> FilePath
$cshowList :: [CopyError] -> FilePath -> FilePath
show :: CopyError -> FilePath
$cshow :: CopyError -> FilePath
showsPrec :: Int -> CopyError -> FilePath -> FilePath
$cshowsPrec :: Int -> CopyError -> FilePath -> FilePath
Show

instance Pretty CopyError where
  pPrint :: CopyError -> Doc
pPrint (CopyError FilePath
reason) =
    FilePath -> Doc
text (FilePath
"Unable to copy a file. Reason was: " forall a. [a] -> [a] -> [a]
++ FilePath
reason)

instance HFErrorProject CopyError where
  eBase :: Proxy CopyError -> Int
eBase Proxy CopyError
_ = Int
70
  eDesc :: Proxy CopyError -> FilePath
eDesc Proxy CopyError
_ = FilePath
"Unable to copy a file."

-- | Unable to merge file trees.
data MergeFileTreeError = MergeFileTreeError IOException FilePath FilePath
  deriving Int -> MergeFileTreeError -> FilePath -> FilePath
[MergeFileTreeError] -> FilePath -> FilePath
MergeFileTreeError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [MergeFileTreeError] -> FilePath -> FilePath
$cshowList :: [MergeFileTreeError] -> FilePath -> FilePath
show :: MergeFileTreeError -> FilePath
$cshow :: MergeFileTreeError -> FilePath
showsPrec :: Int -> MergeFileTreeError -> FilePath -> FilePath
$cshowsPrec :: Int -> MergeFileTreeError -> FilePath -> FilePath
Show

instance Pretty MergeFileTreeError where
  pPrint :: MergeFileTreeError -> Doc
pPrint (MergeFileTreeError IOException
e FilePath
from FilePath
to) =
    FilePath -> Doc
text FilePath
"Failed to merge file tree from" Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
from Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"to" Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
to Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nexception was:" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall e. Exception e => e -> FilePath
displayException IOException
e)
     Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\n...you may need to delete" Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
to Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"manually. Make sure it's gone."

instance HFErrorProject MergeFileTreeError where
  eBase :: Proxy MergeFileTreeError -> Int
eBase Proxy MergeFileTreeError
_ = Int
80
  eDesc :: Proxy MergeFileTreeError -> FilePath
eDesc Proxy MergeFileTreeError
_ = FilePath
"Unable to merge file trees during installation"

-- | Unable to find a tag of a tool.
data TagNotFound = TagNotFound Tag Tool
  deriving Int -> TagNotFound -> FilePath -> FilePath
[TagNotFound] -> FilePath -> FilePath
TagNotFound -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [TagNotFound] -> FilePath -> FilePath
$cshowList :: [TagNotFound] -> FilePath -> FilePath
show :: TagNotFound -> FilePath
$cshow :: TagNotFound -> FilePath
showsPrec :: Int -> TagNotFound -> FilePath -> FilePath
$cshowsPrec :: Int -> TagNotFound -> FilePath -> FilePath
Show

instance Pretty TagNotFound where
  pPrint :: TagNotFound -> Doc
pPrint (TagNotFound Tag
tag Tool
tool) =
    FilePath -> Doc
text FilePath
"Unable to find tag" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tag
tag Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of tool" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tool
tool

instance HFErrorProject TagNotFound where
  eBase :: Proxy TagNotFound -> Int
eBase Proxy TagNotFound
_ = Int
90
  eDesc :: Proxy TagNotFound -> FilePath
eDesc Proxy TagNotFound
_ = FilePath
"Unable to find a tag of a tool"

-- | Unable to find a release day of a tool
data DayNotFound = DayNotFound Day Tool (Maybe Day)
  deriving Int -> DayNotFound -> FilePath -> FilePath
[DayNotFound] -> FilePath -> FilePath
DayNotFound -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [DayNotFound] -> FilePath -> FilePath
$cshowList :: [DayNotFound] -> FilePath -> FilePath
show :: DayNotFound -> FilePath
$cshow :: DayNotFound -> FilePath
showsPrec :: Int -> DayNotFound -> FilePath -> FilePath
$cshowsPrec :: Int -> DayNotFound -> FilePath -> FilePath
Show

instance Pretty DayNotFound where
  pPrint :: DayNotFound -> Doc
pPrint (DayNotFound Day
day Tool
tool Maybe Day
Nothing) =
    FilePath -> Doc
text FilePath
"Unable to find release date" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Day
day) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of tool" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tool
tool
  pPrint (DayNotFound Day
day Tool
tool (Just Day
alternateDay)) =
    FilePath -> Doc
text FilePath
"Unable to find release date" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Day
day) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of tool" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+>
      FilePath -> Doc
text FilePath
"but found an alternative date" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Day
alternateDay)

instance HFErrorProject DayNotFound where
  eBase :: Proxy DayNotFound -> Int
eBase Proxy DayNotFound
_ = Int
95
  eDesc :: Proxy DayNotFound -> FilePath
eDesc Proxy DayNotFound
_ = FilePath
"Unable to find a release date of a tool"

-- | Unable to find the next version of a tool (the one after the currently
-- set one).
data NextVerNotFound = NextVerNotFound Tool
  deriving Int -> NextVerNotFound -> FilePath -> FilePath
[NextVerNotFound] -> FilePath -> FilePath
NextVerNotFound -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NextVerNotFound] -> FilePath -> FilePath
$cshowList :: [NextVerNotFound] -> FilePath -> FilePath
show :: NextVerNotFound -> FilePath
$cshow :: NextVerNotFound -> FilePath
showsPrec :: Int -> NextVerNotFound -> FilePath -> FilePath
$cshowsPrec :: Int -> NextVerNotFound -> FilePath -> FilePath
Show

instance Pretty NextVerNotFound where
  pPrint :: NextVerNotFound -> Doc
pPrint (NextVerNotFound Tool
tool) =
    FilePath -> Doc
text FilePath
"Unable to find next (the one after the currently set one) version of tool" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tool
tool

instance HFErrorProject NextVerNotFound where
  eBase :: Proxy NextVerNotFound -> Int
eBase Proxy NextVerNotFound
_ = Int
100
  eDesc :: Proxy NextVerNotFound -> FilePath
eDesc Proxy NextVerNotFound
_ = FilePath
"Unable to find the next version of a tool (the one after the currently set one)"

-- | The tool (such as GHC) is already installed with that version.
data AlreadyInstalled = AlreadyInstalled Tool Version
  deriving Int -> AlreadyInstalled -> FilePath -> FilePath
[AlreadyInstalled] -> FilePath -> FilePath
AlreadyInstalled -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [AlreadyInstalled] -> FilePath -> FilePath
$cshowList :: [AlreadyInstalled] -> FilePath -> FilePath
show :: AlreadyInstalled -> FilePath
$cshow :: AlreadyInstalled -> FilePath
showsPrec :: Int -> AlreadyInstalled -> FilePath -> FilePath
$cshowsPrec :: Int -> AlreadyInstalled -> FilePath -> FilePath
Show

instance Pretty AlreadyInstalled where
  pPrint :: AlreadyInstalled -> Doc
pPrint (AlreadyInstalled Tool
tool Version
ver') =
    (forall a. Pretty a => a -> Doc
pPrint Tool
tool forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
text FilePath
"-" forall a. Semigroup a => a -> a -> a
<> forall a. Pretty a => a -> Doc
pPrint Version
ver') Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"is already installed;"
    Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"if you really want to reinstall it, you may want to run 'ghcup install" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"--force" Doc -> Doc -> Doc
<+> (forall a. Pretty a => a -> Doc
pPrint Version
ver' forall a. Semigroup a => a -> a -> a
<> FilePath -> Doc
text FilePath
"'")

instance HFErrorProject AlreadyInstalled where
  eBase :: Proxy AlreadyInstalled -> Int
eBase Proxy AlreadyInstalled
_ = Int
110
  eDesc :: Proxy AlreadyInstalled -> FilePath
eDesc Proxy AlreadyInstalled
_ = FilePath
"The tool (such as GHC) is already installed with that version"

-- | The Directory is supposed to be empty, but wasn't.
data DirNotEmpty = DirNotEmpty {DirNotEmpty -> FilePath
path :: FilePath}
  deriving Int -> DirNotEmpty -> FilePath -> FilePath
[DirNotEmpty] -> FilePath -> FilePath
DirNotEmpty -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [DirNotEmpty] -> FilePath -> FilePath
$cshowList :: [DirNotEmpty] -> FilePath -> FilePath
show :: DirNotEmpty -> FilePath
$cshow :: DirNotEmpty -> FilePath
showsPrec :: Int -> DirNotEmpty -> FilePath -> FilePath
$cshowsPrec :: Int -> DirNotEmpty -> FilePath -> FilePath
Show

instance Pretty DirNotEmpty where
  pPrint :: DirNotEmpty -> Doc
pPrint (DirNotEmpty FilePath
path) = do
    FilePath -> Doc
text forall a b. (a -> b) -> a -> b
$ FilePath
"The directory was expected to be empty, but isn't: " forall a. Semigroup a => a -> a -> a
<> FilePath
path

instance HFErrorProject DirNotEmpty where
  eBase :: Proxy DirNotEmpty -> Int
eBase Proxy DirNotEmpty
_ = Int
120
  eDesc :: Proxy DirNotEmpty -> FilePath
eDesc Proxy DirNotEmpty
_ = FilePath
"The Directory is supposed to be empty, but wasn't"

-- | The tool is not installed. Some operations rely on a tool
-- to be installed (such as setting the current GHC version).
data NotInstalled = NotInstalled Tool GHCTargetVersion
  deriving Int -> NotInstalled -> FilePath -> FilePath
[NotInstalled] -> FilePath -> FilePath
NotInstalled -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NotInstalled] -> FilePath -> FilePath
$cshowList :: [NotInstalled] -> FilePath -> FilePath
show :: NotInstalled -> FilePath
$cshow :: NotInstalled -> FilePath
showsPrec :: Int -> NotInstalled -> FilePath -> FilePath
$cshowsPrec :: Int -> NotInstalled -> FilePath -> FilePath
Show

instance Pretty NotInstalled where
  pPrint :: NotInstalled -> Doc
pPrint (NotInstalled Tool
tool GHCTargetVersion
ver) =
    FilePath -> Doc
text FilePath
"The version" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint GHCTargetVersion
ver Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"of the tool" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"is not installed."

instance HFErrorProject NotInstalled where
  eBase :: Proxy NotInstalled -> Int
eBase Proxy NotInstalled
_ = Int
130
  eDesc :: Proxy NotInstalled -> FilePath
eDesc Proxy NotInstalled
_ = FilePath
"The required tool is not installed"

data UninstallFailed = UninstallFailed FilePath [FilePath]
  deriving Int -> UninstallFailed -> FilePath -> FilePath
[UninstallFailed] -> FilePath -> FilePath
UninstallFailed -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [UninstallFailed] -> FilePath -> FilePath
$cshowList :: [UninstallFailed] -> FilePath -> FilePath
show :: UninstallFailed -> FilePath
$cshow :: UninstallFailed -> FilePath
showsPrec :: Int -> UninstallFailed -> FilePath -> FilePath
$cshowsPrec :: Int -> UninstallFailed -> FilePath -> FilePath
Show

instance Pretty UninstallFailed where
  pPrint :: UninstallFailed -> Doc
pPrint (UninstallFailed FilePath
dir [FilePath]
files) =
    FilePath -> Doc
text FilePath
"The following files survived uninstallation: " Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint [FilePath]
files Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"...consider removing" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
dir Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"manually."

instance HFErrorProject UninstallFailed where
  eBase :: Proxy UninstallFailed -> Int
eBase Proxy UninstallFailed
_ = Int
140
  eDesc :: Proxy UninstallFailed -> FilePath
eDesc Proxy UninstallFailed
_ = FilePath
"Uninstallation failed with leftover files"

-- | An executable was expected to be in PATH, but was not found.
data NotFoundInPATH = NotFoundInPATH FilePath
  deriving Int -> NotFoundInPATH -> FilePath -> FilePath
[NotFoundInPATH] -> FilePath -> FilePath
NotFoundInPATH -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NotFoundInPATH] -> FilePath -> FilePath
$cshowList :: [NotFoundInPATH] -> FilePath -> FilePath
show :: NotFoundInPATH -> FilePath
$cshow :: NotFoundInPATH -> FilePath
showsPrec :: Int -> NotFoundInPATH -> FilePath -> FilePath
$cshowsPrec :: Int -> NotFoundInPATH -> FilePath -> FilePath
Show

instance Exception NotFoundInPATH

instance Pretty NotFoundInPATH where
  pPrint :: NotFoundInPATH -> Doc
pPrint (NotFoundInPATH FilePath
exe) =
    FilePath -> Doc
text forall a b. (a -> b) -> a -> b
$ FilePath
"The exe " forall a. Semigroup a => a -> a -> a
<> FilePath
exe forall a. Semigroup a => a -> a -> a
<> FilePath
" was not found in PATH."

instance HFErrorProject NotFoundInPATH where
  eBase :: Proxy NotFoundInPATH -> Int
eBase Proxy NotFoundInPATH
_ = Int
150
  eDesc :: Proxy NotFoundInPATH -> FilePath
eDesc Proxy NotFoundInPATH
_ = FilePath
"An executable was expected to be in PATH, but was not found"

-- | JSON decoding failed.
data JSONError = JSONDecodeError String
  deriving Int -> JSONError -> FilePath -> FilePath
[JSONError] -> FilePath -> FilePath
JSONError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [JSONError] -> FilePath -> FilePath
$cshowList :: [JSONError] -> FilePath -> FilePath
show :: JSONError -> FilePath
$cshow :: JSONError -> FilePath
showsPrec :: Int -> JSONError -> FilePath -> FilePath
$cshowsPrec :: Int -> JSONError -> FilePath -> FilePath
Show

instance Pretty JSONError where
  pPrint :: JSONError -> Doc
pPrint (JSONDecodeError FilePath
err) =
    FilePath -> Doc
text forall a b. (a -> b) -> a -> b
$ FilePath
"JSON decoding failed with: " forall a. Semigroup a => a -> a -> a
<> FilePath
err

instance HFErrorProject JSONError where
  eBase :: Proxy JSONError -> Int
eBase Proxy JSONError
_ = Int
160
  eDesc :: Proxy JSONError -> FilePath
eDesc Proxy JSONError
_ = FilePath
"JSON decoding failed"

-- | A file that is supposed to exist does not exist
-- (e.g. when we use file scheme to "download" something).
data FileDoesNotExistError = FileDoesNotExistError FilePath
  deriving Int -> FileDoesNotExistError -> FilePath -> FilePath
[FileDoesNotExistError] -> FilePath -> FilePath
FileDoesNotExistError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [FileDoesNotExistError] -> FilePath -> FilePath
$cshowList :: [FileDoesNotExistError] -> FilePath -> FilePath
show :: FileDoesNotExistError -> FilePath
$cshow :: FileDoesNotExistError -> FilePath
showsPrec :: Int -> FileDoesNotExistError -> FilePath -> FilePath
$cshowsPrec :: Int -> FileDoesNotExistError -> FilePath -> FilePath
Show

instance Pretty FileDoesNotExistError where
  pPrint :: FileDoesNotExistError -> Doc
pPrint (FileDoesNotExistError FilePath
file) =
    FilePath -> Doc
text forall a b. (a -> b) -> a -> b
$ FilePath
"File " forall a. Semigroup a => a -> a -> a
<> FilePath
file forall a. Semigroup a => a -> a -> a
<> FilePath
" does not exist."

instance HFErrorProject FileDoesNotExistError where
  eBase :: Proxy FileDoesNotExistError -> Int
eBase Proxy FileDoesNotExistError
_ = Int
170
  eDesc :: Proxy FileDoesNotExistError -> FilePath
eDesc Proxy FileDoesNotExistError
_ = FilePath
"A file that is supposed to exist does not exist (oops)"

-- | The file already exists
-- (e.g. when we use isolated installs with the same path).
-- (e.g. This is done to prevent any overwriting)
data FileAlreadyExistsError = FileAlreadyExistsError FilePath
  deriving Int -> FileAlreadyExistsError -> FilePath -> FilePath
[FileAlreadyExistsError] -> FilePath -> FilePath
FileAlreadyExistsError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [FileAlreadyExistsError] -> FilePath -> FilePath
$cshowList :: [FileAlreadyExistsError] -> FilePath -> FilePath
show :: FileAlreadyExistsError -> FilePath
$cshow :: FileAlreadyExistsError -> FilePath
showsPrec :: Int -> FileAlreadyExistsError -> FilePath -> FilePath
$cshowsPrec :: Int -> FileAlreadyExistsError -> FilePath -> FilePath
Show

instance Pretty FileAlreadyExistsError where
  pPrint :: FileAlreadyExistsError -> Doc
pPrint (FileAlreadyExistsError FilePath
file) =
    FilePath -> Doc
text forall a b. (a -> b) -> a -> b
$ FilePath
"File " forall a. Semigroup a => a -> a -> a
<> FilePath
file forall a. Semigroup a => a -> a -> a
<> FilePath
" Already exists."

instance HFErrorProject FileAlreadyExistsError where
  eBase :: Proxy FileAlreadyExistsError -> Int
eBase Proxy FileAlreadyExistsError
_ = Int
180
  eDesc :: Proxy FileAlreadyExistsError -> FilePath
eDesc Proxy FileAlreadyExistsError
_ = FilePath
"A file already exists that wasn't expected to exist"

data TarDirDoesNotExist = TarDirDoesNotExist TarDir
  deriving Int -> TarDirDoesNotExist -> FilePath -> FilePath
[TarDirDoesNotExist] -> FilePath -> FilePath
TarDirDoesNotExist -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [TarDirDoesNotExist] -> FilePath -> FilePath
$cshowList :: [TarDirDoesNotExist] -> FilePath -> FilePath
show :: TarDirDoesNotExist -> FilePath
$cshow :: TarDirDoesNotExist -> FilePath
showsPrec :: Int -> TarDirDoesNotExist -> FilePath -> FilePath
$cshowsPrec :: Int -> TarDirDoesNotExist -> FilePath -> FilePath
Show

instance Pretty TarDirDoesNotExist where
  pPrint :: TarDirDoesNotExist -> Doc
pPrint (TarDirDoesNotExist TarDir
dir) =
    FilePath -> Doc
text FilePath
"Tar directory does not exist:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint TarDir
dir

instance HFErrorProject TarDirDoesNotExist where
  eBase :: Proxy TarDirDoesNotExist -> Int
eBase Proxy TarDirDoesNotExist
_ = Int
190
  eDesc :: Proxy TarDirDoesNotExist -> FilePath
eDesc Proxy TarDirDoesNotExist
_ = FilePath
"The tar directory (e.g. inside an archive) does not exist"

-- | File digest verification failed.
data DigestError = DigestError FilePath Text Text
  deriving Int -> DigestError -> FilePath -> FilePath
[DigestError] -> FilePath -> FilePath
DigestError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [DigestError] -> FilePath -> FilePath
$cshowList :: [DigestError] -> FilePath -> FilePath
show :: DigestError -> FilePath
$cshow :: DigestError -> FilePath
showsPrec :: Int -> DigestError -> FilePath -> FilePath
$cshowsPrec :: Int -> DigestError -> FilePath -> FilePath
Show

instance Pretty DigestError where
  pPrint :: DigestError -> Doc
pPrint (DigestError FilePath
fp Text
currentDigest Text
expectedDigest) =
    FilePath -> Doc
text FilePath
"Digest error for" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
fp forall a. Semigroup a => a -> a -> a
<> FilePath
": expected")
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (Text -> FilePath
T.unpack Text
expectedDigest) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"but got" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Text
currentDigest Doc -> Doc -> Doc
<+> FilePath -> Doc
text
      FilePath
"\nConsider removing the file in case it's cached and try again."

instance HFErrorProject DigestError where
  eBase :: Proxy DigestError -> Int
eBase Proxy DigestError
_ = Int
200
  eDesc :: Proxy DigestError -> FilePath
eDesc Proxy DigestError
_ = FilePath
"File digest verification failed"

-- | File PGP verification failed.
data GPGError = forall xs . (ToVariantMaybe DownloadFailed xs, PopVariant DownloadFailed xs, Show (V xs), Pretty (V xs)) => GPGError (V xs)

deriving instance Show GPGError

instance Pretty GPGError where
  pPrint :: GPGError -> Doc
pPrint (GPGError V xs
reason) = FilePath -> Doc
text FilePath
"GPG verify failed:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint V xs
reason

instance HFErrorProject GPGError where
  eBase :: Proxy GPGError -> Int
eBase Proxy GPGError
_ = Int
210
  eDesc :: Proxy GPGError -> FilePath
eDesc Proxy GPGError
_ = FilePath
"File PGP verification failed"

-- | Unexpected HTTP status.
data HTTPStatusError = HTTPStatusError Int (M.Map (CI ByteString) ByteString)
  deriving Int -> HTTPStatusError -> FilePath -> FilePath
[HTTPStatusError] -> FilePath -> FilePath
HTTPStatusError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [HTTPStatusError] -> FilePath -> FilePath
$cshowList :: [HTTPStatusError] -> FilePath -> FilePath
show :: HTTPStatusError -> FilePath
$cshow :: HTTPStatusError -> FilePath
showsPrec :: Int -> HTTPStatusError -> FilePath -> FilePath
$cshowsPrec :: Int -> HTTPStatusError -> FilePath -> FilePath
Show

instance Pretty HTTPStatusError where
  pPrint :: HTTPStatusError -> Doc
pPrint (HTTPStatusError Int
status Map (CI ByteString) ByteString
_) =
    FilePath -> Doc
text FilePath
"Unexpected HTTP status:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Int
status

instance HFErrorProject HTTPStatusError where
  eBase :: Proxy HTTPStatusError -> Int
eBase Proxy HTTPStatusError
_ = Int
220
  eDesc :: Proxy HTTPStatusError -> FilePath
eDesc Proxy HTTPStatusError
_ = FilePath
"Unexpected HTTP status error (e.g. during downloads)"

-- | Malformed headers.
data MalformedHeaders = MalformedHeaders Text
  deriving Int -> MalformedHeaders -> FilePath -> FilePath
[MalformedHeaders] -> FilePath -> FilePath
MalformedHeaders -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [MalformedHeaders] -> FilePath -> FilePath
$cshowList :: [MalformedHeaders] -> FilePath -> FilePath
show :: MalformedHeaders -> FilePath
$cshow :: MalformedHeaders -> FilePath
showsPrec :: Int -> MalformedHeaders -> FilePath -> FilePath
$cshowsPrec :: Int -> MalformedHeaders -> FilePath -> FilePath
Show

instance Pretty MalformedHeaders where
  pPrint :: MalformedHeaders -> Doc
pPrint (MalformedHeaders Text
h) =
    FilePath -> Doc
text FilePath
"Headers are malformed: " Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Text
h

instance HFErrorProject MalformedHeaders where
  eBase :: Proxy MalformedHeaders -> Int
eBase Proxy MalformedHeaders
_ = Int
230
  eDesc :: Proxy MalformedHeaders -> FilePath
eDesc Proxy MalformedHeaders
_ = FilePath
"Malformed headers during download"

-- | Unexpected HTTP status.
data HTTPNotModified = HTTPNotModified Text
  deriving Int -> HTTPNotModified -> FilePath -> FilePath
[HTTPNotModified] -> FilePath -> FilePath
HTTPNotModified -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [HTTPNotModified] -> FilePath -> FilePath
$cshowList :: [HTTPNotModified] -> FilePath -> FilePath
show :: HTTPNotModified -> FilePath
$cshow :: HTTPNotModified -> FilePath
showsPrec :: Int -> HTTPNotModified -> FilePath -> FilePath
$cshowsPrec :: Int -> HTTPNotModified -> FilePath -> FilePath
Show

instance Pretty HTTPNotModified where
  pPrint :: HTTPNotModified -> Doc
pPrint (HTTPNotModified Text
etag) =
    FilePath -> Doc
text FilePath
"Remote resource not modifed, etag was:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Text
etag

instance HFErrorProject HTTPNotModified where
  eBase :: Proxy HTTPNotModified -> Int
eBase Proxy HTTPNotModified
_ = Int
240
  eDesc :: Proxy HTTPNotModified -> FilePath
eDesc Proxy HTTPNotModified
_ = FilePath
"Not modified HTTP status error (e.g. during downloads)."

-- | The 'Location' header was expected during a 3xx redirect, but not found.
data NoLocationHeader = NoLocationHeader
  deriving Int -> NoLocationHeader -> FilePath -> FilePath
[NoLocationHeader] -> FilePath -> FilePath
NoLocationHeader -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoLocationHeader] -> FilePath -> FilePath
$cshowList :: [NoLocationHeader] -> FilePath -> FilePath
show :: NoLocationHeader -> FilePath
$cshow :: NoLocationHeader -> FilePath
showsPrec :: Int -> NoLocationHeader -> FilePath -> FilePath
$cshowsPrec :: Int -> NoLocationHeader -> FilePath -> FilePath
Show

instance Pretty NoLocationHeader where
  pPrint :: NoLocationHeader -> Doc
pPrint NoLocationHeader
NoLocationHeader =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy NoLocationHeader))

instance HFErrorProject NoLocationHeader where
  eBase :: Proxy NoLocationHeader -> Int
eBase Proxy NoLocationHeader
_ = Int
250
  eDesc :: Proxy NoLocationHeader -> FilePath
eDesc Proxy NoLocationHeader
_ = FilePath
"The 'Location' header was expected during a 3xx redirect, but not found."

-- | Too many redirects.
data TooManyRedirs = TooManyRedirs
  deriving Int -> TooManyRedirs -> FilePath -> FilePath
[TooManyRedirs] -> FilePath -> FilePath
TooManyRedirs -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [TooManyRedirs] -> FilePath -> FilePath
$cshowList :: [TooManyRedirs] -> FilePath -> FilePath
show :: TooManyRedirs -> FilePath
$cshow :: TooManyRedirs -> FilePath
showsPrec :: Int -> TooManyRedirs -> FilePath -> FilePath
$cshowsPrec :: Int -> TooManyRedirs -> FilePath -> FilePath
Show

instance Pretty TooManyRedirs where
  pPrint :: TooManyRedirs -> Doc
pPrint TooManyRedirs
TooManyRedirs =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy TooManyRedirs))

instance HFErrorProject TooManyRedirs where
  eBase :: Proxy TooManyRedirs -> Int
eBase Proxy TooManyRedirs
_ = Int
260
  eDesc :: Proxy TooManyRedirs -> FilePath
eDesc Proxy TooManyRedirs
_ = FilePath
"Too many redirections."

-- | A patch could not be applied.
data PatchFailed = PatchFailed
  deriving Int -> PatchFailed -> FilePath -> FilePath
[PatchFailed] -> FilePath -> FilePath
PatchFailed -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [PatchFailed] -> FilePath -> FilePath
$cshowList :: [PatchFailed] -> FilePath -> FilePath
show :: PatchFailed -> FilePath
$cshow :: PatchFailed -> FilePath
showsPrec :: Int -> PatchFailed -> FilePath -> FilePath
$cshowsPrec :: Int -> PatchFailed -> FilePath -> FilePath
Show

instance Pretty PatchFailed where
  pPrint :: PatchFailed -> Doc
pPrint PatchFailed
PatchFailed =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy PatchFailed))

instance HFErrorProject PatchFailed where
  eBase :: Proxy PatchFailed -> Int
eBase Proxy PatchFailed
_ = Int
270
  eDesc :: Proxy PatchFailed -> FilePath
eDesc Proxy PatchFailed
_ = FilePath
"A patch could not be applied."

-- | The tool requirements could not be found.
data NoToolRequirements = NoToolRequirements
  deriving Int -> NoToolRequirements -> FilePath -> FilePath
[NoToolRequirements] -> FilePath -> FilePath
NoToolRequirements -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoToolRequirements] -> FilePath -> FilePath
$cshowList :: [NoToolRequirements] -> FilePath -> FilePath
show :: NoToolRequirements -> FilePath
$cshow :: NoToolRequirements -> FilePath
showsPrec :: Int -> NoToolRequirements -> FilePath -> FilePath
$cshowsPrec :: Int -> NoToolRequirements -> FilePath -> FilePath
Show

instance Pretty NoToolRequirements where
  pPrint :: NoToolRequirements -> Doc
pPrint NoToolRequirements
NoToolRequirements =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy NoToolRequirements))

instance HFErrorProject NoToolRequirements where
  eBase :: Proxy NoToolRequirements -> Int
eBase Proxy NoToolRequirements
_ = Int
280
  eDesc :: Proxy NoToolRequirements -> FilePath
eDesc Proxy NoToolRequirements
_ = FilePath
"The Tool requirements could not be found."

data InvalidBuildConfig = InvalidBuildConfig Text
  deriving Int -> InvalidBuildConfig -> FilePath -> FilePath
[InvalidBuildConfig] -> FilePath -> FilePath
InvalidBuildConfig -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [InvalidBuildConfig] -> FilePath -> FilePath
$cshowList :: [InvalidBuildConfig] -> FilePath -> FilePath
show :: InvalidBuildConfig -> FilePath
$cshow :: InvalidBuildConfig -> FilePath
showsPrec :: Int -> InvalidBuildConfig -> FilePath -> FilePath
$cshowsPrec :: Int -> InvalidBuildConfig -> FilePath -> FilePath
Show

instance Pretty InvalidBuildConfig where
  pPrint :: InvalidBuildConfig -> Doc
pPrint (InvalidBuildConfig Text
reason) =
    FilePath -> Doc
text FilePath
"The build config is invalid. Reason was:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Text
reason

instance HFErrorProject InvalidBuildConfig where
  eBase :: Proxy InvalidBuildConfig -> Int
eBase Proxy InvalidBuildConfig
_ = Int
290
  eDesc :: Proxy InvalidBuildConfig -> FilePath
eDesc Proxy InvalidBuildConfig
_ = FilePath
"The build config is invalid."

data NoToolVersionSet = NoToolVersionSet Tool
  deriving Int -> NoToolVersionSet -> FilePath -> FilePath
[NoToolVersionSet] -> FilePath -> FilePath
NoToolVersionSet -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoToolVersionSet] -> FilePath -> FilePath
$cshowList :: [NoToolVersionSet] -> FilePath -> FilePath
show :: NoToolVersionSet -> FilePath
$cshow :: NoToolVersionSet -> FilePath
showsPrec :: Int -> NoToolVersionSet -> FilePath -> FilePath
$cshowsPrec :: Int -> NoToolVersionSet -> FilePath -> FilePath
Show

instance Pretty NoToolVersionSet where
  pPrint :: NoToolVersionSet -> Doc
pPrint (NoToolVersionSet Tool
tool) =
    FilePath -> Doc
text FilePath
"No version is set for tool" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Tool
tool Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"."

instance HFErrorProject NoToolVersionSet where
  eBase :: Proxy NoToolVersionSet -> Int
eBase Proxy NoToolVersionSet
_ = Int
300
  eDesc :: Proxy NoToolVersionSet -> FilePath
eDesc Proxy NoToolVersionSet
_ = FilePath
"No version is set for tool (but was expected)."

data NoNetwork = NoNetwork
  deriving Int -> NoNetwork -> FilePath -> FilePath
[NoNetwork] -> FilePath -> FilePath
NoNetwork -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoNetwork] -> FilePath -> FilePath
$cshowList :: [NoNetwork] -> FilePath -> FilePath
show :: NoNetwork -> FilePath
$cshow :: NoNetwork -> FilePath
showsPrec :: Int -> NoNetwork -> FilePath -> FilePath
$cshowsPrec :: Int -> NoNetwork -> FilePath -> FilePath
Show

instance Pretty NoNetwork where
  pPrint :: NoNetwork -> Doc
pPrint NoNetwork
NoNetwork =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy NoNetwork))

instance HFErrorProject NoNetwork where
  eBase :: Proxy NoNetwork -> Int
eBase Proxy NoNetwork
_ = Int
310
  eDesc :: Proxy NoNetwork -> FilePath
eDesc Proxy NoNetwork
_ = FilePath
"A download was required or requested, but '--offline' was specified."

data HadrianNotFound = HadrianNotFound
  deriving Int -> HadrianNotFound -> FilePath -> FilePath
[HadrianNotFound] -> FilePath -> FilePath
HadrianNotFound -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [HadrianNotFound] -> FilePath -> FilePath
$cshowList :: [HadrianNotFound] -> FilePath -> FilePath
show :: HadrianNotFound -> FilePath
$cshow :: HadrianNotFound -> FilePath
showsPrec :: Int -> HadrianNotFound -> FilePath -> FilePath
$cshowsPrec :: Int -> HadrianNotFound -> FilePath -> FilePath
Show

instance Pretty HadrianNotFound where
  pPrint :: HadrianNotFound -> Doc
pPrint HadrianNotFound
HadrianNotFound =
    FilePath -> Doc
text (forall a. HFErrorProject a => Proxy a -> FilePath
eDesc (forall {k} (t :: k). Proxy t
Proxy :: Proxy HadrianNotFound))

instance HFErrorProject HadrianNotFound where
  eBase :: Proxy HadrianNotFound -> Int
eBase Proxy HadrianNotFound
_ = Int
320
  eDesc :: Proxy HadrianNotFound -> FilePath
eDesc Proxy HadrianNotFound
_ = FilePath
"Could not find Hadrian build files. Does this GHC version support Hadrian builds?"

data ToolShadowed = ToolShadowed
                       Tool
                       FilePath  -- shadow binary
                       FilePath  -- upgraded binary
                       Version   -- upgraded version
  deriving Int -> ToolShadowed -> FilePath -> FilePath
[ToolShadowed] -> FilePath -> FilePath
ToolShadowed -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [ToolShadowed] -> FilePath -> FilePath
$cshowList :: [ToolShadowed] -> FilePath -> FilePath
show :: ToolShadowed -> FilePath
$cshow :: ToolShadowed -> FilePath
showsPrec :: Int -> ToolShadowed -> FilePath -> FilePath
$cshowsPrec :: Int -> ToolShadowed -> FilePath -> FilePath
Show

instance Pretty ToolShadowed where
  pPrint :: ToolShadowed -> Doc
pPrint (ToolShadowed Tool
tool FilePath
sh FilePath
up Version
_) =
    FilePath -> Doc
text (forall a. Pretty a => a -> FilePath
prettyShow Tool
tool
         forall a. Semigroup a => a -> a -> a
<> FilePath
" is shadowed by "
         forall a. Semigroup a => a -> a -> a
<> FilePath
sh
         forall a. Semigroup a => a -> a -> a
<> FilePath
".\nThe upgrade will not be in effect, unless you remove "
         forall a. Semigroup a => a -> a -> a
<> FilePath
sh
         forall a. Semigroup a => a -> a -> a
<> FilePath
"\nor make sure "
         forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath
takeDirectory FilePath
up
         forall a. Semigroup a => a -> a -> a
<> FilePath
" comes before "
         forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath
takeDirectory FilePath
sh
         forall a. Semigroup a => a -> a -> a
<> FilePath
" in PATH."
         )

instance HFErrorProject ToolShadowed where
  eBase :: Proxy ToolShadowed -> Int
eBase Proxy ToolShadowed
_ = Int
330
  eDesc :: Proxy ToolShadowed -> FilePath
eDesc Proxy ToolShadowed
_ = FilePath
"A tool is shadowed in PATH."

-- | File content length verification failed.
data ContentLengthError = ContentLengthError (Maybe FilePath) (Maybe Integer) Integer
  deriving Int -> ContentLengthError -> FilePath -> FilePath
[ContentLengthError] -> FilePath -> FilePath
ContentLengthError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [ContentLengthError] -> FilePath -> FilePath
$cshowList :: [ContentLengthError] -> FilePath -> FilePath
show :: ContentLengthError -> FilePath
$cshow :: ContentLengthError -> FilePath
showsPrec :: Int -> ContentLengthError -> FilePath -> FilePath
$cshowsPrec :: Int -> ContentLengthError -> FilePath -> FilePath
Show

instance Pretty ContentLengthError where
  pPrint :: ContentLengthError -> Doc
pPrint (ContentLengthError Maybe FilePath
Nothing Maybe Integer
Nothing Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length exceeded expected size:"
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Integer
expectedSize)
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nConsider removing the file in case it's cached and try again."
  pPrint (ContentLengthError Maybe FilePath
Nothing (Just Integer
currentSize) Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length error. Expected"
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Integer
expectedSize) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"but got" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Integer
currentSize Doc -> Doc -> Doc
<+> FilePath -> Doc
text
      FilePath
"\nConsider removing the file in case it's cached and try again."
  pPrint (ContentLengthError (Just FilePath
fp) (Just Integer
currentSize) Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length error for" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
fp forall a. Semigroup a => a -> a -> a
<> FilePath
": expected")
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Integer
expectedSize) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"but got" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Integer
currentSize Doc -> Doc -> Doc
<+> FilePath -> Doc
text
      FilePath
"\nConsider removing the file in case it's cached and try again."
  pPrint (ContentLengthError (Just FilePath
fp) Maybe Integer
Nothing Integer
expectedSize) =
    FilePath -> Doc
text FilePath
"Content length error for" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
fp forall a. Semigroup a => a -> a -> a
<> FilePath
": expected")
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Integer
expectedSize) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nConsider removing the file in case it's cached and try again."

instance Exception ContentLengthError

instance HFErrorProject ContentLengthError where
  eBase :: Proxy ContentLengthError -> Int
eBase Proxy ContentLengthError
_ = Int
340
  eDesc :: Proxy ContentLengthError -> FilePath
eDesc Proxy ContentLengthError
_ = FilePath
"File content length verification failed"

data DuplicateReleaseChannel = DuplicateReleaseChannel URI
  deriving Int -> DuplicateReleaseChannel -> FilePath -> FilePath
[DuplicateReleaseChannel] -> FilePath -> FilePath
DuplicateReleaseChannel -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [DuplicateReleaseChannel] -> FilePath -> FilePath
$cshowList :: [DuplicateReleaseChannel] -> FilePath -> FilePath
show :: DuplicateReleaseChannel -> FilePath
$cshow :: DuplicateReleaseChannel -> FilePath
showsPrec :: Int -> DuplicateReleaseChannel -> FilePath -> FilePath
$cshowsPrec :: Int -> DuplicateReleaseChannel -> FilePath -> FilePath
Show

instance HFErrorProject DuplicateReleaseChannel where
  eBase :: Proxy DuplicateReleaseChannel -> Int
eBase Proxy DuplicateReleaseChannel
_ = Int
350
  eDesc :: Proxy DuplicateReleaseChannel -> FilePath
eDesc Proxy DuplicateReleaseChannel
_ = FilePath
"Duplicate release channel detected when adding URI.\nGiving up. You can use '--force' to remove and append the duplicate URI (this may change order/semantics)."

instance Pretty DuplicateReleaseChannel where
  pPrint :: DuplicateReleaseChannel -> Doc
pPrint (DuplicateReleaseChannel URI
uri) =
    FilePath -> Doc
text forall a b. (a -> b) -> a -> b
$ FilePath
"Duplicate release channel detected when adding: \n  "
      forall a. Semigroup a => a -> a -> a
<> (Text -> FilePath
T.unpack forall b c a. (b -> c) -> (a -> b) -> a -> c
. OnDecodeError -> ByteString -> Text
E.decodeUtf8With OnDecodeError
E.lenientDecode forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. URIRef a -> ByteString
serializeURIRef') URI
uri
      forall a. Semigroup a => a -> a -> a
<> FilePath
"\nGiving up. You can use '--force' to remove and append the duplicate URI (this may change order/semantics)."

    -------------------------
    --[ High-level errors ]--
    -------------------------

-- | A download failed. The underlying error is encapsulated.
data DownloadFailed = forall xs . (HFErrorProject (V xs), ToVariantMaybe DownloadFailed xs, PopVariant DownloadFailed xs, Show (V xs), Pretty (V xs)) => DownloadFailed (V xs)

instance Pretty DownloadFailed where
  pPrint :: DownloadFailed -> Doc
pPrint (DownloadFailed V xs
reason) =
    case V xs
reason of
      VMaybe (DownloadFailed
_ :: DownloadFailed) -> forall a. Pretty a => a -> Doc
pPrint V xs
reason
      V xs
_ -> FilePath -> Doc
text FilePath
"Download failed:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint V xs
reason

deriving instance Show DownloadFailed

instance HFErrorProject DownloadFailed where
  eBase :: Proxy DownloadFailed -> Int
eBase Proxy DownloadFailed
_ = Int
5000
  eNum :: DownloadFailed -> Int
eNum (DownloadFailed V xs
xs) = Int
5000 forall a. Num a => a -> a -> a
+ forall a. HFErrorProject a => a -> Int
eNum V xs
xs
  eDesc :: Proxy DownloadFailed -> FilePath
eDesc Proxy DownloadFailed
_ = FilePath
"A download failed."

data InstallSetError = forall xs1 xs2 . (Show (V xs1), Pretty (V xs1), HFErrorProject (V xs1), Show (V xs2), Pretty (V xs2), HFErrorProject (V xs2)) => InstallSetError (V xs1) (V xs2)

instance Pretty InstallSetError where
  pPrint :: InstallSetError -> Doc
pPrint (InstallSetError V xs1
reason1 V xs2
reason2) =
     FilePath -> Doc
text FilePath
"Both installation and setting the tool failed. Install error was:"
      Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint V xs1
reason1
      Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nSet error was:"
      Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint V xs2
reason2

deriving instance Show InstallSetError

instance HFErrorProject InstallSetError where
  eBase :: Proxy InstallSetError -> Int
eBase Proxy InstallSetError
_ = Int
7000
  -- will there be collisions?
  eNum :: InstallSetError -> Int
eNum (InstallSetError V xs1
xs1 V xs2
xs2) = Int
7000 forall a. Num a => a -> a -> a
+ forall a. HFErrorProject a => a -> Int
eNum V xs1
xs1 forall a. Num a => a -> a -> a
+ forall a. HFErrorProject a => a -> Int
eNum V xs2
xs2
  eDesc :: Proxy InstallSetError -> FilePath
eDesc Proxy InstallSetError
_ = FilePath
"Installation or setting the tool failed."


-- | A test failed.
data TestFailed = forall es . (ToVariantMaybe TestFailed es, PopVariant TestFailed es, Pretty (V es), Show (V es), HFErrorProject (V es)) => TestFailed FilePath (V es)

instance Pretty TestFailed where
  pPrint :: TestFailed -> Doc
pPrint (TestFailed FilePath
path V es
reason) =
    case V es
reason of
      VMaybe (TestFailed
_ :: TestFailed) -> forall a. Pretty a => a -> Doc
pPrint V es
reason
      V es
_ -> FilePath -> Doc
text (FilePath
"The test failed. GHC test suite is fragile and non-portable. Please also check out the " forall a. Semigroup a => a -> a -> a
<> FilePath -> FilePath -> FilePath
linkEscapeCode FilePath
"issue tracker" FilePath
" https://gitlab.haskell.org/ghc/ghc/-/issues/?sort=updated_desc&state=opened&label_name%5B%5D=testsuite&label_name%5B%5D=packaging&first_page_size=20" forall a. Semigroup a => a -> a -> a
<> FilePath
".\nBuild dir was:") Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
path Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"\nReason was:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint V es
reason

deriving instance Show TestFailed

instance HFErrorProject TestFailed where
  eBase :: Proxy TestFailed -> Int
eBase Proxy TestFailed
_ = Int
4000
  eNum :: TestFailed -> Int
eNum (TestFailed FilePath
_ V es
xs2) = Int
4000 forall a. Num a => a -> a -> a
+ forall a. HFErrorProject a => a -> Int
eNum V es
xs2
  eDesc :: Proxy TestFailed -> FilePath
eDesc Proxy TestFailed
_ = FilePath
"The test failed."

-- | A build failed.
data BuildFailed = forall es . (ToVariantMaybe BuildFailed es, PopVariant BuildFailed es, Pretty (V es), Show (V es), HFErrorProject (V es)) => BuildFailed FilePath (V es)

instance Pretty BuildFailed where
  pPrint :: BuildFailed -> Doc
pPrint (BuildFailed FilePath
path V es
reason) =
    case V es
reason of
      VMaybe (BuildFailed
_ :: BuildFailed) -> forall a. Pretty a => a -> Doc
pPrint V es
reason
      V es
_ -> FilePath -> Doc
text FilePath
"BuildFailed failed in dir" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (FilePath
path forall a. Semigroup a => a -> a -> a
<> FilePath
":") Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint V es
reason

deriving instance Show BuildFailed

instance HFErrorProject BuildFailed where
  eBase :: Proxy BuildFailed -> Int
eBase Proxy BuildFailed
_ = Int
8000
  eNum :: BuildFailed -> Int
eNum (BuildFailed FilePath
_ V es
xs2) = Int
8000 forall a. Num a => a -> a -> a
+ forall a. HFErrorProject a => a -> Int
eNum V es
xs2
  eDesc :: Proxy BuildFailed -> FilePath
eDesc Proxy BuildFailed
_ = FilePath
"The build failed."


-- | Setting the current GHC version failed.
data GHCupSetError = forall es . (ToVariantMaybe GHCupSetError es, PopVariant GHCupSetError es, Show (V es), Pretty (V es), HFErrorProject (V es)) => GHCupSetError (V es)

instance Pretty GHCupSetError where
  pPrint :: GHCupSetError -> Doc
pPrint (GHCupSetError V es
reason) =
    case V es
reason of
      VMaybe (GHCupSetError
_ :: GHCupSetError) -> forall a. Pretty a => a -> Doc
pPrint V es
reason
      V es
_ -> FilePath -> Doc
text FilePath
"Setting the current version failed:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint V es
reason

deriving instance Show GHCupSetError

instance HFErrorProject GHCupSetError where
  eBase :: Proxy GHCupSetError -> Int
eBase Proxy GHCupSetError
_ = Int
9000
  eNum :: GHCupSetError -> Int
eNum (GHCupSetError V es
xs) = Int
9000 forall a. Num a => a -> a -> a
+ forall a. HFErrorProject a => a -> Int
eNum V es
xs
  eDesc :: Proxy GHCupSetError -> FilePath
eDesc Proxy GHCupSetError
_ = FilePath
"Setting the current version failed."


    ---------------------------------------------
    --[ True Exceptions (e.g. for MonadThrow) ]--
    ---------------------------------------------


-- | Parsing failed.
data ParseError = ParseError String
  deriving Int -> ParseError -> FilePath -> FilePath
[ParseError] -> FilePath -> FilePath
ParseError -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [ParseError] -> FilePath -> FilePath
$cshowList :: [ParseError] -> FilePath -> FilePath
show :: ParseError -> FilePath
$cshow :: ParseError -> FilePath
showsPrec :: Int -> ParseError -> FilePath -> FilePath
$cshowsPrec :: Int -> ParseError -> FilePath -> FilePath
Show

instance Pretty ParseError where
  pPrint :: ParseError -> Doc
pPrint (ParseError FilePath
reason) =
    FilePath -> Doc
text FilePath
"Parsing failed:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
reason

instance Exception ParseError

instance HFErrorProject ParseError where
  eBase :: Proxy ParseError -> Int
eBase Proxy ParseError
_ = Int
500
  eDesc :: Proxy ParseError -> FilePath
eDesc Proxy ParseError
_ = FilePath
"A parse error occured."


data UnexpectedListLength = UnexpectedListLength String
  deriving Int -> UnexpectedListLength -> FilePath -> FilePath
[UnexpectedListLength] -> FilePath -> FilePath
UnexpectedListLength -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [UnexpectedListLength] -> FilePath -> FilePath
$cshowList :: [UnexpectedListLength] -> FilePath -> FilePath
show :: UnexpectedListLength -> FilePath
$cshow :: UnexpectedListLength -> FilePath
showsPrec :: Int -> UnexpectedListLength -> FilePath -> FilePath
$cshowsPrec :: Int -> UnexpectedListLength -> FilePath -> FilePath
Show

instance Pretty UnexpectedListLength where
  pPrint :: UnexpectedListLength -> Doc
pPrint (UnexpectedListLength FilePath
reason) =
    FilePath -> Doc
text FilePath
"List length unexpected:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
reason

instance Exception UnexpectedListLength

instance HFErrorProject UnexpectedListLength where
  eBase :: Proxy UnexpectedListLength -> Int
eBase Proxy UnexpectedListLength
_ = Int
510
  eDesc :: Proxy UnexpectedListLength -> FilePath
eDesc Proxy UnexpectedListLength
_ = FilePath
"A list had an unexpected length."

data NoUrlBase = NoUrlBase Text
  deriving Int -> NoUrlBase -> FilePath -> FilePath
[NoUrlBase] -> FilePath -> FilePath
NoUrlBase -> FilePath
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
showList :: [NoUrlBase] -> FilePath -> FilePath
$cshowList :: [NoUrlBase] -> FilePath -> FilePath
show :: NoUrlBase -> FilePath
$cshow :: NoUrlBase -> FilePath
showsPrec :: Int -> NoUrlBase -> FilePath -> FilePath
$cshowsPrec :: Int -> NoUrlBase -> FilePath -> FilePath
Show

instance Pretty NoUrlBase where
  pPrint :: NoUrlBase -> Doc
pPrint (NoUrlBase Text
url) =
    FilePath -> Doc
text FilePath
"Couldn't get a base filename from url" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint Text
url

instance Exception NoUrlBase

instance HFErrorProject NoUrlBase where
  eBase :: Proxy NoUrlBase -> Int
eBase Proxy NoUrlBase
_ = Int
520
  eDesc :: Proxy NoUrlBase -> FilePath
eDesc Proxy NoUrlBase
_ = FilePath
"URL does not have a base filename."



    ------------------------
    --[ orphan instances ]--
    ------------------------

instance Pretty (V '[]) where
   {-# INLINABLE pPrint #-}
   pPrint :: V '[] -> Doc
pPrint V '[]
_ = forall a. HasCallStack => a
undefined

instance
   ( Pretty x
   , Pretty (V xs)
   ) => Pretty (V (x ': xs))
   where
      pPrint :: V (x : xs) -> Doc
pPrint V (x : xs)
v = case forall x (xs :: [*]). V (x : xs) -> Either (V xs) x
popVariantHead V (x : xs)
v of
         Right x
x -> forall a. Pretty a => a -> Doc
pPrint x
x
         Left V xs
xs -> forall a. Pretty a => a -> Doc
pPrint V xs
xs

instance HFErrorProject (V '[]) where
   {-# INLINABLE eBase #-}
   eBase :: Proxy (V '[]) -> Int
eBase Proxy (V '[])
_ = forall a. HasCallStack => a
undefined
   {-# INLINABLE eDesc #-}
   eDesc :: Proxy (V '[]) -> FilePath
eDesc Proxy (V '[])
_ = forall a. HasCallStack => a
undefined

instance
   ( HFErrorProject x
   , HFErrorProject (V xs)
   ) => HFErrorProject (V (x ': xs))
   where
      eNum :: V (x : xs) -> Int
eNum V (x : xs)
v = case forall x (xs :: [*]). V (x : xs) -> Either (V xs) x
popVariantHead V (x : xs)
v of
         Right x
x -> forall a. HFErrorProject a => a -> Int
eNum x
x
         Left V xs
xs -> forall a. HFErrorProject a => a -> Int
eNum V xs
xs
      eDesc :: Proxy (V (x : xs)) -> FilePath
eDesc Proxy (V (x : xs))
_ = forall a. HasCallStack => a
undefined
      eBase :: Proxy (V (x : xs)) -> Int
eBase Proxy (V (x : xs))
_ = forall a. HasCallStack => a
undefined

instance Pretty URIParseError where
  pPrint :: URIParseError -> Doc
pPrint (MalformedScheme SchemaError
reason) =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed scheme:" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show SchemaError
reason)
  pPrint URIParseError
MalformedUserInfo =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed user info."
  pPrint URIParseError
MalformedQuery =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed query."
  pPrint URIParseError
MalformedFragment =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed fragment."
  pPrint URIParseError
MalformedHost =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed host."
  pPrint URIParseError
MalformedPort =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed port."
  pPrint URIParseError
MalformedPath =
    FilePath -> Doc
text FilePath
"Failed to parse URI. Malformed path."
  pPrint (OtherError FilePath
err) =
    FilePath -> Doc
text FilePath
"Failed to parse URI:" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
err

instance HFErrorProject URIParseError where
  eBase :: Proxy URIParseError -> Int
eBase Proxy URIParseError
_ = Int
800

  eNum :: URIParseError -> Int
eNum (MalformedScheme SchemaError
NonAlphaLeading) = Int
801
  eNum (MalformedScheme SchemaError
InvalidChars) = Int
802
  eNum (MalformedScheme SchemaError
MissingColon) = Int
803
  eNum URIParseError
MalformedUserInfo   = Int
804
  eNum URIParseError
MalformedQuery      = Int
805
  eNum URIParseError
MalformedFragment   = Int
806
  eNum URIParseError
MalformedHost       = Int
807
  eNum URIParseError
MalformedPort       = Int
808
  eNum URIParseError
MalformedPath       = Int
809
  eNum (OtherError FilePath
_)      = Int
810

  eDesc :: Proxy URIParseError -> FilePath
eDesc Proxy URIParseError
_ = FilePath
"Failed to parse URI."

instance Pretty ArchiveResult where
  pPrint :: ArchiveResult -> Doc
pPrint ArchiveResult
ArchiveFatal = FilePath -> Doc
text FilePath
"Archive result: fatal"
  pPrint ArchiveResult
ArchiveFailed = FilePath -> Doc
text FilePath
"Archive result: failed"
  pPrint ArchiveResult
ArchiveWarn = FilePath -> Doc
text FilePath
"Archive result: warning"
  pPrint ArchiveResult
ArchiveRetry = FilePath -> Doc
text FilePath
"Archive result: retry"
  pPrint ArchiveResult
ArchiveOk = FilePath -> Doc
text FilePath
"Archive result: Ok"
  pPrint ArchiveResult
ArchiveEOF = FilePath -> Doc
text FilePath
"Archive result: EOF"

instance HFErrorProject ArchiveResult where
  eBase :: Proxy ArchiveResult -> Int
eBase Proxy ArchiveResult
_ = Int
820

  eNum :: ArchiveResult -> Int
eNum ArchiveResult
ArchiveFatal  = Int
821
  eNum ArchiveResult
ArchiveFailed = Int
822
  eNum ArchiveResult
ArchiveWarn   = Int
823
  eNum ArchiveResult
ArchiveRetry  = Int
824
  eNum ArchiveResult
ArchiveOk     = Int
825
  eNum ArchiveResult
ArchiveEOF    = Int
826

  eDesc :: Proxy ArchiveResult -> FilePath
eDesc Proxy ArchiveResult
_ = FilePath
"Archive extraction result."

instance Pretty T.Text where
  pPrint :: Text -> Doc
pPrint = FilePath -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> FilePath
T.unpack

instance Pretty ProcessError where
  pPrint :: ProcessError -> Doc
pPrint (NonZeroExit Int
e FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Process" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"with arguments" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint [FilePath]
args Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"failed with exit code" Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show Int
e forall a. Semigroup a => a -> a -> a
<> FilePath
".")
  pPrint (PTerminated FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Process" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"with arguments" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint [FilePath]
args Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"terminated."
  pPrint (PStopped FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Process" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"with arguments" Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint [FilePath]
args Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"stopped."
  pPrint (NoSuchPid FilePath
exe [FilePath]
args) =
    FilePath -> Doc
text FilePath
"Could not find PID for process running " Doc -> Doc -> Doc
<+> forall a. Pretty a => a -> Doc
pPrint FilePath
exe Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
" with arguments " Doc -> Doc -> Doc
<+> FilePath -> Doc
text (forall a. Show a => a -> FilePath
show [FilePath]
args) Doc -> Doc -> Doc
<+> FilePath -> Doc
text FilePath
"."

instance HFErrorProject ProcessError where
  eBase :: Proxy ProcessError -> Int
eBase Proxy ProcessError
_ = Int
840

  eNum :: ProcessError -> Int
eNum NonZeroExit{}     = Int
841
  eNum (PTerminated FilePath
_ [FilePath]
_) = Int
842
  eNum (PStopped FilePath
_ [FilePath]
_)    = Int
843
  eNum (NoSuchPid FilePath
_ [FilePath]
_)   = Int
844

  eDesc :: Proxy ProcessError -> FilePath
eDesc Proxy ProcessError
_ = FilePath
"A process exited prematurely."