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(..) )
11 import System.Log ( Priority( INFO ) )
13 import Backend ( Backend(..) )
14 import qualified OptionalConfiguration as OC (
15 OptionalConfiguration(..),
18 -- | The main configuration data type. This will be passed to most of
19 -- the important functions once it has been created.
23 connection_string :: String,
24 log_file :: Maybe FilePath,
25 log_level :: Priority,
29 -- | A Configuration with all of its fields set to their default
31 instance Default Configuration where
34 connection_string = def,
40 -- | Merge a Configuration with an OptionalConfiguration. This is more
41 -- or less the Monoid instance for OptionalConfiguration, but since
42 -- the two types are different, we have to repeat ourselves.
43 merge_optional :: Configuration
44 -> OC.OptionalConfiguration
46 merge_optional cfg opt_cfg =
48 (merge (backend cfg) (OC.backend opt_cfg))
49 (merge (connection_string cfg) (OC.connection_string opt_cfg))
50 (OC.merge_maybes (log_file cfg) (OC.log_file opt_cfg))
51 (merge (log_level cfg) (OC.log_level opt_cfg))
52 (merge (syslog cfg) (OC.syslog opt_cfg))
54 -- | If the thing on the right is Just something, return that
55 -- something, otherwise return the thing on the left.
56 merge :: a -> Maybe a -> a