reflex-test-host-0.1.2.2: reflex host methods for testing without external events
Safe HaskellSafe-Inferred
LanguageHaskell2010

Reflex.Test.Monad.Host

Description

 
Synopsis

Documentation

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 #

 

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

Instances details
MonadRef m => MonadReflexTest t (ReflexTestT t intref out m) Source # 
Instance details

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 #

data AppState t m Source #

Constructors

AppState 

Fields

Instances

Instances details
Monad m => MonadState (AppState t m) (ReflexTestT t intref out m) Source # 
Instance details

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

Instances details
MonadHold t m => MonadHold (t :: Type) (ReflexTestT t intref out m) Source # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

Defined in Reflex.Test.Monad.Host

type InnerMonad (ReflexTestT t intref out m) = m
type InputTriggerRefs (ReflexTestT t intref out m) Source # 
Instance details

Defined in Reflex.Test.Monad.Host

type InputTriggerRefs (ReflexTestT t intref out m) = intref
type OutputEvents (ReflexTestT t intref out m) Source # 
Instance details

Defined in Reflex.Test.Monad.Host

type OutputEvents (ReflexTestT t intref out m) = out

runReflexTestT Source #

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 #

data AppOutput app :: Type Source #