reflex-0.6.4.1: Higher-order Functional Reactive Programming

Safe HaskellNone
LanguageHaskell2010

Reflex.Dynamic.Uniq

Description

This module provides a variation of Dynamic values that uses cheap pointer equality checks to reduce the amount of signal propagation needed.

Synopsis

Documentation

data UniqDynamic t a Source #

A Dynamic whose updated Event will never fire with the same value as the current Behavior's contents. In order to maintain this constraint, the value inside a UniqDynamic is always evaluated to weak head normal form.

Internally, UniqDynamic uses pointer equality as a heuristic to avoid unnecessary update propagation; this is much more efficient than performing full comparisons. However, when the UniqDynamic is converted back into a regular Dynamic, a full comparison is performed.

Instances
Reflex t => Monad (UniqDynamic t) Source # 
Instance details

Defined in Reflex.Dynamic.Uniq

Methods

(>>=) :: UniqDynamic t a -> (a -> UniqDynamic t b) -> UniqDynamic t b #

(>>) :: UniqDynamic t a -> UniqDynamic t b -> UniqDynamic t b #

return :: a -> UniqDynamic t a #

fail :: String -> UniqDynamic t a #

Reflex t => Functor (UniqDynamic t) Source # 
Instance details

Defined in Reflex.Dynamic.Uniq

Methods

fmap :: (a -> b) -> UniqDynamic t a -> UniqDynamic t b #

(<$) :: a -> UniqDynamic t b -> UniqDynamic t a #

Reflex t => Applicative (UniqDynamic t) Source # 
Instance details

Defined in Reflex.Dynamic.Uniq

Methods

pure :: a -> UniqDynamic t a #

(<*>) :: UniqDynamic t (a -> b) -> UniqDynamic t a -> UniqDynamic t b #

liftA2 :: (a -> b -> c) -> UniqDynamic t a -> UniqDynamic t b -> UniqDynamic t c #

(*>) :: UniqDynamic t a -> UniqDynamic t b -> UniqDynamic t b #

(<*) :: UniqDynamic t a -> UniqDynamic t b -> UniqDynamic t a #

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 #

uniqDynamic :: Reflex t => Dynamic t a -> UniqDynamic t a Source #

Construct a UniqDynamic by eliminating redundant updates from a Dynamic.

fromUniqDynamic :: (Reflex t, Eq a) => UniqDynamic t a -> Dynamic t a Source #

Retrieve a normal Dynamic from a UniqDynamic. This will perform a final check using the output type's Eq instance to ensure deterministic behavior.

WARNING: If used with a type whose Eq instance is not law-abiding - specifically, if there are cases where x /= x, fromUniqDynamic may eliminate more updated occurrences than it should. For example, NaN values of Double and Float are considered unequal to themselves by the Eq instance, but can be equal by pointer equality. This may cause UniqDynamic to lose changes from NaN to NaN.

alreadyUniqDynamic :: Dynamic t a -> UniqDynamic t a Source #

Create a UniqDynamic without uniqing it on creation. This will be slightly faster than uniqDynamic when used with a Dynamic whose values are always (or nearly always) different from its previous values; if used with a Dynamic whose values do not change frequently, it may be much slower than uniqDynamic