29 May
2009
29 May
'09
5:56 a.m.
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
6265
Age (days ago)
6265
Last active (days ago)
0 comments
1 participants
participants (1)
-
Malcolm Wallace