X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fharbl.git;a=blobdiff_plain;f=harbl%2Fsrc%2FNetwork%2FDNS%2FRBL%2FWeight.hs;h=8447ab35cbd5de48411e68520ec9bbc16e440c74;hp=e56bcd06496704e4c37e6c6ffaa26a08af9a763d;hb=6eb7fe0f53b0d8690a821cce9257b8b1a17fdaad;hpb=67a990c746599a0f64cffa8dd92157626fc4654e diff --git a/harbl/src/Network/DNS/RBL/Weight.hs b/harbl/src/Network/DNS/RBL/Weight.hs index e56bcd0..8447ab3 100644 --- a/harbl/src/Network/DNS/RBL/Weight.hs +++ b/harbl/src/Network/DNS/RBL/Weight.hs @@ -15,6 +15,7 @@ module Network.DNS.RBL.Weight ( weight ) where +import System.Console.CmdArgs.Default ( Default(..) ) import Text.Parsec ( (<|>), char, @@ -47,7 +48,7 @@ import Network.DNS.RBL.Pretty ( Pretty(..) ) -- >>> sum [w1, w2, w3] -- Weight 4 -- -newtype Weight = Weight Int deriving (Eq, Num, Show) +newtype Weight = Weight Int deriving (Eq, Num, Ord, Show) -- | Pretty-print a 'Weight'. This just shows/prints the underlying 'Int'. @@ -61,6 +62,18 @@ instance Pretty Weight where pretty_show (Weight w) = show w +-- | Set a default value for the weight. We use the 'Default' class +-- from the CmdArgs class so that 'Weight's can be easily parsed on +-- the command-line. +-- +-- ==== _Examples_ +-- +-- >>> def :: Weight +-- Weight 1 +-- +instance Default Weight where def = 1 + + -- | Parse the weight multiplier off the end of an input 'Site'. This -- expects there to be a \"multiplier\" character (an asterisk) -- before the integral weight.