]> gitweb.michael.orlitzky.com - mailbox-count.git/blobdiff - src/OptionalConfiguration.hs
mailbox-count.cabal: bump to version 0.0.8
[mailbox-count.git] / src / OptionalConfiguration.hs
index 16fad069670a8c2d47fb96a5299352889d26dd6f..95a6fdba4af28140ed6fd64a5ac9a06a47e9b6f9 100644 (file)
@@ -19,8 +19,6 @@ import qualified Data.Configurator as DC (
   load,
   lookup )
 import Data.Data ( Data )
-import Data.Monoid ( Monoid() )
-import Data.Semigroup ( Semigroup() )
 import Paths_mailbox_count ( getSysconfDir )
 import System.Directory ( getHomeDirectory )
 import System.FilePath ( (</>) )
@@ -55,26 +53,14 @@ merge_maybes Nothing (Just x)  = Just x
 merge_maybes (Just _) (Just y) = Just y
 
 
--- | The Monoid instance for these lets us "combine" two
---   OptionalConfigurations. The "combine" operation that we'd like to
---   perform is, essentially, to mash them together. So if we have two
+-- | The Semigroup instance for these lets us "combine" two
+--   configurations. The "combine" operation that we'd like to perform
+--   is, essentially, to mash them together. So if we have two
 --   OptionalConfigurations, each half full, we could combine them
 --   into one big one.
 --
 --   This is used to merge command-line and config-file settings.
 --
-instance Monoid OptionalConfiguration where
-  -- | An empty OptionalConfiguration.
-  mempty = OptionalConfiguration
-             Nothing
-             Nothing
-             Nothing
-             Nothing
-             Nothing
-             Nothing
-             Nothing
-             Nothing
-
 instance Semigroup OptionalConfiguration where
   -- | Combine @cfg1@ and @cfg2@, giving precedence to @cfg2@.
   cfg1 <> cfg2 =
@@ -89,6 +75,22 @@ instance Semigroup OptionalConfiguration where
       (merge_maybes (username cfg1) (username cfg2))
 
 
+-- | The Monoid instance essentially only provides the "empty
+--   configuration."
+instance Monoid OptionalConfiguration where
+  -- | An empty OptionalConfiguration.
+  mempty = OptionalConfiguration
+             Nothing
+             Nothing
+             Nothing
+             Nothing
+             Nothing
+             Nothing
+             Nothing
+             Nothing
+  mappend = (<>)
+
+
 -- | Obtain an OptionalConfiguration from mailbox-countrc in either
 --   the global configuration directory or the user's home
 --   directory. The one in $HOME is prefixed by a dot so that it is