merge_optional )
where
+-- System imports.
import System.Console.CmdArgs.Default ( Default(..) )
+-- Harbl library imports.
+import Network.DNS.RBL.Weight ( Weight )
+
+-- Local imports.
import qualified OptionalConfiguration as OC (
- OptionalConfiguration(..) )
+ OptionalConfiguration(..),
+ merge_maybe,
+ merge_monoid )
import Hosts ( Hosts(..) )
import Lists ( Lists(..) )
data Configuration =
Configuration {
hosts :: Hosts,
- lists :: Lists }
+ lists :: Lists,
+ threshold :: Weight }
deriving (Show)
-- values.
--
instance Default Configuration where
- def = Configuration { hosts = def, lists = def }
+ def = Configuration { hosts = def,
+ lists = def,
+ threshold = def }
-- | Merge a 'Configuration' with an 'OptionalConfiguration'. This is
merge_optional :: Configuration
-> OC.OptionalConfiguration
-> Configuration
-merge_optional cfg opt_cfg =
- Configuration all_hosts all_lists
+merge_optional cfg opt_cfg = Configuration hs ls t
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)
+ hs = OC.merge_monoid (hosts cfg) (OC.hosts opt_cfg)
+ ls = OC.merge_monoid (lists cfg) (OC.lists opt_cfg)
+ t = OC.merge_maybe (threshold cfg) (OC.threshold opt_cfg)