-- | 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 Data.Monoid ( Monoid(..) ) import System.Console.CmdArgs.Default ( Default(..) ) -- From the harbl library. import Network.DNS.RBL.Weight ( Weight ) 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 } -- threshold :: Weight } deriving (Show) -- | A Configuration with all of its fields set to their default -- values. -- instance Default Configuration where def = Configuration { hosts = def, lists = def } -- threshold = 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 cfg) `mappend` (OC.hosts opt_cfg) all_lists = (lists cfg) `mappend` (OC.lists opt_cfg)