2020-11-15 03:27:13 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
|
|
|
module MetaBrush.Assert
|
|
|
|
( assert )
|
|
|
|
where
|
|
|
|
|
|
|
|
-- base
|
|
|
|
#ifdef ASSERTS
|
|
|
|
import Control.Exception
|
|
|
|
( AssertionFailed(..), throw )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2021-02-23 12:14:32 +00:00
|
|
|
{-# INLINE assert #-}
|
2023-04-25 21:07:18 +00:00
|
|
|
assert :: Bool -> String -> a -> a
|
2020-11-15 03:27:13 +00:00
|
|
|
#ifdef ASSERTS
|
2023-04-25 21:07:18 +00:00
|
|
|
assert False message _ = throw ( AssertionFailed message )
|
2020-11-15 03:27:13 +00:00
|
|
|
#else
|
2023-04-25 21:07:18 +00:00
|
|
|
assert _ _ a = a
|
2020-11-15 03:27:13 +00:00
|
|
|
#endif
|