{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
module Reflex.TriggerEvent.Class
( TriggerEvent (..)
) where
import Reflex.Class
import Control.Monad.Reader
import Control.Monad.State
import qualified Control.Monad.State.Strict as Strict
import Control.Monad.Trans.Maybe (MaybeT)
class Monad m => TriggerEvent t m | m -> t where
newTriggerEvent :: m (Event t a, a -> IO ())
newTriggerEventWithOnComplete :: m (Event t a, a -> IO () -> IO ())
newEventWithLazyTriggerWithOnComplete :: ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
instance TriggerEvent t m => TriggerEvent t (ReaderT r m) where
newTriggerEvent :: forall a. ReaderT r m (Event t a, a -> IO ())
newTriggerEvent = m (Event t a, a -> IO ()) -> ReaderT r m (Event t a, a -> IO ())
forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO ())
forall a. m (Event t a, a -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO ())
newTriggerEvent
newTriggerEventWithOnComplete :: forall a. ReaderT r m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete = m (Event t a, a -> IO () -> IO ())
-> ReaderT r m (Event t a, a -> IO () -> IO ())
forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO () -> IO ())
forall a. m (Event t a, a -> IO () -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete
newEventWithLazyTriggerWithOnComplete :: forall a.
((a -> IO () -> IO ()) -> IO (IO ())) -> ReaderT r m (Event t a)
newEventWithLazyTriggerWithOnComplete = m (Event t a) -> ReaderT r m (Event t a)
forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> ReaderT r m (Event t a))
-> (((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a))
-> ((a -> IO () -> IO ()) -> IO (IO ()))
-> ReaderT r m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall a. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
TriggerEvent t m =>
((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
newEventWithLazyTriggerWithOnComplete
instance TriggerEvent t m => TriggerEvent t (StateT s m) where
newTriggerEvent :: forall a. StateT s m (Event t a, a -> IO ())
newTriggerEvent = m (Event t a, a -> IO ()) -> StateT s m (Event t a, a -> IO ())
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO ())
forall a. m (Event t a, a -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO ())
newTriggerEvent
newTriggerEventWithOnComplete :: forall a. StateT s m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete = m (Event t a, a -> IO () -> IO ())
-> StateT s m (Event t a, a -> IO () -> IO ())
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO () -> IO ())
forall a. m (Event t a, a -> IO () -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete
newEventWithLazyTriggerWithOnComplete :: forall a.
((a -> IO () -> IO ()) -> IO (IO ())) -> StateT s m (Event t a)
newEventWithLazyTriggerWithOnComplete = m (Event t a) -> StateT s m (Event t a)
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> StateT s m (Event t a))
-> (((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a))
-> ((a -> IO () -> IO ()) -> IO (IO ()))
-> StateT s m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall a. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
TriggerEvent t m =>
((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
newEventWithLazyTriggerWithOnComplete
instance TriggerEvent t m => TriggerEvent t (Strict.StateT s m) where
newTriggerEvent :: forall a. StateT s m (Event t a, a -> IO ())
newTriggerEvent = m (Event t a, a -> IO ()) -> StateT s m (Event t a, a -> IO ())
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO ())
forall a. m (Event t a, a -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO ())
newTriggerEvent
newTriggerEventWithOnComplete :: forall a. StateT s m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete = m (Event t a, a -> IO () -> IO ())
-> StateT s m (Event t a, a -> IO () -> IO ())
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO () -> IO ())
forall a. m (Event t a, a -> IO () -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete
newEventWithLazyTriggerWithOnComplete :: forall a.
((a -> IO () -> IO ()) -> IO (IO ())) -> StateT s m (Event t a)
newEventWithLazyTriggerWithOnComplete = m (Event t a) -> StateT s m (Event t a)
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> StateT s m (Event t a))
-> (((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a))
-> ((a -> IO () -> IO ()) -> IO (IO ()))
-> StateT s m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall a. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
TriggerEvent t m =>
((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
newEventWithLazyTriggerWithOnComplete
instance TriggerEvent t m => TriggerEvent t (MaybeT m) where
newTriggerEvent :: forall a. MaybeT m (Event t a, a -> IO ())
newTriggerEvent = m (Event t a, a -> IO ()) -> MaybeT m (Event t a, a -> IO ())
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO ())
forall a. m (Event t a, a -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO ())
newTriggerEvent
newTriggerEventWithOnComplete :: forall a. MaybeT m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete = m (Event t a, a -> IO () -> IO ())
-> MaybeT m (Event t a, a -> IO () -> IO ())
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO () -> IO ())
forall a. m (Event t a, a -> IO () -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete
newEventWithLazyTriggerWithOnComplete :: forall a.
((a -> IO () -> IO ()) -> IO (IO ())) -> MaybeT m (Event t a)
newEventWithLazyTriggerWithOnComplete = m (Event t a) -> MaybeT m (Event t a)
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> MaybeT m (Event t a))
-> (((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a))
-> ((a -> IO () -> IO ()) -> IO (IO ()))
-> MaybeT m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall a. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
TriggerEvent t m =>
((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
newEventWithLazyTriggerWithOnComplete