{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}

-- | Deterministic parsers can be restricted to succeed with a single parsing result.

module Text.Parser.Deterministic where

import Control.Applicative (Alternative ((<|>), many, some), liftA2, optional)
import Control.Monad (MonadPlus, void)
import Control.Monad.Trans.Identity (IdentityT(..))
import Control.Monad.Trans.Reader (ReaderT(..), mapReaderT)
import qualified Control.Monad.Trans.Writer.Lazy as Lazy (WriterT(WriterT))
import qualified Control.Monad.Trans.Writer.Strict as Strict (WriterT(WriterT))
import qualified Control.Monad.Trans.State.Lazy as Lazy (StateT(StateT))
import qualified Control.Monad.Trans.State.Strict as Strict (StateT(StateT))
import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST(RWST))
import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST(RWST))
import Text.ParserCombinators.ReadP (ReadP)
import qualified Text.ParserCombinators.ReadP as ReadP

import Text.Parser.Combinators (Parsing, notFollowedBy, try)

import Text.Parser.Internal (mapLazyWriterT, mapStrictWriterT,
                             mapLazyStateT, mapStrictStateT,
                             mapLazyRWST, mapStrictRWST)
import Text.Parser.Wrapper (Lazy(..), Strict(..))

#ifdef MIN_VERSION_attoparsec
import qualified Data.Attoparsec.ByteString as Attoparsec
import qualified Data.Attoparsec.Text as Attoparsec.Text
#endif

#ifdef MIN_VERSION_binary
import qualified Data.Binary.Get as Binary
#endif

-- | Combinator methods for constructing deterministic parsers, /i.e./, parsers that can succeed with only a single
-- result.
class Parsing m => DeterministicParsing m where
   -- | Left-biased choice: if the left alternative succeeds, the right one is never tried.
   infixl 3 <<|>
   (<<|>) :: m a -> m a -> m a
   -- | Like 'optional', but never succeeds with @Nothing@ if the argument parser can succeed.
   takeOptional :: m a -> m (Maybe a)
   -- | Like 'many', but always consuming the longest matching sequence of input.
   takeMany :: m a -> m [a]
   -- | Like 'some', but always consuming the longest matching sequence of input.
   takeSome :: m a -> m [a]
   -- | Like 'Text.Parser.Input.concatMany', but always consuming the longest matching sequence of input.
   concatAll :: Monoid a => m a -> m a
   -- | Like 'Text.Parser.Combinators.skipMany', but always consuming the longest matching sequence of input.
   skipAll :: m a -> m ()

   m a
p <<|> m a
q = forall (m :: * -> *) a. Parsing m => m a -> m a
try m a
p forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void m a
p) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> m a
q
   takeOptional m a
p = forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
   takeMany m a
p = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many m a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void m a
p)
   takeSome m a
p = forall (f :: * -> *) a. Alternative f => f a -> f [a]
some m a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (m :: * -> *) a. (Parsing m, Show a) => m a -> m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void m a
p)
   concatAll m a
p = m a
go
      where go :: m a
go = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Monoid a => a -> a -> a
mappend m a
p m a
go forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Monoid a => a
mempty
   skipAll m a
p = m a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll m a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()

instance DeterministicParsing ReadP where
  <<|> :: forall a. ReadP a -> ReadP a -> ReadP a
(<<|>) = forall a. ReadP a -> ReadP a -> ReadP a
(ReadP.<++)

instance (Monad m, DeterministicParsing m) => DeterministicParsing (IdentityT m) where
  IdentityT m a
p <<|> :: forall a. IdentityT m a -> IdentityT m a -> IdentityT m a
<<|> IdentityT m a
q = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> m a
q)
  takeOptional :: forall a. IdentityT m a -> IdentityT m (Maybe a)
takeOptional (IdentityT m a
p) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional m a
p)
  takeMany :: forall a. IdentityT m a -> IdentityT m [a]
takeMany (IdentityT m a
p) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany m a
p)
  takeSome :: forall a. IdentityT m a -> IdentityT m [a]
takeSome (IdentityT m a
p) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome m a
p)
  concatAll :: forall a. Monoid a => IdentityT m a -> IdentityT m a
concatAll (IdentityT m a
p) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll m a
p)
  skipAll :: forall a. IdentityT m a -> IdentityT m ()
skipAll (IdentityT m a
p) = forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll m a
p)

instance (MonadPlus m, DeterministicParsing m) => DeterministicParsing (ReaderT e m) where
  ReaderT e -> m a
p <<|> :: forall a. ReaderT e m a -> ReaderT e m a -> ReaderT e m a
<<|> ReaderT e -> m a
q = forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT (\e
a-> e -> m a
p e
a forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> e -> m a
q e
a)
  takeOptional :: forall a. ReaderT e m a -> ReaderT e m (Maybe a)
takeOptional = forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional
  takeMany :: forall a. ReaderT e m a -> ReaderT e m [a]
takeMany = forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany
  takeSome :: forall a. ReaderT e m a -> ReaderT e m [a]
takeSome = forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome
  concatAll :: forall a. Monoid a => ReaderT e m a -> ReaderT e m a
concatAll = forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll
  skipAll :: forall a. ReaderT e m a -> ReaderT e m ()
skipAll = forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll

instance (MonadPlus m, DeterministicParsing m, Monoid w) => DeterministicParsing (Lazy.WriterT w m) where
  Lazy.WriterT m (a, w)
p <<|> :: forall a. WriterT w m a -> WriterT w m a -> WriterT w m a
<<|> Lazy.WriterT m (a, w)
q = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT (m (a, w)
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> m (a, w)
q)
  takeOptional :: forall a. WriterT w m a -> WriterT w m (Maybe a)
takeOptional = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapLazyWriterT forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional
  takeMany :: forall a. WriterT w m a -> WriterT w m [a]
takeMany = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapLazyWriterT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany
  takeSome :: forall a. WriterT w m a -> WriterT w m [a]
takeSome = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapLazyWriterT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome
  concatAll :: forall a. Monoid a => WriterT w m a -> WriterT w m a
concatAll = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapLazyWriterT forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll
  skipAll :: forall a. WriterT w m a -> WriterT w m ()
skipAll = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapLazyWriterT forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll

instance (MonadPlus m, DeterministicParsing m, Monoid w) => DeterministicParsing (Strict.WriterT w m) where
  Strict.WriterT m (a, w)
p <<|> :: forall a. WriterT w m a -> WriterT w m a -> WriterT w m a
<<|> Strict.WriterT m (a, w)
q = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (m (a, w)
p forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> m (a, w)
q)
  takeOptional :: forall a. WriterT w m a -> WriterT w m (Maybe a)
takeOptional = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapStrictWriterT forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional
  takeMany :: forall a. WriterT w m a -> WriterT w m [a]
takeMany = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapStrictWriterT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany
  takeSome :: forall a. WriterT w m a -> WriterT w m [a]
takeSome = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapStrictWriterT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome
  concatAll :: forall a. Monoid a => WriterT w m a -> WriterT w m a
concatAll = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapStrictWriterT forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll
  skipAll :: forall a. WriterT w m a -> WriterT w m ()
skipAll = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> WriterT w m a -> WriterT w m b
mapStrictWriterT forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll

instance (MonadPlus m, DeterministicParsing m, Monoid w) => DeterministicParsing (Lazy.StateT w m) where
  Lazy.StateT w -> m (a, w)
p <<|> :: forall a. StateT w m a -> StateT w m a -> StateT w m a
<<|> Lazy.StateT w -> m (a, w)
q = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT (\w
s-> w -> m (a, w)
p w
s forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> w -> m (a, w)
q w
s)
  takeOptional :: forall a. StateT w m a -> StateT w m (Maybe a)
takeOptional = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> StateT w m a -> StateT w m b
mapLazyStateT forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional
  takeMany :: forall a. StateT w m a -> StateT w m [a]
takeMany = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> StateT w m a -> StateT w m b
mapLazyStateT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany
  takeSome :: forall a. StateT w m a -> StateT w m [a]
takeSome = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> StateT w m a -> StateT w m b
mapLazyStateT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome
  concatAll :: forall a. Monoid a => StateT w m a -> StateT w m a
concatAll = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> StateT w m a -> StateT w m b
mapLazyStateT forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll
  skipAll :: forall a. StateT w m a -> StateT w m ()
skipAll = forall (m :: * -> *) a b w.
Applicative m =>
(m a -> m b) -> StateT w m a -> StateT w m b
mapLazyStateT forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll

instance (MonadPlus m, DeterministicParsing m, Monoid w) => DeterministicParsing (Strict.StateT w m) where
  Strict.StateT w -> m (a, w)
p <<|> :: forall a. StateT w m a -> StateT w m a -> StateT w m a
<<|> Strict.StateT w -> m (a, w)
q = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT (\w
s-> w -> m (a, w)
p w
s forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> w -> m (a, w)
q w
s)
  takeOptional :: forall a. StateT w m a -> StateT w m (Maybe a)
takeOptional = forall (m :: * -> *) a b s.
Applicative m =>
(m a -> m b) -> StateT s m a -> StateT s m b
mapStrictStateT forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional
  takeMany :: forall a. StateT w m a -> StateT w m [a]
takeMany = forall (m :: * -> *) a b s.
Applicative m =>
(m a -> m b) -> StateT s m a -> StateT s m b
mapStrictStateT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany
  takeSome :: forall a. StateT w m a -> StateT w m [a]
takeSome = forall (m :: * -> *) a b s.
Applicative m =>
(m a -> m b) -> StateT s m a -> StateT s m b
mapStrictStateT forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome
  concatAll :: forall a. Monoid a => StateT w m a -> StateT w m a
concatAll = forall (m :: * -> *) a b s.
Applicative m =>
(m a -> m b) -> StateT s m a -> StateT s m b
mapStrictStateT forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll
  skipAll :: forall a. StateT w m a -> StateT w m ()
skipAll = forall (m :: * -> *) a b s.
Applicative m =>
(m a -> m b) -> StateT s m a -> StateT s m b
mapStrictStateT forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll

instance (MonadPlus m, DeterministicParsing m, Monoid w) => DeterministicParsing (Lazy.RWST r w s m) where
  Lazy.RWST r -> s -> m (a, s, w)
p <<|> :: forall a. RWST r w s m a -> RWST r w s m a -> RWST r w s m a
<<|> Lazy.RWST r -> s -> m (a, s, w)
q = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST (\r
r s
s-> r -> s -> m (a, s, w)
p r
r s
s forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> r -> s -> m (a, s, w)
q r
r s
s)
  takeOptional :: forall a. RWST r w s m a -> RWST r w s m (Maybe a)
takeOptional = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapLazyRWST forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional
  takeMany :: forall a. RWST r w s m a -> RWST r w s m [a]
takeMany = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapLazyRWST forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany
  takeSome :: forall a. RWST r w s m a -> RWST r w s m [a]
takeSome = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapLazyRWST forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome
  concatAll :: forall a. Monoid a => RWST r w s m a -> RWST r w s m a
concatAll = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapLazyRWST forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll
  skipAll :: forall a. RWST r w s m a -> RWST r w s m ()
skipAll = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapLazyRWST forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll

instance (MonadPlus m, DeterministicParsing m, Monoid w) => DeterministicParsing (Strict.RWST r w s m) where
  Strict.RWST r -> s -> m (a, s, w)
p <<|> :: forall a. RWST r w s m a -> RWST r w s m a -> RWST r w s m a
<<|> Strict.RWST r -> s -> m (a, s, w)
q = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST (\r
r s
s-> r -> s -> m (a, s, w)
p r
r s
s forall (m :: * -> *) a. DeterministicParsing m => m a -> m a -> m a
<<|> r -> s -> m (a, s, w)
q r
r s
s)
  takeOptional :: forall a. RWST r w s m a -> RWST r w s m (Maybe a)
takeOptional = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapStrictRWST forall (m :: * -> *) a.
DeterministicParsing m =>
m a -> m (Maybe a)
takeOptional
  takeMany :: forall a. RWST r w s m a -> RWST r w s m [a]
takeMany = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapStrictRWST forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeMany
  takeSome :: forall a. RWST r w s m a -> RWST r w s m [a]
takeSome = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapStrictRWST forall (m :: * -> *) a. DeterministicParsing m => m a -> m [a]
takeSome
  concatAll :: forall a. Monoid a => RWST r w s m a -> RWST r w s m a
concatAll = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapStrictRWST forall (m :: * -> *) a.
(DeterministicParsing m, Monoid a) =>
m a -> m a
concatAll
  skipAll :: forall a. RWST r w s m a -> RWST r w s m ()
skipAll = forall (m :: * -> *) a b r w s.
Applicative m =>
(m a -> m b) -> RWST r w s m a -> RWST r w s m b
mapStrictRWST forall (m :: * -> *) a. DeterministicParsing m => m a -> m ()
skipAll

#ifdef MIN_VERSION_attoparsec
instance DeterministicParsing Attoparsec.Parser where
  <<|> :: forall a. Parser a -> Parser a -> Parser a
(<<|>) = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
  takeOptional :: forall a. Parser a -> Parser (Maybe a)
takeOptional = forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
  takeMany :: forall a. Parser a -> Parser [a]
takeMany = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many
  takeSome :: forall a. Parser a -> Parser [a]
takeSome = forall (f :: * -> *) a. Alternative f => f a -> f [a]
some
  skipAll :: forall a. Parser a -> Parser ()
skipAll = forall (f :: * -> *) a. Alternative f => f a -> f ()
Attoparsec.skipMany

instance DeterministicParsing Attoparsec.Text.Parser where
  <<|> :: forall a. Parser a -> Parser a -> Parser a
(<<|>) = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
  takeOptional :: forall a. Parser a -> Parser (Maybe a)
takeOptional = forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
  takeMany :: forall a. Parser a -> Parser [a]
takeMany = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many
  takeSome :: forall a. Parser a -> Parser [a]
takeSome = forall (f :: * -> *) a. Alternative f => f a -> f [a]
some
  skipAll :: forall a. Parser a -> Parser ()
skipAll = forall (f :: * -> *) a. Alternative f => f a -> f ()
Attoparsec.Text.skipMany
#endif

#ifdef MIN_VERSION_binary
instance DeterministicParsing (Lazy Binary.Get) where
  <<|> :: forall a. Lazy Get a -> Lazy Get a -> Lazy Get a
(<<|>) = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
  takeOptional :: forall a. Lazy Get a -> Lazy Get (Maybe a)
takeOptional = forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
  takeMany :: forall a. Lazy Get a -> Lazy Get [a]
takeMany = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many
  takeSome :: forall a. Lazy Get a -> Lazy Get [a]
takeSome = forall (f :: * -> *) a. Alternative f => f a -> f [a]
some

instance DeterministicParsing (Strict Binary.Get) where
  <<|> :: forall a. Strict Get a -> Strict Get a -> Strict Get a
(<<|>) = forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>)
  takeOptional :: forall a. Strict Get a -> Strict Get (Maybe a)
takeOptional = forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
  takeMany :: forall a. Strict Get a -> Strict Get [a]
takeMany = forall (f :: * -> *) a. Alternative f => f a -> f [a]
many
  takeSome :: forall a. Strict Get a -> Strict Get [a]
takeSome = forall (f :: * -> *) a. Alternative f => f a -> f [a]
some
#endif