Andy Gimblett schrieb:
Hi Christian,
[...]
It may make sense to use something like readMaybe (which is missing in
the Prelude) instead of read to allow the parser to fail more nicely.
It seems to be kicking up reasonable errors as it is, e.g.:
*Main parse aFloat 2e-h
Left (line 1,
real :: Parser String
real = do
d - decimal
f - option $ do
p - char '.'
n - many1 digit
return $ p : n
Just to throw two bits in here, this is the only style that doesn't
require leaning on the space bar and squinting to line things up,
doesn't require any fancy editor
Hi Christian,
On 24 Feb 2010, at 13:24, Christian Maeder wrote:
I hope you don't mind if I make some style comments to your final
version.
Not at all - thanks!
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
I'm not
Andy Gimblett wrote:
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
I'm not convinced by this; perhaps while editing the code it's useful,
but those changes don't happen very often, and when they do, any
half-decent
Andy Gimblett schrieb:
For the record, here's the final improved version:
Hi Andy,
I hope you don't mind if I make some style comments to your final version.
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
2. The t ::
On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder
christian.mae...@dfki.de wrote:
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
You can also break it immediately before do, which I think is
sometimes more clear.
Ben Millwood schrieb:
On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder
christian.mae...@dfki.de wrote:
1. break the line after do
(to avoid a layout change when change name or arguments of float' or
rename the variable e)
You can also break it immediately before do, which I think is
Andy Gimblett schrieb:
Hi all,
Short version: How can I pretty print and parse values of type Double
such that those operations are each other's inverse?
Maybe you have more luck with show and read (without Parsec.Token).
Your example:
x = 9.91165677454629
fails because the computation
Short version: How can I pretty print and parse values of type Double
such that those operations are each other's inverse?
Maybe you have more luck with show and read (without Parsec.Token).
Your example:
x = 9.91165677454629
fails because the computation performed by the parser
9.0 +
For the record, here's the final improved version:
float' :: TokenParser st - GenParser Char st Double
float' t = do n - liftCtoS '-'
w - many1 digit
char '.'
f - many1 digit
e - option $ do char 'e'
n' -
10 matches
Mail list logo