Skip to content

Commit

Permalink
no longer using .Unsafe bytestring packages
Browse files Browse the repository at this point in the history
  • Loading branch information
aslatter committed Feb 2, 2008
1 parent 52e514a commit 34ea827
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
7 changes: 1 addition & 6 deletions Text/Parsec/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ module Text.Parsec.ByteString
import Text.Parsec.Error
import Text.Parsec.Prim

import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Char8 as C

instance (Monad m) => Stream C.ByteString m Char where
uncons s
| C.null s = return $ Nothing
| otherwise = return $ Just $
( toEnum $ fromEnum $ B.unsafeHead s
, B.unsafeTail s)
uncons = return . C.uncons

type Parser a = Parsec C.ByteString () a
type GenParser t st a = Parsec C.ByteString st a
Expand Down
8 changes: 1 addition & 7 deletions Text/Parsec/ByteString/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ module Text.Parsec.ByteString.Lazy
import Text.Parsec.Error
import Text.Parsec.Prim

import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Lazy.Char8 as C

instance (Monad m) => Stream C.ByteString m Char where
uncons lbs = case C.toChunks lbs of
[] -> return Nothing -- TODO: should be something better than toEnum . fromEnum
(x:xs) -> return $ Just (toEnum . fromEnum $ B.unsafeHead x,
if B.length x == 1 then C.fromChunks xs
else C.fromChunks (B.unsafeTail x:xs))
uncons = return . C.uncons

type Parser a = Parsec C.ByteString () a
type GenParser t st a = Parsec C.ByteString st a
Expand Down

0 comments on commit 34ea827

Please sign in to comment.