[Haskell-cafe] String to Double conversion in Haskell

Thomas Davie tom.davie at gmail.com
Sun Aug 24 17:33:47 EDT 2008


On 24 Aug 2008, at 23:23, Don Stewart wrote:

> dmehrtash:
>>   I am trying to convert a string to a float.  It seems that  
>> Data.ByteString
>>   library only supports readInt.    After some googling I came  
>> accross a
>>   possibloe implementation: [1]http://sequence.svcs.cs.pdx.edu/node/373
>>
>
> Use the bytstring-lexing library,
>
>    http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-lexing
>
> Which provides a copying and non-copying lexer for doubles,
>
>    readDouble       :: ByteString -> Maybe (Double, ByteString)
>    unsafeReadDouble :: ByteString -> Maybe (Double, ByteString)

Incidentally, is there any reason we can't have this for Lazy BSes?

Bob


More information about the Haskell-Cafe mailing list