Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Synopsis
- module Data.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
- data Behavior t :: Type -> Type
- data Event t :: Type -> Type
- data Dynamic t :: Type -> Type
- data Incremental t :: Type -> Type
- type PushM t :: Type -> Type
- type PullM t :: Type -> Type
- never :: Event t a
- constant :: a -> Behavior t a
- push :: (a -> PushM t (Maybe b)) -> Event t a -> Event t b
- pushCheap :: (a -> PushM t (Maybe b)) -> Event t a -> Event t b
- pull :: PullM t a -> Behavior t a
- mergeG :: GCompare k => (forall a. q a -> Event t (v a)) -> DMap k q -> Event t (DMap k v)
- fanG :: GCompare k => Event t (DMap k v) -> EventSelectorG t k v
- switch :: Behavior t (Event t a) -> Event t a
- coincidence :: Event t (Event t a) -> Event t a
- current :: Dynamic t a -> Behavior t a
- updated :: Dynamic t a -> Event t a
- unsafeBuildDynamic :: PullM t a -> Event t a -> Dynamic t a
- unsafeBuildIncremental :: Patch p => PullM t (PatchTarget p) -> Event t p -> Incremental t p
- mergeIncrementalG :: GCompare k => (forall a. q a -> Event t (v a)) -> Incremental t (PatchDMap k q) -> Event t (DMap k v)
- mergeIncrementalWithMoveG :: GCompare k => (forall a. q a -> Event t (v a)) -> Incremental t (PatchDMapWithMove k q) -> Event t (DMap k v)
- currentIncremental :: Patch p => Incremental t p -> Behavior t (PatchTarget p)
- updatedIncremental :: Patch p => Incremental t p -> Event t p
- incrementalToDynamic :: Patch p => Incremental t p -> Dynamic t (PatchTarget p)
- behaviorCoercion :: Coercion a b -> Coercion (Behavior t a) (Behavior t b)
- eventCoercion :: Coercion a b -> Coercion (Event t a) (Event t b)
- dynamicCoercion :: Coercion a b -> Coercion (Dynamic t a) (Dynamic t b)
- incrementalCoercion :: Coercion (PatchTarget a) (PatchTarget b) -> Coercion a b -> Coercion (Incremental t a) (Incremental t b)
- mergeIntIncremental :: Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a)
- fanInt :: Event t (IntMap a) -> EventSelectorInt t a
- 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
- coerceIncremental :: (Reflex t, Coercible a b, Coercible (PatchTarget a) (PatchTarget b)) => Incremental t a -> Incremental t b
- class (Applicative m, Monad m) => MonadSample t m | m -> t where
- class MonadSample t m => MonadHold t m where
- hold :: a -> Event t a -> m (Behavior t a)
- holdDyn :: a -> Event t a -> m (Dynamic t a)
- holdIncremental :: Patch p => PatchTarget p -> Event t p -> m (Incremental t p)
- buildDynamic :: PushM t a -> Event t a -> m (Dynamic t a)
- headE :: Event t a -> m (Event t a)
- now :: m (Event t ())
- newtype EventSelector t k = EventSelector {}
- newtype EventSelectorG t k v = EventSelectorG {}
- 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
- merge :: (Reflex t, GCompare k) => DMap k (Event t) -> Event t (DMap k Identity)
- mergeIncremental :: (Reflex t, GCompare k) => Incremental t (PatchDMap k (Event t)) -> Event t (DMap k Identity)
- mergeIncrementalWithMove :: (Reflex t, GCompare k) => Incremental t (PatchDMapWithMove k (Event t)) -> Event t (DMap k Identity)
- 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)
- fan :: forall t k. (Reflex t, GCompare k) => Event t (DMap k Identity) -> EventSelector t k
- 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 :: k) (r :: k) (a :: k) :: forall k. k -> k -> k -> Type 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)
- 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)
- 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
- accum :: (MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (f a)
- accumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (f a)
- accumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (f a)
- accumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (f a)
- mapAccum :: (MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (f a, Event t c)
- mapAccumM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (f a, Event t c)
- mapAccumMaybe :: (MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (f a, Event t c)
- mapAccumMaybeM :: (MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a, Maybe c)) -> a -> Event t b -> m (f a, Event t c)
- 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
- mapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b
- fmapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b
- fforMaybe :: Filterable f => f a -> (a -> Maybe b) -> f b
- ffilter :: Filterable f => (a -> Bool) -> f a -> f a
- filterLeft :: Filterable f => f (Either a b) -> f a
- filterRight :: Filterable 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
- 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)
- fmapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b
- mapMaybeCheap :: 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
- slowHeadE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a)
Documentation
module Data.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 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.
data Behavior t :: Type -> Type 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 :: Type -> Type 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 :: Type -> Type 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 :: Type -> Type 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 :: Type -> Type Source #
A monad for doing complex push-based calculations efficiently
type PullM t :: Type -> Type Source #
A monad for doing complex pull-based 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 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 Behavior
s; the result will be
recomputed whenever any of the read Behavior
s 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 #
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.
You maybe looking for 'switchHold
never
' instead.
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.
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 #
eventCoercion :: Coercion a b -> Coercion (Event t a) (Event t b) Source #
dynamicCoercion :: Coercion a b -> Coercion (Dynamic t a) (Dynamic t b) Source #
incrementalCoercion :: Coercion (PatchTarget a) (PatchTarget b) -> Coercion a b -> Coercion (Incremental t a) (Incremental t b) Source #
Construct a Coercion
for an Incremental
given Coercion
s 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
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
.
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 #
headE :: Event t a -> m (Event t a) Source #
now :: m (Event t ()) Source #
An event which only occurs at the current moment in time, such that:
coincidence (pushAlways (\a -> (a <$) <$> now) e) = e
now :: (m ~ f m', MonadTrans f, MonadHold t m') => m (Event t ()) Source #
An event which only occurs at the current moment in time, such that:
coincidence (pushAlways (\a -> (a <$) <$> now) e) = e
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
mapMaybe
.
EventSelector | |
|
newtype EventSelectorG t k v Source #
EventSelectorG | |
|
newtype EventSelectorInt t a Source #
Convenience functions
Combining Event
s
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
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.
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 #
Zips two values by taking the union of their shapes and combining with the provided function.
Nothing
values are dropped.
Breaking up Event
s
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
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 :: k) (r :: k) (a :: k) :: forall k. k -> k -> k -> Type where #
LeftTag :: forall k (l :: k) (r :: k) (a :: k). EitherTag l r l | |
RightTag :: forall k (l :: k) (r :: k) (a :: k). EitherTag l r r |
Instances
GCompare (EitherTag l r :: k -> Type) | |
GEq (EitherTag l r :: k -> Type) | |
GShow (EitherTag l r :: k -> Type) | |
Defined in Data.Functor.Misc gshowsPrec :: Int -> EitherTag l r a -> ShowS # | |
Eq (EitherTag l r a) | |
Ord (EitherTag l r a) | |
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) | |
eitherToDSum :: Either a b -> DSum (EitherTag a b) Identity #
Convert Either
to a DSum
. Inverse of dsumToEither
.
dsumToEither :: DSum (EitherTag a b) Identity -> Either a b #
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 #
Given a PatchTarget
of events (e.g., a Map
with Event
values) and an event of Patch
es
(e.g., a PatchMap
with Event
values), produce an Event
of the PatchTarget
type that
fires with the patched value.
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.
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 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 :: Type) (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 #
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 Nothing
s 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 #
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 #
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 #
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 #
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 Nothing
s 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 #
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 #
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
Instances
FunctorMaybe [] Source # | |
Defined in Reflex.FunctorMaybe | |
FunctorMaybe Maybe Source # | |
FunctorMaybe Option Source # | |
FunctorMaybe IntMap Source # | |
FunctorMaybe (Map k) Source # | |
Reflex t => FunctorMaybe (Event t) Source # | |
mapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b #
Like 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 Left
s from 'f (Either a b)' into a
.
filterRight :: Filterable 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
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
.
Cheap functions
fmapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b Source #
An alias for mapMaybeCheap
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
.
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
.