{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Test.Hspec.BenchGolden.Types
(
BenchGolden(..)
, BenchConfig(..)
, defaultBenchConfig
, BenchAction(..)
, GoldenStats(..)
, ArchConfig(..)
, BenchResult(..)
, Warning(..)
) where
import Data.Aeson
import Data.Text (Text)
import Data.Time (UTCTime)
import Data.Word (Word64)
import GHC.Generics (Generic)
newtype BenchAction = BenchAction { BenchAction -> Word64 -> IO ()
runBenchAction :: Word64 -> IO () }
data BenchGolden = BenchGolden
{ BenchGolden -> String
benchName :: !String
, BenchGolden -> BenchAction
benchAction :: !BenchAction
, BenchGolden -> BenchConfig
benchConfig :: !BenchConfig
}
data BenchConfig = BenchConfig
{ BenchConfig -> Int
iterations :: !Int
, BenchConfig -> Int
warmupIterations :: !Int
, BenchConfig -> Double
tolerancePercent :: !Double
, BenchConfig -> Maybe Double
absoluteToleranceMs :: !(Maybe Double)
, BenchConfig -> Bool
warnOnVarianceChange :: !Bool
, BenchConfig -> Double
varianceTolerancePercent :: !Double
, BenchConfig -> String
outputDir :: !FilePath
, BenchConfig -> Bool
failOnFirstRun :: !Bool
, BenchConfig -> Bool
useRobustStatistics :: !Bool
, BenchConfig -> Double
trimPercent :: !Double
, BenchConfig -> Double
outlierThreshold :: !Double
} deriving (Int -> BenchConfig -> ShowS
[BenchConfig] -> ShowS
BenchConfig -> String
(Int -> BenchConfig -> ShowS)
-> (BenchConfig -> String)
-> ([BenchConfig] -> ShowS)
-> Show BenchConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BenchConfig -> ShowS
showsPrec :: Int -> BenchConfig -> ShowS
$cshow :: BenchConfig -> String
show :: BenchConfig -> String
$cshowList :: [BenchConfig] -> ShowS
showList :: [BenchConfig] -> ShowS
Show, BenchConfig -> BenchConfig -> Bool
(BenchConfig -> BenchConfig -> Bool)
-> (BenchConfig -> BenchConfig -> Bool) -> Eq BenchConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BenchConfig -> BenchConfig -> Bool
== :: BenchConfig -> BenchConfig -> Bool
$c/= :: BenchConfig -> BenchConfig -> Bool
/= :: BenchConfig -> BenchConfig -> Bool
Eq, (forall x. BenchConfig -> Rep BenchConfig x)
-> (forall x. Rep BenchConfig x -> BenchConfig)
-> Generic BenchConfig
forall x. Rep BenchConfig x -> BenchConfig
forall x. BenchConfig -> Rep BenchConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BenchConfig -> Rep BenchConfig x
from :: forall x. BenchConfig -> Rep BenchConfig x
$cto :: forall x. Rep BenchConfig x -> BenchConfig
to :: forall x. Rep BenchConfig x -> BenchConfig
Generic)
defaultBenchConfig :: BenchConfig
defaultBenchConfig :: BenchConfig
defaultBenchConfig = BenchConfig
{ iterations :: Int
iterations = Int
100
, warmupIterations :: Int
warmupIterations = Int
5
, tolerancePercent :: Double
tolerancePercent = Double
15.0
, absoluteToleranceMs :: Maybe Double
absoluteToleranceMs = Double -> Maybe Double
forall a. a -> Maybe a
Just Double
0.01
, warnOnVarianceChange :: Bool
warnOnVarianceChange = Bool
True
, varianceTolerancePercent :: Double
varianceTolerancePercent = Double
50.0
, outputDir :: String
outputDir = String
".golden"
, failOnFirstRun :: Bool
failOnFirstRun = Bool
False
, useRobustStatistics :: Bool
useRobustStatistics = Bool
False
, trimPercent :: Double
trimPercent = Double
10.0
, outlierThreshold :: Double
outlierThreshold = Double
3.0
}
data GoldenStats = GoldenStats
{ GoldenStats -> Double
statsMean :: !Double
, GoldenStats -> Double
statsStddev :: !Double
, GoldenStats -> Double
statsMedian :: !Double
, GoldenStats -> Double
statsMin :: !Double
, GoldenStats -> Double
statsMax :: !Double
, GoldenStats -> [(Int, Double)]
statsPercentiles :: ![(Int, Double)]
, GoldenStats -> Text
statsArch :: !Text
, GoldenStats -> UTCTime
statsTimestamp :: !UTCTime
, GoldenStats -> Double
statsTrimmedMean :: !Double
, GoldenStats -> Double
statsMAD :: !Double
, GoldenStats -> Double
statsIQR :: !Double
, GoldenStats -> [Double]
statsOutliers :: ![Double]
} deriving (Int -> GoldenStats -> ShowS
[GoldenStats] -> ShowS
GoldenStats -> String
(Int -> GoldenStats -> ShowS)
-> (GoldenStats -> String)
-> ([GoldenStats] -> ShowS)
-> Show GoldenStats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GoldenStats -> ShowS
showsPrec :: Int -> GoldenStats -> ShowS
$cshow :: GoldenStats -> String
show :: GoldenStats -> String
$cshowList :: [GoldenStats] -> ShowS
showList :: [GoldenStats] -> ShowS
Show, GoldenStats -> GoldenStats -> Bool
(GoldenStats -> GoldenStats -> Bool)
-> (GoldenStats -> GoldenStats -> Bool) -> Eq GoldenStats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GoldenStats -> GoldenStats -> Bool
== :: GoldenStats -> GoldenStats -> Bool
$c/= :: GoldenStats -> GoldenStats -> Bool
/= :: GoldenStats -> GoldenStats -> Bool
Eq, (forall x. GoldenStats -> Rep GoldenStats x)
-> (forall x. Rep GoldenStats x -> GoldenStats)
-> Generic GoldenStats
forall x. Rep GoldenStats x -> GoldenStats
forall x. GoldenStats -> Rep GoldenStats x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GoldenStats -> Rep GoldenStats x
from :: forall x. GoldenStats -> Rep GoldenStats x
$cto :: forall x. Rep GoldenStats x -> GoldenStats
to :: forall x. Rep GoldenStats x -> GoldenStats
Generic)
data ArchConfig = ArchConfig
{ ArchConfig -> Text
archId :: !Text
, ArchConfig -> Text
archOS :: !Text
, ArchConfig -> Text
archCPU :: !Text
, ArchConfig -> Maybe Text
archModel :: !(Maybe Text)
} deriving (Int -> ArchConfig -> ShowS
[ArchConfig] -> ShowS
ArchConfig -> String
(Int -> ArchConfig -> ShowS)
-> (ArchConfig -> String)
-> ([ArchConfig] -> ShowS)
-> Show ArchConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArchConfig -> ShowS
showsPrec :: Int -> ArchConfig -> ShowS
$cshow :: ArchConfig -> String
show :: ArchConfig -> String
$cshowList :: [ArchConfig] -> ShowS
showList :: [ArchConfig] -> ShowS
Show, ArchConfig -> ArchConfig -> Bool
(ArchConfig -> ArchConfig -> Bool)
-> (ArchConfig -> ArchConfig -> Bool) -> Eq ArchConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArchConfig -> ArchConfig -> Bool
== :: ArchConfig -> ArchConfig -> Bool
$c/= :: ArchConfig -> ArchConfig -> Bool
/= :: ArchConfig -> ArchConfig -> Bool
Eq, (forall x. ArchConfig -> Rep ArchConfig x)
-> (forall x. Rep ArchConfig x -> ArchConfig) -> Generic ArchConfig
forall x. Rep ArchConfig x -> ArchConfig
forall x. ArchConfig -> Rep ArchConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ArchConfig -> Rep ArchConfig x
from :: forall x. ArchConfig -> Rep ArchConfig x
$cto :: forall x. Rep ArchConfig x -> ArchConfig
to :: forall x. Rep ArchConfig x -> ArchConfig
Generic)
data BenchResult
= FirstRun !GoldenStats
| Pass !GoldenStats !GoldenStats ![Warning]
| Regression !GoldenStats !GoldenStats !Double !Double !(Maybe Double)
| Improvement !GoldenStats !GoldenStats !Double !Double !(Maybe Double)
deriving (Int -> BenchResult -> ShowS
[BenchResult] -> ShowS
BenchResult -> String
(Int -> BenchResult -> ShowS)
-> (BenchResult -> String)
-> ([BenchResult] -> ShowS)
-> Show BenchResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BenchResult -> ShowS
showsPrec :: Int -> BenchResult -> ShowS
$cshow :: BenchResult -> String
show :: BenchResult -> String
$cshowList :: [BenchResult] -> ShowS
showList :: [BenchResult] -> ShowS
Show, BenchResult -> BenchResult -> Bool
(BenchResult -> BenchResult -> Bool)
-> (BenchResult -> BenchResult -> Bool) -> Eq BenchResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BenchResult -> BenchResult -> Bool
== :: BenchResult -> BenchResult -> Bool
$c/= :: BenchResult -> BenchResult -> Bool
/= :: BenchResult -> BenchResult -> Bool
Eq)
data Warning
= VarianceIncreased !Double !Double !Double !Double
| VarianceDecreased !Double !Double !Double !Double
| HighVariance !Double
| OutliersDetected !Int ![Double]
deriving (Int -> Warning -> ShowS
[Warning] -> ShowS
Warning -> String
(Int -> Warning -> ShowS)
-> (Warning -> String) -> ([Warning] -> ShowS) -> Show Warning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Warning -> ShowS
showsPrec :: Int -> Warning -> ShowS
$cshow :: Warning -> String
show :: Warning -> String
$cshowList :: [Warning] -> ShowS
showList :: [Warning] -> ShowS
Show, Warning -> Warning -> Bool
(Warning -> Warning -> Bool)
-> (Warning -> Warning -> Bool) -> Eq Warning
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Warning -> Warning -> Bool
== :: Warning -> Warning -> Bool
$c/= :: Warning -> Warning -> Bool
/= :: Warning -> Warning -> Bool
Eq)
instance ToJSON GoldenStats where
toJSON :: GoldenStats -> Value
toJSON GoldenStats{Double
[Double]
[(Int, Double)]
Text
UTCTime
statsMean :: GoldenStats -> Double
statsStddev :: GoldenStats -> Double
statsMedian :: GoldenStats -> Double
statsMin :: GoldenStats -> Double
statsMax :: GoldenStats -> Double
statsPercentiles :: GoldenStats -> [(Int, Double)]
statsArch :: GoldenStats -> Text
statsTimestamp :: GoldenStats -> UTCTime
statsTrimmedMean :: GoldenStats -> Double
statsMAD :: GoldenStats -> Double
statsIQR :: GoldenStats -> Double
statsOutliers :: GoldenStats -> [Double]
statsMean :: Double
statsStddev :: Double
statsMedian :: Double
statsMin :: Double
statsMax :: Double
statsPercentiles :: [(Int, Double)]
statsArch :: Text
statsTimestamp :: UTCTime
statsTrimmedMean :: Double
statsMAD :: Double
statsIQR :: Double
statsOutliers :: [Double]
..} = [Pair] -> Value
object
[ Key
"mean" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsMean
, Key
"stddev" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsStddev
, Key
"median" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsMedian
, Key
"min" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsMin
, Key
"max" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsMax
, Key
"percentiles" Key -> [(Int, Double)] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [(Int, Double)]
statsPercentiles
, Key
"architecture" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
statsArch
, Key
"timestamp" Key -> UTCTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= UTCTime
statsTimestamp
, Key
"trimmedMean" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsTrimmedMean
, Key
"mad" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsMAD
, Key
"iqr" Key -> Double -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Double
statsIQR
, Key
"outliers" Key -> [Double] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Double]
statsOutliers
]
instance FromJSON GoldenStats where
parseJSON :: Value -> Parser GoldenStats
parseJSON = String
-> (Object -> Parser GoldenStats) -> Value -> Parser GoldenStats
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"GoldenStats" ((Object -> Parser GoldenStats) -> Value -> Parser GoldenStats)
-> (Object -> Parser GoldenStats) -> Value -> Parser GoldenStats
forall a b. (a -> b) -> a -> b
$ \Object
v -> Double
-> Double
-> Double
-> Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats
GoldenStats
(Double
-> Double
-> Double
-> Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
-> Parser Double
-> Parser
(Double
-> Double
-> Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"mean"
Parser
(Double
-> Double
-> Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
-> Parser Double
-> Parser
(Double
-> Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"stddev"
Parser
(Double
-> Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
-> Parser Double
-> Parser
(Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"median"
Parser
(Double
-> Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
-> Parser Double
-> Parser
(Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"min"
Parser
(Double
-> [(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
-> Parser Double
-> Parser
([(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"max"
Parser
([(Int, Double)]
-> Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
-> Parser [(Int, Double)]
-> Parser
(Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser [(Int, Double)]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"percentiles"
Parser
(Text
-> UTCTime
-> Double
-> Double
-> Double
-> [Double]
-> GoldenStats)
-> Parser Text
-> Parser
(UTCTime -> Double -> Double -> Double -> [Double] -> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"architecture"
Parser
(UTCTime -> Double -> Double -> Double -> [Double] -> GoldenStats)
-> Parser UTCTime
-> Parser (Double -> Double -> Double -> [Double] -> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser UTCTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"timestamp"
Parser (Double -> Double -> Double -> [Double] -> GoldenStats)
-> Parser Double
-> Parser (Double -> Double -> [Double] -> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"trimmedMean"
Parser (Double -> Double -> [Double] -> GoldenStats)
-> Parser Double -> Parser (Double -> [Double] -> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"mad"
Parser (Double -> [Double] -> GoldenStats)
-> Parser Double -> Parser ([Double] -> GoldenStats)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Double
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"iqr"
Parser ([Double] -> GoldenStats)
-> Parser [Double] -> Parser GoldenStats
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser [Double]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"outliers"
instance ToJSON ArchConfig where
toJSON :: ArchConfig -> Value
toJSON ArchConfig{Maybe Text
Text
archId :: ArchConfig -> Text
archOS :: ArchConfig -> Text
archCPU :: ArchConfig -> Text
archModel :: ArchConfig -> Maybe Text
archId :: Text
archOS :: Text
archCPU :: Text
archModel :: Maybe Text
..} = [Pair] -> Value
object
[ Key
"id" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
archId
, Key
"os" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
archOS
, Key
"cpu" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
archCPU
, Key
"model" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
archModel
]
instance FromJSON ArchConfig where
parseJSON :: Value -> Parser ArchConfig
parseJSON = String
-> (Object -> Parser ArchConfig) -> Value -> Parser ArchConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ArchConfig" ((Object -> Parser ArchConfig) -> Value -> Parser ArchConfig)
-> (Object -> Parser ArchConfig) -> Value -> Parser ArchConfig
forall a b. (a -> b) -> a -> b
$ \Object
v -> Text -> Text -> Text -> Maybe Text -> ArchConfig
ArchConfig
(Text -> Text -> Text -> Maybe Text -> ArchConfig)
-> Parser Text -> Parser (Text -> Text -> Maybe Text -> ArchConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
Parser (Text -> Text -> Maybe Text -> ArchConfig)
-> Parser Text -> Parser (Text -> Maybe Text -> ArchConfig)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"os"
Parser (Text -> Maybe Text -> ArchConfig)
-> Parser Text -> Parser (Maybe Text -> ArchConfig)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"cpu"
Parser (Maybe Text -> ArchConfig)
-> Parser (Maybe Text) -> Parser ArchConfig
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"model"