Permalink
Browse files

Use Monoid in a few more spots

  • Loading branch information...
1 parent 525cb8c commit f844684bfd07a6f3b5148e779f4b43e52cede207 @bos committed Jan 31, 2013
@@ -71,6 +71,7 @@ import Data.Attoparsec.ByteString.FastSet (charClass, memberWord8)
import Data.Attoparsec.Combinator
import Data.Attoparsec.Internal.Types
hiding (Parser, Input, Added, Failure, Success)
+import Data.Monoid (Monoid(..))
import Data.Word (Word8)
import Foreign.ForeignPtr (withForeignPtr)
import Foreign.Ptr (castPtr, minusPtr, plusPtr)
@@ -491,12 +492,12 @@ successK i0 _a0 _m0 a = Done (unI i0) a
-- | Run a parser.
parse :: Parser a -> B.ByteString -> Result a
-parse m s = T.runParser m (I s) (A B.empty) Incomplete failK successK
+parse m s = T.runParser m (I s) mempty Incomplete failK successK
{-# INLINE parse #-}
-- | Run a parser that cannot be resupplied via a 'Partial' result.
parseOnly :: Parser a -> B.ByteString -> Either String a
-parseOnly m s = case T.runParser m (I s) (A B.empty) Complete failK successK of
+parseOnly m s = case T.runParser m (I s) mempty Complete failK successK of
Fail _ _ err -> Left err
Done _ a -> Right a
_ -> error "parseOnly: impossible error!"
@@ -143,7 +143,7 @@ instance Monad (Parser t) where
noAdds :: (Monoid t) =>
Input t -> Added t -> More
-> (Input t -> Added t -> More -> r) -> r
-noAdds i0 _a0 m0 f = f i0 (A mempty) m0
+noAdds i0 _a0 m0 f = f i0 mempty m0
{-# INLINE noAdds #-}
plus :: (Monoid t) => Parser t a -> Parser t a -> Parser t a
@@ -68,6 +68,7 @@ import Control.Applicative ((<|>), (<$>))
import Control.Monad (when)
import Data.Attoparsec.Combinator
import Data.Attoparsec.Internal.Types hiding (Parser, Input, Added, Failure, Success)
+import Data.Monoid (Monoid(..))
import Data.String (IsString(..))
import Data.Text (Text)
import Prelude hiding (getChar, take, takeWhile)
@@ -505,12 +506,12 @@ successK i0 _a0 _m0 a = Done (unI i0) a
-- | Run a parser.
parse :: Parser a -> Text -> Result a
-parse m s = runParser m (I s) (A T.empty) Incomplete failK successK
+parse m s = runParser m (I s) mempty Incomplete failK successK
{-# INLINE parse #-}
-- | Run a parser that cannot be resupplied via a 'Partial' result.
parseOnly :: Parser a -> Text -> Either String a
-parseOnly m s = case runParser m (I s) (A T.empty) Complete failK successK of
+parseOnly m s = case runParser m (I s) mempty Complete failK successK of
Fail _ _ err -> Left err
Done _ a -> Right a
_ -> error "parseOnly: impossible error!"

0 comments on commit f844684

Please sign in to comment.