module Prettyprinter.Render.Util.Panic (
    panicUncaughtFail,
    panicUnpairedPop,
    panicSimpleDocTreeConversionFailed,
    panicInputNotFullyConsumed,
    panicPeekedEmpty,
    panicPoppedEmpty,
) where

-- | Raise a hard 'error' if there is a 'Prettyprinter.SFail' in a
-- 'Prettyprinter.SimpleDocStream'.
panicUncaughtFail :: void
panicUncaughtFail :: void
panicUncaughtFail = [Char] -> void
forall a. HasCallStack => [Char] -> a
error ([Char]
"»SFail« must not appear in a rendered »SimpleDocStream«. This is a bug in the layout algorithm! " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
report)

-- | Raise a hard 'error' when an annotation terminator is encountered in an
-- unannotated region.
panicUnpairedPop :: void
panicUnpairedPop :: void
panicUnpairedPop = [Char] -> void
forall a. HasCallStack => [Char] -> a
error ([Char]
"An unpaired style terminator was encountered. This is a bug in the layout algorithm! " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
report)

-- | Raise a hard generic 'error' when the
-- 'Prettyprinter.SimpleDocStream' to
-- 'Prettyprinter.Render.Util.SimpleDocTree.SimpleDocTree' conversion fails.
panicSimpleDocTreeConversionFailed :: void
panicSimpleDocTreeConversionFailed :: void
panicSimpleDocTreeConversionFailed = [Char] -> void
forall a. HasCallStack => [Char] -> a
error ([Char]
"Conversion from SimpleDocStream to SimpleDocTree failed! " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
report)

-- | Raise a hard 'error' when the »to
-- 'Prettyprinter.Render.Util.SimpleDocTree.SimpleDocTree'« parser finishes
-- without consuming the full input.
panicInputNotFullyConsumed :: void
panicInputNotFullyConsumed :: void
panicInputNotFullyConsumed = [Char] -> void
forall a. HasCallStack => [Char] -> a
error ([Char]
"Conversion from SimpleDocStream to SimpleDocTree left unconsumed input! " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
report)

report :: String
report :: [Char]
report = [Char]
"Please report this as a bug"

panicPeekedEmpty, panicPoppedEmpty :: void
(void
panicPeekedEmpty, void
panicPoppedEmpty) = ([Char] -> void
forall a. [Char] -> a
mkErr [Char]
"Peeked", [Char] -> void
forall a. [Char] -> a
mkErr [Char]
"Popped")
  where
    mkErr :: [Char] -> a
mkErr [Char]
x = [Char] -> a
forall a. HasCallStack => [Char] -> a
error ([Char]
x [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" an empty style stack! Please report this as a bug.")