{-# LANGUAGE Safe #-}
{-# OPTIONS_HADDOCK hide #-}
{-# OPTIONS_GHC -Wno-all-missed-specialisations #-}
module Text.Gigaparsec.Internal.Require (require, RequirementUnsatisfied) where

import Control.Exception (Exception, throw)

type RequirementUnsatisfied :: *
data RequirementUnsatisfied = RequirementUnsatisfied { RequirementUnsatisfied -> String
func :: !String
                                                     , RequirementUnsatisfied -> String
msg :: !String
                                                     }

instance Show RequirementUnsatisfied where
  show :: RequirementUnsatisfied -> String
  show :: RequirementUnsatisfied -> String
show RequirementUnsatisfied{String
func :: RequirementUnsatisfied -> String
msg :: RequirementUnsatisfied -> String
func :: String
msg :: String
..} = String
"requirement unsatisfied, " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
msg String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
func String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"

instance Exception RequirementUnsatisfied

require :: Bool -> String -> String -> a -> a
require :: forall a. Bool -> String -> String -> a -> a
require Bool
True String
_ String
_ = a -> a
forall a. a -> a
id
require Bool
False String
func String
msg = RequirementUnsatisfied -> a -> a
forall a e. Exception e => e -> a
throw (String -> String -> RequirementUnsatisfied
RequirementUnsatisfied String
func String
msg)