Commits

Anonymous committed a28c921

Unified 'get' and 'put' from .Internal modules.

Comments (0)

Files changed (3)

Data/Attoparsec/ByteString/Internal.hs

 import Data.Attoparsec.Combinator
 import Data.Attoparsec.Internal.Types
     hiding (Parser, Input, Added, Failure, Success)
+import Data.Attoparsec.Internal
 import Data.Monoid (Monoid(..))
 import Data.Word (Word8)
 import Foreign.ForeignPtr (withForeignPtr)
                                ks' i a m = ks i a m True
                            in prompt i0 a0 m0 kf' ks'
 
-get :: Parser B.ByteString
-get  = T.Parser $ \i0 a0 m0 _kf ks -> ks i0 a0 m0 (unI i0)
-
-put :: B.ByteString -> Parser ()
-put s = T.Parser $ \_i0 a0 m0 _kf ks -> ks (I s) a0 m0 ()
-
 -- | The parser @satisfy p@ succeeds for any byte for which the
 -- predicate @p@ returns 'True'. Returns the byte that is actually
 -- parsed.

Data/Attoparsec/Internal.hs

 module Data.Attoparsec.Internal
     (
       compareResults
+    , get
+    , put
     ) where
 
-import Data.Attoparsec.Internal.Types (IResult(..))
+import Data.Attoparsec.Internal.Types
 
 -- | Compare two 'IResult' values for equality.
 --
     Just (i0 == i1 && r0 == r1)
 compareResults (Partial _) (Partial _) = Nothing
 compareResults _ _ = Just False
+
+get :: Parser t t
+get = Parser $ \i0 a0 m0 _kf ks -> ks i0 a0 m0 (unI i0)
+{-# INLINE get #-}
+
+put :: t -> Parser t ()
+put c = Parser $ \_i0 a0 m0 _kf ks -> ks (I c) a0 m0 ()
+{-# INLINE put #-}

Data/Attoparsec/Text/Internal.hs

 import Control.Monad (when)
 import Data.Attoparsec.Combinator
 import Data.Attoparsec.Internal.Types hiding (Parser, Input, Added, Failure, Success)
+import Data.Attoparsec.Internal
 import Data.Monoid (Monoid(..))
 import Data.String (IsString(..))
 import Data.Text (Text)
                                ks' i a m = ks i a m True
                            in prompt i0 a0 m0 kf' ks'
 
-get :: Parser Text
-get  = T.Parser $ \i0 a0 m0 _kf ks -> ks i0 a0 m0 (unI i0)
-
-put :: Text -> Parser ()
-put s = T.Parser $ \_i0 a0 m0 _kf ks -> ks (I s) a0 m0 ()
-
 unsafeHead :: Text -> Char
 unsafeHead = T.head