1 {-# LANGUAGE DeriveDataTypeable #-}
3 -- | A newtype around a list of Strings which represent the feed
4 -- hosts. This is all to avoid an orphan instance of Configured for
5 -- [String] if we had defined one in e.g. OptionalConfiguration.
7 -- This was placed under the "TSN" namespace because its Default
8 -- instance is specific to TSN, even though otherwise it's just a
14 -- DC is needed only for the DCT.Configured instance of String.
15 import qualified Data.Configurator as DC()
16 import qualified Data.Configurator.Types as DCT
17 import Data.Data (Data)
18 import System.Console.CmdArgs.Default (Default(..))
19 import Data.Typeable (Typeable)
23 FeedHosts { get_feed_hosts :: [String] }
24 deriving (Data, Show, Typeable)
26 instance Default FeedHosts where
27 -- | The default list of feed hosts. These were found by checking
28 -- PTR records in the neighborhood of the IP address in use. There
29 -- is a feed4.sportsnetwork.com, but it was not operational when
31 def = FeedHosts ["feed1.sportsnetwork.com",
32 "feed2.sportsnetwork.com",
33 "feed3.sportsnetwork.com"]
36 instance DCT.Configured FeedHosts where
37 convert (DCT.List xs) =
38 fmap FeedHosts (mapM convert_string xs)
40 convert_string :: DCT.Value -> Maybe String
41 convert_string = DCT.convert