| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Shrun.Configuration.Data.WithDisabled
Synopsis
- data WithDisabled a
- disabledParser :: Applicative f => Text -> f a -> f (WithDisabled a)
- toMaybe :: WithDisabled a -> Maybe a
- (<|?|>) :: Maybe (WithDisabled a) -> Maybe (WithDisabled a) -> Maybe a
Documentation
data WithDisabled a Source #
WithDisabled augments some type with a disabled option. Isomorphic to
Maybe, it exists to distinguish "missing" vs. explicitly
disabled. For instance, we want to be able to disable the parameter
notify-action, but we do not want to add another constructor to it, because
we want NotifyActionComplete to represent definite actions, hence the user config
(CLI and Toml) is 'Maybe (Disabled NotifyActionComplete)' i.e.
- Just Disabled: NotifyActionComplete explicitly disabled.
- Nothing: NotifyActionComplete not given.
- Just Enabled _: NotifyActionComplete explicity enabled.
We have this for the purposes of allowing CLI the override whatever Toml parameter might exist, while at shrun's runtime it is merged to 'Maybe NotifyActionComplete':
- Nothing: Notifications off.
- Just NotifyActionComplete: Notifications on.
Instances
disabledParser :: Applicative f => Text -> f a -> f (WithDisabled a) Source #
toMaybe :: WithDisabled a -> Maybe a Source #
(<|?|>) :: Maybe (WithDisabled a) -> Maybe (WithDisabled a) -> Maybe a infixr 6 Source #
Runs Maybes Alternative instance, then binds with toMaybe. I.e., takes any Just if it exists (left-biased), then performs monadic join.