Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Reflex.Test.Monad.Host
Description
Synopsis
- type TestGuestT t (m :: Type -> Type) = TriggerEventT t (PostBuildT t (PerformEventT t m))
- type TestGuestConstraints t (m :: Type -> Type) = (MonadReflexHost t m, MonadHold t m, MonadSample t m, Ref m ~ Ref IO, MonadRef m, MonadRef (HostFrame t), Ref (HostFrame t) ~ Ref IO, MonadIO (HostFrame t), PrimMonad (HostFrame t), MonadIO m, MonadFix m)
- type ReflexTriggerRef t (m :: Type -> Type) a = Ref m (Maybe (EventTrigger t a))
- class MonadReflexTest t m | m -> t where
- type InputTriggerRefs m :: Type
- type OutputEvents m :: Type
- type InnerMonad m :: Type -> Type
- inputTriggerRefs :: m (InputTriggerRefs m)
- queueEventTrigger :: DSum (EventTrigger t) Identity -> m ()
- queueEventTriggerRef :: Ref (InnerMonad m) (Maybe (EventTrigger t a)) -> a -> m ()
- outputs :: m (OutputEvents m)
- fireQueuedEventsAndRead :: ReadPhase (InnerMonad m) a -> m [a]
- fireQueuedEvents :: Monad (ReadPhase (InnerMonad m)) => m [()]
- data AppState t m = AppState {
- _appState_queuedEvents :: [DSum (EventTrigger t) Identity]
- _appState_fire :: FireCommand t m
- newtype ReflexTestT t intref out m a = ReflexTestT {
- unReflexTestM :: ReaderT (intref, out) (StateT (AppState t m) m) a
- runReflexTestT :: forall intref inev out t m a. TestGuestConstraints t m => (inev, intref) -> (inev -> TestGuestT t m out) -> ReflexTestT t intref out m a -> m ()
- class ReflexTestApp app t m | app -> t m where
- data AppInputTriggerRefs app :: Type
- data AppInputEvents app :: Type
- data AppOutput app :: Type
- getApp :: AppInputEvents app -> TestGuestT t m (AppOutput app)
- makeInputs :: m (AppInputEvents app, AppInputTriggerRefs app)
- runReflexTestApp :: (ReflexTestApp app t m, TestGuestConstraints t m) => ReflexTestT t (AppInputTriggerRefs app) (AppOutput app) m () -> m ()
Documentation
type TestGuestT t (m :: Type -> Type) = TriggerEventT t (PostBuildT t (PerformEventT t m)) Source #
type TestGuestConstraints t (m :: Type -> Type) = (MonadReflexHost t m, MonadHold t m, MonadSample t m, Ref m ~ Ref IO, MonadRef m, MonadRef (HostFrame t), Ref (HostFrame t) ~ Ref IO, MonadIO (HostFrame t), PrimMonad (HostFrame t), MonadIO m, MonadFix m) Source #
type ReflexTriggerRef t (m :: Type -> Type) a = Ref m (Maybe (EventTrigger t a)) Source #
since we work with this type directly a lot, it helps to wrap it around a type synonym
class MonadReflexTest t m | m -> t where Source #
Minimal complete definition
inputTriggerRefs, queueEventTrigger, queueEventTriggerRef, outputs, fireQueuedEventsAndRead
Associated Types
type InputTriggerRefs m :: Type Source #
since event subscriptions also happen within the monad, input triggers created via newEventWithTriggerRef
may be stuck in the Nothing
state as there are no listeners yet
therefore it's necessary to pass in IORefs to the EventTriggers, thus the name of this type
in practice, this will likely be a record containing many trigger refs and the monad user must deref them all
type OutputEvents m :: Type Source #
in practice, this will likely be a record containing events and behaviors for the monad user to build a ReadPhase
that is passed into fireQueuedEventsAndRead
type InnerMonad m :: Type -> Type Source #
the inner monad that reflex is running in likely 'SpiderHost Global'
Methods
inputTriggerRefs :: m (InputTriggerRefs m) Source #
see comments for InputTriggerRefs
queueEventTrigger :: DSum (EventTrigger t) Identity -> m () Source #
all queued triggers will fire simultaneous on the next execution of fireQueuedEventsAndRead
queueEventTriggerRef :: Ref (InnerMonad m) (Maybe (EventTrigger t a)) -> a -> m () Source #
same as queueEventTrigger
except works with trigger refs
if the trigger ref derefs to Nothing
, the event does not get queued
outputs :: m (OutputEvents m) Source #
see comments for OutputEvents
fireQueuedEventsAndRead :: ReadPhase (InnerMonad m) a -> m [a] Source #
fire all queued events and run a ReadPhase to produce results from the execution frames readphase takes place in the inner monad
fireQueuedEvents :: Monad (ReadPhase (InnerMonad m)) => m [()] Source #
same as above with no ReadPhase
Instances
MonadRef m => MonadReflexTest t (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Associated Types type InputTriggerRefs (ReflexTestT t intref out m) Source # type OutputEvents (ReflexTestT t intref out m) Source # type InnerMonad (ReflexTestT t intref out m) :: Type -> Type Source # Methods inputTriggerRefs :: ReflexTestT t intref out m (InputTriggerRefs (ReflexTestT t intref out m)) Source # queueEventTrigger :: DSum (EventTrigger t) Identity -> ReflexTestT t intref out m () Source # queueEventTriggerRef :: Ref (InnerMonad (ReflexTestT t intref out m)) (Maybe (EventTrigger t a)) -> a -> ReflexTestT t intref out m () Source # outputs :: ReflexTestT t intref out m (OutputEvents (ReflexTestT t intref out m)) Source # fireQueuedEventsAndRead :: ReadPhase (InnerMonad (ReflexTestT t intref out m)) a -> ReflexTestT t intref out m [a] Source # fireQueuedEvents :: ReflexTestT t intref out m [()] Source # |
Constructors
AppState | |
Fields
|
Instances
Monad m => MonadState (AppState t m) (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods get :: ReflexTestT t intref out m (AppState t m) # put :: AppState t m -> ReflexTestT t intref out m () # state :: (AppState t m -> (a, AppState t m)) -> ReflexTestT t intref out m a # |
newtype ReflexTestT t intref out m a Source #
implementation of MonadReflexTest
Constructors
ReflexTestT | |
Fields
|
Instances
MonadHold t m => MonadHold (t :: Type) (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods hold :: a -> Event t a -> ReflexTestT t intref out m (Behavior t a) # holdDyn :: a -> Event t a -> ReflexTestT t intref out m (Dynamic t a) # holdIncremental :: Patch p => PatchTarget p -> Event t p -> ReflexTestT t intref out m (Incremental t p) # buildDynamic :: PushM t a -> Event t a -> ReflexTestT t intref out m (Dynamic t a) # headE :: Event t a -> ReflexTestT t intref out m (Event t a) # now :: ReflexTestT t intref out m (Event t ()) # | |
MonadSample t m => MonadSample (t :: Type) (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods sample :: Behavior t a -> ReflexTestT t intref out m a # | |
MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> ReflexTestT t intref out m (Event t a) # newFanEventWithTrigger :: GCompare k => (forall a. k a -> EventTrigger t a -> IO (IO ())) -> ReflexTestT t intref out m (EventSelector t k) # | |
MonadSubscribeEvent t m => MonadSubscribeEvent t (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods subscribeEvent :: Event t a -> ReflexTestT t intref out m (EventHandle t a) # | |
MonadRef m => MonadReflexTest t (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Associated Types type InputTriggerRefs (ReflexTestT t intref out m) Source # type OutputEvents (ReflexTestT t intref out m) Source # type InnerMonad (ReflexTestT t intref out m) :: Type -> Type Source # Methods inputTriggerRefs :: ReflexTestT t intref out m (InputTriggerRefs (ReflexTestT t intref out m)) Source # queueEventTrigger :: DSum (EventTrigger t) Identity -> ReflexTestT t intref out m () Source # queueEventTriggerRef :: Ref (InnerMonad (ReflexTestT t intref out m)) (Maybe (EventTrigger t a)) -> a -> ReflexTestT t intref out m () Source # outputs :: ReflexTestT t intref out m (OutputEvents (ReflexTestT t intref out m)) Source # fireQueuedEventsAndRead :: ReadPhase (InnerMonad (ReflexTestT t intref out m)) a -> ReflexTestT t intref out m [a] Source # fireQueuedEvents :: ReflexTestT t intref out m [()] Source # | |
Monad m => MonadReader (intref, out) (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods ask :: ReflexTestT t intref out m (intref, out) # local :: ((intref, out) -> (intref, out)) -> ReflexTestT t intref out m a -> ReflexTestT t intref out m a # reader :: ((intref, out) -> a) -> ReflexTestT t intref out m a # | |
Monad m => MonadState (AppState t m) (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods get :: ReflexTestT t intref out m (AppState t m) # put :: AppState t m -> ReflexTestT t intref out m () # state :: (AppState t m -> (a, AppState t m)) -> ReflexTestT t intref out m a # | |
MonadTrans (ReflexTestT t intref out) Source # | |
Defined in Reflex.Test.Monad.Host Methods lift :: Monad m => m a -> ReflexTestT t intref out m a # | |
MonadFix m => MonadFix (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods mfix :: (a -> ReflexTestT t intref out m a) -> ReflexTestT t intref out m a # | |
MonadIO m => MonadIO (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods liftIO :: IO a -> ReflexTestT t intref out m a # | |
Monad m => Applicative (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods pure :: a -> ReflexTestT t intref out m a # (<*>) :: ReflexTestT t intref out m (a -> b) -> ReflexTestT t intref out m a -> ReflexTestT t intref out m b # liftA2 :: (a -> b -> c) -> ReflexTestT t intref out m a -> ReflexTestT t intref out m b -> ReflexTestT t intref out m c # (*>) :: ReflexTestT t intref out m a -> ReflexTestT t intref out m b -> ReflexTestT t intref out m b # (<*) :: ReflexTestT t intref out m a -> ReflexTestT t intref out m b -> ReflexTestT t intref out m a # | |
Functor m => Functor (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods fmap :: (a -> b) -> ReflexTestT t intref out m a -> ReflexTestT t intref out m b # (<$) :: a -> ReflexTestT t intref out m b -> ReflexTestT t intref out m a # | |
Monad m => Monad (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host Methods (>>=) :: ReflexTestT t intref out m a -> (a -> ReflexTestT t intref out m b) -> ReflexTestT t intref out m b # (>>) :: ReflexTestT t intref out m a -> ReflexTestT t intref out m b -> ReflexTestT t intref out m b # return :: a -> ReflexTestT t intref out m a # | |
type InnerMonad (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host | |
type InputTriggerRefs (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host | |
type OutputEvents (ReflexTestT t intref out m) Source # | |
Defined in Reflex.Test.Monad.Host |
Arguments
:: forall intref inev out t m a. TestGuestConstraints t m | |
=> (inev, intref) | make sure intref match inev, i.e. return values of newEventWithTriggerRef |
-> (inev -> TestGuestT t m out) | network to test |
-> ReflexTestT t intref out m a | test monad to run |
-> m () |
class ReflexTestApp app t m | app -> t m where Source #
class to help bind network and types to a ReflexTestT
see testReflexTestMonadHostSpec.hs for usage example
Associated Types
data AppInputTriggerRefs app :: Type Source #
data AppInputEvents app :: Type Source #
Methods
getApp :: AppInputEvents app -> TestGuestT t m (AppOutput app) Source #
makeInputs :: m (AppInputEvents app, AppInputTriggerRefs app) Source #
runReflexTestApp :: (ReflexTestApp app t m, TestGuestConstraints t m) => ReflexTestT t (AppInputTriggerRefs app) (AppOutput app) m () -> m () Source #