module Foreign.Marshal.Error ( throwIf, throwIf_, throwIfNeg, throwIfNeg_, throwIfNull, void,) whereimport qualified Prelude(); import MiniPreludeimport Data.Functor(void)import Foreign.Ptrimport System.IO.Error(ioError, userError)throwIf :: (a -> Bool) -> (a -> String) -> IO a -> IO athrowIf pred msgfct act = do res <- act (if pred res then ioError . userError . msgfct else return) resthrowIf_ :: (a -> Bool) -> (a -> String) -> IO a -> IO ()throwIf_ pred msgfct act = void $ throwIf pred msgfct actthrowIfNeg :: (Ord a, Num a) => (a -> String) -> IO a -> IO athrowIfNeg = throwIf (< 0)throwIfNeg_ :: (Ord a, Num a) => (a -> String) -> IO a -> IO ()throwIfNeg_ = throwIf_ (< 0)throwIfNull :: String -> IO (Ptr a) -> IO (Ptr a)throwIfNull = throwIf (== nullPtr) . const