haskell / attoparsec

A fast Haskell library for parsing ByteStrings
http://hackage.haskell.org/package/attoparsec
Other
514 stars 93 forks source link

Add `anyWord8` function to `Data.Attoparsec.Zepto` #205

Open RyanGlScott opened 2 years ago

RyanGlScott commented 2 years ago

I recently found use for a version of the anyWord8 function defined over Zepto, which I implemented as:

import qualified Data.ByteString.Unsafe as BSU

anyWord8 :: Monad m => ZeptoT m Word8
anyWord8 = do
  b <- Zepto.take 1
  pure (BSU.unsafeHead b)

Since this requires using Data.ByteString.Unsafe, it would be nice to define this in attoparsec itself rather than in my downstream library (which would otherwise not need to make use of unsafe ByteString functions).