+-- | 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
+
+