-- | If you are only interested in full parses of some parser @p@, enforce
-- full parses on the `Parser` level using the
-- `ParseLib.Simple.Derived.eof` combinator as in @`parse` (p <*
-- `ParseLib.Simple.Derived.eof`) input@. This ensures error reporting.
--
-- Report bugs to [gitlab](https://gitlab.com/rdnz/uu-tc-error/-/issues)
-- or @p.rednaz\@googlemail.com@, please.

module ParseLib.Simple.Core
  (
    -- * The type of parsers
    Parser,
    -- * Elementary parsers
    anySymbol,
    satisfy,
    empty,
    failp,
    succeed,
    pure,
    fail,
    expected,
    -- * Parser combinators
    (<|>),
    (<<|>),
    (<*>),
    (<$>),
    (>>=),
    -- * Lookahead
    look,
    -- * Running parsers
    parseAndTrace,
    parseWithConfig,
    parse,
  )
  where

import Data.Bifunctor (first, second)
import Data.DifferenceList (DifferenceList)
import qualified Data.DifferenceList as D
import Data.Foldable (toList)
import Data.List.NonEmpty (NonEmpty ((:|)))
import ParseLib.Error
  ( Config (Config, errorCount),
    ErrorsPretty (errorBundlePrettyImproved),
    ParseError (Fail, ParseError),
    ParseErrorBundle (ParseErrorBundle),
    defaultConfig,
    toBundle,
    traceErrorMessage,
  )
import Prelude hiding (MonadFail (..), pure, (<$>), (<*>), (>>=))

-- | An input string is mapped to a list of successful parses.
-- For each succesful parse, we return the result of type 'r',
-- and the remaining input string. The input must be a list of
-- symbols.
type Parser s r = [s] -> ([(r, [s])], DifferenceList (ParseError [s]))

fail :: String -> Parser s a
fail :: forall s a. String -> Parser s a
fail String
text [s]
input = ([], ParseError [s] -> DifferenceList (ParseError [s])
forall a. a -> DifferenceList a
D.singleton (ParseError [s] -> DifferenceList (ParseError [s]))
-> ParseError [s] -> DifferenceList (ParseError [s])
forall a b. (a -> b) -> a -> b
$ String -> [s] -> ParseError [s]
forall symbols. String -> symbols -> ParseError symbols
Fail String
text [s]
input)

expected :: [s] -> Parser s a
expected :: forall s a. [s] -> Parser s a
expected [s]
expect [s]
input = ([], ParseError [s] -> DifferenceList (ParseError [s])
forall a. a -> DifferenceList a
D.singleton (ParseError [s] -> DifferenceList (ParseError [s]))
-> ParseError [s] -> DifferenceList (ParseError [s])
forall a b. (a -> b) -> a -> b
$ [s] -> [s] -> ParseError [s]
forall symbols. symbols -> symbols -> ParseError symbols
ParseError [s]
expect [s]
input)

-- | Parses any single symbol.
anySymbol :: Parser s s
anySymbol :: forall s. Parser s s
anySymbol (s
x:[s]
xs)  =  ([(s
x,[s]
xs)], DifferenceList (ParseError [s])
forall a. Monoid a => a
mempty)
anySymbol []      =  String -> Parser s s
forall s a. String -> Parser s a
fail String
"Core.anySymbol expected any symbol." []

-- | Takes a predicate and returns a parser that parses a
-- single symbol satisfying that predicate.
satisfy  ::  (s -> Bool) -> Parser s s
satisfy :: forall s. (s -> Bool) -> Parser s s
satisfy s -> Bool
p (s
x:[s]
xs) | s -> Bool
p s
x  =  ([(s
x,[s]
xs)], DifferenceList (ParseError [s])
forall a. Monoid a => a
mempty)
satisfy s -> Bool
_ [s]
input         =  String -> Parser s s
forall s a. String -> Parser s a
fail String
"Core.satisfy expected a symbol satisfying the predicate argument." [s]
input

-- | Parser for the empty language, i.e., parser that always fails.
empty :: Parser s a
empty :: forall s a. Parser s a
empty = String -> Parser s a
forall s a. String -> Parser s a
fail String
"Core.empty"

-- | Same as 'empty'; provided for compatibility with the lecture notes.
failp :: Parser s a
failp :: forall s a. Parser s a
failp = String -> Parser s a
forall s a. String -> Parser s a
fail String
"Core.failp"

-- | Parser that always succeeds, i.e., for epsilon.
succeed :: a -> Parser s a
succeed :: forall a s. a -> Parser s a
succeed a
r [s]
xs = ([(a
r, [s]
xs)], DifferenceList (ParseError [s])
forall a. Monoid a => a
mempty)

-- | Same as 'succeed'; provided for compatiblity with the applicative
-- interface.
pure :: a -> Parser s a
pure :: forall a s. a -> Parser s a
pure = a -> Parser s a
forall a s. a -> Parser s a
succeed

infixl 4  <$>, <*>
infixr 3  <|>, <<|>
infixl 1  >>=

-- | Choice between two parsers with the same result type.
(<|>) :: Parser s a -> Parser s a -> Parser s a
(Parser s a
p <|> :: forall s a. Parser s a -> Parser s a -> Parser s a
<|> Parser s a
q) [s]
xs  =  Parser s a
p [s]
xs ([(a, [s])], DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
forall a. Semigroup a => a -> a -> a
<> Parser s a
q [s]
xs

-- | Biased choice. If the left hand side parser succeeds,
-- the right hand side is not considered. Use with care!
(<<|>) :: Parser s a -> Parser s a -> Parser s a
(Parser s a
p <<|> :: forall s a. Parser s a -> Parser s a -> Parser s a
<<|> Parser s a
q) [s]
xs  =  let pxs :: ([(a, [s])], DifferenceList (ParseError [s]))
pxs@([(a, [s])]
r, DifferenceList (ParseError [s])
es) = Parser s a
p [s]
xs in if [(a, [s])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(a, [s])]
r then (DifferenceList (ParseError [s])
 -> DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (DifferenceList (ParseError [s])
es DifferenceList (ParseError [s])
-> DifferenceList (ParseError [s])
-> DifferenceList (ParseError [s])
forall a. Semigroup a => a -> a -> a
<>) (Parser s a
q [s]
xs) else ([(a, [s])], DifferenceList (ParseError [s]))
pxs

-- | Sequence of two parsers.
(<*>) :: Parser s (b -> a) -> Parser s b -> Parser s a
(Parser s (b -> a)
p <*> :: forall s b a. Parser s (b -> a) -> Parser s b -> Parser s a
<*> Parser s b
q) [s]
xs =
  (DifferenceList (ParseError [s])
 -> DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (DifferenceList (ParseError [s])
es0 DifferenceList (ParseError [s])
-> DifferenceList (ParseError [s])
-> DifferenceList (ParseError [s])
forall a. Semigroup a => a -> a -> a
<>) (([(a, [s])], DifferenceList (ParseError [s]))
 -> ([(a, [s])], DifferenceList (ParseError [s])))
-> ([(a, [s])], DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
forall a b. (a -> b) -> a -> b
$
  ((b -> a, [s]) -> ([(a, [s])], DifferenceList (ParseError [s])))
-> [(b -> a, [s])] -> ([(a, [s])], DifferenceList (ParseError [s]))
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\(b -> a
f, [s]
ys) -> (([(b, [s])] -> [(a, [s])])
-> ([(b, [s])], DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (([(b, [s])] -> [(a, [s])])
 -> ([(b, [s])], DifferenceList (ParseError [s]))
 -> ([(a, [s])], DifferenceList (ParseError [s])))
-> ((b -> a) -> [(b, [s])] -> [(a, [s])])
-> (b -> a)
-> ([(b, [s])], DifferenceList (ParseError [s]))
-> ([(a, [s])], DifferenceList (ParseError [s]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((b, [s]) -> (a, [s])) -> [(b, [s])] -> [(a, [s])]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((b, [s]) -> (a, [s])) -> [(b, [s])] -> [(a, [s])])
-> ((b -> a) -> (b, [s]) -> (a, [s]))
-> (b -> a)
-> [(b, [s])]
-> [(a, [s])]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> a) -> (b, [s]) -> (a, [s])
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first) b -> a
f (Parser s b
q [s]
ys)) ([(b -> a, [s])] -> ([(a, [s])], DifferenceList (ParseError [s])))
-> [(b -> a, [s])] -> ([(a, [s])], DifferenceList (ParseError [s]))
forall a b. (a -> b) -> a -> b
$
  [(b -> a, [s])]
r0
  where ([(b -> a, [s])]
r0, DifferenceList (ParseError [s])
es0) = Parser s (b -> a)
p [s]
xs

-- | Map a function over the results of a parser. The '<$>' combinator
-- can also be defined in terms of 'succeed' and '<*>':
--
-- > f <$> p  =  succeed f <*> p
--
(<$>) :: (a -> b) -> Parser s a -> Parser s b
(a -> b
f <$> :: forall a b s. (a -> b) -> Parser s a -> Parser s b
<$> Parser s a
p) [s]
xs =
  (
    [(a -> b
f a
y,[s]
ys)
    |(  a
y,[s]
ys) <- [(a, [s])]
r
    ]
    ,
    DifferenceList (ParseError [s])
es0
  )
  where ([(a, [s])]
r, DifferenceList (ParseError [s])
es0) = Parser s a
p [s]
xs

-- | Monadic bind. Do not use this combinator unless absolutely
-- required. Most sequencing can be done with '<*>'.
(>>=) :: Parser s a -> (a -> Parser s b) -> Parser s b
(Parser s a
p >>= :: forall s a b. Parser s a -> (a -> Parser s b) -> Parser s b
>>= a -> Parser s b
f) [s]
xs  =
  (DifferenceList (ParseError [s])
 -> DifferenceList (ParseError [s]))
-> ([(b, [s])], DifferenceList (ParseError [s]))
-> ([(b, [s])], DifferenceList (ParseError [s]))
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (DifferenceList (ParseError [s])
es0 DifferenceList (ParseError [s])
-> DifferenceList (ParseError [s])
-> DifferenceList (ParseError [s])
forall a. Semigroup a => a -> a -> a
<>) (([(b, [s])], DifferenceList (ParseError [s]))
 -> ([(b, [s])], DifferenceList (ParseError [s])))
-> ([(b, [s])], DifferenceList (ParseError [s]))
-> ([(b, [s])], DifferenceList (ParseError [s]))
forall a b. (a -> b) -> a -> b
$
  ((a, [s]) -> ([(b, [s])], DifferenceList (ParseError [s])))
-> [(a, [s])] -> ([(b, [s])], DifferenceList (ParseError [s]))
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\(a
a, [s]
ys) -> a -> Parser s b
f a
a [s]
ys) ([(a, [s])] -> ([(b, [s])], DifferenceList (ParseError [s])))
-> [(a, [s])] -> ([(b, [s])], DifferenceList (ParseError [s]))
forall a b. (a -> b) -> a -> b
$
  [(a, [s])]
r
  where ([(a, [s])]
r, DifferenceList (ParseError [s])
es0) = Parser s a
p [s]
xs

-- | Returns the rest of the input without consuming anything.
look :: Parser s [s]
look :: forall s. Parser s [s]
look [s]
xs = ([([s]
xs, [s]
xs)], DifferenceList (ParseError [s])
forall a. Monoid a => a
mempty)

-- | Runs a parser on a given string printing error messages to standard
-- error (stderr).
--
-- The `ErrorsPretty` constraint is automatically fulfilled by `Show`
-- instances. But if you see the following GHC error, you usually need to
-- add an @(`ErrorsPretty` s)@ constraint to your function and @import
-- ParseLib.Error (`ErrorsPretty`)@.
--
-- @
-- Overlapping instances for ErrorsPretty s
-- arising from a use of ‘parseAndTrace’
-- @
--
-- `ErrorsPretty` is not defined in this package but in
-- @[uu-tc-error-error](https://hackage.haskell.org/package/uu-tc-error-error)@. We
-- did this so you can switch back and forth between this library and
-- @[uu-tc](https://hackage.haskell.org/package/uu-tc)@ without the need to
-- remove `ErrorsPretty` constraints from your code. Just permanently keep
-- @[uu-tc-error-error](https://hackage.haskell.org/package/uu-tc-error-error)@
-- in your @.cabal@ file. It does not conflict with
-- @[uu-tc](https://hackage.haskell.org/package/uu-tc)@ because there are
-- no module name collisions.
parseAndTrace ::
  (ErrorsPretty s, Ord s) => Config -> Parser s a -> [s] -> [(a, [s])]
parseAndTrace :: forall s a.
(ErrorsPretty s, Ord s) =>
Config -> Parser s a -> [s] -> [(a, [s])]
parseAndTrace Config
config Parser s a
p [s]
input =
  Either String (NonEmpty (a, [s])) -> [(a, [s])]
forall a s. Either String (NonEmpty (a, [s])) -> [(a, [s])]
traceErrorMessage (Either String (NonEmpty (a, [s])) -> [(a, [s])])
-> Either String (NonEmpty (a, [s])) -> [(a, [s])]
forall a b. (a -> b) -> a -> b
$
  (ParseErrorBundle [s] -> String)
-> Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
-> Either String (NonEmpty (a, [s]))
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Config -> [s] -> ParseErrorBundle [s] -> String
forall symbol.
ErrorsPretty symbol =>
Config -> [symbol] -> ParseErrorBundle [symbol] -> String
errorBundlePrettyImproved Config
config [s]
input) (Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
 -> Either String (NonEmpty (a, [s])))
-> Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
-> Either String (NonEmpty (a, [s]))
forall a b. (a -> b) -> a -> b
$
  Config
-> Parser s a
-> [s]
-> Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
forall s a.
Ord s =>
Config
-> Parser s a
-> [s]
-> Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
parseWithConfig Config
config Parser s a
p [s]
input

-- | Runs a parser on a given string. Pretty print the error information
-- with `errorBundlePrettyImproved`.
parseWithConfig ::
  (Ord s) =>
  Config ->
  Parser s a ->
  [s] ->
  Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
parseWithConfig :: forall s a.
Ord s =>
Config
-> Parser s a
-> [s]
-> Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
parseWithConfig (Config {Int
errorCount :: Config -> Int
errorCount :: Int
errorCount}) Parser s a
p =
  -- Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
  ([(WithLength [s], NonEmpty (BundledParseError [s]))]
 -> ParseErrorBundle [s])
-> Either
     [(WithLength [s], NonEmpty (BundledParseError [s]))]
     (NonEmpty (a, [s]))
-> Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first [(WithLength [s], NonEmpty (BundledParseError [s]))]
-> ParseErrorBundle [s]
forall symbols.
[(WithLength symbols, NonEmpty (BundledParseError symbols))]
-> ParseErrorBundle symbols
ParseErrorBundle (Either
   [(WithLength [s], NonEmpty (BundledParseError [s]))]
   (NonEmpty (a, [s]))
 -> Either (ParseErrorBundle [s]) (NonEmpty (a, [s])))
-> ([s]
    -> Either
         [(WithLength [s], NonEmpty (BundledParseError [s]))]
         (NonEmpty (a, [s])))
-> [s]
-> Either (ParseErrorBundle [s]) (NonEmpty (a, [s]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  -- Either [(WithLength [s], NonEmpty (BundledParseError [s]))] (NonEmpty (a, [s]))
  (if Int
errorCount Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0 then ([(WithLength [s], NonEmpty (BundledParseError [s]))]
 -> [(WithLength [s], NonEmpty (BundledParseError [s]))])
-> Either
     [(WithLength [s], NonEmpty (BundledParseError [s]))]
     (NonEmpty (a, [s]))
-> Either
     [(WithLength [s], NonEmpty (BundledParseError [s]))]
     (NonEmpty (a, [s]))
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Int
-> [(WithLength [s], NonEmpty (BundledParseError [s]))]
-> [(WithLength [s], NonEmpty (BundledParseError [s]))]
forall a. Int -> [a] -> [a]
take Int
errorCount) else Either
  [(WithLength [s], NonEmpty (BundledParseError [s]))]
  (NonEmpty (a, [s]))
-> Either
     [(WithLength [s], NonEmpty (BundledParseError [s]))]
     (NonEmpty (a, [s]))
forall a. a -> a
id) (Either
   [(WithLength [s], NonEmpty (BundledParseError [s]))]
   (NonEmpty (a, [s]))
 -> Either
      [(WithLength [s], NonEmpty (BundledParseError [s]))]
      (NonEmpty (a, [s])))
-> ([s]
    -> Either
         [(WithLength [s], NonEmpty (BundledParseError [s]))]
         (NonEmpty (a, [s])))
-> [s]
-> Either
     [(WithLength [s], NonEmpty (BundledParseError [s]))]
     (NonEmpty (a, [s]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  -- Either [(WithLength [s], NonEmpty (BundledParseError [s]))] (NonEmpty (a, [s]))
  ([ParseError [s]]
 -> [(WithLength [s], NonEmpty (BundledParseError [s]))])
-> Either [ParseError [s]] (NonEmpty (a, [s]))
-> Either
     [(WithLength [s], NonEmpty (BundledParseError [s]))]
     (NonEmpty (a, [s]))
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first [ParseError [s]]
-> [(WithLength [s], NonEmpty (BundledParseError [s]))]
forall s.
Ord s =>
[ParseError [s]]
-> [(WithLength [s], NonEmpty (BundledParseError [s]))]
toBundle (Either [ParseError [s]] (NonEmpty (a, [s]))
 -> Either
      [(WithLength [s], NonEmpty (BundledParseError [s]))]
      (NonEmpty (a, [s])))
-> ([s] -> Either [ParseError [s]] (NonEmpty (a, [s])))
-> [s]
-> Either
     [(WithLength [s], NonEmpty (BundledParseError [s]))]
     (NonEmpty (a, [s]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  -- Either [ParseError [s]] (NonEmpty (a, [s]))
  (DifferenceList (ParseError [s]) -> [ParseError [s]])
-> Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s]))
-> Either [ParseError [s]] (NonEmpty (a, [s]))
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first DifferenceList (ParseError [s]) -> [ParseError [s]]
forall a. DifferenceList a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s]))
 -> Either [ParseError [s]] (NonEmpty (a, [s])))
-> ([s]
    -> Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s])))
-> [s]
-> Either [ParseError [s]] (NonEmpty (a, [s]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  -- Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s]))
  (\case
    ([], DifferenceList (ParseError [s])
errors) -> DifferenceList (ParseError [s])
-> Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s]))
forall a b. a -> Either a b
Left DifferenceList (ParseError [s])
errors
    ((a, [s])
a : [(a, [s])]
b, DifferenceList (ParseError [s])
_) -> NonEmpty (a, [s])
-> Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s]))
forall a b. b -> Either a b
Right ((a, [s])
a (a, [s]) -> [(a, [s])] -> NonEmpty (a, [s])
forall a. a -> [a] -> NonEmpty a
:| [(a, [s])]
b)
  ) (([(a, [s])], DifferenceList (ParseError [s]))
 -> Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s])))
-> Parser s a
-> [s]
-> Either (DifferenceList (ParseError [s])) (NonEmpty (a, [s]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  -- ([(a, [s])], DifferenceList (ParseError [s]))
  Parser s a
p
  -- [s]

-- | Runs a parser on a given string printing error messages to standard
-- error (stderr).
--
-- Notice that, when using `parse`, you might need to add `Ord` and
-- `ErrorsPretty` constraints to your own functions and ensure your own
-- data types are @deriving (`Ord`, `Show`)@.
--
-- The `ErrorsPretty` constraint is automatically fulfilled by `Show`
-- instances. But if you see the following GHC error, you usually need to
-- add an @(`ErrorsPretty` s)@ constraint to your function and @import
-- ParseLib.Error (`ErrorsPretty`)@.
--
-- @
-- Overlapping instances for ErrorsPretty s
-- arising from a use of ‘parse’
-- @
--
-- `ErrorsPretty` is not defined in this package but in
-- @[uu-tc-error-error](https://hackage.haskell.org/package/uu-tc-error-error)@. We
-- did this so you can switch back and forth between this library and
-- @[uu-tc](https://hackage.haskell.org/package/uu-tc)@ without the need to
-- remove `ErrorsPretty` constraints from your code. Just permanently keep
-- @[uu-tc-error-error](https://hackage.haskell.org/package/uu-tc-error-error)@
-- in your @.cabal@ file. It does not conflict with
-- @[uu-tc](https://hackage.haskell.org/package/uu-tc)@ because there are
-- no module name collisions.
parse :: (ErrorsPretty s, Ord s) => Parser s a -> [s] -> [(a, [s])]
parse :: forall s a.
(ErrorsPretty s, Ord s) =>
Parser s a -> [s] -> [(a, [s])]
parse = Config -> Parser s a -> [s] -> [(a, [s])]
forall s a.
(ErrorsPretty s, Ord s) =>
Config -> Parser s a -> [s] -> [(a, [s])]
parseAndTrace Config
defaultConfig