Safe Haskell  None 

Language  Haskell98 
Synopsis
 module Reflex.Patch
 class (MonadHold t (PushM t), MonadSample t (PullM t), MonadFix (PushM t), Functor (Dynamic t), Applicative (Dynamic t), Monad (Dynamic t)) => Reflex t where
 mergeInt :: Reflex t => IntMap (Event t a) > Event t (IntMap a)
 coerceBehavior :: (Reflex t, Coercible a b) => Behavior t a > Behavior t b
 coerceEvent :: (Reflex t, Coercible a b) => Event t a > Event t b
 coerceDynamic :: (Reflex t, Coercible a b) => Dynamic t a > Dynamic t b
 class (Applicative m, Monad m) => MonadSample t m  m > t where
 class MonadSample t m => MonadHold t m where
 newtype EventSelector t k = EventSelector {}
 newtype EventSelectorInt t a = EventSelectorInt {}
 constDyn :: Reflex t => a > Dynamic t a
 pushAlways :: Reflex t => (a > PushM t b) > Event t a > Event t b
 leftmost :: Reflex t => [Event t a] > Event t a
 mergeMap :: (Reflex t, Ord k) => Map k (Event t a) > Event t (Map k a)
 mergeIntMap :: Reflex t => IntMap (Event t a) > Event t (IntMap a)
 mergeMapIncremental :: (Reflex t, Ord k) => Incremental t (PatchMap k (Event t a)) > Event t (Map k a)
 mergeMapIncrementalWithMove :: (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Event t a)) > Event t (Map k a)
 mergeIntMapIncremental :: Reflex t => Incremental t (PatchIntMap (Event t a)) > Event t (IntMap a)
 coincidencePatchMap :: (Reflex t, Ord k) => Event t (PatchMap k (Event t v)) > Event t (PatchMap k v)
 coincidencePatchMapWithMove :: (Reflex t, Ord k) => Event t (PatchMapWithMove k (Event t v)) > Event t (PatchMapWithMove k v)
 coincidencePatchIntMap :: Reflex t => Event t (PatchIntMap (Event t v)) > Event t (PatchIntMap v)
 mergeList :: Reflex t => [Event t a] > Event t (NonEmpty a)
 mergeWith :: Reflex t => (a > a > a) > [Event t a] > Event t a
 difference :: Reflex t => Event t a > Event t b > Event t a
 alignEventWithMaybe :: Reflex t => (These a b > Maybe c) > Event t a > Event t b > Event t c
 splitE :: Reflex t => Event t (a, b) > (Event t a, Event t b)
 fanEither :: Reflex t => Event t (Either a b) > (Event t a, Event t b)
 fanThese :: Reflex t => Event t (These a b) > (Event t a, Event t b)
 fanMap :: (Reflex t, Ord k) => Event t (Map k a) > EventSelector t (Const2 k a)
 dmapToThese :: DMap (EitherTag a b) Identity > Maybe (These a b)
 data EitherTag l r a where
 eitherToDSum :: Either a b > DSum (EitherTag a b) Identity
 dsumToEither :: DSum (EitherTag a b) Identity > Either a b
 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))))
 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))
 switchHold :: (Reflex t, MonadHold t m) => Event t a > Event t (Event t a) > m (Event t a)
 switchHoldPromptly :: (Reflex t, MonadHold t m) => Event t a > Event t (Event t a) > m (Event t a)
 switchHoldPromptOnly :: (Reflex t, MonadHold t m) => Event t a > Event t (Event t a) > m (Event t a)
 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))
 tag :: Reflex t => Behavior t b > Event t a > Event t b
 tagMaybe :: Reflex t => Behavior t (Maybe b) > Event t a > Event t b
 attach :: Reflex t => Behavior t a > Event t b > Event t (a, b)
 attachWith :: Reflex t => (a > b > c) > Behavior t a > Event t b > Event t c
 attachWithMaybe :: Reflex t => (a > b > Maybe c) > Behavior t a > Event t b > Event t c
 gate :: Reflex t => Behavior t Bool > Event t a > Event t a
 distributeDMapOverDynPure :: forall t k. (Reflex t, GCompare k) => DMap k (Dynamic t) > Dynamic t (DMap k Identity)
 distributeListOverDyn :: Reflex t => [Dynamic t a] > Dynamic t [a]
 distributeListOverDynWith :: Reflex t => ([a] > b) > [Dynamic t a] > Dynamic t b
 zipDyn :: Reflex t => Dynamic t a > Dynamic t b > Dynamic t (a, b)
 zipDynWith :: Reflex t => (a > b > c) > Dynamic t a > Dynamic t b > Dynamic t c
 class Reflex t => Accumulator t f  f > t where
 accumDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > a) > a > Event t b > m (Dynamic t a)
 accumMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t a) > a > Event t b > m (Dynamic t a)
 accumMaybeDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > Maybe a) > a > Event t b > m (Dynamic t a)
 accumMaybeMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t (Maybe a)) > a > Event t b > m (Dynamic t a)
 mapAccumDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > (a, c)) > a > Event t b > m (Dynamic t a, Event t c)
 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)
 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)
 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)
 accumB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > a) > a > Event t b > m (Behavior t a)
 accumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t a) > a > Event t b > m (Behavior t a)
 accumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > Maybe a) > a > Event t b > m (Behavior t a)
 accumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t (Maybe a)) > a > Event t b > m (Behavior t a)
 mapAccumB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > (a, c)) > a > Event t b > m (Behavior t a, Event t c)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 accumIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p > b > p) > PatchTarget p > Event t b > m (Incremental t p)
 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)
 accumMaybeIncremental :: (Reflex t, Patch p, MonadHold t m, MonadFix m) => (PatchTarget p > b > Maybe p) > PatchTarget p > Event t b > m (Incremental t p)
 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)
 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)
 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)
 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)
 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)
 zipListWithEvent :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > c) > [a] > Event t b > m (Event t c)
 numberOccurrences :: (Reflex t, MonadHold t m, MonadFix m, Num b) => Event t a > m (Event t (b, a))
 numberOccurrencesFrom :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b > Event t a > m (Event t (b, a))
 numberOccurrencesFrom_ :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b > Event t a > m (Event t b)
 (<@>) :: Reflex t => Behavior t (a > b) > Event t a > Event t b
 (<@) :: Reflex t => Behavior t b > Event t a > Event t b
 tailE :: (Reflex t, MonadHold t m) => Event t a > m (Event t a)
 headTailE :: (Reflex t, MonadHold t m) => Event t a > m (Event t a, Event t a)
 takeWhileE :: forall t m a. (Reflex t, MonadFix m, MonadHold t m) => (a > Bool) > Event t a > m (Event t a)
 takeWhileJustE :: forall t m a b. (Reflex t, MonadFix m, MonadHold t m) => (a > Maybe b) > Event t a > m (Event t b)
 dropWhileE :: forall t m a. (Reflex t, MonadFix m, MonadHold t m) => (a > Bool) > Event t a > m (Event t a)
 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)
 switcher :: (Reflex t, MonadHold t m) => Behavior t a > Event t (Behavior t a) > m (Behavior t a)
 traceEvent :: (Reflex t, Show a) => String > Event t a > Event t a
 traceEventWith :: Reflex t => (a > String) > Event t a > Event t a
 unsafeDynamic :: Reflex t => Behavior t a > Event t a > Dynamic t a
 unsafeMapIncremental :: (Reflex t, Patch p, Patch p') => (PatchTarget p > PatchTarget p') > (p > p') > Incremental t p > Incremental t p'
 class FunctorMaybe f where
 fforMaybe :: FunctorMaybe f => f a > (a > Maybe b) > f b
 ffilter :: FunctorMaybe f => (a > Bool) > f a > f a
 filterLeft :: FunctorMaybe f => f (Either a b) > f a
 filterRight :: FunctorMaybe f => f (Either a b) > f b
 ffor :: Functor f => f a > (a > b) > f b
 ffor2 :: Applicative f => f a > f b > (a > b > c) > f c
 ffor3 :: Applicative f => f a > f b > f c > (a > b > c > d) > f d
 appendEvents :: (Reflex t, Monoid a) => Event t a > Event t a > Event t a
 onceE :: MonadHold t m => Event t a > m (Event t a)
 sequenceThese :: Monad m => These (m a) (m b) > m (These a b)
 fmapMaybeCheap :: Reflex t => (a > Maybe b) > Event t a > Event t b
 fmapCheap :: Reflex t => (a > b) > Event t a > Event t b
 fforCheap :: Reflex t => Event t a > (a > b) > Event t b
 fforMaybeCheap :: Reflex t => Event t a > (a > Maybe b) > Event t b
 pushAlwaysCheap :: Reflex t => (a > PushM t b) > Event t a > Event t b
 tagCheap :: Reflex t => Behavior t b > Event t a > Event t b
 mergeWithCheap :: Reflex t => (a > a > a) > [Event t a] > Event t a
 mergeWithCheap' :: Reflex t => (a > b) > (b > b > b) > [Event t a] > Event t b
 switchPromptly :: (Reflex t, MonadHold t m) => Event t a > Event t (Event t a) > m (Event t a)
 switchPromptOnly :: (Reflex t, MonadHold t m) => Event t a > Event t (Event t a) > m (Event t a)
 slowHeadE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a > m (Event t a)
Documentation
module Reflex.Patch
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 fullyindependent FRP contexts,
and the type of the timeline determines the FRP engine to be used. For most
purposes, the Spider
implementation is recommended.
never, constant, push, pushCheap, pull, merge, fan, switch, coincidence, current, updated, unsafeBuildDynamic, unsafeBuildIncremental, mergeIncremental, mergeIncrementalWithMove, currentIncremental, updatedIncremental, incrementalToDynamic, behaviorCoercion, eventCoercion, dynamicCoercion, mergeIntIncremental, fanInt
data Behavior t :: * > * Source #
A container for a value that can change over time. Behavior
s 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 pushbased calculations efficiently
type PullM t :: * > * Source #
A monad for doing complex pullbased calculations efficiently
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
Behavior
s and hold Event
s, and use the results to produce a occurring
(Just) or nonoccurring (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 Behavior
s; the result will be
recomputed whenever any of the read Behavior
s changes
merge :: 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
fan :: GCompare k => Event t (DMap k Identity) > EventSelector t k Source #
Efficiently fanout an event to many destinations. This function should be partially applied, and then the result applied repeatedly to create child events
switch :: Behavior t (Event t a) > Event t a Source #
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 #
updated :: Dynamic t a > Event t a Source #
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.
mergeIncremental :: GCompare k => Incremental t (PatchDMap k (Event t)) > Event t (DMap k Identity) Source #
Create a merge whose parents can change over time
mergeIncrementalWithMove :: 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
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 #
eventCoercion :: Coercion a b > Coercion (Event t a) (Event t b) Source #
dynamicCoercion :: Coercion a b > Coercion (Dynamic t a) (Dynamic t b) Source #
mergeIntIncremental :: Incremental t (PatchIntMap (Event t a)) > Event t (IntMap a) Source #
fanInt :: Event t (IntMap a) > EventSelectorInt t a Source #
Instances
coerceBehavior :: (Reflex t, Coercible a b) => Behavior t a > Behavior t b Source #
Coerce a Behavior
between representationallyequivalent value types
coerceEvent :: (Reflex t, Coercible a b) => Event t a > Event t b Source #
Coerce an Event
between representationallyequivalent occurrence types
coerceDynamic :: (Reflex t, Coercible a b) => Dynamic t a > Dynamic t b Source #
Coerce a Dynamic
between representationallyequivalent 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
.
Instances
class MonadSample t m => MonadHold t m where Source #
MonadHold
designates monads that can create new Behavior
s based on
Event
s; usually this will be PushM
or a monad based on it. MonadHold
is required to create any stateful computations with Reflex.
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 #
holdDyn :: (m ~ f m', MonadTrans f, MonadHold t m') => a > Event t a > m (Dynamic t a) Source #
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 #
Instances
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
fmapMaybe
.
EventSelector  

newtype EventSelectorInt t a Source #
Convenience functions
Combining
Event
s
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. Nonfiring inner events will be replaced with deletions.
coincidencePatchMapWithMove :: (Reflex t, Ord k) => Event t (PatchMapWithMove k (Event t v)) > Event t (PatchMapWithMove k v) Source #
coincidencePatchIntMap :: Reflex t => Event t (PatchIntMap (Event t v)) > Event t (PatchIntMap v) Source #
alignEventWithMaybe :: Reflex t => (These a b > Maybe c) > Event t a > Event t b > Event t c Source #
Breaking up
Event
s
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 Event
s.
data EitherTag l r a where Source #
Instances
GCompare (EitherTag l r :: k > *) Source #  
GEq (EitherTag l r :: k > *) Source #  
GShow (EitherTag l r :: k > *) Source #  
Defined in Data.Functor.Misc gshowsPrec :: Int > EitherTag l r a > ShowS #  
(Show l, Show r) => ShowTag (EitherTag l r :: * > *) Identity Source #  
Defined in Data.Functor.Misc  
Eq (EitherTag l r a) Source #  
Ord (EitherTag l r a) Source #  
Defined in Data.Functor.Misc 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 #  
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 #
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 #
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 #
Using
Event
s to sample Behavior
s
attachWithMaybe :: Reflex t => (a > b > Maybe c) > Behavior t a > Event t b > Event t c Source #
Blocking an
Event
based on a Behavior
Combining
Dynamic
s
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 Dynamic
s into a
Dynamic
DMap
. Its implementation is more efficient than doing the same
through the use of multiple uses of zipDynWith
or Applicative
operators.
Accumulating state
class Reflex t => Accumulator t f  f > t where Source #
An Accumulator
type can be built by accumulating occurrences of an
Event
.
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 #  
Defined in Reflex.Class 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 #  
Defined in Reflex.Class 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 #  
Defined in Reflex.Class 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 :: *) (UniqDynamic t) Source #  
Defined in Reflex.Dynamic.Uniq 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 #
accumMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t a) > a > Event t b > m (Dynamic t a) Source #
accumMaybeDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > Maybe a) > a > Event t b > m (Dynamic t a) Source #
accumMaybeMDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t (Maybe a)) > a > Event t b > m (Dynamic t a) Source #
mapAccumDyn :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > (a, c)) > a > Event t b > m (Dynamic t a, Event t c) Source #
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 #
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 #
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 #
accumB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > a) > a > Event t b > m (Behavior t a) Source #
accumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t a) > a > Event t b > m (Behavior t a) Source #
accumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > Maybe a) > a > Event t b > m (Behavior t a) Source #
accumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > PushM t (Maybe a)) > a > Event t b > m (Behavior t a) Source #
mapAccumB :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > (a, c)) > a > Event t b > m (Behavior t a, Event t c) Source #
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 #
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 #
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 #
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 #
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 #
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 #
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 #
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 #
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 #
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 #
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 #
zipListWithEvent :: (Reflex t, MonadHold t m, MonadFix m) => (a > b > c) > [a] > Event t b > m (Event t c) Source #
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 Behavior
s 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
Behavior
s 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
Behavior
s 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.
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
Unsafe functions
unsafeMapIncremental :: (Reflex t, Patch p, Patch p') => (PatchTarget p > PatchTarget p') > (p > p') > Incremental t p > Incremental t p' Source #
FunctorMaybe
class FunctorMaybe f where Source #
A class for values that combines filtering and mapping using Maybe
.
Morally,
. Also similar is the
FunctorMaybe
~ KleisliFunctor Maybe
Witherable
typeclass, but it requires Foldable f
and Traverable f
,
and e.g. Event
is instance of neither.
A definition of fmapMaybe
must satisfy the following laws:
Instances
FunctorMaybe [] Source #  fmapMaybe = mapMaybe 
Defined in Reflex.FunctorMaybe  
FunctorMaybe Maybe Source #  @fmapMaybe = (=<<) 
FunctorMaybe IntMap Source #  
FunctorMaybe (Map k) Source #  
FunctorMaybe (MonoidalMap k) Source #  
Defined in Data.AppendMap fmapMaybe :: (a > Maybe b) > MonoidalMap k a > MonoidalMap k b Source #  
HasSpiderTimeline x => FunctorMaybe (Event x) Source #  
Reflex t => FunctorMaybe (Event t) Source #  
ffilter :: FunctorMaybe f => (a > Bool) > f a > f a Source #
Filter 'f a' using the provided predicate.
Relies on fforMaybe
.
filterLeft :: FunctorMaybe f => f (Either a b) > f a Source #
Filter Left
s from 'f (Either a b)' into a
.
filterRight :: FunctorMaybe f => f (Either a b) > f b Source #
Filter Right
s from 'f (Either a b)' into b
.
Miscellaneous convenience functions
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
sequenceThese :: Monad m => These (m a) (m b) > m (These a b) Source #
Deprecated: Use bisequenceA or bisequence from the bifunctors package instead
Run both sides of a These
monadically, combining the results.
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
.
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
.