]> gitweb.michael.orlitzky.com - dead/htsn.git/blob - src/FeedHosts.hs
Initial commit of something working.
[dead/htsn.git] / src / 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 module FeedHosts
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 FeedHosts =
19 FeedHosts { get_feed_hosts :: [String] }
20 deriving (Data, Show, Typeable)
21
22
23 instance Default FeedHosts where
24 def = FeedHosts ["feed1.sportsnetwork.com",
25 "feed2.sportsnetwork.com",
26 "feed3.sportsnetwork.com"]
27
28
29 instance DCT.Configured FeedHosts where
30 convert (DCT.List xs) =
31 fmap FeedHosts (mapM convert_string xs)
32 where
33 convert_string :: DCT.Value -> Maybe String
34 convert_string = DCT.convert
35
36 convert _ = Nothing
37