]> gitweb.michael.orlitzky.com - dead/harbl.git/blob - harbl-cli/src/Lists.hs
Clean up the configurator code in the CLI app.
[dead/harbl.git] / harbl-cli / src / Lists.hs
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'.
4 --
5 {-# LANGUAGE DeriveDataTypeable #-}
6 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
7
8 module Lists ( Lists(..) )
9 where
10
11 import Data.Configurator () -- Needed for predefined instances.
12 import Data.Configurator.Types ( Configured(..) )
13 import Data.Data ( Data )
14 import Data.Monoid ( Monoid )
15 import System.Console.CmdArgs.Default ( Default(..) )
16 import Data.Typeable ( Typeable )
17
18 import Configurator ( convert_newtype_list )
19
20
21 -- | A (wrapper around a) list of blacklists.
22 --
23 newtype Lists =
24 Lists { get_lists :: [String] }
25 deriving (Data, Monoid, Show, Typeable)
26
27
28 -- | The default list of white/blacklists. It's empty.
29 --
30 instance Default Lists where def = Lists []
31
32 instance 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 convert = convert_newtype_list Lists