Commits

Mario Blažević  committed 8c9256c

Moved the Monoid instance of Parser into Data.Attoparsec.Types.

  • Participants
  • Parent commits c3841e1

Comments (0)

Files changed (9)

File Data/Attoparsec/ByteString.hs

 import qualified Data.ByteString as B
 import Data.Attoparsec.ByteString.Internal (Result, parse)
 import qualified Data.Attoparsec.Types.Internal as T
+import qualified Data.Attoparsec.Types ()
 
 -- $parsec
 --

File Data/Attoparsec/ByteString/Internal.hs

 import Foreign.Storable (Storable(peek, sizeOf))
 import Prelude hiding (getChar, take, takeWhile)
 import qualified Data.Attoparsec.Types.Internal as T
+import qualified Data.Attoparsec.Types ()
 import qualified Data.ByteString as B8
 import qualified Data.ByteString.Char8 as B
 import qualified Data.ByteString.Internal as B

File Data/Attoparsec/ByteString/Lazy.hs

 import qualified Data.ByteString as B
 import qualified Data.Attoparsec.ByteString as A
 import qualified Data.Attoparsec.Types.Internal as T
+import qualified Data.Attoparsec.Types ()
 import Data.Attoparsec.ByteString
     hiding (IResult(..), Result, eitherResult, maybeResult,
             parse, parseWith, parseTest)

File Data/Attoparsec/Combinator.hs

 #endif
 
 #if __GLASGOW_HASKELL__ >= 700
-import Data.Attoparsec.Types.Internal (Parser)
+import Data.Attoparsec.Types (Parser)
 import qualified Data.Attoparsec.Zepto as Z
 import Data.ByteString (ByteString)
 import Data.Text (Text)

File Data/Attoparsec/Text.hs

 import Data.Word (Word8, Word16, Word32, Word64, Word)
 import qualified Data.Attoparsec.Internal as I
 import qualified Data.Attoparsec.Types.Internal as T
+import qualified Data.Attoparsec.Types ()
 import qualified Data.Attoparsec.Text.Internal as I
 import qualified Data.Text as T
 

File Data/Attoparsec/Text/Internal.hs

+
 {-# LANGUAGE BangPatterns, CPP, FlexibleInstances, GADTs, OverloadedStrings,
     Rank2Types, RecordWildCards, TypeFamilies, TypeSynonymInstances #-}
 {-# OPTIONS_GHC -fno-warn-orphans #-}
 import Prelude hiding (getChar, take, takeWhile)
 import Data.Char (chr, ord)
 import qualified Data.Attoparsec.Types.Internal as T
+import qualified Data.Attoparsec.Types ()
 import qualified Data.Attoparsec.Text.FastSet as Set
 import qualified Data.Text as T
 import qualified Data.Text.Internal as T

File Data/Attoparsec/Text/Lazy.hs

 import Control.DeepSeq (NFData(rnf))
 import Data.Text.Lazy.Internal (Text(..), chunk)
 import qualified Data.Attoparsec.Types.Internal as T
+import qualified Data.Attoparsec.Types ()
 import qualified Data.Attoparsec.Text as A
 import qualified Data.Text as T
 import Data.Attoparsec.Text hiding (IResult(..), Result, eitherResult,

File Data/Attoparsec/Types.hs

+{-# OPTIONS_GHC -fno-warn-orphans #-}
 -- |
 -- Module      :  Data.Attoparsec.Types
 -- Copyright   :  Bryan O'Sullivan 2011
     , IResult(..)
     ) where
 
+import Control.Applicative (Alternative(..))
+import Data.Monoid (Monoid(..))
 import Data.Attoparsec.Types.Internal (Parser(..), IResult(..))
+
+instance (Monoid t) => Monoid (Parser t a) where
+    mempty  = empty
+    {-# INLINE mempty #-}
+    mappend = (<|>)
+    {-# INLINE mappend #-}

File Data/Attoparsec/Types/Internal.hs

 --
 -- Simple, efficient parser combinators, loosely based on the Parsec
 -- library.
+--
+-- You should not use this module unless you really need the type 
+-- definition internals. Furthermore, some of the type instances are 
+-- orphans defined in "Data.Attoparsec.Types", so you should import that 
+-- module as well.
 
 module Data.Attoparsec.Types.Internal
     (
 --   arbitrary lookahead.)
 --
 -- * 'Alternative', which follows 'MonadPlus'.
+--
+-- * 'Monoid', which follows 'Alternative', is defined in 
+--   module "Data.Attoparsec.Types".
 newtype Parser t a = Parser {
       runParser :: forall r. Input t -> Added t -> More
                 -> Failure t   r
     {-# INLINE (<*) #-}
 #endif
 
-instance (Monoid t) => Monoid (Parser t a) where
-    mempty  = failDesc "mempty"
-    {-# INLINE mempty #-}
-    mappend = plus
-    {-# INLINE mappend #-}
-
 instance (Monoid t) => Alternative (Parser t) where
     empty = failDesc "empty"
     {-# INLINE empty #-}