X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailbox-count.git;a=blobdiff_plain;f=src%2FOptionalConfiguration.hs;fp=src%2FOptionalConfiguration.hs;h=31aa7f1f7d37566538b3db1dad9a5f9d3e0bd8cb;hp=16fad069670a8c2d47fb96a5299352889d26dd6f;hb=a70e43f3ee42517d9e18e69cf482471c626645b6;hpb=57ae0c295cb129e699a9d8bcb668ae3dd7033808 diff --git a/src/OptionalConfiguration.hs b/src/OptionalConfiguration.hs index 16fad06..31aa7f1 100644 --- a/src/OptionalConfiguration.hs +++ b/src/OptionalConfiguration.hs @@ -55,26 +55,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 +77,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