{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Reflex.TriggerEvent.Base
( TriggerEventT (..)
, runTriggerEventT
, askEvents
, TriggerInvocation (..)
, EventTriggerRef (..)
) where
import Control.Applicative (liftA2)
import Control.Concurrent
import Control.Monad.Exception
import Control.Monad.Primitive
import Control.Monad.Reader
import Control.Monad.Ref
import Data.Coerce
import Data.Dependent.Sum
import Data.IORef
import Data.Monoid ((<>))
import qualified Data.Semigroup as S
import Reflex.Class
import Reflex.Adjustable.Class
import Reflex.Host.Class
import Reflex.PerformEvent.Class
import Reflex.PostBuild.Class
import Reflex.TriggerEvent.Class
data TriggerInvocation a = TriggerInvocation a (IO ())
newtype EventTriggerRef t a = EventTriggerRef { EventTriggerRef t a -> IORef (Maybe (EventTrigger t a))
unEventTriggerRef :: IORef (Maybe (EventTrigger t a)) }
newtype TriggerEventT t m a = TriggerEventT { TriggerEventT t m a
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
unTriggerEventT :: ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a }
deriving (a -> TriggerEventT t m b -> TriggerEventT t m a
(a -> b) -> TriggerEventT t m a -> TriggerEventT t m b
(forall a b.
(a -> b) -> TriggerEventT t m a -> TriggerEventT t m b)
-> (forall a b. a -> TriggerEventT t m b -> TriggerEventT t m a)
-> Functor (TriggerEventT t m)
forall a b. a -> TriggerEventT t m b -> TriggerEventT t m a
forall a b. (a -> b) -> TriggerEventT t m a -> TriggerEventT t m b
forall t (m :: * -> *) a b.
Functor m =>
a -> TriggerEventT t m b -> TriggerEventT t m a
forall t (m :: * -> *) a b.
Functor m =>
(a -> b) -> TriggerEventT t m a -> TriggerEventT t m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> TriggerEventT t m b -> TriggerEventT t m a
$c<$ :: forall t (m :: * -> *) a b.
Functor m =>
a -> TriggerEventT t m b -> TriggerEventT t m a
fmap :: (a -> b) -> TriggerEventT t m a -> TriggerEventT t m b
$cfmap :: forall t (m :: * -> *) a b.
Functor m =>
(a -> b) -> TriggerEventT t m a -> TriggerEventT t m b
Functor, Functor (TriggerEventT t m)
a -> TriggerEventT t m a
Functor (TriggerEventT t m)
-> (forall a. a -> TriggerEventT t m a)
-> (forall a b.
TriggerEventT t m (a -> b)
-> TriggerEventT t m a -> TriggerEventT t m b)
-> (forall a b c.
(a -> b -> c)
-> TriggerEventT t m a
-> TriggerEventT t m b
-> TriggerEventT t m c)
-> (forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b)
-> (forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a)
-> Applicative (TriggerEventT t m)
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
TriggerEventT t m (a -> b)
-> TriggerEventT t m a -> TriggerEventT t m b
(a -> b -> c)
-> TriggerEventT t m a
-> TriggerEventT t m b
-> TriggerEventT t m c
forall a. a -> TriggerEventT t m a
forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
forall a b.
TriggerEventT t m (a -> b)
-> TriggerEventT t m a -> TriggerEventT t m b
forall a b c.
(a -> b -> c)
-> TriggerEventT t m a
-> TriggerEventT t m b
-> TriggerEventT t m c
forall t (m :: * -> *).
Applicative m =>
Functor (TriggerEventT t m)
forall t (m :: * -> *) a. Applicative m => a -> TriggerEventT t m a
forall t (m :: * -> *) a b.
Applicative m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
forall t (m :: * -> *) a b.
Applicative m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
forall t (m :: * -> *) a b.
Applicative m =>
TriggerEventT t m (a -> b)
-> TriggerEventT t m a -> TriggerEventT t m b
forall t (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> TriggerEventT t m a
-> TriggerEventT t m b
-> TriggerEventT t 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
<* :: TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
$c<* :: forall t (m :: * -> *) a b.
Applicative m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
*> :: TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
$c*> :: forall t (m :: * -> *) a b.
Applicative m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
liftA2 :: (a -> b -> c)
-> TriggerEventT t m a
-> TriggerEventT t m b
-> TriggerEventT t m c
$cliftA2 :: forall t (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> TriggerEventT t m a
-> TriggerEventT t m b
-> TriggerEventT t m c
<*> :: TriggerEventT t m (a -> b)
-> TriggerEventT t m a -> TriggerEventT t m b
$c<*> :: forall t (m :: * -> *) a b.
Applicative m =>
TriggerEventT t m (a -> b)
-> TriggerEventT t m a -> TriggerEventT t m b
pure :: a -> TriggerEventT t m a
$cpure :: forall t (m :: * -> *) a. Applicative m => a -> TriggerEventT t m a
$cp1Applicative :: forall t (m :: * -> *).
Applicative m =>
Functor (TriggerEventT t m)
Applicative, Applicative (TriggerEventT t m)
a -> TriggerEventT t m a
Applicative (TriggerEventT t m)
-> (forall a b.
TriggerEventT t m a
-> (a -> TriggerEventT t m b) -> TriggerEventT t m b)
-> (forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b)
-> (forall a. a -> TriggerEventT t m a)
-> Monad (TriggerEventT t m)
TriggerEventT t m a
-> (a -> TriggerEventT t m b) -> TriggerEventT t m b
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
forall a. a -> TriggerEventT t m a
forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
forall a b.
TriggerEventT t m a
-> (a -> TriggerEventT t m b) -> TriggerEventT t m b
forall t (m :: * -> *). Monad m => Applicative (TriggerEventT t m)
forall t (m :: * -> *) a. Monad m => a -> TriggerEventT t m a
forall t (m :: * -> *) a b.
Monad m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
forall t (m :: * -> *) a b.
Monad m =>
TriggerEventT t m a
-> (a -> TriggerEventT t m b) -> TriggerEventT t 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 :: a -> TriggerEventT t m a
$creturn :: forall t (m :: * -> *) a. Monad m => a -> TriggerEventT t m a
>> :: TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
$c>> :: forall t (m :: * -> *) a b.
Monad m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m b
>>= :: TriggerEventT t m a
-> (a -> TriggerEventT t m b) -> TriggerEventT t m b
$c>>= :: forall t (m :: * -> *) a b.
Monad m =>
TriggerEventT t m a
-> (a -> TriggerEventT t m b) -> TriggerEventT t m b
$cp1Monad :: forall t (m :: * -> *). Monad m => Applicative (TriggerEventT t m)
Monad, Monad (TriggerEventT t m)
Monad (TriggerEventT t m)
-> (forall a. (a -> TriggerEventT t m a) -> TriggerEventT t m a)
-> MonadFix (TriggerEventT t m)
(a -> TriggerEventT t m a) -> TriggerEventT t m a
forall a. (a -> TriggerEventT t m a) -> TriggerEventT t m a
forall t (m :: * -> *). MonadFix m => Monad (TriggerEventT t m)
forall t (m :: * -> *) a.
MonadFix m =>
(a -> TriggerEventT t m a) -> TriggerEventT t m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> TriggerEventT t m a) -> TriggerEventT t m a
$cmfix :: forall t (m :: * -> *) a.
MonadFix m =>
(a -> TriggerEventT t m a) -> TriggerEventT t m a
$cp1MonadFix :: forall t (m :: * -> *). MonadFix m => Monad (TriggerEventT t m)
MonadFix, Monad (TriggerEventT t m)
Monad (TriggerEventT t m)
-> (forall a. IO a -> TriggerEventT t m a)
-> MonadIO (TriggerEventT t m)
IO a -> TriggerEventT t m a
forall a. IO a -> TriggerEventT t m a
forall t (m :: * -> *). MonadIO m => Monad (TriggerEventT t m)
forall t (m :: * -> *) a. MonadIO m => IO a -> TriggerEventT t m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> TriggerEventT t m a
$cliftIO :: forall t (m :: * -> *) a. MonadIO m => IO a -> TriggerEventT t m a
$cp1MonadIO :: forall t (m :: * -> *). MonadIO m => Monad (TriggerEventT t m)
MonadIO, Monad (TriggerEventT t m)
e -> TriggerEventT t m a
Monad (TriggerEventT t m)
-> (forall e a. Exception e => e -> TriggerEventT t m a)
-> (forall e a.
Exception e =>
TriggerEventT t m a
-> (e -> TriggerEventT t m a) -> TriggerEventT t m a)
-> (forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a)
-> MonadException (TriggerEventT t m)
TriggerEventT t m a
-> (e -> TriggerEventT t m a) -> TriggerEventT t m a
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
forall e a. Exception e => e -> TriggerEventT t m a
forall e a.
Exception e =>
TriggerEventT t m a
-> (e -> TriggerEventT t m a) -> TriggerEventT t m a
forall a b.
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
forall t (m :: * -> *).
MonadException m =>
Monad (TriggerEventT t m)
forall t (m :: * -> *) e a.
(MonadException m, Exception e) =>
e -> TriggerEventT t m a
forall t (m :: * -> *) e a.
(MonadException m, Exception e) =>
TriggerEventT t m a
-> (e -> TriggerEventT t m a) -> TriggerEventT t m a
forall t (m :: * -> *) a b.
MonadException m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
forall (m :: * -> *).
Monad m
-> (forall e a. Exception e => e -> m a)
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> (forall a b. m a -> m b -> m a)
-> MonadException m
finally :: TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
$cfinally :: forall t (m :: * -> *) a b.
MonadException m =>
TriggerEventT t m a -> TriggerEventT t m b -> TriggerEventT t m a
catch :: TriggerEventT t m a
-> (e -> TriggerEventT t m a) -> TriggerEventT t m a
$ccatch :: forall t (m :: * -> *) e a.
(MonadException m, Exception e) =>
TriggerEventT t m a
-> (e -> TriggerEventT t m a) -> TriggerEventT t m a
throw :: e -> TriggerEventT t m a
$cthrow :: forall t (m :: * -> *) e a.
(MonadException m, Exception e) =>
e -> TriggerEventT t m a
$cp1MonadException :: forall t (m :: * -> *).
MonadException m =>
Monad (TriggerEventT t m)
MonadException, MonadIO (TriggerEventT t m)
MonadException (TriggerEventT t m)
MonadIO (TriggerEventT t m)
-> MonadException (TriggerEventT t m)
-> (forall b.
((forall a. TriggerEventT t m a -> TriggerEventT t m a)
-> TriggerEventT t m b)
-> TriggerEventT t m b)
-> MonadAsyncException (TriggerEventT t m)
((forall a. TriggerEventT t m a -> TriggerEventT t m a)
-> TriggerEventT t m b)
-> TriggerEventT t m b
forall b.
((forall a. TriggerEventT t m a -> TriggerEventT t m a)
-> TriggerEventT t m b)
-> TriggerEventT t m b
forall t (m :: * -> *).
MonadAsyncException m =>
MonadIO (TriggerEventT t m)
forall t (m :: * -> *).
MonadAsyncException m =>
MonadException (TriggerEventT t m)
forall t (m :: * -> *) b.
MonadAsyncException m =>
((forall a. TriggerEventT t m a -> TriggerEventT t m a)
-> TriggerEventT t m b)
-> TriggerEventT t m b
forall (m :: * -> *).
MonadIO m
-> MonadException m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> MonadAsyncException m
mask :: ((forall a. TriggerEventT t m a -> TriggerEventT t m a)
-> TriggerEventT t m b)
-> TriggerEventT t m b
$cmask :: forall t (m :: * -> *) b.
MonadAsyncException m =>
((forall a. TriggerEventT t m a -> TriggerEventT t m a)
-> TriggerEventT t m b)
-> TriggerEventT t m b
$cp2MonadAsyncException :: forall t (m :: * -> *).
MonadAsyncException m =>
MonadException (TriggerEventT t m)
$cp1MonadAsyncException :: forall t (m :: * -> *).
MonadAsyncException m =>
MonadIO (TriggerEventT t m)
MonadAsyncException)
runTriggerEventT :: TriggerEventT t m a -> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a
runTriggerEventT :: TriggerEventT t m a
-> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a
runTriggerEventT = ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a)
-> (TriggerEventT t m a
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a)
-> TriggerEventT t m a
-> Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TriggerEventT t m a
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
forall t (m :: * -> *) a.
TriggerEventT t m a
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
unTriggerEventT
instance MonadTrans (TriggerEventT t) where
{-# INLINABLE lift #-}
lift :: m a -> TriggerEventT t m a
lift = ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a
forall t (m :: * -> *) a.
ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a
TriggerEventT (ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a)
-> (m a
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a)
-> m a
-> TriggerEventT t m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift
instance PrimMonad m => PrimMonad (TriggerEventT t m) where
type PrimState (TriggerEventT t m) = PrimState m
{-# INLINABLE primitive #-}
primitive :: (State# (PrimState (TriggerEventT t m))
-> (# State# (PrimState (TriggerEventT t m)), a #))
-> TriggerEventT t m a
primitive = m a -> TriggerEventT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> TriggerEventT t m a)
-> ((State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a)
-> (State# (PrimState m) -> (# State# (PrimState m), a #))
-> TriggerEventT t m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
forall (m :: * -> *) a.
PrimMonad m =>
(State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
primitive
instance PerformEvent t m => PerformEvent t (TriggerEventT t m) where
type Performable (TriggerEventT t m) = Performable m
{-# INLINABLE performEvent_ #-}
performEvent_ :: Event t (Performable (TriggerEventT t m) ())
-> TriggerEventT t m ()
performEvent_ Event t (Performable (TriggerEventT t m) ())
e = m () -> TriggerEventT t m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TriggerEventT t m ()) -> m () -> TriggerEventT t m ()
forall a b. (a -> b) -> a -> b
$ Event t (Performable m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_ Event t (Performable m ())
Event t (Performable (TriggerEventT t m) ())
e
{-# INLINABLE performEvent #-}
performEvent :: Event t (Performable (TriggerEventT t m) a)
-> TriggerEventT t m (Event t a)
performEvent Event t (Performable (TriggerEventT t m) a)
e = m (Event t a) -> TriggerEventT t m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> TriggerEventT t m (Event t a))
-> m (Event t a) -> TriggerEventT t m (Event t a)
forall a b. (a -> b) -> a -> b
$ Event t (Performable m a) -> m (Event t a)
forall t (m :: * -> *) a.
PerformEvent t m =>
Event t (Performable m a) -> m (Event t a)
performEvent Event t (Performable m a)
Event t (Performable (TriggerEventT t m) a)
e
instance PostBuild t m => PostBuild t (TriggerEventT t m) where
{-# INLINABLE getPostBuild #-}
getPostBuild :: TriggerEventT t m (Event t ())
getPostBuild = m (Event t ()) -> TriggerEventT t m (Event t ())
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t ())
forall t (m :: * -> *). PostBuild t m => m (Event t ())
getPostBuild
instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (TriggerEventT t m) where
{-# INLINABLE newEventWithTrigger #-}
newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> TriggerEventT t m (Event t a)
newEventWithTrigger = m (Event t a) -> TriggerEventT t m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> TriggerEventT t m (Event t a))
-> ((EventTrigger t a -> IO (IO ())) -> m (Event t a))
-> (EventTrigger t a -> IO (IO ()))
-> TriggerEventT t m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EventTrigger t a -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
MonadReflexCreateTrigger t m =>
(EventTrigger t a -> IO (IO ())) -> m (Event t a)
newEventWithTrigger
{-# INLINABLE newFanEventWithTrigger #-}
newFanEventWithTrigger :: (forall a. k a -> EventTrigger t a -> IO (IO ()))
-> TriggerEventT t m (EventSelector t k)
newFanEventWithTrigger forall a. k a -> EventTrigger t a -> IO (IO ())
f = m (EventSelector t k) -> TriggerEventT t m (EventSelector t k)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (EventSelector t k) -> TriggerEventT t m (EventSelector t k))
-> m (EventSelector t k) -> TriggerEventT t m (EventSelector t k)
forall a b. (a -> b) -> a -> b
$ (forall a. k a -> EventTrigger t a -> IO (IO ()))
-> m (EventSelector t k)
forall t (m :: * -> *) (k :: * -> *).
(MonadReflexCreateTrigger t m, GCompare k) =>
(forall a. k a -> EventTrigger t a -> IO (IO ()))
-> m (EventSelector t k)
newFanEventWithTrigger forall a. k a -> EventTrigger t a -> IO (IO ())
f
instance (Monad m, MonadRef m, Ref m ~ Ref IO, MonadReflexCreateTrigger t m) => TriggerEvent t (TriggerEventT t m) where
{-# INLINABLE newTriggerEvent #-}
newTriggerEvent :: TriggerEventT t m (Event t a, a -> IO ())
newTriggerEvent = do
(Event t a
e, a -> IO () -> IO ()
t) <- TriggerEventT t m (Event t a, a -> IO () -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete
(Event t a, a -> IO ())
-> TriggerEventT t m (Event t a, a -> IO ())
forall (m :: * -> *) a. Monad m => a -> m a
return (Event t a
e, \a
a -> a -> IO () -> IO ()
t a
a (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
{-# INLINABLE newTriggerEventWithOnComplete #-}
newTriggerEventWithOnComplete :: TriggerEventT t m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete = do
Chan [DSum (EventTriggerRef t) TriggerInvocation]
events <- TriggerEventT
t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
forall (m :: * -> *) t.
Monad m =>
TriggerEventT
t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
askEvents
(Event t a
eResult, IORef (Maybe (EventTrigger t a))
reResultTrigger) <- m (Event t a, IORef (Maybe (EventTrigger t a)))
-> TriggerEventT t m (Event t a, IORef (Maybe (EventTrigger t a)))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, IORef (Maybe (EventTrigger t a)))
forall t (m :: * -> *) a.
(MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref IO) =>
m (Event t a, Ref m (Maybe (EventTrigger t a)))
newEventWithTriggerRef
(Event t a, a -> IO () -> IO ())
-> TriggerEventT t m (Event t a, a -> IO () -> IO ())
forall (m :: * -> *) a. Monad m => a -> m a
return ((Event t a, a -> IO () -> IO ())
-> TriggerEventT t m (Event t a, a -> IO () -> IO ()))
-> ((a -> IO () -> IO ()) -> (Event t a, a -> IO () -> IO ()))
-> (a -> IO () -> IO ())
-> TriggerEventT t m (Event t a, a -> IO () -> IO ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (,) Event t a
eResult ((a -> IO () -> IO ())
-> TriggerEventT t m (Event t a, a -> IO () -> IO ()))
-> (a -> IO () -> IO ())
-> TriggerEventT t m (Event t a, a -> IO () -> IO ())
forall a b. (a -> b) -> a -> b
$ \a
a IO ()
cb ->
Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> [DSum (EventTriggerRef t) TriggerInvocation] -> IO ()
forall a. Chan a -> a -> IO ()
writeChan Chan [DSum (EventTriggerRef t) TriggerInvocation]
events [IORef (Maybe (EventTrigger t a)) -> EventTriggerRef t a
forall t a. IORef (Maybe (EventTrigger t a)) -> EventTriggerRef t a
EventTriggerRef IORef (Maybe (EventTrigger t a))
reResultTrigger EventTriggerRef t a
-> TriggerInvocation a
-> DSum (EventTriggerRef t) TriggerInvocation
forall k (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> a -> IO () -> TriggerInvocation a
forall a. a -> IO () -> TriggerInvocation a
TriggerInvocation a
a IO ()
cb]
{-# INLINABLE newEventWithLazyTriggerWithOnComplete #-}
newEventWithLazyTriggerWithOnComplete :: ((a -> IO () -> IO ()) -> IO (IO ()))
-> TriggerEventT t m (Event t a)
newEventWithLazyTriggerWithOnComplete (a -> IO () -> IO ()) -> IO (IO ())
f = do
Chan [DSum (EventTriggerRef t) TriggerInvocation]
events <- TriggerEventT
t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
forall (m :: * -> *) t.
Monad m =>
TriggerEventT
t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
askEvents
m (Event t a) -> TriggerEventT t m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> TriggerEventT t m (Event t a))
-> ((EventTrigger t a -> IO (IO ())) -> m (Event t a))
-> (EventTrigger t a -> IO (IO ()))
-> TriggerEventT t m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EventTrigger t a -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
MonadReflexCreateTrigger t m =>
(EventTrigger t a -> IO (IO ())) -> m (Event t a)
newEventWithTrigger ((EventTrigger t a -> IO (IO ())) -> TriggerEventT t m (Event t a))
-> (EventTrigger t a -> IO (IO ()))
-> TriggerEventT t m (Event t a)
forall a b. (a -> b) -> a -> b
$ \EventTrigger t a
t ->
(a -> IO () -> IO ()) -> IO (IO ())
f ((a -> IO () -> IO ()) -> IO (IO ()))
-> (a -> IO () -> IO ()) -> IO (IO ())
forall a b. (a -> b) -> a -> b
$ \a
a IO ()
cb -> do
IORef (Maybe (EventTrigger t a))
reResultTrigger <- Maybe (EventTrigger t a) -> IO (Ref IO (Maybe (EventTrigger t a)))
forall (m :: * -> *) a. MonadRef m => a -> m (Ref m a)
newRef (Maybe (EventTrigger t a)
-> IO (Ref IO (Maybe (EventTrigger t a))))
-> Maybe (EventTrigger t a)
-> IO (Ref IO (Maybe (EventTrigger t a)))
forall a b. (a -> b) -> a -> b
$ EventTrigger t a -> Maybe (EventTrigger t a)
forall a. a -> Maybe a
Just EventTrigger t a
t
Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> [DSum (EventTriggerRef t) TriggerInvocation] -> IO ()
forall a. Chan a -> a -> IO ()
writeChan Chan [DSum (EventTriggerRef t) TriggerInvocation]
events [IORef (Maybe (EventTrigger t a)) -> EventTriggerRef t a
forall t a. IORef (Maybe (EventTrigger t a)) -> EventTriggerRef t a
EventTriggerRef IORef (Maybe (EventTrigger t a))
reResultTrigger EventTriggerRef t a
-> TriggerInvocation a
-> DSum (EventTriggerRef t) TriggerInvocation
forall k (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> a -> IO () -> TriggerInvocation a
forall a. a -> IO () -> TriggerInvocation a
TriggerInvocation a
a IO ()
cb]
instance MonadRef m => MonadRef (TriggerEventT t m) where
type Ref (TriggerEventT t m) = Ref m
{-# INLINABLE newRef #-}
newRef :: a -> TriggerEventT t m (Ref (TriggerEventT t m) a)
newRef = m (Ref m a) -> TriggerEventT t m (Ref m a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Ref m a) -> TriggerEventT t m (Ref m a))
-> (a -> m (Ref m a)) -> a -> TriggerEventT t m (Ref m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> m (Ref m a)
newRef
{-# INLINABLE readRef #-}
readRef :: Ref (TriggerEventT t m) a -> TriggerEventT t m a
readRef = m a -> TriggerEventT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> TriggerEventT t m a)
-> (Ref m a -> m a) -> Ref m a -> TriggerEventT t m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef
{-# INLINABLE writeRef #-}
writeRef :: Ref (TriggerEventT t m) a -> a -> TriggerEventT t m ()
writeRef Ref (TriggerEventT t m) a
r = m () -> TriggerEventT t m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TriggerEventT t m ())
-> (a -> m ()) -> a -> TriggerEventT t m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> a -> m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> m ()
writeRef Ref m a
Ref (TriggerEventT t m) a
r
instance MonadAtomicRef m => MonadAtomicRef (TriggerEventT t m) where
{-# INLINABLE atomicModifyRef #-}
atomicModifyRef :: Ref (TriggerEventT t m) a -> (a -> (a, b)) -> TriggerEventT t m b
atomicModifyRef Ref (TriggerEventT t m) a
r = m b -> TriggerEventT t m b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m b -> TriggerEventT t m b)
-> ((a -> (a, b)) -> m b) -> (a -> (a, b)) -> TriggerEventT t m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> (a -> (a, b)) -> m b
forall (m :: * -> *) a b.
MonadAtomicRef m =>
Ref m a -> (a -> (a, b)) -> m b
atomicModifyRef Ref m a
Ref (TriggerEventT t m) a
r
instance MonadSample t m => MonadSample t (TriggerEventT t m) where
{-# INLINABLE sample #-}
sample :: Behavior t a -> TriggerEventT t m a
sample = m a -> TriggerEventT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> TriggerEventT t m a)
-> (Behavior t a -> m a) -> Behavior t a -> TriggerEventT t m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Behavior t a -> m a
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample
instance MonadHold t m => MonadHold t (TriggerEventT t m) where
{-# INLINABLE hold #-}
hold :: a -> Event t a -> TriggerEventT t m (Behavior t a)
hold a
v0 Event t a
v' = m (Behavior t a) -> TriggerEventT t m (Behavior t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Behavior t a) -> TriggerEventT t m (Behavior t a))
-> m (Behavior t a) -> TriggerEventT t m (Behavior t a)
forall a b. (a -> b) -> a -> b
$ a -> Event t a -> m (Behavior t a)
forall k (t :: k) (m :: * -> *) a.
MonadHold t m =>
a -> Event t a -> m (Behavior t a)
hold a
v0 Event t a
v'
{-# INLINABLE holdDyn #-}
holdDyn :: a -> Event t a -> TriggerEventT t m (Dynamic t a)
holdDyn a
v0 Event t a
v' = m (Dynamic t a) -> TriggerEventT t m (Dynamic t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t a) -> TriggerEventT t m (Dynamic t a))
-> m (Dynamic t a) -> TriggerEventT t m (Dynamic t a)
forall a b. (a -> b) -> a -> b
$ a -> Event t a -> m (Dynamic t a)
forall k (t :: k) (m :: * -> *) a.
MonadHold t m =>
a -> Event t a -> m (Dynamic t a)
holdDyn a
v0 Event t a
v'
{-# INLINABLE holdIncremental #-}
holdIncremental :: PatchTarget p -> Event t p -> TriggerEventT t m (Incremental t p)
holdIncremental PatchTarget p
v0 Event t p
v' = m (Incremental t p) -> TriggerEventT t m (Incremental t p)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Incremental t p) -> TriggerEventT t m (Incremental t p))
-> m (Incremental t p) -> TriggerEventT t m (Incremental t p)
forall a b. (a -> b) -> a -> b
$ PatchTarget p -> Event t p -> m (Incremental t p)
forall k (t :: k) (m :: * -> *) p.
(MonadHold t m, Patch p) =>
PatchTarget p -> Event t p -> m (Incremental t p)
holdIncremental PatchTarget p
v0 Event t p
v'
{-# INLINABLE buildDynamic #-}
buildDynamic :: PushM t a -> Event t a -> TriggerEventT t m (Dynamic t a)
buildDynamic PushM t a
a0 = m (Dynamic t a) -> TriggerEventT t m (Dynamic t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t a) -> TriggerEventT t m (Dynamic t a))
-> (Event t a -> m (Dynamic t a))
-> Event t a
-> TriggerEventT t m (Dynamic t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PushM t a -> Event t a -> m (Dynamic t a)
forall k (t :: k) (m :: * -> *) a.
MonadHold t m =>
PushM t a -> Event t a -> m (Dynamic t a)
buildDynamic PushM t a
a0
{-# INLINABLE headE #-}
headE :: Event t a -> TriggerEventT t m (Event t a)
headE = m (Event t a) -> TriggerEventT t m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> TriggerEventT t m (Event t a))
-> (Event t a -> m (Event t a))
-> Event t a
-> TriggerEventT t m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t a -> m (Event t a)
forall k (t :: k) (m :: * -> *) a.
MonadHold t m =>
Event t a -> m (Event t a)
headE
{-# INLINABLE now #-}
now :: TriggerEventT t m (Event t ())
now = m (Event t ()) -> TriggerEventT t m (Event t ())
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t ())
forall k (t :: k) (m :: * -> *). MonadHold t m => m (Event t ())
now
instance Adjustable t m => Adjustable t (TriggerEventT t m) where
{-# INLINABLE runWithReplace #-}
runWithReplace :: TriggerEventT t m a
-> Event t (TriggerEventT t m b)
-> TriggerEventT t m (a, Event t b)
runWithReplace (TriggerEventT ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
a0) Event t (TriggerEventT t m b)
a' = ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(a, Event t b)
-> TriggerEventT t m (a, Event t b)
forall t (m :: * -> *) a.
ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a
TriggerEventT (ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(a, Event t b)
-> TriggerEventT t m (a, Event t b))
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(a, Event t b)
-> TriggerEventT t m (a, Event t b)
forall a b. (a -> b) -> a -> b
$ ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> Event
t (ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m b)
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(a, Event t b)
forall t (m :: * -> *) a b.
Adjustable t m =>
m a -> Event t (m b) -> m (a, Event t b)
runWithReplace ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
a0 (Event t (TriggerEventT t m b)
-> Event
t (ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m b)
forall k (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent Event t (TriggerEventT t m b)
a')
{-# INLINABLE traverseIntMapWithKeyWithAdjust #-}
traverseIntMapWithKeyWithAdjust :: (Key -> v -> TriggerEventT t m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> TriggerEventT t m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust Key -> v -> TriggerEventT t m v'
f IntMap v
dm0 Event t (PatchIntMap v)
dm' = ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(IntMap v', Event t (PatchIntMap v'))
-> TriggerEventT t m (IntMap v', Event t (PatchIntMap v'))
forall t (m :: * -> *) a.
ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a
TriggerEventT (ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(IntMap v', Event t (PatchIntMap v'))
-> TriggerEventT t m (IntMap v', Event t (PatchIntMap v')))
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(IntMap v', Event t (PatchIntMap v'))
-> TriggerEventT t m (IntMap v', Event t (PatchIntMap v'))
forall a b. (a -> b) -> a -> b
$ (Key
-> v
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(IntMap v', Event t (PatchIntMap v'))
forall t (m :: * -> *) v v'.
Adjustable t m =>
(Key -> v -> m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust ((v -> TriggerEventT t m v')
-> v
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m v'
coerce ((v -> TriggerEventT t m v')
-> v
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m v')
-> (Key -> v -> TriggerEventT t m v')
-> Key
-> v
-> ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m v'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Key -> v -> TriggerEventT t m v'
f) IntMap v
dm0 Event t (PatchIntMap v)
dm'
{-# INLINABLE traverseDMapWithKeyWithAdjust #-}
traverseDMapWithKeyWithAdjust :: (forall a. k a -> v a -> TriggerEventT t m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> TriggerEventT t m (DMap k v', Event t (PatchDMap k v'))
traverseDMapWithKeyWithAdjust forall a. k a -> v a -> TriggerEventT t m (v' a)
f DMap k v
dm0 Event t (PatchDMap k v)
dm' = ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMap k v'))
-> TriggerEventT t m (DMap k v', Event t (PatchDMap k v'))
forall t (m :: * -> *) a.
ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a
TriggerEventT (ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMap k v'))
-> TriggerEventT t m (DMap k v', Event t (PatchDMap k v')))
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMap k v'))
-> TriggerEventT t m (DMap k v', Event t (PatchDMap k v'))
forall a b. (a -> b) -> a -> b
$ (forall a.
k a
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMap k v'))
forall t (m :: * -> *) (k :: * -> *) (v :: * -> *) (v' :: * -> *).
(Adjustable t m, GCompare k) =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> m (DMap k v', Event t (PatchDMap k v'))
traverseDMapWithKeyWithAdjust ((v a -> TriggerEventT t m (v' a))
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a)
coerce ((v a -> TriggerEventT t m (v' a))
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a))
-> (k a -> v a -> TriggerEventT t m (v' a))
-> k a
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. k a -> v a -> TriggerEventT t m (v' a)
forall a. k a -> v a -> TriggerEventT t m (v' a)
f) DMap k v
dm0 Event t (PatchDMap k v)
dm'
{-# INLINABLE traverseDMapWithKeyWithAdjustWithMove #-}
traverseDMapWithKeyWithAdjustWithMove :: (forall a. k a -> v a -> TriggerEventT t m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> TriggerEventT t m (DMap k v', Event t (PatchDMapWithMove k v'))
traverseDMapWithKeyWithAdjustWithMove forall a. k a -> v a -> TriggerEventT t m (v' a)
f DMap k v
dm0 Event t (PatchDMapWithMove k v)
dm' = ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMapWithMove k v'))
-> TriggerEventT t m (DMap k v', Event t (PatchDMapWithMove k v'))
forall t (m :: * -> *) a.
ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a
TriggerEventT (ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMapWithMove k v'))
-> TriggerEventT t m (DMap k v', Event t (PatchDMapWithMove k v')))
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMapWithMove k v'))
-> TriggerEventT t m (DMap k v', Event t (PatchDMapWithMove k v'))
forall a b. (a -> b) -> a -> b
$ (forall a.
k a
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(DMap k v', Event t (PatchDMapWithMove k v'))
forall t (m :: * -> *) (k :: * -> *) (v :: * -> *) (v' :: * -> *).
(Adjustable t m, GCompare k) =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> m (DMap k v', Event t (PatchDMapWithMove k v'))
traverseDMapWithKeyWithAdjustWithMove ((v a -> TriggerEventT t m (v' a))
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a)
coerce ((v a -> TriggerEventT t m (v' a))
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a))
-> (k a -> v a -> TriggerEventT t m (v' a))
-> k a
-> v a
-> ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation]) m (v' a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. k a -> v a -> TriggerEventT t m (v' a)
forall a. k a -> v a -> TriggerEventT t m (v' a)
f) DMap k v
dm0 Event t (PatchDMapWithMove k v)
dm'
instance (Monoid a, Applicative m) => Monoid (TriggerEventT t m a) where
mempty :: TriggerEventT t m a
mempty = a -> TriggerEventT t m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Monoid a => a
mempty
mappend :: TriggerEventT t m a -> TriggerEventT t m a -> TriggerEventT t m a
mappend = TriggerEventT t m a -> TriggerEventT t m a -> TriggerEventT t m a
forall a. Semigroup a => a -> a -> a
(<>)
instance (S.Semigroup a, Applicative m) => S.Semigroup (TriggerEventT t m a) where
<> :: TriggerEventT t m a -> TriggerEventT t m a -> TriggerEventT t m a
(<>) = (a -> a -> a)
-> TriggerEventT t m a
-> TriggerEventT t m a
-> TriggerEventT t m a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semigroup a => a -> a -> a
(S.<>)
askEvents :: Monad m => TriggerEventT t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
askEvents :: TriggerEventT
t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
askEvents = ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
-> TriggerEventT
t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
forall t (m :: * -> *) a.
ReaderT (Chan [DSum (EventTriggerRef t) TriggerInvocation]) m a
-> TriggerEventT t m a
TriggerEventT ReaderT
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
m
(Chan [DSum (EventTriggerRef t) TriggerInvocation])
forall r (m :: * -> *). MonadReader r m => m r
ask