{-# LANGUAGE UndecidableInstances #-}

module Shrun.Configuration.Data.Core
  ( -- * Types
    CoreConfigP (..),
    CoreConfigArgs,
    CoreConfigToml,
    CoreConfigMerged,

    -- * Functions
    mergeCoreConfig,
    withCoreEnv,

    -- * Misc
    defaultMerged,
  )
where

import Shrun.Configuration.Data.CommandLogging (CommandLoggingP, mergeCommandLogging)
import Shrun.Configuration.Data.CommandLogging qualified as CommandLogging
import Shrun.Configuration.Data.CommonLogging (CommonLoggingP, mergeCommonLogging)
import Shrun.Configuration.Data.CommonLogging qualified as CommonLogging
import Shrun.Configuration.Data.ConfigPhase
  ( ConfigPhase
      ( ConfigPhaseArgs,
        ConfigPhaseEnv,
        ConfigPhaseMerged,
        ConfigPhaseToml
      ),
    ConfigPhaseMaybeF,
  )
import Shrun.Configuration.Data.ConsoleLogging (ConsoleLoggingP, mergeConsoleLogging)
import Shrun.Configuration.Data.ConsoleLogging qualified as ConsoleLogging
import Shrun.Configuration.Data.Core.Timeout (Timeout)
import Shrun.Configuration.Data.FileLogging (FileLoggingP, mergeFileLogging)
import Shrun.Configuration.Data.FileLogging qualified as FileLogging
import Shrun.Configuration.Data.Notify (NotifyP, mergeNotifyLogging)
import Shrun.Configuration.Data.Notify qualified as Notify
import Shrun.Configuration.Data.WithDisabled ((<>??))
import Shrun.Configuration.Default (Default (def))
import Shrun.Notify.MonadDBus (MonadDBus)
import Shrun.Prelude

-- | For types that are only guaranteed to exist for Args. Generally this
-- describes "aggregate" types e.g. CommandLoggingP, which always exists for
-- Args (as subfields can independently override toml), but is not
-- guaranteed to exist on toml/merged, since its presence in the latter two
-- indicates active status.
type family ArgsOnlyDetF p a where
  ArgsOnlyDetF ConfigPhaseArgs a = a
  ArgsOnlyDetF ConfigPhaseToml a = Maybe a
  ArgsOnlyDetF ConfigPhaseMerged a = Maybe a
  ArgsOnlyDetF ConfigPhaseEnv a = Maybe a

-- | For types that are optional only on the Toml.
type family TomlOptF p a where
  TomlOptF ConfigPhaseArgs a = a
  TomlOptF ConfigPhaseToml a = Maybe a
  TomlOptF ConfigPhaseMerged a = a
  TomlOptF ConfigPhaseEnv a = a

-- | Holds core configuration data.
type CoreConfigP :: ConfigPhase -> Type
data CoreConfigP p = MkCoreConfigP
  { -- | Shell logic to run before each command.
    forall (p :: ConfigPhase).
CoreConfigP p -> ConfigPhaseMaybeF p Text
init :: ConfigPhaseMaybeF p Text,
    -- | Timeout.
    forall (p :: ConfigPhase).
CoreConfigP p -> ConfigPhaseMaybeF p Timeout
timeout :: ConfigPhaseMaybeF p Timeout,
    -- | Holds common logging config.
    forall (p :: ConfigPhase).
CoreConfigP p -> TomlOptF p (CommonLoggingP p)
commonLogging :: TomlOptF p (CommonLoggingP p),
    -- | Command log config.
    forall (p :: ConfigPhase).
CoreConfigP p -> TomlOptF p (CommandLoggingP p)
commandLogging :: TomlOptF p (CommandLoggingP p),
    -- | Holds console logging config.
    forall (p :: ConfigPhase).
CoreConfigP p -> TomlOptF p (ConsoleLoggingP p)
consoleLogging :: TomlOptF p (ConsoleLoggingP p),
    -- | File log config.
    forall (p :: ConfigPhase).
CoreConfigP p -> ArgsOnlyDetF p (FileLoggingP p)
fileLogging :: ArgsOnlyDetF p (FileLoggingP p),
    -- | Notify config.
    forall (p :: ConfigPhase).
CoreConfigP p -> ArgsOnlyDetF p (NotifyP p)
notify :: ArgsOnlyDetF p (NotifyP p)
  }

instance
  ( k ~ A_Lens,
    a ~ ConfigPhaseMaybeF p Text,
    b ~ ConfigPhaseMaybeF p Text
  ) =>
  LabelOptic "init" k (CoreConfigP p) (CoreConfigP p) a b
  where
  labelOptic :: Optic k NoIx (CoreConfigP p) (CoreConfigP p) a b
labelOptic =
    LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall (s :: OpticKind) (t :: OpticKind) (a :: OpticKind)
       (b :: OpticKind).
LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CoreConfigP p) (CoreConfigP p) a b
 -> Lens (CoreConfigP p) (CoreConfigP p) a b)
-> LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f
         ( MkCoreConfigP
             ConfigPhaseMaybeF p Text
_init
             ConfigPhaseMaybeF p Timeout
_timeout
             TomlOptF p (CommonLoggingP p)
_commonLogging
             TomlOptF p (CommandLoggingP p)
_commandLogging
             TomlOptF p (ConsoleLoggingP p)
_consoleLogging
             ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
             ArgsOnlyDetF p (NotifyP p)
_notify
           ) ->
          (b -> CoreConfigP p) -> f b -> f (CoreConfigP p)
forall (a :: OpticKind) (b :: OpticKind). (a -> b) -> f a -> f b
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Functor f =>
(a -> b) -> f a -> f b
fmap
            ( \b
init' ->
                ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
forall (p :: ConfigPhase).
ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
MkCoreConfigP
                  b
ConfigPhaseMaybeF p Text
init'
                  ConfigPhaseMaybeF p Timeout
_timeout
                  TomlOptF p (CommonLoggingP p)
_commonLogging
                  TomlOptF p (CommandLoggingP p)
_commandLogging
                  TomlOptF p (ConsoleLoggingP p)
_consoleLogging
                  ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
                  ArgsOnlyDetF p (NotifyP p)
_notify
            )
            (a -> f b
f a
ConfigPhaseMaybeF p Text
_init)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ ConfigPhaseMaybeF p Timeout,
    b ~ ConfigPhaseMaybeF p Timeout
  ) =>
  LabelOptic "timeout" k (CoreConfigP p) (CoreConfigP p) a b
  where
  labelOptic :: Optic k NoIx (CoreConfigP p) (CoreConfigP p) a b
labelOptic =
    LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall (s :: OpticKind) (t :: OpticKind) (a :: OpticKind)
       (b :: OpticKind).
LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CoreConfigP p) (CoreConfigP p) a b
 -> Lens (CoreConfigP p) (CoreConfigP p) a b)
-> LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f
         ( MkCoreConfigP
             ConfigPhaseMaybeF p Text
_init
             ConfigPhaseMaybeF p Timeout
_timeout
             TomlOptF p (CommonLoggingP p)
_commonLogging
             TomlOptF p (CommandLoggingP p)
_commandLogging
             TomlOptF p (ConsoleLoggingP p)
_consoleLogging
             ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
             ArgsOnlyDetF p (NotifyP p)
_notify
           ) ->
          (b -> CoreConfigP p) -> f b -> f (CoreConfigP p)
forall (a :: OpticKind) (b :: OpticKind). (a -> b) -> f a -> f b
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Functor f =>
(a -> b) -> f a -> f b
fmap
            ( \b
timeout' ->
                ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
forall (p :: ConfigPhase).
ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
MkCoreConfigP
                  ConfigPhaseMaybeF p Text
_init
                  b
ConfigPhaseMaybeF p Timeout
timeout'
                  TomlOptF p (CommonLoggingP p)
_commonLogging
                  TomlOptF p (CommandLoggingP p)
_commandLogging
                  TomlOptF p (ConsoleLoggingP p)
_consoleLogging
                  ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
                  ArgsOnlyDetF p (NotifyP p)
_notify
            )
            (a -> f b
f a
ConfigPhaseMaybeF p Timeout
_timeout)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ TomlOptF p (CommonLoggingP p),
    b ~ TomlOptF p (CommonLoggingP p)
  ) =>
  LabelOptic "commonLogging" k (CoreConfigP p) (CoreConfigP p) a b
  where
  labelOptic :: Optic k NoIx (CoreConfigP p) (CoreConfigP p) a b
labelOptic =
    LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall (s :: OpticKind) (t :: OpticKind) (a :: OpticKind)
       (b :: OpticKind).
LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CoreConfigP p) (CoreConfigP p) a b
 -> Lens (CoreConfigP p) (CoreConfigP p) a b)
-> LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f
         ( MkCoreConfigP
             ConfigPhaseMaybeF p Text
_init
             ConfigPhaseMaybeF p Timeout
_timeout
             TomlOptF p (CommonLoggingP p)
_commonLogging
             TomlOptF p (CommandLoggingP p)
_commandLogging
             TomlOptF p (ConsoleLoggingP p)
_consoleLogging
             ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
             ArgsOnlyDetF p (NotifyP p)
_notify
           ) ->
          (b -> CoreConfigP p) -> f b -> f (CoreConfigP p)
forall (a :: OpticKind) (b :: OpticKind). (a -> b) -> f a -> f b
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Functor f =>
(a -> b) -> f a -> f b
fmap
            ( \b
commonLogging' ->
                ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
forall (p :: ConfigPhase).
ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
MkCoreConfigP
                  ConfigPhaseMaybeF p Text
_init
                  ConfigPhaseMaybeF p Timeout
_timeout
                  b
TomlOptF p (CommonLoggingP p)
commonLogging'
                  TomlOptF p (CommandLoggingP p)
_commandLogging
                  TomlOptF p (ConsoleLoggingP p)
_consoleLogging
                  ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
                  ArgsOnlyDetF p (NotifyP p)
_notify
            )
            (a -> f b
f a
TomlOptF p (CommonLoggingP p)
_commonLogging)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ TomlOptF p (CommandLoggingP p),
    b ~ TomlOptF p (CommandLoggingP p)
  ) =>
  LabelOptic "commandLogging" k (CoreConfigP p) (CoreConfigP p) a b
  where
  labelOptic :: Optic k NoIx (CoreConfigP p) (CoreConfigP p) a b
labelOptic =
    LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall (s :: OpticKind) (t :: OpticKind) (a :: OpticKind)
       (b :: OpticKind).
LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CoreConfigP p) (CoreConfigP p) a b
 -> Lens (CoreConfigP p) (CoreConfigP p) a b)
-> LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f
         ( MkCoreConfigP
             ConfigPhaseMaybeF p Text
_init
             ConfigPhaseMaybeF p Timeout
_timeout
             TomlOptF p (CommonLoggingP p)
_commonLogging
             TomlOptF p (CommandLoggingP p)
_commandLogging
             TomlOptF p (ConsoleLoggingP p)
_consoleLogging
             ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
             ArgsOnlyDetF p (NotifyP p)
_notify
           ) ->
          (b -> CoreConfigP p) -> f b -> f (CoreConfigP p)
forall (a :: OpticKind) (b :: OpticKind). (a -> b) -> f a -> f b
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Functor f =>
(a -> b) -> f a -> f b
fmap
            ( \b
commandLogging' ->
                ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
forall (p :: ConfigPhase).
ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
MkCoreConfigP
                  ConfigPhaseMaybeF p Text
_init
                  ConfigPhaseMaybeF p Timeout
_timeout
                  TomlOptF p (CommonLoggingP p)
_commonLogging
                  b
TomlOptF p (CommandLoggingP p)
commandLogging'
                  TomlOptF p (ConsoleLoggingP p)
_consoleLogging
                  ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
                  ArgsOnlyDetF p (NotifyP p)
_notify
            )
            (a -> f b
f a
TomlOptF p (CommandLoggingP p)
_commandLogging)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ TomlOptF p (ConsoleLoggingP p),
    b ~ TomlOptF p (ConsoleLoggingP p)
  ) =>
  LabelOptic "consoleLogging" k (CoreConfigP p) (CoreConfigP p) a b
  where
  labelOptic :: Optic k NoIx (CoreConfigP p) (CoreConfigP p) a b
labelOptic =
    LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall (s :: OpticKind) (t :: OpticKind) (a :: OpticKind)
       (b :: OpticKind).
LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CoreConfigP p) (CoreConfigP p) a b
 -> Lens (CoreConfigP p) (CoreConfigP p) a b)
-> LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f
         ( MkCoreConfigP
             ConfigPhaseMaybeF p Text
_init
             ConfigPhaseMaybeF p Timeout
_timeout
             TomlOptF p (CommonLoggingP p)
_commonLogging
             TomlOptF p (CommandLoggingP p)
_commandLogging
             TomlOptF p (ConsoleLoggingP p)
_consoleLogging
             ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
             ArgsOnlyDetF p (NotifyP p)
_notify
           ) ->
          (b -> CoreConfigP p) -> f b -> f (CoreConfigP p)
forall (a :: OpticKind) (b :: OpticKind). (a -> b) -> f a -> f b
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Functor f =>
(a -> b) -> f a -> f b
fmap
            ( \b
consoleLogging' ->
                ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
forall (p :: ConfigPhase).
ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
MkCoreConfigP
                  ConfigPhaseMaybeF p Text
_init
                  ConfigPhaseMaybeF p Timeout
_timeout
                  TomlOptF p (CommonLoggingP p)
_commonLogging
                  TomlOptF p (CommandLoggingP p)
_commandLogging
                  b
TomlOptF p (ConsoleLoggingP p)
consoleLogging'
                  ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
                  ArgsOnlyDetF p (NotifyP p)
_notify
            )
            (a -> f b
f a
TomlOptF p (ConsoleLoggingP p)
_consoleLogging)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ ArgsOnlyDetF p (FileLoggingP p),
    b ~ ArgsOnlyDetF p (FileLoggingP p)
  ) =>
  LabelOptic "fileLogging" k (CoreConfigP p) (CoreConfigP p) a b
  where
  labelOptic :: Optic k NoIx (CoreConfigP p) (CoreConfigP p) a b
labelOptic =
    LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall (s :: OpticKind) (t :: OpticKind) (a :: OpticKind)
       (b :: OpticKind).
LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CoreConfigP p) (CoreConfigP p) a b
 -> Lens (CoreConfigP p) (CoreConfigP p) a b)
-> LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f
         ( MkCoreConfigP
             ConfigPhaseMaybeF p Text
_init
             ConfigPhaseMaybeF p Timeout
_timeout
             TomlOptF p (CommonLoggingP p)
_commonLogging
             TomlOptF p (CommandLoggingP p)
_commandLogging
             TomlOptF p (ConsoleLoggingP p)
_consoleLogging
             ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
             ArgsOnlyDetF p (NotifyP p)
_notify
           ) ->
          (b -> CoreConfigP p) -> f b -> f (CoreConfigP p)
forall (a :: OpticKind) (b :: OpticKind). (a -> b) -> f a -> f b
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Functor f =>
(a -> b) -> f a -> f b
fmap
            ( \b
fileLogging' ->
                ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
forall (p :: ConfigPhase).
ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
MkCoreConfigP
                  ConfigPhaseMaybeF p Text
_init
                  ConfigPhaseMaybeF p Timeout
_timeout
                  TomlOptF p (CommonLoggingP p)
_commonLogging
                  TomlOptF p (CommandLoggingP p)
_commandLogging
                  TomlOptF p (ConsoleLoggingP p)
_consoleLogging
                  b
ArgsOnlyDetF p (FileLoggingP p)
fileLogging'
                  ArgsOnlyDetF p (NotifyP p)
_notify
            )
            (a -> f b
f a
ArgsOnlyDetF p (FileLoggingP p)
_fileLogging)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ ArgsOnlyDetF p (NotifyP p),
    b ~ ArgsOnlyDetF p (NotifyP p)
  ) =>
  LabelOptic "notify" k (CoreConfigP p) (CoreConfigP p) a b
  where
  labelOptic :: Optic k NoIx (CoreConfigP p) (CoreConfigP p) a b
labelOptic =
    LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall (s :: OpticKind) (t :: OpticKind) (a :: OpticKind)
       (b :: OpticKind).
LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CoreConfigP p) (CoreConfigP p) a b
 -> Lens (CoreConfigP p) (CoreConfigP p) a b)
-> LensVL (CoreConfigP p) (CoreConfigP p) a b
-> Lens (CoreConfigP p) (CoreConfigP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f
         ( MkCoreConfigP
             ConfigPhaseMaybeF p Text
_init
             ConfigPhaseMaybeF p Timeout
_timeout
             TomlOptF p (CommonLoggingP p)
_commonLogging
             TomlOptF p (CommandLoggingP p)
_commandLogging
             TomlOptF p (ConsoleLoggingP p)
_consoleLogging
             ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
             ArgsOnlyDetF p (NotifyP p)
_notify
           ) ->
          (b -> CoreConfigP p) -> f b -> f (CoreConfigP p)
forall (a :: OpticKind) (b :: OpticKind). (a -> b) -> f a -> f b
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Functor f =>
(a -> b) -> f a -> f b
fmap
            ( ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
forall (p :: ConfigPhase).
ConfigPhaseMaybeF p Text
-> ConfigPhaseMaybeF p Timeout
-> TomlOptF p (CommonLoggingP p)
-> TomlOptF p (CommandLoggingP p)
-> TomlOptF p (ConsoleLoggingP p)
-> ArgsOnlyDetF p (FileLoggingP p)
-> ArgsOnlyDetF p (NotifyP p)
-> CoreConfigP p
MkCoreConfigP
                ConfigPhaseMaybeF p Text
_init
                ConfigPhaseMaybeF p Timeout
_timeout
                TomlOptF p (CommonLoggingP p)
_commonLogging
                TomlOptF p (CommandLoggingP p)
_commandLogging
                TomlOptF p (ConsoleLoggingP p)
_consoleLogging
                ArgsOnlyDetF p (FileLoggingP p)
_fileLogging
            )
            (a -> f b
f a
ArgsOnlyDetF p (NotifyP p)
_notify)
  {-# INLINE labelOptic #-}

type CoreConfigArgs = CoreConfigP ConfigPhaseArgs

type CoreConfigToml = CoreConfigP ConfigPhaseToml

type CoreConfigMerged = CoreConfigP ConfigPhaseMerged

type CoreConfigEnv = CoreConfigP ConfigPhaseEnv

deriving stock instance Eq (CoreConfigP ConfigPhaseArgs)

deriving stock instance Show (CoreConfigP ConfigPhaseArgs)

deriving stock instance Eq (CoreConfigP ConfigPhaseToml)

deriving stock instance Show (CoreConfigP ConfigPhaseToml)

deriving stock instance Eq (CoreConfigP ConfigPhaseMerged)

deriving stock instance Show (CoreConfigP ConfigPhaseMerged)

mergeCoreConfig ::
  ( HasCallStack,
    MonadTerminal m
  ) =>
  CoreConfigArgs ->
  Maybe CoreConfigToml ->
  m CoreConfigMerged
mergeCoreConfig :: forall (m :: OpticKind -> OpticKind).
(HasCallStack, MonadTerminal m) =>
CoreConfigP 'ConfigPhaseArgs
-> Maybe (CoreConfigP 'ConfigPhaseToml)
-> m (CoreConfigP 'ConfigPhaseMerged)
mergeCoreConfig CoreConfigP 'ConfigPhaseArgs
args Maybe (CoreConfigP 'ConfigPhaseToml)
mToml = do
  ConsoleLoggingP 'ConfigPhaseMerged
consoleLogging <-
    ConsoleLoggingP 'ConfigPhaseArgs
-> Maybe (ConsoleLoggingP 'ConfigPhaseToml)
-> m (ConsoleLoggingP 'ConfigPhaseMerged)
forall (m :: OpticKind -> OpticKind).
(HasCallStack, MonadTerminal m) =>
ConsoleLoggingP 'ConfigPhaseArgs
-> Maybe (ConsoleLoggingP 'ConfigPhaseToml)
-> m (ConsoleLoggingP 'ConfigPhaseMerged)
mergeConsoleLogging
      (CoreConfigP 'ConfigPhaseArgs
args CoreConfigP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseArgs)
     (ConsoleLoggingP 'ConfigPhaseArgs)
-> ConsoleLoggingP 'ConfigPhaseArgs
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseArgs)
  (ConsoleLoggingP 'ConfigPhaseArgs)
#consoleLogging)
      (CoreConfigP 'ConfigPhaseToml
toml CoreConfigP 'ConfigPhaseToml
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseToml)
     (Maybe (ConsoleLoggingP 'ConfigPhaseToml))
-> Maybe (ConsoleLoggingP 'ConfigPhaseToml)
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseToml)
  (Maybe (ConsoleLoggingP 'ConfigPhaseToml))
#consoleLogging)

  Maybe (FileLoggingP 'ConfigPhaseMerged)
fileLogging <-
    FileLoggingP 'ConfigPhaseArgs
-> Maybe (FileLoggingP 'ConfigPhaseToml)
-> m (Maybe (FileLoggingP 'ConfigPhaseMerged))
forall (m :: OpticKind -> OpticKind).
(HasCallStack, MonadTerminal m) =>
FileLoggingP 'ConfigPhaseArgs
-> Maybe (FileLoggingP 'ConfigPhaseToml)
-> m (Maybe (FileLoggingP 'ConfigPhaseMerged))
mergeFileLogging
      (CoreConfigP 'ConfigPhaseArgs
args CoreConfigP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseArgs)
     (FileLoggingP 'ConfigPhaseArgs)
-> FileLoggingP 'ConfigPhaseArgs
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseArgs)
  (FileLoggingP 'ConfigPhaseArgs)
#fileLogging)
      (CoreConfigP 'ConfigPhaseToml
toml CoreConfigP 'ConfigPhaseToml
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseToml)
     (Maybe (FileLoggingP 'ConfigPhaseToml))
-> Maybe (FileLoggingP 'ConfigPhaseToml)
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseToml)
  (Maybe (FileLoggingP 'ConfigPhaseToml))
#fileLogging)

  pure
    $ MkCoreConfigP
      { timeout :: ConfigPhaseMaybeF 'ConfigPhaseMerged Timeout
timeout = (CoreConfigP 'ConfigPhaseArgs
args CoreConfigP 'ConfigPhaseArgs
-> Optic'
     A_Lens NoIx (CoreConfigP 'ConfigPhaseArgs) (WithDisabled Timeout)
-> WithDisabled Timeout
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx (CoreConfigP 'ConfigPhaseArgs) (WithDisabled Timeout)
#timeout) WithDisabled Timeout -> Maybe Timeout -> Maybe Timeout
forall (a :: OpticKind). WithDisabled a -> Maybe a -> Maybe a
<>?? (CoreConfigP 'ConfigPhaseToml
toml CoreConfigP 'ConfigPhaseToml
-> Optic'
     A_Lens NoIx (CoreConfigP 'ConfigPhaseToml) (Maybe Timeout)
-> Maybe Timeout
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx (CoreConfigP 'ConfigPhaseToml) (Maybe Timeout)
#timeout),
        init :: ConfigPhaseMaybeF 'ConfigPhaseMerged Text
init = (CoreConfigP 'ConfigPhaseArgs
args CoreConfigP 'ConfigPhaseArgs
-> Optic'
     A_Lens NoIx (CoreConfigP 'ConfigPhaseArgs) (WithDisabled Text)
-> WithDisabled Text
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx (CoreConfigP 'ConfigPhaseArgs) (WithDisabled Text)
#init) WithDisabled Text -> Maybe Text -> Maybe Text
forall (a :: OpticKind). WithDisabled a -> Maybe a -> Maybe a
<>?? (CoreConfigP 'ConfigPhaseToml
toml CoreConfigP 'ConfigPhaseToml
-> Optic' A_Lens NoIx (CoreConfigP 'ConfigPhaseToml) (Maybe Text)
-> Maybe Text
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx (CoreConfigP 'ConfigPhaseToml) (Maybe Text)
#init),
        commonLogging :: TomlOptF 'ConfigPhaseMerged (CommonLoggingP 'ConfigPhaseMerged)
commonLogging =
          CommonLoggingP 'ConfigPhaseArgs
-> Maybe (CommonLoggingP 'ConfigPhaseToml)
-> CommonLoggingP 'ConfigPhaseMerged
mergeCommonLogging
            (CoreConfigP 'ConfigPhaseArgs
args CoreConfigP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseArgs)
     (CommonLoggingP 'ConfigPhaseArgs)
-> CommonLoggingP 'ConfigPhaseArgs
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseArgs)
  (CommonLoggingP 'ConfigPhaseArgs)
#commonLogging)
            (CoreConfigP 'ConfigPhaseToml
toml CoreConfigP 'ConfigPhaseToml
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseToml)
     (Maybe (CommonLoggingP 'ConfigPhaseToml))
-> Maybe (CommonLoggingP 'ConfigPhaseToml)
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseToml)
  (Maybe (CommonLoggingP 'ConfigPhaseToml))
#commonLogging),
        ConsoleLoggingP 'ConfigPhaseMerged
TomlOptF 'ConfigPhaseMerged (ConsoleLoggingP 'ConfigPhaseMerged)
consoleLogging :: TomlOptF 'ConfigPhaseMerged (ConsoleLoggingP 'ConfigPhaseMerged)
consoleLogging :: ConsoleLoggingP 'ConfigPhaseMerged
consoleLogging,
        commandLogging :: TomlOptF 'ConfigPhaseMerged (CommandLoggingP 'ConfigPhaseMerged)
commandLogging =
          CommandLoggingP 'ConfigPhaseArgs
-> Maybe (CommandLoggingP 'ConfigPhaseToml)
-> CommandLoggingP 'ConfigPhaseMerged
mergeCommandLogging
            (CoreConfigP 'ConfigPhaseArgs
args CoreConfigP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseArgs)
     (CommandLoggingP 'ConfigPhaseArgs)
-> CommandLoggingP 'ConfigPhaseArgs
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseArgs)
  (CommandLoggingP 'ConfigPhaseArgs)
#commandLogging)
            (CoreConfigP 'ConfigPhaseToml
toml CoreConfigP 'ConfigPhaseToml
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseToml)
     (Maybe (CommandLoggingP 'ConfigPhaseToml))
-> Maybe (CommandLoggingP 'ConfigPhaseToml)
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseToml)
  (Maybe (CommandLoggingP 'ConfigPhaseToml))
#commandLogging),
        Maybe (FileLoggingP 'ConfigPhaseMerged)
ArgsOnlyDetF 'ConfigPhaseMerged (FileLoggingP 'ConfigPhaseMerged)
fileLogging :: ArgsOnlyDetF 'ConfigPhaseMerged (FileLoggingP 'ConfigPhaseMerged)
fileLogging :: Maybe (FileLoggingP 'ConfigPhaseMerged)
fileLogging,
        notify :: ArgsOnlyDetF 'ConfigPhaseMerged (NotifyP 'ConfigPhaseMerged)
notify =
          NotifyP 'ConfigPhaseArgs
-> Maybe (NotifyP 'ConfigPhaseToml)
-> Maybe (NotifyP 'ConfigPhaseMerged)
mergeNotifyLogging
            (CoreConfigP 'ConfigPhaseArgs
args CoreConfigP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseArgs)
     (NotifyP 'ConfigPhaseArgs)
-> NotifyP 'ConfigPhaseArgs
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseArgs)
  (NotifyP 'ConfigPhaseArgs)
#notify)
            (CoreConfigP 'ConfigPhaseToml
toml CoreConfigP 'ConfigPhaseToml
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseToml)
     (Maybe (NotifyP 'ConfigPhaseToml))
-> Maybe (NotifyP 'ConfigPhaseToml)
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseToml)
  (Maybe (NotifyP 'ConfigPhaseToml))
#notify)
      }
  where
    toml :: CoreConfigP 'ConfigPhaseToml
toml = CoreConfigP 'ConfigPhaseToml
-> Maybe (CoreConfigP 'ConfigPhaseToml)
-> CoreConfigP 'ConfigPhaseToml
forall (a :: OpticKind). a -> Maybe a -> a
fromMaybe CoreConfigP 'ConfigPhaseToml
defaultToml Maybe (CoreConfigP 'ConfigPhaseToml)
mToml

-- | Given a merged CoreConfig, constructs a ConfigEnv and calls the
-- continuation.
withCoreEnv ::
  forall m a.
  ( HasCallStack,
    MonadDBus m,
    MonadFileWriter m,
    MonadHandleWriter m,
    MonadPathReader m,
    MonadPathWriter m,
    MonadSTM m,
    MonadTerminal m,
    MonadThrow m
  ) =>
  CoreConfigMerged ->
  (CoreConfigEnv -> m a) ->
  m a
withCoreEnv :: forall (m :: OpticKind -> OpticKind) (a :: OpticKind).
(HasCallStack, MonadDBus m, MonadFileWriter m, MonadHandleWriter m,
 MonadPathReader m, MonadPathWriter m, MonadSTM m, MonadTerminal m,
 MonadThrow m) =>
CoreConfigP 'ConfigPhaseMerged -> (CoreConfigEnv -> m a) -> m a
withCoreEnv CoreConfigP 'ConfigPhaseMerged
merged CoreConfigEnv -> m a
onCoreConfigEnv = do
  Maybe NotifyEnv
notify <- (NotifyP 'ConfigPhaseMerged -> m NotifyEnv)
-> Maybe (NotifyP 'ConfigPhaseMerged) -> m (Maybe NotifyEnv)
forall (t :: OpticKind -> OpticKind) (f :: OpticKind -> OpticKind)
       (a :: OpticKind) (b :: OpticKind).
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: OpticKind -> OpticKind) (a :: OpticKind)
       (b :: OpticKind).
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse NotifyP 'ConfigPhaseMerged -> m NotifyEnv
forall (m :: OpticKind -> OpticKind).
(HasCallStack, MonadDBus m, MonadThrow m) =>
NotifyP 'ConfigPhaseMerged -> m NotifyEnv
Notify.toEnv (CoreConfigP 'ConfigPhaseMerged
merged CoreConfigP 'ConfigPhaseMerged
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseMerged)
     (Maybe (NotifyP 'ConfigPhaseMerged))
-> Maybe (NotifyP 'ConfigPhaseMerged)
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseMerged)
  (Maybe (NotifyP 'ConfigPhaseMerged))
#notify)

  Maybe (FileLoggingP 'ConfigPhaseMerged)
-> (Maybe FileLoggingEnv -> m a) -> m a
forall (m :: OpticKind -> OpticKind) (a :: OpticKind).
(HasCallStack, MonadFileWriter m, MonadHandleWriter m,
 MonadPathReader m, MonadPathWriter m, MonadSTM m,
 MonadTerminal m) =>
Maybe (FileLoggingP 'ConfigPhaseMerged)
-> (Maybe FileLoggingEnv -> m a) -> m a
FileLogging.withFileLoggingEnv (CoreConfigP 'ConfigPhaseMerged
merged CoreConfigP 'ConfigPhaseMerged
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseMerged)
     (Maybe (FileLoggingP 'ConfigPhaseMerged))
-> Maybe (FileLoggingP 'ConfigPhaseMerged)
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseMerged)
  (Maybe (FileLoggingP 'ConfigPhaseMerged))
#fileLogging) ((Maybe FileLoggingEnv -> m a) -> m a)
-> (Maybe FileLoggingEnv -> m a) -> m a
forall a b. (a -> b) -> a -> b
$ \Maybe FileLoggingEnv
fileLoggingEnv ->
    let coreConfigEnv :: CoreConfigEnv
coreConfigEnv =
          MkCoreConfigP
            { init :: ConfigPhaseMaybeF 'ConfigPhaseEnv Text
init = CoreConfigP 'ConfigPhaseMerged
merged CoreConfigP 'ConfigPhaseMerged
-> Optic' A_Lens NoIx (CoreConfigP 'ConfigPhaseMerged) (Maybe Text)
-> Maybe Text
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx (CoreConfigP 'ConfigPhaseMerged) (Maybe Text)
#init,
              timeout :: ConfigPhaseMaybeF 'ConfigPhaseEnv Timeout
timeout = CoreConfigP 'ConfigPhaseMerged
merged CoreConfigP 'ConfigPhaseMerged
-> Optic'
     A_Lens NoIx (CoreConfigP 'ConfigPhaseMerged) (Maybe Timeout)
-> Maybe Timeout
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx (CoreConfigP 'ConfigPhaseMerged) (Maybe Timeout)
#timeout,
              commonLogging :: TomlOptF 'ConfigPhaseEnv (CommonLoggingP 'ConfigPhaseEnv)
commonLogging = CommonLoggingP 'ConfigPhaseMerged -> CommonLoggingP 'ConfigPhaseEnv
CommonLogging.toEnv (CoreConfigP 'ConfigPhaseMerged
merged CoreConfigP 'ConfigPhaseMerged
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseMerged)
     (CommonLoggingP 'ConfigPhaseMerged)
-> CommonLoggingP 'ConfigPhaseMerged
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseMerged)
  (CommonLoggingP 'ConfigPhaseMerged)
#commonLogging),
              commandLogging :: TomlOptF 'ConfigPhaseEnv (CommandLoggingP 'ConfigPhaseEnv)
commandLogging = CommandLoggingP 'ConfigPhaseMerged
-> CommandLoggingP 'ConfigPhaseEnv
CommandLogging.toEnv (CoreConfigP 'ConfigPhaseMerged
merged CoreConfigP 'ConfigPhaseMerged
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseMerged)
     (CommandLoggingP 'ConfigPhaseMerged)
-> CommandLoggingP 'ConfigPhaseMerged
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseMerged)
  (CommandLoggingP 'ConfigPhaseMerged)
#commandLogging),
              consoleLogging :: TomlOptF 'ConfigPhaseEnv (ConsoleLoggingP 'ConfigPhaseEnv)
consoleLogging = ConsoleLoggingP 'ConfigPhaseMerged
-> ConsoleLoggingP 'ConfigPhaseEnv
ConsoleLogging.toEnv (CoreConfigP 'ConfigPhaseMerged
merged CoreConfigP 'ConfigPhaseMerged
-> Optic'
     A_Lens
     NoIx
     (CoreConfigP 'ConfigPhaseMerged)
     (ConsoleLoggingP 'ConfigPhaseMerged)
-> ConsoleLoggingP 'ConfigPhaseMerged
forall (k :: OpticKind) (s :: OpticKind) (is :: IxList)
       (a :: OpticKind).
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CoreConfigP 'ConfigPhaseMerged)
  (ConsoleLoggingP 'ConfigPhaseMerged)
#consoleLogging),
              fileLogging :: ArgsOnlyDetF 'ConfigPhaseEnv FileLoggingEnv
fileLogging = Maybe FileLoggingEnv
ArgsOnlyDetF 'ConfigPhaseEnv FileLoggingEnv
fileLoggingEnv,
              Maybe NotifyEnv
ArgsOnlyDetF 'ConfigPhaseEnv NotifyEnv
notify :: ArgsOnlyDetF 'ConfigPhaseEnv NotifyEnv
notify :: Maybe NotifyEnv
notify
            }
     in CoreConfigEnv -> m a
onCoreConfigEnv CoreConfigEnv
coreConfigEnv

instance
  ( Default (ConfigPhaseMaybeF p Text),
    Default (ConfigPhaseMaybeF p Timeout),
    Default (TomlOptF p (CommonLoggingP p)),
    Default (TomlOptF p (CommandLoggingP p)),
    Default (TomlOptF p (ConsoleLoggingP p)),
    Default (ArgsOnlyDetF p (FileLoggingP p)),
    Default (ArgsOnlyDetF p (NotifyP p))
  ) =>
  Default (CoreConfigP p)
  where
  def :: CoreConfigP p
def =
    MkCoreConfigP
      { init :: ConfigPhaseMaybeF p Text
init = ConfigPhaseMaybeF p Text
forall (a :: OpticKind). Default a => a
def,
        timeout :: ConfigPhaseMaybeF p Timeout
timeout = ConfigPhaseMaybeF p Timeout
forall (a :: OpticKind). Default a => a
def,
        commonLogging :: TomlOptF p (CommonLoggingP p)
commonLogging = TomlOptF p (CommonLoggingP p)
forall (a :: OpticKind). Default a => a
def,
        commandLogging :: TomlOptF p (CommandLoggingP p)
commandLogging = TomlOptF p (CommandLoggingP p)
forall (a :: OpticKind). Default a => a
def,
        consoleLogging :: TomlOptF p (ConsoleLoggingP p)
consoleLogging = TomlOptF p (ConsoleLoggingP p)
forall (a :: OpticKind). Default a => a
def,
        fileLogging :: ArgsOnlyDetF p (FileLoggingP p)
fileLogging = ArgsOnlyDetF p (FileLoggingP p)
forall (a :: OpticKind). Default a => a
def,
        notify :: ArgsOnlyDetF p (NotifyP p)
notify = ArgsOnlyDetF p (NotifyP p)
forall (a :: OpticKind). Default a => a
def
      }

defaultToml :: CoreConfigToml
defaultToml :: CoreConfigP 'ConfigPhaseToml
defaultToml =
  MkCoreConfigP
    { init :: ConfigPhaseMaybeF 'ConfigPhaseToml Text
init = Maybe Text
ConfigPhaseMaybeF 'ConfigPhaseToml Text
forall (a :: OpticKind). Maybe a
Nothing,
      timeout :: ConfigPhaseMaybeF 'ConfigPhaseToml Timeout
timeout = Maybe Timeout
ConfigPhaseMaybeF 'ConfigPhaseToml Timeout
forall (a :: OpticKind). Maybe a
Nothing,
      commonLogging :: TomlOptF 'ConfigPhaseToml (CommonLoggingP 'ConfigPhaseToml)
commonLogging = Maybe (CommonLoggingP 'ConfigPhaseToml)
TomlOptF 'ConfigPhaseToml (CommonLoggingP 'ConfigPhaseToml)
forall (a :: OpticKind). Maybe a
Nothing,
      commandLogging :: TomlOptF 'ConfigPhaseToml (CommandLoggingP 'ConfigPhaseToml)
commandLogging = Maybe (CommandLoggingP 'ConfigPhaseToml)
TomlOptF 'ConfigPhaseToml (CommandLoggingP 'ConfigPhaseToml)
forall (a :: OpticKind). Maybe a
Nothing,
      consoleLogging :: TomlOptF 'ConfigPhaseToml (ConsoleLoggingP 'ConfigPhaseToml)
consoleLogging = Maybe (ConsoleLoggingP 'ConfigPhaseToml)
TomlOptF 'ConfigPhaseToml (ConsoleLoggingP 'ConfigPhaseToml)
forall (a :: OpticKind). Maybe a
Nothing,
      fileLogging :: ArgsOnlyDetF 'ConfigPhaseToml (FileLoggingP 'ConfigPhaseToml)
fileLogging = Maybe (FileLoggingP 'ConfigPhaseToml)
ArgsOnlyDetF 'ConfigPhaseToml (FileLoggingP 'ConfigPhaseToml)
forall (a :: OpticKind). Maybe a
Nothing,
      notify :: ArgsOnlyDetF 'ConfigPhaseToml (NotifyP 'ConfigPhaseToml)
notify = Maybe (NotifyP 'ConfigPhaseToml)
ArgsOnlyDetF 'ConfigPhaseToml (NotifyP 'ConfigPhaseToml)
forall (a :: OpticKind). Maybe a
Nothing
    }

defaultMerged :: CoreConfigMerged
defaultMerged :: CoreConfigP 'ConfigPhaseMerged
defaultMerged =
  MkCoreConfigP
    { init :: ConfigPhaseMaybeF 'ConfigPhaseMerged Text
init = Maybe Text
ConfigPhaseMaybeF 'ConfigPhaseMerged Text
forall (a :: OpticKind). Maybe a
Nothing,
      timeout :: ConfigPhaseMaybeF 'ConfigPhaseMerged Timeout
timeout = Maybe Timeout
ConfigPhaseMaybeF 'ConfigPhaseMerged Timeout
forall (a :: OpticKind). Maybe a
Nothing,
      commonLogging :: TomlOptF 'ConfigPhaseMerged (CommonLoggingP 'ConfigPhaseMerged)
commonLogging = CommonLoggingP 'ConfigPhaseMerged
TomlOptF 'ConfigPhaseMerged (CommonLoggingP 'ConfigPhaseMerged)
CommonLogging.defaultMerged,
      commandLogging :: TomlOptF 'ConfigPhaseMerged (CommandLoggingP 'ConfigPhaseMerged)
commandLogging = CommandLoggingP 'ConfigPhaseMerged
TomlOptF 'ConfigPhaseMerged (CommandLoggingP 'ConfigPhaseMerged)
CommandLogging.defaultMerged,
      consoleLogging :: TomlOptF 'ConfigPhaseMerged (ConsoleLoggingP 'ConfigPhaseMerged)
consoleLogging = ConsoleLoggingP 'ConfigPhaseMerged
TomlOptF 'ConfigPhaseMerged (ConsoleLoggingP 'ConfigPhaseMerged)
ConsoleLogging.defaultMerged,
      fileLogging :: ArgsOnlyDetF 'ConfigPhaseMerged (FileLoggingP 'ConfigPhaseMerged)
fileLogging = Maybe (FileLoggingP 'ConfigPhaseMerged)
ArgsOnlyDetF 'ConfigPhaseMerged (FileLoggingP 'ConfigPhaseMerged)
forall (a :: OpticKind). Maybe a
Nothing,
      notify :: ArgsOnlyDetF 'ConfigPhaseMerged (NotifyP 'ConfigPhaseMerged)
notify = Maybe (NotifyP 'ConfigPhaseMerged)
ArgsOnlyDetF 'ConfigPhaseMerged (NotifyP 'ConfigPhaseMerged)
forall (a :: OpticKind). Maybe a
Nothing
    }