{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
module Navi.Services.Custom.Single.Toml
( SingleToml (..),
)
where
import Navi.Data.NaviNote (NaviNote)
import Navi.Data.PollInterval (PollInterval (..), pollIntervalOptDecoder)
import Navi.Event.Toml
( ErrorNoteToml,
RepeatEventToml,
errorNoteOptDecoder,
repeatEventOptDecoder,
)
import Navi.Prelude
import Navi.Utils (commandDecoder)
import Pythia.Data.Command (Command (..))
data SingleToml = MkSingleToml
{
SingleToml -> Command
command :: Command,
SingleToml -> Maybe Text
name :: Maybe Text,
SingleToml -> Text
triggerVal :: Text,
SingleToml -> Maybe PollInterval
pollInterval :: Maybe PollInterval,
SingleToml -> NaviNote
note :: NaviNote,
SingleToml -> Maybe RepeatEventToml
repeatEventCfg :: Maybe RepeatEventToml,
SingleToml -> Maybe ErrorNoteToml
errEventCfg :: Maybe ErrorNoteToml
}
deriving stock (SingleToml -> SingleToml -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SingleToml -> SingleToml -> Bool
$c/= :: SingleToml -> SingleToml -> Bool
== :: SingleToml -> SingleToml -> Bool
$c== :: SingleToml -> SingleToml -> Bool
Eq, Int -> SingleToml -> ShowS
[SingleToml] -> ShowS
SingleToml -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SingleToml] -> ShowS
$cshowList :: [SingleToml] -> ShowS
show :: SingleToml -> String
$cshow :: SingleToml -> String
showsPrec :: Int -> SingleToml -> ShowS
$cshowsPrec :: Int -> SingleToml -> ShowS
Show)
makeFieldLabelsNoPrefix ''SingleToml
instance DecodeTOML SingleToml where
tomlDecoder :: Decoder SingleToml
tomlDecoder =
Command
-> Maybe Text
-> Text
-> Maybe PollInterval
-> NaviNote
-> Maybe RepeatEventToml
-> Maybe ErrorNoteToml
-> SingleToml
MkSingleToml
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder Command
commandDecoder
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> forall a. DecodeTOML a => Text -> Decoder (Maybe a)
getFieldOpt Text
"name"
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> forall a. DecodeTOML a => Text -> Decoder a
getField Text
"trigger"
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
<*> forall a. DecodeTOML a => Text -> Decoder a
getField Text
"note"
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