module Control.Monad.Schedule.Yield where
import qualified Control.Concurrent as Concurrent
import Control.Monad.IO.Class
import Data.Functor.Identity (Identity (runIdentity))
import Control.Monad.Schedule.Class
import Control.Monad.Schedule.Trans
type YieldT = ScheduleT ()
type Yield = YieldT Identity
yield :: Monad m => YieldT m ()
yield :: YieldT m ()
yield = () -> YieldT m ()
forall (m :: * -> *) diff. Monad m => diff -> ScheduleT diff m ()
wait ()
runYieldT :: Monad m => YieldT m a -> m a
runYieldT :: YieldT m a -> m a
runYieldT = (() -> m ()) -> YieldT m a -> m a
forall (m :: * -> *) diff a.
Monad m =>
(diff -> m ()) -> ScheduleT diff m a -> m a
runScheduleT ((() -> m ()) -> YieldT m a -> m a)
-> (() -> m ()) -> YieldT m a -> m a
forall a b. (a -> b) -> a -> b
$ m () -> () -> m ()
forall a b. a -> b -> a
const (m () -> () -> m ()) -> m () -> () -> m ()
forall a b. (a -> b) -> a -> b
$ () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
runYield :: Yield a -> a
runYield :: Yield a -> a
runYield = Identity a -> a
forall a. Identity a -> a
runIdentity (Identity a -> a) -> (Yield a -> Identity a) -> Yield a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Yield a -> Identity a
forall (m :: * -> *) a. Monad m => YieldT m a -> m a
runYieldT
runYieldIO
:: MonadIO m
=> YieldT m a -> m a
runYieldIO :: YieldT m a -> m a
runYieldIO = (() -> m ()) -> YieldT m a -> m a
forall (m :: * -> *) diff a.
Monad m =>
(diff -> m ()) -> ScheduleT diff m a -> m a
runScheduleT ((() -> m ()) -> YieldT m a -> m a)
-> (() -> m ()) -> YieldT m a -> m a
forall a b. (a -> b) -> a -> b
$ m () -> () -> m ()
forall a b. a -> b -> a
const (m () -> () -> m ()) -> m () -> () -> m ()
forall a b. (a -> b) -> a -> b
$ IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ()
Concurrent.yield