{-# LANGUAGE CPP #-}
module Emacs.Module.Assert
( WithCallStack
, emacsAssert
) where
import Data.Kind (Constraint)
#ifdef CALL_STACKS
import GHC.Stack (HasCallStack)
#endif
#ifdef CALL_STACKS
type WithCallStack = (HasCallStack :: Constraint)
#else
type WithCallStack = (() :: Constraint)
#endif
#ifdef ASSERTIONS
emacsAssert :: WithCallStack => Bool -> String -> a -> a
emacsAssert True _ = id
emacsAssert False msg = error $ "Assertion failed: " ++ msg
#else
{-# INLINE emacsAssert #-}
emacsAssert :: Bool -> String -> a -> a
emacsAssert :: forall a. Bool -> String -> a -> a
emacsAssert Bool
_ String
_ = forall a. a -> a
id
#endif