--- /dev/null
+-- | This module defines the 'Configuration' type, which is just a
+-- wrapper around all of the configuration options we accept on the
+-- command line.
+--
+module Configuration (
+ Configuration(..),
+ merge_optional )
+where
+
+import System.Console.CmdArgs.Default ( Default(..) )
+
+import qualified OptionalConfiguration as OC (
+ OptionalConfiguration(..) )
+import Hosts ( Hosts(..) )
+import Lists ( Lists(..) )
+
+
+-- | The main configuration data type. This will be passed to most of
+-- the important functions once it has been created.
+--
+data Configuration =
+ Configuration {
+ hosts :: Hosts,
+ lists :: Lists }
+ deriving (Show)
+
+
+-- | A Configuration with all of its fields set to their default
+-- values.
+--
+instance Default Configuration where
+ def = Configuration { hosts = def, lists = def }
+
+
+-- | Merge a 'Configuration' with an 'OptionalConfiguration'. This is
+-- more or less the Monoid instance for 'OptionalConfiguration', but
+-- since the two types are different, we have to repeat ourselves.
+--
+merge_optional :: Configuration
+ -> OC.OptionalConfiguration
+ -> Configuration
+merge_optional cfg opt_cfg =
+ Configuration all_hosts all_lists
+ where
+ all_hosts =
+ Hosts $ (get_hosts $ hosts cfg) ++ (get_hosts $ OC.hosts opt_cfg)
+ all_lists =
+ Lists $ (get_lists $ lists cfg) ++ (get_lists $ OC.lists opt_cfg)