@@ -33,31 +33,39 @@ getError = liftIO $ do
3333 cstr <- Raw. getError
3434 Text. decodeUtf8 <$> BS. packCString cstr
3535
36+ {-# INLINE throwIf #-}
3637throwIf :: MonadIO m => (a -> Bool ) -> Text -> Text -> m a -> m a
3738throwIf f caller funName m = do
3839 a <- m
3940 liftIO $ when (f a) $
4041 (SDLCallFailed caller funName <$> getError) >>= throwIO
4142 return a
4243
44+ {-# INLINE throwIf_ #-}
4345throwIf_ :: MonadIO m => (a -> Bool ) -> Text -> Text -> m a -> m ()
4446throwIf_ f caller funName m = throwIf f caller funName m >> return ()
4547
48+ {-# INLINE throwIfNeg #-}
4649throwIfNeg :: (MonadIO m , Num a , Ord a ) => Text -> Text -> m a -> m a
4750throwIfNeg = throwIf (< 0 )
4851
52+ {-# INLINE throwIfNeg_ #-}
4953throwIfNeg_ :: (MonadIO m , Num a , Ord a ) => Text -> Text -> m a -> m ()
5054throwIfNeg_ = throwIf_ (< 0 )
5155
56+ {-# INLINE throwIfNull #-}
5257throwIfNull :: (MonadIO m ) => Text -> Text -> m (Ptr a ) -> m (Ptr a )
5358throwIfNull = throwIf (== nullPtr)
5459
60+ {-# INLINE throwIf0 #-}
5561throwIf0 :: (Eq a , MonadIO m , Num a ) => Text -> Text -> m a -> m a
5662throwIf0 = throwIf (== 0 )
5763
64+ {-# INLINE throwIfNot0 #-}
5865throwIfNot0 :: (Eq a , MonadIO m , Num a ) => Text -> Text -> m a -> m a
5966throwIfNot0 = throwIf (/= 0 )
6067
68+ {-# INLINE throwIfNot0_ #-}
6169throwIfNot0_ :: (Eq a , MonadIO m , Num a ) => Text -> Text -> m a -> m ()
6270throwIfNot0_ = throwIf_ (/= 0 )
6371
0 commit comments