{-# LANGUAGE Safe #-}
{-# LANGUAGE GADTs, NamedFieldPuns, BinaryLiterals, NumericUnderscores, DataKinds, BangPatterns #-}
{-# OPTIONS_HADDOCK hide #-}
{-# OPTIONS_GHC -Wno-missing-import-lists #-}
module Text.Gigaparsec.Internal.Errors.DefuncHints (
    DefuncHints(Blank),
    replace, addError
  ) where

import Text.Gigaparsec.Internal.Errors.DefuncTypes (
    DefuncHints(Blank, Replace, AddErr),
    DefuncError(DefuncError), ErrKindSingleton(IsVanilla)
  )

import Data.Set (Set)

{-# INLINABLE replace #-}
replace :: Set String -> DefuncHints -> DefuncHints
replace :: Set String -> DefuncHints -> DefuncHints
replace !Set String
_ DefuncHints
Blank = DefuncHints
Blank
replace Set String
ls DefuncHints
_      = Set String -> DefuncHints
Replace Set String
ls

{-# INLINABLE addError #-}
addError :: DefuncHints -> DefuncError -> DefuncHints
addError :: DefuncHints -> DefuncError -> DefuncHints
addError DefuncHints
hints (DefuncError ErrKindSingleton k
IsVanilla Word32
_ Word
_ Word
_ DefuncError_ k
err) = DefuncHints -> DefuncError_ 'Vanilla -> DefuncHints
AddErr DefuncHints
hints DefuncError_ k
DefuncError_ 'Vanilla
err
addError DefuncHints
_ DefuncError
_ = String -> DefuncHints
forall a. HasCallStack => String -> a
error String
"invariance broken: a specialised error is never added to hints"