1 -- | This module defines the 'Configuration' type, which is just a
2 -- wrapper around all of the configuration options we accept on the
10 import System.Console.CmdArgs.Default (Default(..))
12 import qualified OptionalConfiguration as OC (OptionalConfiguration(..))
13 import TSN.FeedHosts (FeedHosts(..))
17 feed_hosts :: FeedHosts,
19 output_directory :: FilePath,
23 -- | A Configuration with all of its fields set to their default
25 instance Default Configuration where
26 def = Configuration def def "." def
29 -- | Merge a Configuration with an OptionalConfiguration. This is more
30 -- or less the Monoid instance for OptionalConfiguration, but since
31 -- the two types are different, we have to repeat ourselves.
32 merge_optional :: Configuration
33 -> OC.OptionalConfiguration
35 merge_optional cfg opt_cfg =
38 (merge (password cfg) (OC.password opt_cfg))
39 (merge (output_directory cfg) (OC.output_directory opt_cfg))
40 (merge (username cfg) (OC.username opt_cfg))
42 merge :: a -> Maybe a -> a
46 -- If there are any optional usernames, use only those.
47 all_feed_hosts = if (null (get_feed_hosts (OC.feed_hosts opt_cfg)))
49 else (OC.feed_hosts opt_cfg)