module Streamly.Internal.Control.Exception
( assertM
, verify
, verifyM
)
where
import Control.Exception (assert)
{-# INLINE assertM #-}
assertM :: Applicative f => Bool -> f ()
assertM :: Bool -> f ()
assertM Bool
predicate = Bool -> f () -> f ()
forall a. (?callStack::CallStack) => Bool -> a -> a
assert Bool
predicate (() -> f ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
{-# INLINE verify #-}
verify :: Bool -> a -> a
verify :: Bool -> a -> a
verify Bool
predicate a
val =
if Bool
predicate
then [Char] -> a
forall a. (?callStack::CallStack) => [Char] -> a
error [Char]
"verify failed"
else a
val
{-# INLINE verifyM #-}
verifyM :: Applicative f => Bool -> f ()
verifyM :: Bool -> f ()
verifyM Bool
predicate = Bool -> f () -> f ()
forall a. Bool -> a -> a
verify Bool
predicate (() -> f ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())