[Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles?

Andy Gimblett haskell at gimbo.org.uk
Tue Feb 23 16:55:41 EST 2010


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' <- liftCtoS '-'
                                   m <- many1 digit
                                   return $ concat ["e", n', m]
               whiteSpace t
               return $ read $ concat [n, w, ".", f, e]
   where liftCtoS a = option "" (char a >> return [a])

Thanks for all the help, again.

-Andy

--
Andy Gimblett
http://gimbo.org.uk/



More information about the Haskell-Cafe mailing list