module CabalGild.Type.Optional where
data Optional a
= Default
| Specific a
deriving (Optional a -> Optional a -> Bool
(Optional a -> Optional a -> Bool)
-> (Optional a -> Optional a -> Bool) -> Eq (Optional a)
forall a. Eq a => Optional a -> Optional a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Optional a -> Optional a -> Bool
== :: Optional a -> Optional a -> Bool
$c/= :: forall a. Eq a => Optional a -> Optional a -> Bool
/= :: Optional a -> Optional a -> Bool
Eq, Int -> Optional a -> ShowS
[Optional a] -> ShowS
Optional a -> String
(Int -> Optional a -> ShowS)
-> (Optional a -> String)
-> ([Optional a] -> ShowS)
-> Show (Optional a)
forall a. Show a => Int -> Optional a -> ShowS
forall a. Show a => [Optional a] -> ShowS
forall a. Show a => Optional a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Optional a -> ShowS
showsPrec :: Int -> Optional a -> ShowS
$cshow :: forall a. Show a => Optional a -> String
show :: Optional a -> String
$cshowList :: forall a. Show a => [Optional a] -> ShowS
showList :: [Optional a] -> ShowS
Show)
withDefault :: a -> Optional a -> a
withDefault :: forall a. a -> Optional a -> a
withDefault = (a -> (a -> a) -> Optional a -> a)
-> (a -> a) -> a -> Optional a -> a
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> (a -> a) -> Optional a -> a
forall b a. b -> (a -> b) -> Optional a -> b
optional a -> a
forall a. a -> a
id
optional :: b -> (a -> b) -> Optional a -> b
optional :: forall b a. b -> (a -> b) -> Optional a -> b
optional b
b a -> b
f Optional a
o = case Optional a
o of
Optional a
Default -> b
b
Specific a
s -> a -> b
f a
s