Anut-py / h-raylib

Haskell bindings for raylib
https://hackage.haskell.org/package/h-raylib
Apache License 2.0
84 stars 14 forks source link

Considering add some helper `bracket` functions to Util in order to avoid begin* and end* syntax #23

Closed futu2 closed 1 year ago

futu2 commented 1 year ago
import Control.Monad.Catch (MonadMask, bracket_)
drawing :: (MonadIO m, MonadMask m) => m () -> m ()
drawing = bracket_ (liftIO beginDrawing) (liftIO endDrawing)

mode3D :: (MonadIO m, MonadMask m) => RL.Camera3D -> m () -> m ()
mode3D c = bracket_ (liftIO $ beginMode3D c) (liftIO endMode3D)

mode2D :: (MonadIO m, MonadMask m) => RL.Camera2D -> m () -> m ()
mode2D c = bracket_ (liftIO $ beginMode2D c) (liftIO endMode2D)
futu2 commented 1 year ago

similar things

withWindow :: (MonadIO m, MonadMask m) => Int -> Int -> String -> Int -> (WindowResources -> m b) -> m b
withWindow w h title fps = bracket (liftIO $ initWindow w h title <* setTargetFPS fps) (liftIO . closeWindow)
Anut-py commented 1 year ago

Published in 4.6.0.5