{-# LANGUAGE Safe #-}
module Text.Gigaparsec.Errors.Combinator (module Text.Gigaparsec.Errors.Combinator) where

import Text.Gigaparsec (Parsec)
-- We want to use this to make the docs point to the right definition for users.
--import Text.Gigaparsec.Internal qualified as Internal (Parsec(Parsec))
import Text.Gigaparsec.Internal.Require (require)

import Data.Set (Set)

-- the empty set is weird here, do we require non-empty or just make it id?
label :: Set String -> Parsec a -> Parsec a
label :: forall a. Set String -> Parsec a -> Parsec a
label Set String
ls =
  forall a. Bool -> String -> String -> a -> a
require (Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any forall (t :: * -> *) a. Foldable t => t a -> Bool
null Set String
ls)) String
"Text.Gigaparsec.Errors.Combinator.label" String
"labels cannot be empty" forall a. a -> a
id --TODO:

{-# INLINE (<?>) #-}
infix 0 <?>
(<?>) :: Parsec a -> Set String -> Parsec a
<?> :: forall a. Parsec a -> Set String -> Parsec a
(<?>) = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a. Set String -> Parsec a -> Parsec a
label