module System.Cron.Internal.Describe.Options where
import Data.Default.Class
import Data.Semigroup as Semigroup
import System.Cron.Internal.Describe.Types
data OptionBuilder = Builder (Options -> Options)
defaultOpts :: OptionBuilder
defaultOpts :: OptionBuilder
defaultOpts = (Options -> Options) -> OptionBuilder
Builder (Options -> Options -> Options
forall a b. a -> b -> a
const Options
forall a. Default a => a
def)
twentyFourHourFormat :: OptionBuilder
twentyFourHourFormat :: OptionBuilder
twentyFourHourFormat = (Options -> Options) -> OptionBuilder
Builder (\Options
o -> Options
o {timeFormat = Hour24} )
twelveHourFormat :: OptionBuilder
twelveHourFormat :: OptionBuilder
twelveHourFormat = (Options -> Options) -> OptionBuilder
Builder (\Options
o -> Options
o {timeFormat = Hour12} )
verbose :: OptionBuilder
verbose :: OptionBuilder
verbose = (Options -> Options) -> OptionBuilder
Builder (\Options
o -> Options
o {verbosity = Verbose})
notVerbose :: OptionBuilder
notVerbose :: OptionBuilder
notVerbose = (Options -> Options) -> OptionBuilder
Builder (\Options
o -> Options
o {verbosity = NotVerbose})
getOpts :: OptionBuilder -> Options
getOpts :: OptionBuilder -> Options
getOpts (Builder Options -> Options
f) = Options -> Options
f Options
forall a. Default a => a
def
data Options = Opts {
Options -> TimeFormat
timeFormat :: TimeFormat
, Options -> Verbosity
verbosity :: Verbosity
}
instance Default Options where
def :: Options
def = Opts {timeFormat :: TimeFormat
timeFormat = TimeFormat
Hour12, verbosity :: Verbosity
verbosity = Verbosity
NotVerbose}
instance Semigroup.Semigroup OptionBuilder where
(Builder Options -> Options
f) <> :: OptionBuilder -> OptionBuilder -> OptionBuilder
<> (Builder Options -> Options
a) = (Options -> Options) -> OptionBuilder
Builder (Options -> Options
a (Options -> Options) -> (Options -> Options) -> Options -> Options
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> Options
f)
instance Monoid OptionBuilder where
mempty :: OptionBuilder
mempty = (Options -> Options) -> OptionBuilder
Builder (Options -> Options -> Options
forall a b. a -> b -> a
const Options
forall a. Default a => a
def)
mappend :: OptionBuilder -> OptionBuilder -> OptionBuilder
mappend = OptionBuilder -> OptionBuilder -> OptionBuilder
forall a. Semigroup a => a -> a -> a
(<>)