+-- | 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
+
+
+-- | Allow the configurator library to parse a 'Weight' from a config
+-- file.
+--
+-- ==== _Examples_
+--
+-- >>> import Data.Configurator () -- Get predefined 'Configured' instances.
+-- >>> import Data.Text ( pack )
+-- >>> import Data.Configurator.Types ( Value( Number, String ) )
+-- >>> let n1 = Number 2
+-- >>> convert n1 :: Maybe Weight
+-- Just (Weight 2)
+-- >>> let s = String (pack "foo1")
+-- >>> convert s :: Maybe Weight
+-- Nothing
+--
+instance Configured Weight where
+ -- Don't give us a fractional weight, we'll ignore the denominator.
+ convert (Number x) = Just (Weight (fromInteger $ numerator x))
+ convert _ = Nothing
+
+