Closed basvandijk closed 12 years ago
Your changes don't compile:
Data/Configurator/Parser.hs:87:22:
No instance for (RealFloat Rational)
arising from a use of `rational'
Possible fix: add an instance declaration for (RealFloat Rational)
In the second argument of `(<$>)', namely `rational'
In the expression: Number <$> rational
In the first argument of `mconcat', namely
`[string "on" *> pure (Bool True),
string "off" *> pure (Bool False),
string "true" *> pure (Bool True),
string "false" *> pure (Bool False), ....]'
Thanks for merging this Bryan!
Hi Bryan,
I would like to use
configurator
but I need to be a able to specify Rational configuration values.I see two ways of adding these:
Number
constructor from:Number Integer
to:Number Number
where theNumber
type will be defined inattoparsec-text
(or just inconfigurator
) and will be similar to theNumber
type fromattoparsec
but uses aRational
instead of aDouble
. See the following for an implementation. The followingnumber
parser should also be defined:Number
constructor from:Number Integer
to:Number Rational
. In the previous solution, if a user wants to check if a number is an integer or a rational she can write a pattern match. In this solution this is still also possible by checking if the denominator is 1.What do you think?
(In my own private code I will go for the latter solution as that is much simpler than the former.)