{-# LANGUAGE TupleSections #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Control.Monad.Schedule.RoundRobin where
import Control.Monad.IO.Class
import Data.Functor.Identity
import qualified Data.List.NonEmpty as NonEmpty
import Control.Monad.Trans.Class
import Control.Monad.Schedule.Class
newtype RoundRobinT m a = RoundRobinT { forall (m :: * -> *) a. RoundRobinT m a -> m a
unRoundRobin :: m a }
deriving (forall a b. a -> RoundRobinT m b -> RoundRobinT m a
forall a b. (a -> b) -> RoundRobinT m a -> RoundRobinT m b
forall (m :: * -> *) a b.
Functor m =>
a -> RoundRobinT m b -> RoundRobinT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> RoundRobinT m a -> RoundRobinT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> RoundRobinT m b -> RoundRobinT m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> RoundRobinT m b -> RoundRobinT m a
fmap :: forall a b. (a -> b) -> RoundRobinT m a -> RoundRobinT m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> RoundRobinT m a -> RoundRobinT m b
Functor, forall a. a -> RoundRobinT m a
forall a b. RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m a
forall a b. RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
forall a b.
RoundRobinT m (a -> b) -> RoundRobinT m a -> RoundRobinT m b
forall a b c.
(a -> b -> c)
-> RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall {m :: * -> *}. Applicative m => Functor (RoundRobinT m)
forall (m :: * -> *) a. Applicative m => a -> RoundRobinT m a
forall (m :: * -> *) a b.
Applicative m =>
RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m a
forall (m :: * -> *) a b.
Applicative m =>
RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
forall (m :: * -> *) a b.
Applicative m =>
RoundRobinT m (a -> b) -> RoundRobinT m a -> RoundRobinT m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m c
<* :: forall a b. RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m a
*> :: forall a b. RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
liftA2 :: forall a b c.
(a -> b -> c)
-> RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m c
<*> :: forall a b.
RoundRobinT m (a -> b) -> RoundRobinT m a -> RoundRobinT m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
RoundRobinT m (a -> b) -> RoundRobinT m a -> RoundRobinT m b
pure :: forall a. a -> RoundRobinT m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> RoundRobinT m a
Applicative, forall a. a -> RoundRobinT m a
forall a b. RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
forall a b.
RoundRobinT m a -> (a -> RoundRobinT m b) -> RoundRobinT m b
forall {m :: * -> *}. Monad m => Applicative (RoundRobinT m)
forall (m :: * -> *) a. Monad m => a -> RoundRobinT m a
forall (m :: * -> *) a b.
Monad m =>
RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
forall (m :: * -> *) a b.
Monad m =>
RoundRobinT m a -> (a -> RoundRobinT m b) -> RoundRobinT m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: forall a. a -> RoundRobinT m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> RoundRobinT m a
>> :: forall a b. RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
RoundRobinT m a -> RoundRobinT m b -> RoundRobinT m b
>>= :: forall a b.
RoundRobinT m a -> (a -> RoundRobinT m b) -> RoundRobinT m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
RoundRobinT m a -> (a -> RoundRobinT m b) -> RoundRobinT m b
Monad, forall a. IO a -> RoundRobinT m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall {m :: * -> *}. MonadIO m => Monad (RoundRobinT m)
forall (m :: * -> *) a. MonadIO m => IO a -> RoundRobinT m a
liftIO :: forall a. IO a -> RoundRobinT m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> RoundRobinT m a
MonadIO)
instance MonadTrans RoundRobinT where
lift :: forall (m :: * -> *) a. Monad m => m a -> RoundRobinT m a
lift = forall (m :: * -> *) a. m a -> RoundRobinT m a
RoundRobinT
instance Monad m => MonadSchedule (RoundRobinT m) where
schedule :: forall a.
NonEmpty (RoundRobinT m a)
-> RoundRobinT m (NonEmpty a, [RoundRobinT m a])
schedule NonEmpty (RoundRobinT m a)
actions = ( , forall a. NonEmpty a -> [a]
NonEmpty.tail NonEmpty (RoundRobinT m a)
actions) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. NonEmpty a -> a
NonEmpty.head NonEmpty (RoundRobinT m a)
actions)
type RoundRobin = RoundRobinT Identity