is there any reason why float parses only positive numbers?

It is usual in parsing libraries to separate the recognition of a leading sign from recognition of the number itself: the sign-only parser can be reused in many contexts, e.g. in the Haskell'98 Numeric library, there is

 readSigned :: Real a => ReadS a -> ReadS a

which takes a secondary parser as its argument. You can instantiate that argument to any of

 readDec   :: Num a => ReadS a
 readHex   :: Num a => ReadS a
 readFloat :: Num a => ReadS a

etc. I do not know if the equivalent of "readSigned" exists in Parsec, but it in polyparse's Text.Parse module, it is called "parseSigned", rather unsurprisingly.

Regards,
    Malcolm

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to