]> gitweb.michael.orlitzky.com - dead/htsn.git/blobdiff - src/TSN/FeedHosts.hs
Add scaffolding to allow logging via syslog or a file.
[dead/htsn.git] / src / TSN / FeedHosts.hs
index 0b2056ec3ee983587b2ed74133ebfebc15fa6bdd..d2f295bea53a1a1ff40a448b07983c7a9cd216e3 100644 (file)
@@ -13,7 +13,10 @@ where
 
 -- DC is needed only for the DCT.Configured instance of String.
 import qualified Data.Configurator as DC()
-import qualified Data.Configurator.Types as DCT
+import qualified Data.Configurator.Types as DCT (
+  Configured,
+  Value( List ),
+  convert )
 import Data.Data (Data)
 import System.Console.CmdArgs.Default (Default(..))
 import Data.Typeable (Typeable)
@@ -34,11 +37,18 @@ instance Default FeedHosts where
 
 
 instance DCT.Configured FeedHosts where
+  -- | This allows us to read a FeedHosts object out of a Configurator
+  --   config file. By default Configurator wouldn't know what to do,
+  --   so we have to tell it that we expect a list, and if that list
+  --   has strings in it, we can apply the FeedHosts constructor to
+  --   it.
   convert (DCT.List xs) =
+    -- mapM gives us a Maybe [String] here.
     fmap FeedHosts (mapM convert_string xs)
     where
       convert_string :: DCT.Value -> Maybe String
       convert_string = DCT.convert
 
+  -- If we read anything other than a list of values out of the file,
+  -- fail.
   convert _ = Nothing
-