X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=blobdiff_plain;f=src%2FUsernames.hs;fp=src%2FUsernames.hs;h=6f2fb2874108bd436a18ad0aedde8ad4db5112a3;hp=0000000000000000000000000000000000000000;hb=dd4abc21674b98bc55a3775291a8667dffec2863;hpb=93577603f6df06e4627ca13a6f5fe412b28dc817 diff --git a/src/Usernames.hs b/src/Usernames.hs new file mode 100644 index 0000000..6f2fb28 --- /dev/null +++ b/src/Usernames.hs @@ -0,0 +1,34 @@ +{-# LANGUAGE DeriveDataTypeable #-} + +-- | A newtype around a list of Strings which represent the usernames +-- to watch. This is all to avoid an orphan instance of Configured +-- for [String] if we had defined one in e.g. OptionalConfiguration. +-- +module Usernames +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 Data.Data (Data) +import System.Console.CmdArgs.Default (Default(..)) +import Data.Typeable (Typeable) + + +newtype Usernames = + Usernames { get_usernames :: [String] } + deriving (Data, Show, Typeable) + + +instance Default Usernames where + def = Usernames [] + + +instance DCT.Configured Usernames where + convert (DCT.List xs) = + fmap Usernames (mapM convert_string xs) + where + convert_string :: DCT.Value -> Maybe String + convert_string = DCT.convert + + convert _ = Nothing