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 :: Parser Number
number = floaty $ \real frac fracDenom ->
if frac == 0 && fracDenom == 0
then I real
else R $! asRational real frac fracDenom
asRational :: Integer -> Integer -> Integer -> Rational
asRational real frac fracDenom = real % 1 + frac % fracDenom
What do you think?
(In my own private code I will go for the latter solution as that is much simpler than the former.)
Changed Number constructor from Integer to Rational
Fixes issue #3
Your changes don't compile:
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!