module Effectful.Timeout
(
Timeout
, runTimeout
, timeout
) where
import qualified System.Timeout as T
import Effectful
import Effectful.Dispatch.Static
data Timeout :: Effect
type instance DispatchOf Timeout = Static WithSideEffects
data instance StaticRep Timeout = Timeout
runTimeout :: IOE :> es => Eff (Timeout : es) a -> Eff es a
runTimeout :: Eff (Timeout : es) a -> Eff es a
runTimeout = StaticRep Timeout -> Eff (Timeout : es) a -> Eff es a
forall (e :: (Type -> Type) -> Type -> Type)
(sideEffects :: SideEffects)
(es :: [(Type -> Type) -> Type -> Type]) a.
(DispatchOf e ~ 'Static sideEffects, MaybeIOE sideEffects es) =>
StaticRep e -> Eff (e : es) a -> Eff es a
evalStaticRep StaticRep Timeout
Timeout
timeout
:: Timeout :> es
=> Int
-> Eff es a
-> Eff es (Maybe a)
timeout :: Int -> Eff es a -> Eff es (Maybe a)
timeout = (IO a -> IO (Maybe a)) -> Eff es a -> Eff es (Maybe a)
forall a b (es :: [(Type -> Type) -> Type -> Type]).
HasCallStack =>
(IO a -> IO b) -> Eff es a -> Eff es b
unsafeLiftMapIO ((IO a -> IO (Maybe a)) -> Eff es a -> Eff es (Maybe a))
-> (Int -> IO a -> IO (Maybe a))
-> Int
-> Eff es a
-> Eff es (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO a -> IO (Maybe a)
forall a. Int -> IO a -> IO (Maybe a)
T.timeout