]> gitweb.michael.orlitzky.com - dead/htsn.git/blob - src/TSN/FeedHosts.hs
Allow a global /etc/htsnrc to override the user's ~/.htsnrc.
[dead/htsn.git] / src / TSN / FeedHosts.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2
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.
6 --
7 -- This was placed under the "TSN" namespace because its Default
8 -- instance is specific to TSN, even though otherwise it's just a
9 -- list of strings.
10 --
11 module TSN.FeedHosts
12 where
13
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)
20
21
22 newtype FeedHosts =
23 FeedHosts { get_feed_hosts :: [String] }
24 deriving (Data, Show, Typeable)
25
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
30 -- this was written.
31 def = FeedHosts ["feed1.sportsnetwork.com",
32 "feed2.sportsnetwork.com",
33 "feed3.sportsnetwork.com"]
34
35
36 instance DCT.Configured FeedHosts where
37 convert (DCT.List xs) =
38 fmap FeedHosts (mapM convert_string xs)
39 where
40 convert_string :: DCT.Value -> Maybe String
41 convert_string = DCT.convert
42
43 convert _ = Nothing
44