{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Distribution.Types.BenchmarkType (
BenchmarkType(..),
knownBenchmarkTypes,
benchmarkTypeExe,
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Parsec
import Distribution.Pretty
import Distribution.Version
import Text.PrettyPrint (char, text)
data BenchmarkType = BenchmarkTypeExe Version
| BenchmarkTypeUnknown String Version
deriving (forall x. Rep BenchmarkType x -> BenchmarkType
forall x. BenchmarkType -> Rep BenchmarkType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BenchmarkType x -> BenchmarkType
$cfrom :: forall x. BenchmarkType -> Rep BenchmarkType x
Generic, Int -> BenchmarkType -> ShowS
[BenchmarkType] -> ShowS
BenchmarkType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BenchmarkType] -> ShowS
$cshowList :: [BenchmarkType] -> ShowS
show :: BenchmarkType -> String
$cshow :: BenchmarkType -> String
showsPrec :: Int -> BenchmarkType -> ShowS
$cshowsPrec :: Int -> BenchmarkType -> ShowS
Show, ReadPrec [BenchmarkType]
ReadPrec BenchmarkType
Int -> ReadS BenchmarkType
ReadS [BenchmarkType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BenchmarkType]
$creadListPrec :: ReadPrec [BenchmarkType]
readPrec :: ReadPrec BenchmarkType
$creadPrec :: ReadPrec BenchmarkType
readList :: ReadS [BenchmarkType]
$creadList :: ReadS [BenchmarkType]
readsPrec :: Int -> ReadS BenchmarkType
$creadsPrec :: Int -> ReadS BenchmarkType
Read, BenchmarkType -> BenchmarkType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BenchmarkType -> BenchmarkType -> Bool
$c/= :: BenchmarkType -> BenchmarkType -> Bool
== :: BenchmarkType -> BenchmarkType -> Bool
$c== :: BenchmarkType -> BenchmarkType -> Bool
Eq, Eq BenchmarkType
BenchmarkType -> BenchmarkType -> Bool
BenchmarkType -> BenchmarkType -> Ordering
BenchmarkType -> BenchmarkType -> BenchmarkType
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 :: BenchmarkType -> BenchmarkType -> BenchmarkType
$cmin :: BenchmarkType -> BenchmarkType -> BenchmarkType
max :: BenchmarkType -> BenchmarkType -> BenchmarkType
$cmax :: BenchmarkType -> BenchmarkType -> BenchmarkType
>= :: BenchmarkType -> BenchmarkType -> Bool
$c>= :: BenchmarkType -> BenchmarkType -> Bool
> :: BenchmarkType -> BenchmarkType -> Bool
$c> :: BenchmarkType -> BenchmarkType -> Bool
<= :: BenchmarkType -> BenchmarkType -> Bool
$c<= :: BenchmarkType -> BenchmarkType -> Bool
< :: BenchmarkType -> BenchmarkType -> Bool
$c< :: BenchmarkType -> BenchmarkType -> Bool
compare :: BenchmarkType -> BenchmarkType -> Ordering
$ccompare :: BenchmarkType -> BenchmarkType -> Ordering
Ord, Typeable, Typeable BenchmarkType
BenchmarkType -> DataType
BenchmarkType -> Constr
(forall b. Data b => b -> b) -> BenchmarkType -> BenchmarkType
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BenchmarkType -> u
forall u. (forall d. Data d => d -> u) -> BenchmarkType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BenchmarkType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BenchmarkType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BenchmarkType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BenchmarkType -> c BenchmarkType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BenchmarkType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BenchmarkType)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BenchmarkType -> m BenchmarkType
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BenchmarkType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BenchmarkType -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> BenchmarkType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BenchmarkType -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BenchmarkType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BenchmarkType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BenchmarkType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BenchmarkType -> r
gmapT :: (forall b. Data b => b -> b) -> BenchmarkType -> BenchmarkType
$cgmapT :: (forall b. Data b => b -> b) -> BenchmarkType -> BenchmarkType
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BenchmarkType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BenchmarkType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BenchmarkType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BenchmarkType)
dataTypeOf :: BenchmarkType -> DataType
$cdataTypeOf :: BenchmarkType -> DataType
toConstr :: BenchmarkType -> Constr
$ctoConstr :: BenchmarkType -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BenchmarkType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BenchmarkType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BenchmarkType -> c BenchmarkType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BenchmarkType -> c BenchmarkType
Data)
instance Binary BenchmarkType
instance Structured BenchmarkType
instance NFData BenchmarkType where rnf :: BenchmarkType -> ()
rnf = forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
knownBenchmarkTypes :: [BenchmarkType]
knownBenchmarkTypes :: [BenchmarkType]
knownBenchmarkTypes = [ BenchmarkType
benchmarkTypeExe ]
benchmarkTypeExe :: BenchmarkType
benchmarkTypeExe :: BenchmarkType
benchmarkTypeExe = Version -> BenchmarkType
BenchmarkTypeExe ([Int] -> Version
mkVersion [Int
1,Int
0])
instance Pretty BenchmarkType where
pretty :: BenchmarkType -> Doc
pretty (BenchmarkTypeExe Version
ver) = String -> Doc
text String
"exitcode-stdio-" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
ver
pretty (BenchmarkTypeUnknown String
name Version
ver) = String -> Doc
text String
name Doc -> Doc -> Doc
<<>> Char -> Doc
char Char
'-' Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
ver
instance Parsec BenchmarkType where
parsec :: forall (m :: * -> *). CabalParsing m => m BenchmarkType
parsec = forall (m :: * -> *) ver a.
(CabalParsing m, Parsec ver) =>
(ver -> String -> a) -> m a
parsecStandard forall a b. (a -> b) -> a -> b
$ \Version
ver String
name -> case String
name of
String
"exitcode-stdio" -> Version -> BenchmarkType
BenchmarkTypeExe Version
ver
String
_ -> String -> Version -> BenchmarkType
BenchmarkTypeUnknown String
name Version
ver