[Haskell-cafe] ANN: bytestring-lexing 0.3.0

Erik de Castro Lopo mle+hs at mega-nerd.com
Sun Jan 29 09:43:58 CET 2012


Wren,

I notice that readDecimal has a typesig:


    readDecimal :: Integral a => ByteString -> Maybe (a, ByteString)

which I would then use in Warp as:

    readInt64BSL :: ByteString -> Int64
    readInt64BSL bs = fst $ fromMaybe (0, "") $ BSL.readDecimal bs

However, this version with the fromMaybe and fst is a little slower
than if these two extra bits weren't necessary.

Would you consider a function with the following signature in
bytestring-lexing?

    readDecimalX :: Integral a => ByteString -> a

The idea is that it gives something faster for applications like Warp
where reading an valid decimal should be as fast as possible, but if
the string isn't valid it doesn't really matter what the result is.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



More information about the Haskell-Cafe mailing list