]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/Usernames.hs
92e5c4376f77fc2416044941ee3457f0597727cc
[dead/halcyon.git] / src / Usernames.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2
3 -- | A newtype around a list of Strings which represent the usernames
4 -- to watch. This is all to avoid an orphan instance of Configured
5 -- for [String] if we had defined one in e.g. OptionalConfiguration.
6 --
7 module Usernames ( Usernames(..) )
8 where
9
10 -- DC is needed only for the DCT.Configured instance of String.
11 import qualified Data.Configurator as DC()
12 import qualified Data.Configurator.Types as DCT
13 import Data.Data ( Data )
14 import System.Console.CmdArgs.Default ( Default(..) )
15 import Data.Typeable ( Typeable )
16
17
18 newtype Usernames =
19 Usernames { get_usernames :: [String] }
20 deriving (Data, Show, Typeable)
21
22
23 instance Default Usernames where
24 def = Usernames []
25
26
27 instance DCT.Configured Usernames where
28 convert (DCT.List xs) =
29 fmap Usernames (mapM convert_string xs)
30 where
31 convert_string :: DCT.Value -> Maybe String
32 convert_string = DCT.convert
33
34 convert _ = Nothing