1 -- | A newtype around a list of Strings representing blacklists.
2 -- This is all to avoid an orphan instance of 'Configured' for
3 -- [String] if we had defined one in e.g. 'OptionalConfiguration'.
5 {-# LANGUAGE DeriveDataTypeable #-}
7 module Lists ( Lists(..) )
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 (
16 import Data.Data ( Data )
17 import System.Console.CmdArgs.Default ( Default(..) )
18 import Data.Typeable ( Typeable )
21 -- | A (wrapper around a) list of blacklists.
24 Lists { get_lists :: [String] }
25 deriving (Data, Show, Typeable)
28 -- | The default list of white/blacklists. It's empty.
30 instance Default Lists where def = Lists []
32 instance DCT.Configured Lists where
33 -- | This allows us to read a 'Lists' object out of a Configurator
34 -- config file. By default Configurator wouldn't know what to do,
35 -- so we have to tell it that we expect a list, and if that list
36 -- has strings in it, we can apply the Lists constructor to
38 convert (DCT.List xs) =
39 -- mapM gives us a Maybe [String] here.
40 fmap Lists (mapM convert_string xs)
42 convert_string :: DCT.Value -> Maybe String
43 convert_string = DCT.convert
45 -- If we read anything other than a list of values out of the file,