]> gitweb.michael.orlitzky.com - mailbox-count.git/commitdiff
src/OptionalConfiguration.hs: make OptionalConfiguration.hs a Semigroup.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 2 Feb 2020 05:02:07 +0000 (00:02 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 2 Feb 2020 05:08:52 +0000 (00:08 -0500)
This fixes the build with >=ghc-8.4, where monoids must also be
semigroups. The "semigroups" package was added as a build dependency
to (hopefully) keep things working with older versions of GHC.

mailbox-count.cabal
src/OptionalConfiguration.hs

index cf30c2ec67e88a8a6d24a6324d5f41fff30fd482..0b7fa2939c12d44a816e660a433431cf01b551a3 100644 (file)
@@ -163,6 +163,7 @@ executable mailbox-count
     HDBC-postgresql             >= 2.3,
     HDBC-sqlite3                >= 2.3,
     MissingH                    >= 1.2,
+    semigroups                  >= 0.18,
     tasty                       >= 0.8,
     tasty-hunit                 >= 0.8
   main-is:
@@ -198,6 +199,7 @@ test-suite testsuite
     HDBC-postgresql             >= 2.3,
     HDBC-sqlite3                >= 2.3,
     MissingH                    >= 1.2,
+    semigroups                  >= 0.18,
     tasty                       >= 0.8,
     tasty-hunit                 >= 0.8
 
index 2d74d27965e1281f0e816ae45500af9221f67440..16a61bf802630250feb0dad9029d4e12cf1615e5 100644 (file)
@@ -21,6 +21,7 @@ import qualified Data.Configurator as DC (
 import Data.Data ( Data )
 import Data.Typeable ( Typeable )
 import Data.Monoid ( Monoid(..) )
+import Data.Semigroup ( Semigroup( (<>) ) )
 import Paths_mailbox_count ( getSysconfDir )
 import System.Directory ( getHomeDirectory )
 import System.FilePath ( (</>) )
@@ -75,8 +76,9 @@ instance Monoid OptionalConfiguration where
              Nothing
              Nothing
 
+instance Semigroup OptionalConfiguration where
   -- | Combine @cfg1@ and @cfg2@, giving precedence to @cfg2@.
-  cfg1 `mappend` cfg2 =
+  cfg1 <> cfg2 =
     OptionalConfiguration
       (merge_maybes (database cfg1) (database cfg2))
       (merge_maybes (detail cfg1) (detail cfg2))