-- | Lifted "Control.Concurrent.QSem".
module Effectful.Concurrent.QSem
  ( -- * Effect
    Concurrent

    -- ** Handlers
  , runConcurrent

    -- * QSem
  , QSem
  , newQSem
  , waitQSem
  , signalQSem
  ) where

import Control.Concurrent.QSem (QSem)
import qualified Control.Concurrent.QSem as Q

import Effectful
import Effectful.Concurrent.Effect
import Effectful.Dispatch.Static

-- | Lifted 'Q.newQSem'.
newQSem :: Concurrent :> es => Int -> Eff es QSem
newQSem :: forall (es :: [Effect]). (Concurrent :> es) => Int -> Eff es QSem
newQSem = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO QSem
Q.newQSem

-- | Lifted 'Q.waitQSem'.
waitQSem :: Concurrent :> es => QSem -> Eff es ()
waitQSem :: forall (es :: [Effect]). (Concurrent :> es) => QSem -> Eff es ()
waitQSem = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. QSem -> IO ()
Q.waitQSem

-- | Lifted 'Q.signalQSem'.
signalQSem :: Concurrent :> es => QSem -> Eff es ()
signalQSem :: forall (es :: [Effect]). (Concurrent :> es) => QSem -> Eff es ()
signalQSem = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. QSem -> IO ()
Q.signalQSem