{-|
Extra megaparsec combinators.
-}
module HeadedMegaparsec.Megaparsec
where

import HeadedMegaparsec.Prelude hiding (try, head, body)
import Text.Megaparsec hiding (some, endBy1, someTill, sepBy1, sepEndBy1)
import Text.Megaparsec.Char
import Control.Applicative.Combinators
import qualified Text.Megaparsec.Char.Lexer as Lexer


contPossibly :: (Ord err, Stream strm) => Parsec err strm (Either a (Parsec err strm a)) -> Parsec err strm a
contPossibly :: Parsec err strm (Either a (Parsec err strm a)) -> Parsec err strm a
contPossibly Parsec err strm (Either a (Parsec err strm a))
p = do
  Either a (Parsec err strm a)
junction <- Parsec err strm (Either a (Parsec err strm a))
-> Parsec err strm (Either a (Parsec err strm a))
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try Parsec err strm (Either a (Parsec err strm a))
p
  case Either a (Parsec err strm a)
junction of
    Left a
a -> a -> Parsec err strm a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
    Right Parsec err strm a
cont -> Parsec err strm a
cont