From: Michael Orlitzky Date: Sun, 2 Feb 2020 05:02:07 +0000 (-0500) Subject: src/OptionalConfiguration.hs: make OptionalConfiguration.hs a Semigroup. X-Git-Tag: 0.0.3~4 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=17ce59153f9b7aef917bb4395cf8fb992a6f738c;p=mailbox-count.git src/OptionalConfiguration.hs: make OptionalConfiguration.hs a Semigroup. 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. --- diff --git a/mailbox-count.cabal b/mailbox-count.cabal index cf30c2e..0b7fa29 100644 --- a/mailbox-count.cabal +++ b/mailbox-count.cabal @@ -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 diff --git a/src/OptionalConfiguration.hs b/src/OptionalConfiguration.hs index 2d74d27..16a61bf 100644 --- a/src/OptionalConfiguration.hs +++ b/src/OptionalConfiguration.hs @@ -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))