packages feed

dear-imgui-raw-1.0.0: src/DearImGui/Bracket.hs

-- | Unlifted create\/destroy scope shared by the context and backend-init brackets.
module DearImGui.Bracket
  ( withCreated
  ) where

import Control.Exception (bracket)
import Control.Monad.IO.Unlift (MonadUnliftIO, withRunInIO)

withCreated :: (MonadUnliftIO m) => IO resource -> (resource -> IO ()) -> m a -> m a
withCreated create destroy body =
  withRunInIO \run ->
    bracket create destroy (const (run body))