reflex-0.6.3: Higher-order Functional Reactive Programming

Safe HaskellTrustworthy
LanguageHaskell98

Reflex.Class

Contents

Description

 
Synopsis

Documentation

Primitives

class (MonadHold t (PushM t), MonadSample t (PullM t), MonadFix (PushM t), Functor (Dynamic t), Applicative (Dynamic t), Monad (Dynamic t)) => Reflex t where Source #

The Reflex class contains all the primitive functionality needed for Functional Reactive Programming (FRP). The t type parameter indicates which "timeline" is in use. Timelines are fully-independent FRP contexts, and the type of the timeline determines the FRP engine to be used. For most purposes, the Spider implementation is recommended.

Associated Types

data Behavior t :: * -> * Source #

A container for a value that can change over time. Behaviors can be sampled at will, but it is not possible to be notified when they change

data Event t :: * -> * Source #

A stream of occurrences. During any given frame, an Event is either occurring or not occurring; if it is occurring, it will contain a value of the given type (its "occurrence type")

data Dynamic t :: * -> * Source #

A container for a value that can change over time and allows notifications on changes. Basically a combination of a Behavior and an Event, with a rule that the Behavior will change if and only if the Event fires.

data Incremental t :: * -> * Source #

An Incremental is a more general form of a Dynamic. Instead of always fully replacing the value, only parts of it can be patched. This is only needed for performance critical code via mergeIncremental to make small changes to large values.

type PushM t :: * -> * Source #

A monad for doing complex push-based calculations efficiently

type PullM t :: * -> * Source #

A monad for doing complex pull-based calculations efficiently

Methods

never :: Event t a Source #

An Event with no occurrences

constant :: a -> Behavior t a Source #

Create a Behavior that always has the given value

push :: (a -> PushM t (Maybe b)) -> Event t a -> Event t b Source #

Create an Event from another Event; the provided function can sample Behaviors and hold Events, and use the results to produce a occurring (Just) or non-occurring (Nothing) result

pushCheap :: (a -> PushM t (Maybe b)) -> Event t a -> Event t b Source #

Like push but intended for functions that the implementation can consider cheap to compute for performance considerations. WARNING: The function passed to pushCheap may be run multiple times without any caching.

pull :: PullM t a -> Behavior t a Source #

Create a Behavior by reading from other Behaviors; the result will be recomputed whenever any of the read Behaviors changes

mergeG :: GCompare k => (forall a. q a -> Event t (v a)) -> DMap k q -> Event t (DMap k v) Source #

Merge a collection of events; the resulting Event will only occur if at least one input event is occurring, and will contain all of the input keys that are occurring simultaneously

fanG :: GCompare k => Event t (DMap k v) -> EventSelectorG t k v Source #

Efficiently fan-out an event to many destinations. You should save the result in a let-binding, and then repeatedly selectG on the result to create child events

switch :: Behavior t (Event t a) -> Event t a Source #

Create an Event that will occur whenever the currently-selected input Event occurs

coincidence :: Event t (Event t a) -> Event t a Source #

Create an Event that will occur whenever the input event is occurring -- and its occurrence value, another Event, is also occurring

current :: Dynamic t a -> Behavior t a Source #

Extract the Behavior of a Dynamic.

updated :: Dynamic t a -> Event t a Source #

Extract the Event of the Dynamic.

unsafeBuildDynamic :: PullM t a -> Event t a -> Dynamic t a Source #

Create a new Dynamic. The given PullM must always return the most recent firing of the given Event, if any.

unsafeBuildIncremental :: Patch p => PullM t (PatchTarget p) -> Event t p -> Incremental t p Source #

Create a new Incremental. The given PullM's value must always change in the same way that the accumulated application of patches would change that value.

mergeIncrementalG :: GCompare k => (forall a. q a -> Event t (v a)) -> Incremental t (PatchDMap k q) -> Event t (DMap k v) Source #

Create a merge whose parents can change over time

mergeIncrementalWithMoveG :: GCompare k => (forall a. q a -> Event t (v a)) -> Incremental t (PatchDMapWithMove k q) -> Event t (DMap k v) Source #

Experimental: Create a merge whose parents can change over time; changing the key of an Event is more efficient than with mergeIncremental

currentIncremental :: Patch p => Incremental t p -> Behavior t (PatchTarget p) Source #

Extract the Behavior component of an Incremental

updatedIncremental :: Patch p => Incremental t p -> Event t p Source #

Extract the Event component of an Incremental

incrementalToDynamic :: Patch p => Incremental t p -> Dynamic t (PatchTarget p) Source #

Convert an Incremental to a Dynamic

behaviorCoercion :: Coercion a b -> Coercion (Behavior t a) (Behavior t b) Source #

Construct a Coercion for a Behavior given an Coercion for its occurrence type

eventCoercion :: Coercion a b -> Coercion (Event t a) (Event t b) Source #

Construct a Coercion for an Event given an Coercion for its occurrence type

dynamicCoercion :: Coercion a b -> Coercion (Dynamic t a) (Dynamic t b) Source #

Construct a Coercion for a Dynamic given an Coercion for its occurrence type

incrementalCoercion :: Coercion (PatchTarget a) (PatchTarget b) -> Coercion a b -> Coercion (Incremental t a) (Incremental t b) Source #

Construct a Coercion for an Incremental given Coercions for its patch target and patch types.

mergeIntIncremental :: Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a) Source #

fanInt :: Event t (IntMap a) -> EventSelectorInt t a Source #

Instances
(Enum t, HasTrie t, Ord t) => Reflex (Pure t :: Type) Source #

The Enum instance of t must be dense: for all x :: t, there must not exist any y :: t such that pred x < y < x. The HasTrie instance will be used exclusively to memoize functions of t, not for any of its other capabilities.

Instance details

Defined in Reflex.Pure

Associated Types

data Behavior (Pure t) a :: Type Source #

data Event (Pure t) a :: Type Source #

data Dynamic (Pure t) a :: Type Source #

data Incremental (Pure t) a :: Type Source #

type PushM (Pure t) :: Type -> Type Source #

type PullM (Pure t) :: Type -> Type Source #

Methods

never :: Event (Pure t) a Source #

constant :: a -> Behavior (Pure t) a Source #

push :: (a -> PushM (Pure t) (Maybe b)) -> Event (Pure t) a -> Event (Pure t) b Source #

pushCheap :: (a -> PushM (Pure t) (Maybe b)) -> Event (Pure t) a -> Event (Pure t) b Source #

pull :: PullM (Pure t) a -> Behavior (Pure t) a Source #

mergeG :: GCompare k => (forall (a :: k). q a -> Event (Pure t) (v a)) -> DMap k q -> Event (Pure t) (DMap k v) Source #

fanG :: GCompare k => Event (Pure t) (DMap k v) -> EventSelectorG (Pure t) k v Source #

switch :: Behavior (Pure t) (Event (Pure t) a) -> Event (Pure t) a Source #

coincidence :: Event (Pure t) (Event (Pure t) a) -> Event (Pure t) a Source #

current :: Dynamic (Pure t) a -> Behavior (Pure t) a Source #

updated :: Dynamic (Pure t) a -> Event (Pure t) a Source #

unsafeBuildDynamic :: PullM (Pure t) a -> Event (Pure t) a -> Dynamic (Pure t) a Source #

unsafeBuildIncremental :: Patch p => PullM (Pure t) (PatchTarget p) -> Event (Pure t) p -> Incremental (Pure t) p Source #

mergeIncrementalG :: GCompare k => (forall (a :: k). q a -> Event (Pure t) (v a)) -> Incremental (Pure t) (PatchDMap k q) -> Event (Pure t) (DMap k v) Source #

mergeIncrementalWithMoveG :: GCompare k => (forall (a :: k). q a -> Event (Pure t) (v a)) -> Incremental (Pure t) (PatchDMapWithMove k q) -> Event (Pure t) (DMap k v) Source #

currentIncremental :: Patch p => Incremental (Pure t) p -> Behavior (Pure t) (PatchTarget p) Source #

updatedIncremental :: Patch p => Incremental (Pure t) p -> Event (Pure t) p Source #

incrementalToDynamic :: Patch p => Incremental (Pure t) p -> Dynamic (Pure t) (PatchTarget p) Source #

behaviorCoercion :: Coercion a b -> Coercion (Behavior (Pure t) a) (Behavior (Pure t) b) Source #

eventCoercion :: Coercion a b -> Coercion (Event (Pure t) a) (Event (Pure t) b) Source #

dynamicCoercion :: Coercion a b -> Coercion (Dynamic (Pure t) a) (Dynamic (Pure t) b) Source #

incrementalCoercion :: Coercion (PatchTarget a) (PatchTarget b) -> Coercion a b -> Coercion (Incremental (Pure t) a) (Incremental (Pure t) b) Source #

mergeIntIncremental :: Incremental (Pure t) (PatchIntMap (Event (Pure t) a)) -> Event (Pure t) (IntMap a) Source #

fanInt :: Event (Pure t) (IntMap a) -> EventSelectorInt (Pure t) a Source #

Reflex t => Reflex (ProfiledTimeline t :: Type) Source # 
Instance details

Defined in Reflex.Profiled

Methods

never :: Event (ProfiledTimeline t) a Source #

constant :: a -> Behavior (ProfiledTimeline t) a Source #

push :: (a -> PushM (ProfiledTimeline t) (Maybe b)) -> Event (ProfiledTimeline t) a -> Event (ProfiledTimeline t) b Source #

pushCheap :: (a -> PushM (ProfiledTimeline t) (Maybe b)) -> Event (ProfiledTimeline t) a -> Event (ProfiledTimeline t) b Source #

pull :: PullM (ProfiledTimeline t) a -> Behavior (ProfiledTimeline t) a Source #

mergeG :: GCompare k => (forall (a :: k). q a -> Event (ProfiledTimeline t) (v a)) -> DMap k q -> Event (ProfiledTimeline t) (DMap k v) Source #

fanG :: GCompare k => Event (ProfiledTimeline t) (DMap k v) -> EventSelectorG (ProfiledTimeline t) k v Source #

switch :: Behavior (ProfiledTimeline t) (Event (ProfiledTimeline t) a) -> Event (ProfiledTimeline t) a Source #

coincidence :: Event (ProfiledTimeline t) (Event (ProfiledTimeline t) a) -> Event (ProfiledTimeline t) a Source #

current :: Dynamic (ProfiledTimeline t) a -> Behavior (ProfiledTimeline t) a Source #

updated :: Dynamic (ProfiledTimeline t) a -> Event (ProfiledTimeline t) a Source #

unsafeBuildDynamic :: PullM (ProfiledTimeline t) a -> Event (ProfiledTimeline t) a -> Dynamic (ProfiledTimeline t) a Source #

unsafeBuildIncremental :: Patch p => PullM (ProfiledTimeline t) (PatchTarget p) -> Event (ProfiledTimeline t) p -> Incremental (ProfiledTimeline t) p Source #

mergeIncrementalG :: GCompare k => (forall (a :: k). q a -> Event (ProfiledTimeline t) (v a)) -> Incremental (ProfiledTimeline t) (PatchDMap k q) -> Event (ProfiledTimeline t) (DMap k v) Source #

mergeIncrementalWithMoveG :: GCompare k => (forall (a :: k). q a -> Event (ProfiledTimeline t) (v a)) -> Incremental (ProfiledTimeline t) (PatchDMapWithMove k q) -> Event (ProfiledTimeline t) (DMap k v) Source #

currentIncremental :: Patch p => Incremental (ProfiledTimeline t) p -> Behavior (ProfiledTimeline t) (PatchTarget p) Source #

updatedIncremental :: Patch p => Incremental (ProfiledTimeline t) p -> Event (ProfiledTimeline t) p Source #

incrementalToDynamic :: Patch p => Incremental (ProfiledTimeline t) p -> Dynamic (ProfiledTimeline t) (PatchTarget p) Source #

behaviorCoercion :: Coercion a b -> Coercion (Behavior (ProfiledTimeline t) a) (Behavior (ProfiledTimeline t) b) Source #

eventCoercion :: Coercion a b -> Coercion (Event (ProfiledTimeline t) a) (Event (ProfiledTimeline t) b) Source #

dynamicCoercion :: Coercion a b -> Coercion (Dynamic (ProfiledTimeline t) a) (Dynamic (ProfiledTimeline t) b) Source #

incrementalCoercion :: Coercion (PatchTarget a) (PatchTarget b) -> Coercion a b -> Coercion (Incremental (ProfiledTimeline t) a) (Incremental (ProfiledTimeline t) b) Source #

mergeIntIncremental :: Incremental (ProfiledTimeline t) (PatchIntMap (Event (ProfiledTimeline t) a)) -> Event (ProfiledTimeline t) (IntMap a) Source #

fanInt :: Event (ProfiledTimeline t) (IntMap a) -> EventSelectorInt (ProfiledTimeline t) a Source #

HasSpiderTimeline x => Reflex (SpiderTimeline x :: Type) Source # 
Instance details

Defined in Reflex.Spider.Internal

Methods

never :: Event (SpiderTimeline x) a Source #

constant :: a -> Behavior (SpiderTimeline x) a Source #

push :: (a -> PushM (SpiderTimeline x) (Maybe b)) -> Event (SpiderTimeline x) a -> Event (SpiderTimeline x) b Source #

pushCheap :: (a -> PushM (SpiderTimeline x) (Maybe b)) -> Event (SpiderTimeline x) a -> Event (SpiderTimeline x) b Source #

pull :: PullM (SpiderTimeline x) a -> Behavior (SpiderTimeline x) a Source #

mergeG :: GCompare k => (forall (a :: k). q a -> Event (SpiderTimeline x) (v a)) -> DMap k q -> Event (SpiderTimeline x) (DMap k v) Source #

fanG :: GCompare k => Event (SpiderTimeline x) (DMap k v) -> EventSelectorG (SpiderTimeline x) k v Source #

switch :: Behavior (SpiderTimeline x) (Event (SpiderTimeline x) a) -> Event (SpiderTimeline x) a Source #

coincidence :: Event (SpiderTimeline x) (Event (SpiderTimeline x) a) -> Event (SpiderTimeline x) a Source #

current :: Dynamic (SpiderTimeline x) a -> Behavior (SpiderTimeline x) a Source #

updated :: Dynamic (SpiderTimeline x) a -> Event (SpiderTimeline x) a Source #

unsafeBuildDynamic :: PullM (SpiderTimeline x) a -> Event (SpiderTimeline x) a -> Dynamic (SpiderTimeline x) a Source #

unsafeBuildIncremental :: Patch p => PullM (SpiderTimeline x) (PatchTarget p) -> Event (SpiderTimeline x) p -> Incremental (SpiderTimeline x) p Source #

mergeIncrementalG :: GCompare k => (forall (a :: k). q a -> Event (SpiderTimeline x) (v a)) -> Incremental (SpiderTimeline x) (PatchDMap k q) -> Event (SpiderTimeline x) (DMap k v) Source #

mergeIncrementalWithMoveG :: GCompare k => (forall (a :: k). q a -> Event (SpiderTimeline x) (v a)) -> Incremental (SpiderTimeline x) (PatchDMapWithMove k q) -> Event (SpiderTimeline x) (DMap k v) Source #

currentIncremental :: Patch p => Incremental (SpiderTimeline x) p -> Behavior (SpiderTimeline x) (PatchTarget p) Source #

updatedIncremental :: Patch p => Incremental (SpiderTimeline x) p -> Event (SpiderTimeline x) p Source #

incrementalToDynamic :: Patch p => Incremental (SpiderTimeline x) p -> Dynamic (SpiderTimeline x) (PatchTarget p) Source #

behaviorCoercion :: Coercion a b -> Coercion (Behavior (SpiderTimeline x) a) (Behavior (SpiderTimeline x) b) Source #

eventCoercion :: Coercion a b -> Coercion (Event (SpiderTimeline x) a) (Event (SpiderTimeline x) b) Source #

dynamicCoercion :: Coercion a b -> Coercion (Dynamic (SpiderTimeline x) a) (Dynamic (SpiderTimeline x) b) Source #

incrementalCoercion :: Coercion (PatchTarget a) (PatchTarget b) -> Coercion a b -> Coercion (Incremental (SpiderTimeline x) a) (Incremental (SpiderTimeline x) b) Source #

mergeIntIncremental :: Incremental (SpiderTimeline x) (PatchIntMap (Event (SpiderTimeline x) a)) -> Event (SpiderTimeline x) (IntMap a) Source #

fanInt :: Event (SpiderTimeline x) (IntMap a) -> EventSelectorInt (SpiderTimeline x) a Source #

mergeInt :: Reflex t => IntMap (Event t a) -> Event t (IntMap a) Source #

Constructs a single Event out of a map of events. The output event may fire with multiple keys simultaneously.

coerceBehavior :: (Reflex t, Coercible a b) => Behavior t a -> Behavior t b Source #

Coerce a Behavior between representationally-equivalent value types

coerceEvent :: (Reflex t, Coercible a b) => Event t a -> Event t b Source #

Coerce an Event between representationally-equivalent occurrence types

coerceDynamic :: (Reflex t, Coercible a b) => Dynamic t a -> Dynamic t b Source #

Coerce a Dynamic between representationally-equivalent value types

coerceIncremental :: (Reflex t, Coercible a b, Coercible (PatchTarget a) (PatchTarget b)) => Incremental t a -> Incremental t b Source #

Coerce an Incremental between representationally-equivalent value types

class (Applicative m, Monad m) => MonadSample t m | m -> t where Source #

MonadSample designates monads that can read the current value of a Behavior. This includes both PullM and PushM.

Methods

sample :: Behavior t a -> m a Source #

Get the current value in the Behavior

Instances
MonadSample t m => MonadSample (t :: k) (ExceptT e m) Source # 
Instance details

Defined in Reflex.Class

Methods

sample :: Behavior t a -> ExceptT e m a Source #

MonadSample t m => MonadSample (t :: k) (StateT s m) Source # 
Instance details

Defined in Reflex.Class

Methods

sample :: Behavior t a -> StateT s m a Source #

(MonadSample t m, Monoid r) => MonadSample (t :: k) (WriterT r m) Source # 
Instance details

Defined in Reflex.Class

Methods

sample :: Behavior t a -> WriterT r m a Source #

MonadSample t m => MonadSample (t :: k) (ReaderT r m) Source # 
Instance details

Defined in Reflex.Class

Methods

sample :: Behavior t a -> ReaderT r m a Source #

MonadSample t m => MonadSample (t :: k) (ContT r m) Source # 
Instance details

Defined in Reflex.Class

Methods

sample :: Behavior t a -> ContT r m a Source #

(MonadSample t m, Monoid w) => MonadSample (t :: k) (RWST r w s m) Source # 
Instance details

Defined in Reflex.Class

Methods

sample :: Behavior t a -> RWST r w s m a Source #

MonadSample t m => MonadSample (t :: Type) (TriggerEventT t m) Source # 
Instance details

Defined in Reflex.TriggerEvent.Base

Methods

sample :: Behavior t a -> TriggerEventT t m a Source #

MonadSample t m => MonadSample (t :: Type) (PostBuildT t m) Source # 
Instance details

Defined in Reflex.PostBuild.Base

Methods

sample :: Behavior t a -> PostBuildT t m a Source #

ReflexHost t => MonadSample (t :: Type) (PerformEventT t m) Source # 
Instance details

Defined in Reflex.PerformEvent.Base

Methods

sample :: Behavior t a -> PerformEventT t m a Source #

MonadSample t m => MonadSample (t :: Type) (EventWriterT t w m) Source # 
Instance details

Defined in Reflex.EventWriter.Base

Methods

sample :: Behavior t a -> EventWriterT t w m a Source #

MonadSample t m => MonadSample (t :: Type) (QueryT t q m) Source # 
Instance details

Defined in Reflex.Query.Base

Methods

sample :: Behavior t a -> QueryT t q m a Source #

MonadSample t m => MonadSample (t :: Type) (DynamicWriterT t w m) Source # 
Instance details

Defined in Reflex.DynamicWriter.Base

Methods

sample :: Behavior t a -> DynamicWriterT t w m a Source #

MonadSample t m => MonadSample (t :: Type) (BehaviorWriterT t w m) Source # 
Instance details

Defined in Reflex.BehaviorWriter.Base

Methods

sample :: Behavior t a -> BehaviorWriterT t w m a Source #

MonadSample t m => MonadSample (t :: Type) (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base

Methods

sample :: Behavior t a -> RequesterT t request response m a Source #

MonadSample (Pure t :: Type) ((->) t :: Type -> Type) Source # 
Instance details

Defined in Reflex.Pure

Methods

sample :: Behavior (Pure t) a -> t -> a Source #

HasSpiderTimeline x => MonadSample (SpiderTimeline x :: Type) (SpiderHost x) Source # 
Instance details

Defined in Reflex.Spider.Internal

HasSpiderTimeline x => MonadSample (SpiderTimeline x :: Type) (SpiderHostFrame x) Source # 
Instance details

Defined in Reflex.Spider.Internal

HasSpiderTimeline x => MonadSample (SpiderTimeline x :: Type) (SpiderPushM x) Source # 
Instance details

Defined in Reflex.Spider.Internal

MonadSample (SpiderTimeline x :: Type) (SpiderPullM x) Source # 
Instance details

Defined in Reflex.Spider.Internal

MonadSample t m => MonadSample (ProfiledTimeline t :: Type) (ProfiledM m) Source # 
Instance details

Defined in Reflex.Profiled

HasSpiderTimeline x => MonadSample (SpiderTimeline x :: Type) (ReadPhase x) Source # 
Instance details

Defined in Reflex.Spider.Internal

HasSpiderTimeline x => MonadSample (SpiderTimeline x :: Type) (EventM x) Source # 
Instance details

Defined in Reflex.Spider.Internal

Methods

sample :: Behavior (SpiderTimeline x) a -> EventM x a Source #

class MonadSample t m => MonadHold t m where Source #

MonadHold designates monads that can create new Behaviors based on Events; usually this will be PushM or a monad based on it. MonadHold is required to create any stateful computations with Reflex.

Minimal complete definition

buildDynamic, headE

Methods

hold :: a -> Event t a -> m (Behavior t a) Source #

Create a new Behavior whose value will initially be equal to the given value and will be updated whenever the given Event occurs. The update takes effect immediately after the Event occurs; if the occurrence that sets the Behavior (or one that is simultaneous with it) is used to sample the Behavior, it will see the old value of the Behavior, not the new one.

hold :: (m ~ f m', MonadTrans f, MonadHold t m') => a -> Event t a -> m (Behavior t a) Source #

Create a new Behavior whose value will initially be equal to the given value and will be updated whenever the given Event occurs. The update takes effect immediately after the Event occurs; if the occurrence that sets the Behavior (or one that is simultaneous with it) is used to sample the Behavior, it will see the old value of the Behavior, not the new one.

holdDyn :: a -> Event t a -> m (Dynamic t a) Source #

Create a Dynamic value using the given initial value that changes every time the Event occurs.

holdDyn :: (m ~ f m', MonadTrans f, MonadHold t m') => a -> Event t a -> m (Dynamic t a) Source #

Create a Dynamic value using the given initial value that changes every time the Event occurs.

holdIncremental :: Patch p => PatchTarget p -> Event t p -> m (Incremental t p) Source #

Create an Incremental value using the given initial value that changes every time the Event occurs.

holdIncremental :: (Patch p, m ~ f m', MonadTrans f, MonadHold t m') => PatchTarget p -> Event t p -> m (Incremental t p) Source #

Create an Incremental value using the given initial value that changes every time the Event occurs.

buildDynamic :: PushM t a -> Event t a -> m (Dynamic t a) Source #

headE :: Event t a -> m (Event t a) Source #

Create a new Event that only occurs only once, on the first occurrence of the supplied Event.

Instances
MonadHold t m => MonadHold (t :: k) (ExceptT e m) Source # 
Instance details

Defined in Reflex.Class

Methods

hold :: a -> Event t a -> ExceptT e m (Behavior t a) Source #

holdDyn :: a -> Event t a -> ExceptT e m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> ExceptT e m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> ExceptT e m (Dynamic t a) Source #

headE :: Event t a -> ExceptT e m (Event t a) Source #

MonadHold t m => MonadHold (t :: k) (StateT s m) Source # 
Instance details

Defined in Reflex.Class

Methods

hold :: a -> Event t a -> StateT s m (Behavior t a) Source #

holdDyn :: a -> Event t a -> StateT s m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> StateT s m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> StateT s m (Dynamic t a) Source #

headE :: Event t a -> StateT s m (Event t a) Source #

(MonadHold t m, Monoid r) => MonadHold (t :: k) (WriterT r m) Source # 
Instance details

Defined in Reflex.Class

Methods

hold :: a -> Event t a -> WriterT r m (Behavior t a) Source #

holdDyn :: a -> Event t a -> WriterT r m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> WriterT r m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> WriterT r m (Dynamic t a) Source #

headE :: Event t a -> WriterT r m (Event t a) Source #

MonadHold t m => MonadHold (t :: k) (ReaderT r m) Source # 
Instance details

Defined in Reflex.Class

Methods

hold :: a -> Event t a -> ReaderT r m (Behavior t a) Source #

holdDyn :: a -> Event t a -> ReaderT r m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> ReaderT r m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> ReaderT r m (Dynamic t a) Source #

headE :: Event t a -> ReaderT r m (Event t a) Source #

MonadHold t m => MonadHold (t :: k) (ContT r m) Source # 
Instance details

Defined in Reflex.Class

Methods

hold :: a -> Event t a -> ContT r m (Behavior t a) Source #

holdDyn :: a -> Event t a -> ContT r m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> ContT r m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> ContT r m (Dynamic t a) Source #

headE :: Event t a -> ContT r m (Event t a) Source #

(MonadHold t m, Monoid w) => MonadHold (t :: k) (RWST r w s m) Source # 
Instance details

Defined in Reflex.Class

Methods

hold :: a -> Event t a -> RWST r w s m (Behavior t a) Source #

holdDyn :: a -> Event t a -> RWST r w s m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> RWST r w s m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> RWST r w s m (Dynamic t a) Source #

headE :: Event t a -> RWST r w s m (Event t a) Source #

MonadHold t m => MonadHold (t :: Type) (TriggerEventT t m) Source # 
Instance details

Defined in Reflex.TriggerEvent.Base

Methods

hold :: a -> Event t a -> TriggerEventT t m (Behavior t a) Source #

holdDyn :: a -> Event t a -> TriggerEventT t m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> TriggerEventT t m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> TriggerEventT t m (Dynamic t a) Source #

headE :: Event t a -> TriggerEventT t m (Event t a) Source #

MonadHold t m => MonadHold (t :: Type) (PostBuildT t m) Source # 
Instance details

Defined in Reflex.PostBuild.Base

Methods

hold :: a -> Event t a -> PostBuildT t m (Behavior t a) Source #

holdDyn :: a -> Event t a -> PostBuildT t m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> PostBuildT t m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> PostBuildT t m (Dynamic t a) Source #

headE :: Event t a -> PostBuildT t m (Event t a) Source #

(ReflexHost t, MonadHold t m) => MonadHold (t :: Type) (PerformEventT t m) Source # 
Instance details

Defined in Reflex.PerformEvent.Base

Methods

hold :: a -> Event t a -> PerformEventT t m (Behavior t a) Source #

holdDyn :: a -> Event t a -> PerformEventT t m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> PerformEventT t m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> PerformEventT t m (Dynamic t a) Source #

headE :: Event t a -> PerformEventT t m (Event t a) Source #

MonadHold t m => MonadHold (t :: Type) (EventWriterT t w m) Source # 
Instance details

Defined in Reflex.EventWriter.Base

Methods

hold :: a -> Event t a -> EventWriterT t w m (Behavior t a) Source #

holdDyn :: a -> Event t a -> EventWriterT t w m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> EventWriterT t w m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> EventWriterT t w m (Dynamic t a) Source #

headE :: Event t a -> EventWriterT t w m (Event t a) Source #

MonadHold t m => MonadHold (t :: Type) (QueryT t q m) Source # 
Instance details

Defined in Reflex.Query.Base

Methods

hold :: a -> Event t a -> QueryT t q m (Behavior t a) Source #

holdDyn :: a -> Event t a -> QueryT t q m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> QueryT t q m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> QueryT t q m (Dynamic t a) Source #

headE :: Event t a -> QueryT t q m (Event t a) Source #

MonadHold t m => MonadHold (t :: Type) (DynamicWriterT t w m) Source # 
Instance details

Defined in Reflex.DynamicWriter.Base

Methods

hold :: a -> Event t a -> DynamicWriterT t w m (Behavior t a) Source #

holdDyn :: a -> Event t a -> DynamicWriterT t w m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> DynamicWriterT t w m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> DynamicWriterT t w m (Dynamic t a) Source #

headE :: Event t a -> DynamicWriterT t w m (Event t a) Source #

MonadHold t m => MonadHold (t :: Type) (BehaviorWriterT t w m) Source # 
Instance details

Defined in Reflex.BehaviorWriter.Base

Methods

hold :: a -> Event t a -> BehaviorWriterT t w m (Behavior t a) Source #

holdDyn :: a -> Event t a -> BehaviorWriterT t w m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> BehaviorWriterT t w m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> BehaviorWriterT t w m (Dynamic t a) Source #

headE :: Event t a -> BehaviorWriterT t w m (Event t a) Source #

MonadHold t m => MonadHold (t :: Type) (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base

Methods

hold :: a -> Event t a -> RequesterT t request response m (Behavior t a) Source #

holdDyn :: a -> Event t a -> RequesterT t request response m (Dynamic t a) Source #

holdIncremental :: Patch p => PatchTarget p -> Event t p -> RequesterT t request response m (Incremental t p) Source #

buildDynamic :: PushM t a -> Event t a -> RequesterT t request response m (Dynamic t a) Source #

headE :: Event t a -> RequesterT t request response m (Event t a) Source #

(Enum t, HasTrie t, Ord t) => MonadHold (Pure t :: Type) ((->) t :: Type -> Type) Source # 
Instance details

Defined in Reflex.Pure

Methods

hold :: a -> Event (Pure t) a -> t -> Behavior (Pure t) a Source #

holdDyn :: a -> Event (Pure t) a -> t -> Dynamic (Pure t) a Source #

holdIncremental :: Patch p => PatchTarget p -> Event (Pure t) p -> t -> Incremental (Pure t) p Source #

buildDynamic :: PushM (Pure t) a -> Event (Pure t) a -> t -> Dynamic (Pure t) a Source #

headE :: Event (Pure t) a -> t -> Event (Pure t) a Source #

HasSpiderTimeline x => MonadHold (SpiderTimeline x :: Type) (SpiderHostFrame x) Source # 
Instance details

Defined in Reflex.Spider.Internal

HasSpiderTimeline x => MonadHold (SpiderTimeline x :: Type) (SpiderHost x) Source # 
Instance details

Defined in Reflex.Spider.Internal

HasSpiderTimeline x => MonadHold (SpiderTimeline x :: Type) (SpiderPushM x) Source # 
Instance details

Defined in Reflex.Spider.Internal

MonadHold t m => MonadHold (ProfiledTimeline t :: Type) (ProfiledM m) Source # 
Instance details

Defined in Reflex.Profiled

HasSpiderTimeline x => MonadHold (SpiderTimeline x :: Type) (ReadPhase x) Source # 
Instance details

Defined in Reflex.Spider.Internal

HasSpiderTimeline x => MonadHold (SpiderTimeline x :: Type) (EventM x) Source # 
Instance details

Defined in Reflex.Spider.Internal

fan related types

newtype EventSelector t k Source #

An EventSelector allows you to efficiently select an Event based on a key. This is much more efficient than filtering for each key with mapMaybe.

Constructors

EventSelector 

Fields

  • select :: forall a. k a -> Event t a

    Retrieve the Event for the given key. The type of the Event is determined by the type of the key, so this can be used to fan-out Events whose sub-Events have different types.

    Using EventSelectors and the fan primitive is far more efficient than (but equivalent to) using mapMaybe to select only the relevant occurrences of an Event.

newtype EventSelectorG t k v Source #

Constructors

EventSelectorG 

Fields

  • selectG :: forall a. k a -> Event t (v a)

    Retrieve the Event for the given key. The type of the Event is determined by the type of the key, so this can be used to fan-out Events whose sub-Events have different types.

    Using EventSelectors and the fan primitive is far more efficient than (but equivalent to) using mapMaybe to select only the relevant occurrences of an Event.

newtype EventSelectorInt t a Source #

Efficiently select an Event keyed on Int. This is more efficient than manually filtering by key.

Constructors

EventSelectorInt 

Fields

Convenience functions

constDyn :: Reflex t => a -> Dynamic t a Source #

Construct a Dynamic value that never changes

pushAlways :: Reflex t => (a -> PushM t b) -> Event t a -> Event t b Source #

Create an Event from another Event. The provided function can sample Behaviors and hold Events.

Combining Events

leftmost :: Reflex t => [Event t a] -> Event t a Source #

Create a new Event that occurs if at least one of the Events in the list occurs. If multiple occur at the same time the value is the value of the leftmost event.

merge :: (Reflex t, GCompare k) => DMap k (Event t) -> Event t (DMap k Identity) Source #

Merge a collection of events; the resulting Event will only occur if at least one input event is occurring, and will contain all of the input keys that are occurring simultaneously

mergeIncremental :: (Reflex t, GCompare k) => Incremental t (PatchDMap k (Event t)) -> Event t (DMap k Identity) Source #

Create a merge whose parents can change over time

mergeIncrementalWithMove :: (Reflex t, GCompare k) => Incremental t (PatchDMapWithMove k (Event t)) -> Event t (DMap k Identity) Source #

Experimental: Create a merge whose parents can change over time; changing the key of an Event is more efficient than with mergeIncremental

mergeMap :: (Reflex t, Ord k) => Map k (Event t a) -> Event t (Map k a) Source #

Create a new Event combining the map of Events into an Event that occurs if at least one of them occurs and has a map of values of all Events occurring at that time.

mergeIntMap :: Reflex t => IntMap (Event t a) -> Event t (IntMap a) Source #

Like mergeMap but for IntMap.

mergeMapIncremental :: (Reflex t, Ord k) => Incremental t (PatchMap k (Event t a)) -> Event t (Map k a) Source #

Create a merge whose parents can change over time

mergeMapIncrementalWithMove :: (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Event t a)) -> Event t (Map k a) Source #

Experimental: Create a merge whose parents can change over time; changing the key of an Event is more efficient than with mergeIncremental

mergeIntMapIncremental :: Reflex t => Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a) Source #

Create a merge whose parents can change over time

coincidencePatchMap :: (Reflex t, Ord k) => Event t (PatchMap k (Event t v)) -> Event t (PatchMap k v) Source #

When the given outer event fires, condense the inner events into the contained patch. Non-firing inner events will be replaced with deletions.

mergeList :: Reflex t => [Event t a] -> Event t (NonEmpty a) Source #

Create a new Event that occurs if at least one of the Events in the list occurs and has a list of the values of all Events occurring at that time.

mergeWith :: Reflex t => (a -> a -> a) -> [Event t a] -> Event t a Source #

Create a new Event that occurs if at least one of the Events in the list occurs. If multiple occur at the same time they are folded from the left with the given function.

difference :: Reflex t => Event t a -> Event t b -> Event t a Source #

Create a new Event that occurs when the first supplied Event occurs unless the second supplied Event occurs simultaneously.

alignEventWithMaybe :: Reflex t => (These a b -> Maybe c) -> Event t a -> Event t b -> Event t c Source #

Zips two values by taking the union of their shapes and combining with the provided function. Nothing values are dropped.

Breaking up Events

splitE :: Reflex t => Event t (a, b) -> (Event t a, Event t b) Source #

Split the supplied Event into two individual Events occurring at the same time with the respective values from the tuple.

fan :: forall t k. (Reflex t, GCompare k) => Event t (DMap k Identity) -> EventSelector t k Source #

Efficiently fan-out an event to many destinations. You should save the result in a let-binding, and then repeatedly select on the result to create child events

fanEither :: Reflex t => Event t (Either a b) -> (Event t a, Event t b) Source #

Split the event into separate events for Left and Right values.

fanThese :: Reflex t => Event t (These a b) -> (Event t a, Event t b) Source #

Split the event into separate events for This and That values, allowing them to fire simultaneously when the input value is These.

fanMap :: (Reflex t, Ord k) => Event t (Map k a) -> EventSelector t (Const2 k a) Source #

Split the event into an EventSelector that allows efficient selection of the individual Events.

dmapToThese :: DMap (EitherTag a b) Identity -> Maybe (These a b) Source #

Extract the values of a DMap of EitherTags.

data EitherTag l r a where Source #

Tag type for Either to use it as a DSum.

Constructors

LeftTag :: EitherTag l r l 
RightTag :: EitherTag l r r 
Instances
GCompare (EitherTag l r :: k -> Type) Source # 
Instance details

Defined in Data.Functor.Misc

Methods

gcompare :: EitherTag l r a -> EitherTag l r b -> GOrdering a b #

GEq (EitherTag l r :: k -> Type) Source # 
Instance details

Defined in Data.Functor.Misc

Methods

geq :: EitherTag l r a -> EitherTag l r b -> Maybe (a :~: b) #

GShow (EitherTag l r :: k -> Type) Source # 
Instance details

Defined in Data.Functor.Misc

Methods

gshowsPrec :: Int -> EitherTag l r a -> ShowS #

Eq (EitherTag l r a) Source # 
Instance details

Defined in Data.Functor.Misc

Methods

(==) :: EitherTag l r a -> EitherTag l r a -> Bool #

(/=) :: EitherTag l r a -> EitherTag l r a -> Bool #

Ord (EitherTag l r a) Source # 
Instance details

Defined in Data.Functor.Misc

Methods

compare :: EitherTag l r a -> EitherTag l r a -> Ordering #

(<) :: EitherTag l r a -> EitherTag l r a -> Bool #

(<=) :: EitherTag l r a -> EitherTag l r a -> Bool #

(>) :: EitherTag l r a -> EitherTag l r a -> Bool #

(>=) :: EitherTag l r a -> EitherTag l r a -> Bool #

max :: EitherTag l r a -> EitherTag l r a -> EitherTag l r a #

min :: EitherTag l r a -> EitherTag l r a -> EitherTag l r a #

Show (EitherTag l r a) Source # 
Instance details

Defined in Data.Functor.Misc

Methods

showsPrec :: Int -> EitherTag l r a -> ShowS #

show :: EitherTag l r a -> String #

showList :: [EitherTag l r a] -> ShowS #

eitherToDSum :: Either a b -> DSum (EitherTag a b) Identity Source #

Convert Either to a DSum. Inverse of dsumToEither.

dsumToEither :: DSum (EitherTag a b) Identity -> Either a b Source #

Convert DSum to Either. Inverse of eitherToDSum.

factorEvent :: forall t m k v a. (Reflex t, MonadFix m, MonadHold t m, GEq k) => k a -> Event t (DSum k v) -> m (Event t (v a), Event t (DSum k (Product v (Compose (Event t) v)))) Source #

Factor the input DSum Event to produce an Event which fires when the DSum key changes and contains both the value of the DSum at switchover and an Event of values produced by subsequent firings of the input Event that do not change the DSum key.

filterEventKey :: forall t m k v a. (Reflex t, MonadFix m, MonadHold t m, GEq k) => k a -> Event t (DSum k v) -> m (Event t (v a)) Source #

Produces an Event that fires only when the input event fires with a DSum key that matches the provided key.

Collapsing 'Event . Event'

switchHold :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a) Source #

Switches to the new event whenever it receives one. Only the old event is considered the moment a new one is switched in; the output event will fire at that moment only if the old event does.

Because the simultaneous firing case is irrelevant, this function imposes laxer "timing requirements" on the overall circuit, avoiding many potential cyclic dependency / metastability failures. It's also more performant. Use this rather than switchHoldPromptly and switchHoldPromptOnly unless you are absolutely sure you need to act on the new event in the coincidental case.

switchHoldPromptly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a) Source #

Switches to the new event whenever it receives one. Whenever a new event is provided, if it is firing, its value will be the resulting event's value; if it is not firing, but the old one is, the old one's value will be used.

switchHold, by always forwarding the old event the moment it is switched out, avoids many potential cyclic dependency problems / metastability problems. It's also more performant. Use it instead unless you are sure you cannot.

switchHoldPromptOnly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a) Source #

switches to a new event whenever it receives one. At the moment of switching, the old event will be ignored if it fires, and the new one will be used if it fires; this is the opposite of switch, which will use only the old value.

switchHold, by always forwarding the old event the moment it is switched out, avoids many potential cyclic dependency problems / metastability problems. It's also more performant. Use it instead unless you are sure you cannot.

switchHoldPromptOnlyIncremental :: forall t m p pt w. (Reflex t, MonadHold t m, Patch (p (Event t w)), PatchTarget (p (Event t w)) ~ pt (Event t w), Patch (p w), PatchTarget (p w) ~ pt w, Monoid (pt w)) => (Incremental t (p (Event t w)) -> Event t (pt w)) -> (Event t (p (Event t w)) -> Event t (p w)) -> pt (Event t w) -> Event t (p (Event t w)) -> m (Event t (pt w)) Source #

Given a PatchTarget of events (e.g., a Map with Event values) and an event of Patches (e.g., a PatchMap with Event values), produce an Event of the PatchTarget type that fires with the patched value.

Using Events to sample Behaviors

tag :: Reflex t => Behavior t b -> Event t a -> Event t b Source #

Replace each occurrence value of the Event with the value of the Behavior at the time of that occurrence.

tagMaybe :: Reflex t => Behavior t (Maybe b) -> Event t a -> Event t b Source #

Replace each occurrence value of the Event with the value of the Behavior at that time; if it is Just, fire with the contained value; if it is Nothing, drop the occurrence.

attach :: Reflex t => Behavior t a -> Event t b -> Event t (a, b) Source #

Create a new Event that combines occurrences of supplied Event with the current value of the Behavior.

attachWith :: Reflex t => (a -> b -> c) -> Behavior t a -> Event t b -> Event t c Source #

Create a new Event that occurs when the supplied Event occurs by combining it with the current value of the Behavior.

attachWithMaybe :: Reflex t => (a -> b -> Maybe c) -> Behavior t a -> Event t b -> Event t c Source #

Create a new Event by combining each occurrence with the current value of the Behavior. The occurrence is discarded if the combining function returns Nothing

Blocking an Event based on a Behavior

gate :: Reflex t => Behavior t Bool -> Event t a -> Event t a Source #

Create a new Event that only occurs if the supplied Event occurs and the Behavior is true at the time of occurrence.

Combining Dynamics

distributeDMapOverDynPure :: forall t k. (Reflex t, GCompare k) => DMap k (Dynamic t) -> Dynamic t (DMap k Identity) Source #

This function converts a DMap whose elements are Dynamics into a Dynamic DMap. Its implementation is more efficient than doing the same through the use of multiple uses of zipDynWith or Applicative operators.

distributeDMapOverDynPureG :: forall t k q v. (Reflex t, GCompare k) => (forall a. q a -> Dynamic t (v a)) -> DMap k q -> Dynamic t (DMap k v) Source #

This function converts a DMap whose elements are Dynamics into a Dynamic DMap. Its implementation is more efficient than doing the same through the use of multiple uses of zipDynWith or Applicative operators.

distributeListOverDyn :: Reflex t => [Dynamic t a] -> Dynamic t [a] Source #

Convert a list of Dynamics into a Dynamic list.

distributeListOverDynWith :: Reflex t => ([a] -> b) -> [Dynamic t a] -> Dynamic t b Source #

Create a new Dynamic by applying a combining function to a list of Dynamics

zipDyn :: Reflex t => Dynamic t a -> Dynamic t b -> Dynamic t (a, b) Source #

Combine two Dynamics. The result will change whenever either (or both) input Dynamic changes. Equivalent to zipDynWith (,).

zipDynWith :: Reflex t => (a -> b -> c) -> Dynamic t a -> Dynamic t b -> Dynamic t c Source #

Combine two Dynamics with a combining function. The result will change whenever either (or both) input Dynamic changes. More efficient than liftA2.

Accumulating state

class Reflex t => Accumulator t f | f -> t where Source #

An Accumulator type can be built by accumulating occurrences of an Event.

Minimal complete definition

accumMaybeM, mapAccumMaybeM

Methods

accum :: (MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (f a) Source #

accumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (f a) Source #

accumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (f a) Source #

accumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (f a) Source #

mapAccum :: (MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (f a, Event t c) Source #

mapAccumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (f a, Event t c) Source #

mapAccumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (f a, Event t c) Source #

mapAccumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (f a, Event t c) Source #

Instances
Reflex t => Accumulator (t :: k) (Event t) Source # 
Instance details

Defined in Reflex.Class

Methods

accum :: (MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Event t a) Source #

accumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (Event t a) Source #

accumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (Event t a) Source #

accumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Event t a) Source #

mapAccum :: (MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Event t a, Event t c) Source #

mapAccumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Event t a, Event t c) Source #

mapAccumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Event t a, Event t c) Source #

mapAccumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (Event t a, Event t c) Source #

Reflex t => Accumulator (t :: k) (Behavior t) Source # 
Instance details

Defined in Reflex.Class

Methods

accum :: (MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Behavior t a) Source #

accumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (Behavior t a) Source #

accumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (Behavior t a) Source #

accumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Behavior t a) Source #

mapAccum :: (MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

mapAccumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

mapAccumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

mapAccumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

Reflex t => Accumulator (t :: k) (Dynamic t) Source # 
Instance details

Defined in Reflex.Class

Methods

accum :: (MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Dynamic t a) Source #

accumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (Dynamic t a) Source #

accumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (Dynamic t a) Source #

accumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Dynamic t a) Source #

mapAccum :: (MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

mapAccumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

mapAccumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

mapAccumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

Reflex t => Accumulator (t :: Type) (UniqDynamic t) Source # 
Instance details

Defined in Reflex.Dynamic.Uniq

Methods

accum :: (MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (UniqDynamic t a) Source #

accumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (UniqDynamic t a) Source #

accumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (UniqDynamic t a) Source #

accumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (UniqDynamic t a) Source #

mapAccum :: (MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (UniqDynamic t a, Event t c) Source #

mapAccumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (UniqDynamic t a, Event t c) Source #

mapAccumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (UniqDynamic t a, Event t c) Source #

mapAccumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (UniqDynamic t a, Event t c) Source #

accumDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Dynamic t a) Source #

Accumulate a Dynamic by folding occurrences of an Event with the provided function. See foldDyn.

accumMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (Dynamic t a) Source #

Accumulate a Dynamic by folding occurrences of an Event with the provided PushM action.

accumMaybeDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (Dynamic t a) Source #

Accumulate a Dynamic by folding occurrences of an Event with the provided function, discarding Nothing results.

accumMaybeMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Dynamic t a) Source #

Accumulate a Dynamic by folding occurrences of an Event with the provided PushM action, discarding Nothing results.

mapAccumDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

Accumulate a Dynamic by folding occurrences of an Event with a function that both accumulates and produces a value to fire as an Event. Returns both the accumulated value and an Event.

mapAccumMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

Similar to mapAccumDyn except that the combining function is a PushM action.

mapAccumMaybeDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

Accumulate a Dynamic by folding occurrences of an Event with a function that both optionally accumulates and optionally produces a value to fire as a separate output Event. Note that because Nothings are discarded in both cases, the output Event may fire even though the output Dynamic has not changed, and the output Dynamic may update even when the output Event is not firing.

mapAccumMaybeMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (Dynamic t a, Event t c) Source #

Like mapAccumMaybeDyn except that the combining function is a PushM action.

accumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Behavior t a) Source #

Accumulate a Behavior by folding occurrences of an Event with the provided function.

accumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (Behavior t a) Source #

Like accumB except that the combining function is a PushM action.

accumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (Behavior t a) Source #

Accumulate a Behavior by folding occurrences of an Event with the provided function, discarding Nothing results.

accumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Behavior t a) Source #

Like accumMaybeB except that the combining function is a PushM action.

mapAccumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

Accumulate a Behavior by folding occurrences of an Event with a function that both accumulates and produces a value to fire as an Event. Returns both the accumulated value and an Event.

mapAccumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

Like mapAccumB except that the combining function is a PushM action.

mapAccumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

Accumulate a Behavior by folding occurrences of an Event with a function that both optionally accumulates and optionally produces a value to fire as a separate output Event. Nothings are discarded.

mapAccumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (Behavior t a, Event t c) Source #

Like mapAccumMaybeB except that the combining function is a PushM action.

mapAccum_ :: forall t m a b c. (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Event t c) Source #

Accumulate occurrences of an Event, producing an output occurrence each time. Discard the underlying Accumulator.

mapAccumM_ :: forall t m a b c. (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Event t c) Source #

Accumulate occurrences of an Event, using a PushM action and producing an output occurrence each time. Discard the underlying Accumulator.

mapAccumMaybe_ :: forall t m a b c. (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Event t c) Source #

Accumulate occurrences of an Event, possibly producing an output occurrence each time. Discard the underlying Accumulator.

mapAccumMaybeM_ :: forall t m a b c. (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (Event t c) Source #

Accumulate occurrences of an Event, using a PushM action and possibly producing an output occurrence each time. Discard the underlying Accumulator.

accumIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> p) -> PatchTarget p -> Event t b -> m (Incremental t p) Source #

Accumulate an Incremental with the supplied initial value and the firings of the provided Event, using the combining function to produce a patch.

accumMIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> PushM t p) -> PatchTarget p -> Event t b -> m (Incremental t p) Source #

Similar to accumIncremental but the combining function runs in PushM

accumMaybeIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> Maybe p) -> PatchTarget p -> Event t b -> m (Incremental t p) Source #

Similar to accumIncremental but allows filtering of updates (by dropping updates when the combining function produces Nothing)

accumMaybeMIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> PushM t (Maybe p)) -> PatchTarget p -> Event t b -> m (Incremental t p) Source #

Similar to accumMaybeMIncremental but the combining function runs in PushM

mapAccumIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> (p, c)) -> PatchTarget p -> Event t b -> m (Incremental t p, Event t c) Source #

Accumulate an Incremental by folding occurrences of an Event with a function that both accumulates and produces a value to fire as an Event. Returns both the accumulated value and the constructed Event.

mapAccumMIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> PushM t (p, c)) -> PatchTarget p -> Event t b -> m (Incremental t p, Event t c) Source #

Like mapAccumIncremental but the combining function runs in PushM

mapAccumMaybeIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> (Maybe p, Maybe c)) -> PatchTarget p -> Event t b -> m (Incremental t p, Event t c) Source #

Accumulate an Incremental by folding occurrences of an Event with a function that both optionally accumulates and optionally produces a value to fire as a separate output Event. Note that because Nothings are discarded in both cases, the output Event may fire even though the output Incremental has not changed, and the output Incremental may update even when the output Event is not firing.

mapAccumMaybeMIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p -> b -> PushM t (Maybe p, Maybe c)) -> PatchTarget p -> Event t b -> m (Incremental t p, Event t c) Source #

Like mapAccumMaybeIncremental but the combining function is a PushM action

zipListWithEvent :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> c) -> [a] -> Event t b -> m (Event t c) Source #

Create a new Event by combining each occurrence with the next value of the list using the supplied function. If the list runs out of items, all subsequent Event occurrences will be ignored.

numberOccurrences :: (Reflex t, MonadHold t m, MonadFix m, Num b) => Event t a -> m (Event t (b, a)) Source #

Assign a number to each occurrence of the given Event, starting from 0

numberOccurrencesFrom :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t (b, a)) Source #

Assign a number to each occurrence of the given Event

numberOccurrencesFrom_ :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t b) Source #

Assign a number to each occurrence of the given Event; discard the occurrences' values

(<@>) :: Reflex t => Behavior t (a -> b) -> Event t a -> Event t b infixl 4 Source #

This is used to sample the value of a Behavior using an Event.

The <@> operator is intended to be used in conjunction with the Applicative instance for Behavior.

This is useful when we want to combine the values of one Event and the value of several Behaviors at the time the Event is firing.

If we have:

f  :: a -> b -> c -> d
b1 :: Behavior t a
b2 :: Behavior t b
e  :: Event t c

then we can do:

f <$> b1 <*> b2 <@> e :: Event t d

in order to apply the function f to the relevant values.

The alternative would be something like:

attachWith (\(x1, x2) y -> f x1 x2 y) ((,) <$> b1 <*> b2) e :: Event t d

or a variation involing a custom data type to hold the combination of Behaviors even when that combination might only ever be used by f.

A more suggestive example might be:

handleMouse <$> bPlayerState <*> bMousePosition <@> eMouseClick :: Event t (GameState -> GameState)

(<@) :: Reflex t => Behavior t b -> Event t a -> Event t b infixl 4 Source #

An version of <@> that does not use the value of the Event.

Alternatively, it is tag in operator form.

This is useful when we want to combine the values of several Behaviors at particular points in time using an Applicative style syntax.

If we have:

g  :: a -> b -> d
b1 :: Behavior t a
b2 :: Behavior t b
e  :: Event t c

where e is firing at the points in time of interest.

Then we can use <@:

g <$> b1 <*> b2 <@  e :: Event t d

to combine the values of b1 and b2 at each of those points of time, with the function g being used to combine the values.

This is the same as <@> except that the Event is being used only to act as a trigger.

tailE :: (Reflex t, MonadHold t m) => Event t a -> m (Event t a) Source #

Create a new Event that occurs on all but the first occurrence of the supplied Event.

headTailE :: (Reflex t, MonadHold t m) => Event t a -> m (Event t a, Event t a) Source #

Create a tuple of two Events with the first one occurring only the first time the supplied Event occurs and the second occurring on all but the first occurrence.

takeWhileE :: forall t m a. (Reflex t, MonadFix m, MonadHold t m) => (a -> Bool) -> Event t a -> m (Event t a) Source #

Take the streak of occurrences starting at the current time for which the event returns True.

Starting at the current time, fire all the occurrences of the Event for which the given predicate returns True. When first False is returned, do not fire, and permanently stop firing, even if True values would have been encountered later.

takeWhileJustE :: forall t m a b. (Reflex t, MonadFix m, MonadHold t m) => (a -> Maybe b) -> Event t a -> m (Event t b) Source #

Take the streak of occurrences starting at the current time for which the event returns 'Just b'.

Starting at the current time, fire all the occurrences of the Event for which the given predicate returns 'Just b'. When first Nothing is returned, do not fire, and permanently stop firing, even if 'Just b' values would have been encountered later.

dropWhileE :: forall t m a. (Reflex t, MonadFix m, MonadHold t m) => (a -> Bool) -> Event t a -> m (Event t a) Source #

Drop the streak of occurrences starting at the current time for which the event returns True.

Starting at the current time, do not fire all the occurrences of the Event for which the given predicate returns True. When False is first returned, do fire, and permanently continue firing, even if True values would have been encountered later.

takeDropWhileJustE :: forall t m a b. (Reflex t, MonadFix m, MonadHold t m) => (a -> Maybe b) -> Event t a -> m (Event t b, Event t a) Source #

Both take and drop the streak of occurrences starting at the current time for which the event returns 'Just b'.

For the left event, starting at the current time, fire all the occurrences of the Event for which the given function returns 'Just b'. When Nothing is returned, do not fire, and permanently stop firing, even if 'Just b' values would have been encountered later.

For the right event, do not fire until the first occurrence where the given function returns Nothing, and fire that one and all subsequent occurrences. Even if the function would have again returned 'Just b', keep on firing.

switcher :: (Reflex t, MonadHold t m) => Behavior t a -> Event t (Behavior t a) -> m (Behavior t a) Source #

Create a new behavior given a starting behavior and switch to the behavior carried by the event when it fires.

Debugging functions

traceEvent :: (Reflex t, Show a) => String -> Event t a -> Event t a Source #

Print the supplied String and the value of the Event on each occurrence. This should only be used for debugging.

Note: As with Debug.Trace.trace, the message will only be printed if the Event is actually used.

traceEventWith :: Reflex t => (a -> String) -> Event t a -> Event t a Source #

Print the output of the supplied function on each occurrence of the Event. This should only be used for debugging.

Note: As with Debug.Trace.trace, the message will only be printed if the Event is actually used.

Unsafe functions

unsafeDynamic :: Reflex t => Behavior t a -> Event t a -> Dynamic t a Source #

Construct a Dynamic from a Behavior and an Event. The Behavior must change when and only when the Event fires, such that the Behavior's value is always equal to the most recent firing of the Event; if this is not the case, the resulting Dynamic will behave nondeterministically.

unsafeMapIncremental :: (Reflex t, Patch p, Patch p') => (PatchTarget p -> PatchTarget p') -> (p -> p') -> Incremental t p -> Incremental t p' Source #

Filterable convenience functions

class FunctorMaybe f Source #

Deprecated: Use Filterable from Data.Witherable instead

A class for values that combines filtering and mapping using Maybe. Morally, FunctorMaybe ~ KleisliFunctor Maybe.

Minimal complete definition

fmapMaybe

Instances
FunctorMaybe [] Source # 
Instance details

Defined in Reflex.FunctorMaybe

Methods

fmapMaybe :: (a -> Maybe b) -> [a] -> [b] Source #

FunctorMaybe Maybe Source # 
Instance details

Defined in Reflex.FunctorMaybe

Methods

fmapMaybe :: (a -> Maybe b) -> Maybe a -> Maybe b Source #

FunctorMaybe Option Source # 
Instance details

Defined in Reflex.FunctorMaybe

Methods

fmapMaybe :: (a -> Maybe b) -> Option a -> Option b Source #

FunctorMaybe IntMap Source # 
Instance details

Defined in Reflex.FunctorMaybe

Methods

fmapMaybe :: (a -> Maybe b) -> IntMap a -> IntMap b Source #

FunctorMaybe (Map k) Source # 
Instance details

Defined in Reflex.FunctorMaybe

Methods

fmapMaybe :: (a -> Maybe b) -> Map k a -> Map k b Source #

Reflex t => FunctorMaybe (Event t) Source # 
Instance details

Defined in Reflex.Class

Methods

fmapMaybe :: (a -> Maybe b) -> Event t a -> Event t b Source #

mapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b #

Like mapMaybe.

fmapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b Source #

Alias for mapMaybe

fforMaybe :: Filterable f => f a -> (a -> Maybe b) -> f b Source #

Flipped version of mapMaybe.

ffilter :: Filterable f => (a -> Bool) -> f a -> f a Source #

Filter 'f a' using the provided predicate.

filterLeft :: Filterable f => f (Either a b) -> f a Source #

Filter Lefts from 'f (Either a b)' into a.

filterRight :: Filterable f => f (Either a b) -> f b Source #

Filter Rights from 'f (Either a b)' into b.

Miscellaneous convenience functions

ffor :: Functor f => f a -> (a -> b) -> f b Source #

Flipped version of fmap.

ffor2 :: Applicative f => f a -> f b -> (a -> b -> c) -> f c Source #

Rotated version of liftA2.

ffor3 :: Applicative f => f a -> f b -> f c -> (a -> b -> c -> d) -> f d Source #

Rotated version of liftA3.

Deprecated functions

switchPromptly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a) Source #

Deprecated: Use switchHoldPromptly instead. The 'switchHold*' naming convention was chosen because those functions are more closely related to each other than they are to switch.

See switchHoldPromptly

switchPromptOnly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a) Source #

Deprecated: Use switchHoldPromptOnly instead. The 'switchHold*' naming convention was chosen because those functions are more closely related to each other than they are to switch.

See switchHoldPromptOnly

Cheap functions

fmapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b Source #

An alias for mapMaybeCheap

mapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b Source #

A "cheap" version of mapMaybe. See the performance note on pushCheap.

fmapCheap :: Reflex t => (a -> b) -> Event t a -> Event t b Source #

A "cheap" version of fmap. See the performance note on pushCheap.

fforCheap :: Reflex t => Event t a -> (a -> b) -> Event t b Source #

A "cheap" version of ffor. See the performance note on pushCheap.

fforMaybeCheap :: Reflex t => Event t a -> (a -> Maybe b) -> Event t b Source #

A "cheap" version of fforMaybe. See the performance note on pushCheap.

pushAlwaysCheap :: Reflex t => (a -> PushM t b) -> Event t a -> Event t b Source #

A "cheap" version of pushAlways. See the performance note on pushCheap.

tagCheap :: Reflex t => Behavior t b -> Event t a -> Event t b Source #

A "cheap" version of tag. See the performance note on pushCheap.

mergeWithCheap :: Reflex t => (a -> a -> a) -> [Event t a] -> Event t a Source #

A "cheap" version of mergeWithCheap. See the performance note on pushCheap.

mergeWithCheap' :: Reflex t => (a -> b) -> (b -> b -> b) -> [Event t a] -> Event t b Source #

A "cheap" version of mergeWithCheap'. See the performance note on pushCheap.

Slow, but general, implementations

slowHeadE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a) Source #

A somewhat slow implementation of headE