{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeApplications #-}

module Ouroboros.Consensus.Util.Assert (assertWithMsg) where

import           GHC.Stack (HasCallStack)
import           Ouroboros.Consensus.Util.RedundantConstraints

assertWithMsg :: HasCallStack => Either String () -> a -> a
#if ENABLE_ASSERTIONS
assertWithMsg :: forall a. HasCallStack => Either String () -> a -> a
assertWithMsg (Left String
msg) a
_ = String -> a
forall a. HasCallStack => String -> a
error String
msg
#endif
assertWithMsg Either String ()
_          a
a = a
a
  where
    ()
_ = Proxy HasCallStack -> ()
forall (c :: Constraint) (proxy :: Constraint -> *).
c =>
proxy c -> ()
keepRedundantConstraint (forall {k} (t :: k). Proxy t
forall (t :: Constraint). Proxy t
Proxy @HasCallStack)