Safe Haskell | None |
---|---|
Language | GHC2021 |
Synopsis
- data WithDisabled a
- fromMaybe :: Maybe a -> WithDisabled a
- fromBool :: Bool -> WithDisabled ()
- toMaybe :: WithDisabled a -> Maybe a
- toBool :: WithDisabled a -> Bool
- fromWithDisabled :: a -> WithDisabled a -> a
- fromDefault :: Default a => WithDisabled a -> a
- (<>?) :: WithDisabled a -> Maybe a -> WithDisabled a
- (<>?.) :: Default a => WithDisabled a -> Maybe a -> a
- (<>??) :: WithDisabled a -> Maybe a -> Maybe a
- _With :: Prism' (WithDisabled a) a
- _Without :: Prism' (WithDisabled a) ()
- _Disabled :: Prism' (WithDisabled a) ()
Documentation
data WithDisabled a Source #
Like Maybe but adds an extra constructor representing a "disabled" state. The idea is that both CLI Args and Toml and have optional fields, but the CLI can also be "disabled", which overrides everything.
The semigroup is similar to Maybe's:
Disabled
<> _ ===Disabled
=== _ <>Disabled
Instances
Construction
fromBool :: Bool -> WithDisabled () Source #
Elimination
toBool :: WithDisabled a -> Bool Source #
fromWithDisabled :: a -> WithDisabled a -> a Source #
Eliminates WithDisabled
.
fromDefault :: Default a => WithDisabled a -> a Source #
Eliminates WithDisabled
via its Default
instance.
Misc
(<>?) :: WithDisabled a -> Maybe a -> WithDisabled a infixr 6 Source #
l <>? r
lifts Maybe
r
into a WithDisabled
per fromMaybe
then
runs the Semigroup
.
(<>?.) :: Default a => WithDisabled a -> Maybe a -> a infixr 6 Source #
Like (<>?)
except we extract a result via fromDefault
.
Optics
_With :: Prism' (WithDisabled a) a Source #
_Without :: Prism' (WithDisabled a) () Source #
_Disabled :: Prism' (WithDisabled a) () Source #