1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Distribution
.Types
.BenchmarkType
11 import Distribution
.Compat
.Prelude
14 import Distribution
.Parsec
15 import Distribution
.Pretty
16 import Distribution
.Version
17 import Text
.PrettyPrint
(char
, text
)
19 -- | The \"benchmark-type\" field in the benchmark stanza.
21 = -- | \"type: exitcode-stdio-x.y\"
22 BenchmarkTypeExe Version
23 |
-- | Some unknown benchmark type e.g. \"type: foo\"
24 BenchmarkTypeUnknown
String Version
25 deriving (Generic
, Show, Read, Eq
, Ord
, Typeable
, Data
)
27 instance Binary BenchmarkType
28 instance Structured BenchmarkType
29 instance NFData BenchmarkType
where rnf
= genericRnf
31 knownBenchmarkTypes
:: [BenchmarkType
]
32 knownBenchmarkTypes
= [benchmarkTypeExe
]
34 benchmarkTypeExe
:: BenchmarkType
35 benchmarkTypeExe
= BenchmarkTypeExe
(mkVersion
[1, 0])
37 instance Pretty BenchmarkType
where
38 pretty
(BenchmarkTypeExe ver
) = text
"exitcode-stdio-" <<>> pretty ver
39 pretty
(BenchmarkTypeUnknown name ver
) = text name
<<>> char
'-' <<>> pretty ver
41 instance Parsec BenchmarkType
where
42 parsec
= parsecStandard
$ \ver name
-> case name
of
43 "exitcode-stdio" -> BenchmarkTypeExe ver
44 _
-> BenchmarkTypeUnknown name ver