{-# LANGUAGE DeriveGeneric #-}
module Distribution.Client.BuildReports.Types (
ReportLevel(..),
BuildReport (..),
InstallOutcome(..),
Outcome(..),
) where
import Distribution.Client.Compat.Prelude
import Prelude ()
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
import Distribution.Compiler (CompilerId (..))
import Distribution.PackageDescription (FlagAssignment)
import Distribution.System (Arch, OS)
import Distribution.Types.PackageId (PackageIdentifier)
data ReportLevel = NoReports | AnonymousReports | DetailedReports
deriving (ReportLevel -> ReportLevel -> Bool
(ReportLevel -> ReportLevel -> Bool)
-> (ReportLevel -> ReportLevel -> Bool) -> Eq ReportLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReportLevel -> ReportLevel -> Bool
$c/= :: ReportLevel -> ReportLevel -> Bool
== :: ReportLevel -> ReportLevel -> Bool
$c== :: ReportLevel -> ReportLevel -> Bool
Eq, Eq ReportLevel
Eq ReportLevel
-> (ReportLevel -> ReportLevel -> Ordering)
-> (ReportLevel -> ReportLevel -> Bool)
-> (ReportLevel -> ReportLevel -> Bool)
-> (ReportLevel -> ReportLevel -> Bool)
-> (ReportLevel -> ReportLevel -> Bool)
-> (ReportLevel -> ReportLevel -> ReportLevel)
-> (ReportLevel -> ReportLevel -> ReportLevel)
-> Ord ReportLevel
ReportLevel -> ReportLevel -> Bool
ReportLevel -> ReportLevel -> Ordering
ReportLevel -> ReportLevel -> ReportLevel
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ReportLevel -> ReportLevel -> ReportLevel
$cmin :: ReportLevel -> ReportLevel -> ReportLevel
max :: ReportLevel -> ReportLevel -> ReportLevel
$cmax :: ReportLevel -> ReportLevel -> ReportLevel
>= :: ReportLevel -> ReportLevel -> Bool
$c>= :: ReportLevel -> ReportLevel -> Bool
> :: ReportLevel -> ReportLevel -> Bool
$c> :: ReportLevel -> ReportLevel -> Bool
<= :: ReportLevel -> ReportLevel -> Bool
$c<= :: ReportLevel -> ReportLevel -> Bool
< :: ReportLevel -> ReportLevel -> Bool
$c< :: ReportLevel -> ReportLevel -> Bool
compare :: ReportLevel -> ReportLevel -> Ordering
$ccompare :: ReportLevel -> ReportLevel -> Ordering
$cp1Ord :: Eq ReportLevel
Ord, Int -> ReportLevel
ReportLevel -> Int
ReportLevel -> [ReportLevel]
ReportLevel -> ReportLevel
ReportLevel -> ReportLevel -> [ReportLevel]
ReportLevel -> ReportLevel -> ReportLevel -> [ReportLevel]
(ReportLevel -> ReportLevel)
-> (ReportLevel -> ReportLevel)
-> (Int -> ReportLevel)
-> (ReportLevel -> Int)
-> (ReportLevel -> [ReportLevel])
-> (ReportLevel -> ReportLevel -> [ReportLevel])
-> (ReportLevel -> ReportLevel -> [ReportLevel])
-> (ReportLevel -> ReportLevel -> ReportLevel -> [ReportLevel])
-> Enum ReportLevel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: ReportLevel -> ReportLevel -> ReportLevel -> [ReportLevel]
$cenumFromThenTo :: ReportLevel -> ReportLevel -> ReportLevel -> [ReportLevel]
enumFromTo :: ReportLevel -> ReportLevel -> [ReportLevel]
$cenumFromTo :: ReportLevel -> ReportLevel -> [ReportLevel]
enumFromThen :: ReportLevel -> ReportLevel -> [ReportLevel]
$cenumFromThen :: ReportLevel -> ReportLevel -> [ReportLevel]
enumFrom :: ReportLevel -> [ReportLevel]
$cenumFrom :: ReportLevel -> [ReportLevel]
fromEnum :: ReportLevel -> Int
$cfromEnum :: ReportLevel -> Int
toEnum :: Int -> ReportLevel
$ctoEnum :: Int -> ReportLevel
pred :: ReportLevel -> ReportLevel
$cpred :: ReportLevel -> ReportLevel
succ :: ReportLevel -> ReportLevel
$csucc :: ReportLevel -> ReportLevel
Enum, ReportLevel
ReportLevel -> ReportLevel -> Bounded ReportLevel
forall a. a -> a -> Bounded a
maxBound :: ReportLevel
$cmaxBound :: ReportLevel
minBound :: ReportLevel
$cminBound :: ReportLevel
Bounded, Int -> ReportLevel -> ShowS
[ReportLevel] -> ShowS
ReportLevel -> String
(Int -> ReportLevel -> ShowS)
-> (ReportLevel -> String)
-> ([ReportLevel] -> ShowS)
-> Show ReportLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReportLevel] -> ShowS
$cshowList :: [ReportLevel] -> ShowS
show :: ReportLevel -> String
$cshow :: ReportLevel -> String
showsPrec :: Int -> ReportLevel -> ShowS
$cshowsPrec :: Int -> ReportLevel -> ShowS
Show, (forall x. ReportLevel -> Rep ReportLevel x)
-> (forall x. Rep ReportLevel x -> ReportLevel)
-> Generic ReportLevel
forall x. Rep ReportLevel x -> ReportLevel
forall x. ReportLevel -> Rep ReportLevel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReportLevel x -> ReportLevel
$cfrom :: forall x. ReportLevel -> Rep ReportLevel x
Generic)
instance Binary ReportLevel
instance Structured ReportLevel
instance Pretty ReportLevel where
pretty :: ReportLevel -> Doc
pretty ReportLevel
NoReports = String -> Doc
Disp.text String
"none"
pretty ReportLevel
AnonymousReports = String -> Doc
Disp.text String
"anonymous"
pretty ReportLevel
DetailedReports = String -> Doc
Disp.text String
"detailed"
instance Parsec ReportLevel where
parsec :: m ReportLevel
parsec = do
String
name <- (Char -> Bool) -> m String
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m String
P.munch1 Char -> Bool
isAlpha
case ShowS
lowercase String
name of
String
"none" -> ReportLevel -> m ReportLevel
forall (m :: * -> *) a. Monad m => a -> m a
return ReportLevel
NoReports
String
"anonymous" -> ReportLevel -> m ReportLevel
forall (m :: * -> *) a. Monad m => a -> m a
return ReportLevel
AnonymousReports
String
"detailed" -> ReportLevel -> m ReportLevel
forall (m :: * -> *) a. Monad m => a -> m a
return ReportLevel
DetailedReports
String
_ -> String -> m ReportLevel
forall (m :: * -> *) a. Parsing m => String -> m a
P.unexpected (String -> m ReportLevel) -> String -> m ReportLevel
forall a b. (a -> b) -> a -> b
$ String
"ReportLevel: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
name
lowercase :: String -> String
lowercase :: ShowS
lowercase = (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower
data BuildReport = BuildReport {
BuildReport -> PackageIdentifier
package :: PackageIdentifier,
BuildReport -> OS
os :: OS,
BuildReport -> Arch
arch :: Arch,
BuildReport -> CompilerId
compiler :: CompilerId,
BuildReport -> PackageIdentifier
client :: PackageIdentifier,
BuildReport -> FlagAssignment
flagAssignment :: FlagAssignment,
BuildReport -> [PackageIdentifier]
dependencies :: [PackageIdentifier],
BuildReport -> InstallOutcome
installOutcome :: InstallOutcome,
BuildReport -> Outcome
docsOutcome :: Outcome,
BuildReport -> Outcome
testsOutcome :: Outcome
}
deriving (BuildReport -> BuildReport -> Bool
(BuildReport -> BuildReport -> Bool)
-> (BuildReport -> BuildReport -> Bool) -> Eq BuildReport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuildReport -> BuildReport -> Bool
$c/= :: BuildReport -> BuildReport -> Bool
== :: BuildReport -> BuildReport -> Bool
$c== :: BuildReport -> BuildReport -> Bool
Eq, Int -> BuildReport -> ShowS
[BuildReport] -> ShowS
BuildReport -> String
(Int -> BuildReport -> ShowS)
-> (BuildReport -> String)
-> ([BuildReport] -> ShowS)
-> Show BuildReport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuildReport] -> ShowS
$cshowList :: [BuildReport] -> ShowS
show :: BuildReport -> String
$cshow :: BuildReport -> String
showsPrec :: Int -> BuildReport -> ShowS
$cshowsPrec :: Int -> BuildReport -> ShowS
Show, (forall x. BuildReport -> Rep BuildReport x)
-> (forall x. Rep BuildReport x -> BuildReport)
-> Generic BuildReport
forall x. Rep BuildReport x -> BuildReport
forall x. BuildReport -> Rep BuildReport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuildReport x -> BuildReport
$cfrom :: forall x. BuildReport -> Rep BuildReport x
Generic)
data InstallOutcome
= PlanningFailed
| DependencyFailed PackageIdentifier
| DownloadFailed
| UnpackFailed
| SetupFailed
| ConfigureFailed
| BuildFailed
| TestsFailed
| InstallFailed
| InstallOk
deriving (InstallOutcome -> InstallOutcome -> Bool
(InstallOutcome -> InstallOutcome -> Bool)
-> (InstallOutcome -> InstallOutcome -> Bool) -> Eq InstallOutcome
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstallOutcome -> InstallOutcome -> Bool
$c/= :: InstallOutcome -> InstallOutcome -> Bool
== :: InstallOutcome -> InstallOutcome -> Bool
$c== :: InstallOutcome -> InstallOutcome -> Bool
Eq, Int -> InstallOutcome -> ShowS
[InstallOutcome] -> ShowS
InstallOutcome -> String
(Int -> InstallOutcome -> ShowS)
-> (InstallOutcome -> String)
-> ([InstallOutcome] -> ShowS)
-> Show InstallOutcome
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstallOutcome] -> ShowS
$cshowList :: [InstallOutcome] -> ShowS
show :: InstallOutcome -> String
$cshow :: InstallOutcome -> String
showsPrec :: Int -> InstallOutcome -> ShowS
$cshowsPrec :: Int -> InstallOutcome -> ShowS
Show, (forall x. InstallOutcome -> Rep InstallOutcome x)
-> (forall x. Rep InstallOutcome x -> InstallOutcome)
-> Generic InstallOutcome
forall x. Rep InstallOutcome x -> InstallOutcome
forall x. InstallOutcome -> Rep InstallOutcome x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstallOutcome x -> InstallOutcome
$cfrom :: forall x. InstallOutcome -> Rep InstallOutcome x
Generic)
instance Pretty InstallOutcome where
pretty :: InstallOutcome -> Doc
pretty InstallOutcome
PlanningFailed = String -> Doc
Disp.text String
"PlanningFailed"
pretty (DependencyFailed PackageIdentifier
pkgid) = String -> Doc
Disp.text String
"DependencyFailed" Doc -> Doc -> Doc
<+> PackageIdentifier -> Doc
forall a. Pretty a => a -> Doc
pretty PackageIdentifier
pkgid
pretty InstallOutcome
DownloadFailed = String -> Doc
Disp.text String
"DownloadFailed"
pretty InstallOutcome
UnpackFailed = String -> Doc
Disp.text String
"UnpackFailed"
pretty InstallOutcome
SetupFailed = String -> Doc
Disp.text String
"SetupFailed"
pretty InstallOutcome
ConfigureFailed = String -> Doc
Disp.text String
"ConfigureFailed"
pretty InstallOutcome
BuildFailed = String -> Doc
Disp.text String
"BuildFailed"
pretty InstallOutcome
TestsFailed = String -> Doc
Disp.text String
"TestsFailed"
pretty InstallOutcome
InstallFailed = String -> Doc
Disp.text String
"InstallFailed"
pretty InstallOutcome
InstallOk = String -> Doc
Disp.text String
"InstallOk"
instance Parsec InstallOutcome where
parsec :: m InstallOutcome
parsec = do
String
name <- (Char -> Bool) -> m String
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m String
P.munch1 Char -> Bool
isAlpha
case String
name of
String
"PlanningFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
PlanningFailed
String
"DependencyFailed" -> PackageIdentifier -> InstallOutcome
DependencyFailed (PackageIdentifier -> InstallOutcome)
-> m () -> m (PackageIdentifier -> InstallOutcome)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ m ()
forall (m :: * -> *). CharParsing m => m ()
P.spaces m (PackageIdentifier -> InstallOutcome)
-> m PackageIdentifier -> m InstallOutcome
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m PackageIdentifier
forall a (m :: * -> *). (Parsec a, CabalParsing m) => m a
parsec
String
"DownloadFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
DownloadFailed
String
"UnpackFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
UnpackFailed
String
"SetupFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
SetupFailed
String
"ConfigureFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
ConfigureFailed
String
"BuildFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
BuildFailed
String
"TestsFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
TestsFailed
String
"InstallFailed" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
InstallFailed
String
"InstallOk" -> InstallOutcome -> m InstallOutcome
forall (m :: * -> *) a. Monad m => a -> m a
return InstallOutcome
InstallOk
String
_ -> String -> m InstallOutcome
forall (m :: * -> *) a. Parsing m => String -> m a
P.unexpected (String -> m InstallOutcome) -> String -> m InstallOutcome
forall a b. (a -> b) -> a -> b
$ String
"InstallOutcome: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
name
data Outcome = NotTried | Failed | Ok
deriving (Outcome -> Outcome -> Bool
(Outcome -> Outcome -> Bool)
-> (Outcome -> Outcome -> Bool) -> Eq Outcome
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Outcome -> Outcome -> Bool
$c/= :: Outcome -> Outcome -> Bool
== :: Outcome -> Outcome -> Bool
$c== :: Outcome -> Outcome -> Bool
Eq, Int -> Outcome -> ShowS
[Outcome] -> ShowS
Outcome -> String
(Int -> Outcome -> ShowS)
-> (Outcome -> String) -> ([Outcome] -> ShowS) -> Show Outcome
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Outcome] -> ShowS
$cshowList :: [Outcome] -> ShowS
show :: Outcome -> String
$cshow :: Outcome -> String
showsPrec :: Int -> Outcome -> ShowS
$cshowsPrec :: Int -> Outcome -> ShowS
Show, Int -> Outcome
Outcome -> Int
Outcome -> [Outcome]
Outcome -> Outcome
Outcome -> Outcome -> [Outcome]
Outcome -> Outcome -> Outcome -> [Outcome]
(Outcome -> Outcome)
-> (Outcome -> Outcome)
-> (Int -> Outcome)
-> (Outcome -> Int)
-> (Outcome -> [Outcome])
-> (Outcome -> Outcome -> [Outcome])
-> (Outcome -> Outcome -> [Outcome])
-> (Outcome -> Outcome -> Outcome -> [Outcome])
-> Enum Outcome
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Outcome -> Outcome -> Outcome -> [Outcome]
$cenumFromThenTo :: Outcome -> Outcome -> Outcome -> [Outcome]
enumFromTo :: Outcome -> Outcome -> [Outcome]
$cenumFromTo :: Outcome -> Outcome -> [Outcome]
enumFromThen :: Outcome -> Outcome -> [Outcome]
$cenumFromThen :: Outcome -> Outcome -> [Outcome]
enumFrom :: Outcome -> [Outcome]
$cenumFrom :: Outcome -> [Outcome]
fromEnum :: Outcome -> Int
$cfromEnum :: Outcome -> Int
toEnum :: Int -> Outcome
$ctoEnum :: Int -> Outcome
pred :: Outcome -> Outcome
$cpred :: Outcome -> Outcome
succ :: Outcome -> Outcome
$csucc :: Outcome -> Outcome
Enum, Outcome
Outcome -> Outcome -> Bounded Outcome
forall a. a -> a -> Bounded a
maxBound :: Outcome
$cmaxBound :: Outcome
minBound :: Outcome
$cminBound :: Outcome
Bounded, (forall x. Outcome -> Rep Outcome x)
-> (forall x. Rep Outcome x -> Outcome) -> Generic Outcome
forall x. Rep Outcome x -> Outcome
forall x. Outcome -> Rep Outcome x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Outcome x -> Outcome
$cfrom :: forall x. Outcome -> Rep Outcome x
Generic)
instance Pretty Outcome where
pretty :: Outcome -> Doc
pretty Outcome
NotTried = String -> Doc
Disp.text String
"NotTried"
pretty Outcome
Failed = String -> Doc
Disp.text String
"Failed"
pretty Outcome
Ok = String -> Doc
Disp.text String
"Ok"
instance Parsec Outcome where
parsec :: m Outcome
parsec = do
String
name <- (Char -> Bool) -> m String
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m String
P.munch1 Char -> Bool
isAlpha
case String
name of
String
"NotTried" -> Outcome -> m Outcome
forall (m :: * -> *) a. Monad m => a -> m a
return Outcome
NotTried
String
"Failed" -> Outcome -> m Outcome
forall (m :: * -> *) a. Monad m => a -> m a
return Outcome
Failed
String
"Ok" -> Outcome -> m Outcome
forall (m :: * -> *) a. Monad m => a -> m a
return Outcome
Ok
String
_ -> String -> m Outcome
forall (m :: * -> *) a. Parsing m => String -> m a
P.unexpected (String -> m Outcome) -> String -> m Outcome
forall a b. (a -> b) -> a -> b
$ String
"Outcome: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
name