Bryan O'Sullivan avatar Bryan O'Sullivan committed 39eeec6

Add some more combinator specialisations

Comments (0)

Files changed (1)

Data/Attoparsec/Combinator.hs

 import Control.Applicative (Alternative, Applicative(..), empty, liftA2,
                             (<|>), (*>), (<$>))
 import Data.Attoparsec.Internal.Types (Parser)
+import qualified Data.Attoparsec.Zepto as Z
 
 -- | @choice ps@ tries to apply the actions in the list @ps@ in order,
 -- until one of them succeeds. Returns the value of the succeeding
 -- action.
 choice :: Alternative f => [f a] -> f a
 {-# SPECIALIZE choice :: [Parser a] -> Parser a #-}
+{-# SPECIALIZE choice :: [Z.Parser a] -> Z.Parser a #-}
 choice = foldr (<|>) empty
 
 -- | @option x p@ tries to apply action @p@. If @p@ fails without
 -- > priority  = option 0 (digitToInt <$> digit)
 option :: Alternative f => a -> f a -> f a
 {-# SPECIALIZE option :: a -> Parser a -> Parser a #-}
+{-# SPECIALIZE option :: a -> Z.Parser a -> Z.Parser a #-}
 option x p = p <|> pure x
 
 -- | @many1 p@ applies the action @p@ /one/ or more times. Returns a
 -- > commaSep p  = p `sepBy` (symbol ",")
 sepBy :: Alternative f => f a -> f s -> f [a]
 {-# SPECIALIZE sepBy :: Parser a -> Parser s -> Parser [a] #-}
+{-# SPECIALIZE sepBy :: Z.Parser a -> Z.Parser s -> Z.Parser [a] #-}
 sepBy p s = liftA2 (:) p ((s *> sepBy1 p s) <|> pure []) <|> pure []
 
 -- | @sepBy1 p sep@ applies /one/ or more occurrences of @p@, separated
 -- > commaSep p  = p `sepBy` (symbol ",")
 sepBy1 :: Alternative f => f a -> f s -> f [a]
 {-# SPECIALIZE sepBy1 :: Parser a -> Parser s -> Parser [a] #-}
+{-# SPECIALIZE sepBy1 :: Z.Parser a -> Z.Parser s -> Z.Parser [a] #-}
 sepBy1 p s = scan
     where scan = liftA2 (:) p ((s *> scan) <|> pure [])
 
 -- therefore the use of the 'try' combinator.
 manyTill :: Alternative f => f a -> f b -> f [a]
 {-# SPECIALIZE manyTill :: Parser a -> Parser b -> Parser [a] #-}
+{-# SPECIALIZE manyTill :: Z.Parser a -> Z.Parser b -> Z.Parser [a] #-}
 manyTill p end = scan
     where scan = (end *> pure []) <|> liftA2 (:) p scan
 
 -- | Skip zero or more instances of an action.
 skipMany :: Alternative f => f a -> f ()
 {-# SPECIALIZE skipMany :: Parser a -> Parser () #-}
+{-# SPECIALIZE skipMany :: Z.Parser a -> Z.Parser () #-}
 skipMany p = scan
     where scan = (p *> scan) <|> pure ()
 
 -- | Skip one or more instances of an action.
 skipMany1 :: Alternative f => f a -> f ()
 {-# SPECIALIZE skipMany1 :: Parser a -> Parser () #-}
+{-# SPECIALIZE skipMany1 :: Z.Parser a -> Z.Parser () #-}
 skipMany1 p = p *> skipMany p
 
 -- | Apply the given action repeatedly, returning every result.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.