{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
module Navi.Services.Battery.Status.Toml
( BatteryStatusToml (..),
)
where
import Navi.Data.NaviNote (Timeout, timeoutOptDecoder)
import Navi.Data.PollInterval (PollInterval (..), pollIntervalOptDecoder)
import Navi.Event.Toml
( ErrorNoteToml,
RepeatEventToml,
errorNoteOptDecoder,
repeatEventOptDecoder,
)
import Navi.Prelude
import Navi.Services.Battery.Common (batteryAppDecoder)
import Pythia.Services.Battery (BatteryApp (..))
data BatteryStatusToml = MkBatteryStatusToml
{
BatteryStatusToml -> BatteryApp
app :: BatteryApp,
BatteryStatusToml -> Maybe PollInterval
pollInterval :: Maybe PollInterval,
BatteryStatusToml -> Maybe RepeatEventToml
repeatEvent :: Maybe RepeatEventToml,
BatteryStatusToml -> Maybe ErrorNoteToml
errorNote :: Maybe ErrorNoteToml,
BatteryStatusToml -> Maybe Timeout
mTimeout :: Maybe Timeout
}
deriving stock (BatteryStatusToml -> BatteryStatusToml -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatteryStatusToml -> BatteryStatusToml -> Bool
$c/= :: BatteryStatusToml -> BatteryStatusToml -> Bool
== :: BatteryStatusToml -> BatteryStatusToml -> Bool
$c== :: BatteryStatusToml -> BatteryStatusToml -> Bool
Eq, Int -> BatteryStatusToml -> ShowS
[BatteryStatusToml] -> ShowS
BatteryStatusToml -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatteryStatusToml] -> ShowS
$cshowList :: [BatteryStatusToml] -> ShowS
show :: BatteryStatusToml -> String
$cshow :: BatteryStatusToml -> String
showsPrec :: Int -> BatteryStatusToml -> ShowS
$cshowsPrec :: Int -> BatteryStatusToml -> ShowS
Show)
makeFieldLabelsNoPrefix ''BatteryStatusToml
instance DecodeTOML BatteryStatusToml where
tomlDecoder :: Decoder BatteryStatusToml
tomlDecoder =
BatteryApp
-> Maybe PollInterval
-> Maybe RepeatEventToml
-> Maybe ErrorNoteToml
-> Maybe Timeout
-> BatteryStatusToml
MkBatteryStatusToml
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Decoder a -> Text -> Decoder a
getFieldWith Decoder BatteryApp
batteryAppDecoder Text
"app"
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe PollInterval)
pollIntervalOptDecoder
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe RepeatEventToml)
repeatEventOptDecoder
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe ErrorNoteToml)
errorNoteOptDecoder
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe Timeout)
timeoutOptDecoder