]> gitweb.michael.orlitzky.com - dead/halcyon.git/blobdiff - src/Usernames.hs
Add configuration options for daemonize, pidfile, run_as_group and run_as_user.
[dead/halcyon.git] / src / Usernames.hs
index 6aec228ed06397873a3dc496afcf221f5dc9a19c..e31b118405c908c1eab3e09b6fc54b43d3e18cae 100644 (file)
@@ -11,8 +11,9 @@ where
 import qualified Data.Configurator as DC()
 import qualified Data.Configurator.Types as DCT
 import Data.Data ( Data )
-import System.Console.CmdArgs.Default ( Default(..) )
+import Data.Monoid ( Monoid(..) )
 import Data.Typeable ( Typeable )
+import System.Console.CmdArgs.Default ( Default(..) )
 
 
 -- | Wrapper around a list of strings (usernames).
@@ -28,6 +29,20 @@ instance Default Usernames where
   def = Usernames []
 
 
+-- | The 'Monoid' instance for 'Usernames' uses an
+--   'Monoid' instance for lists.
+--
+instance Monoid Usernames where
+  -- | The \"empty\" 'Usernames' simply wraps an empty list.
+  mempty = Usernames []
+
+  -- | This mappend is a little funny; it always chooses the second
+  --   list if that list is nonempty. Otherwise, it chooses the
+  --   first. This is actually associative!
+  u1 `mappend` u2
+    | null (get_usernames u2)  = u1
+    | otherwise = u2
+
 
 instance DCT.Configured Usernames where
   -- | This allows us to read a 'Usernames' object out of a