| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
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
- data UniqDynamic t a
- uniqDynamic :: Reflex t => Dynamic t a -> UniqDynamic t a
- fromUniqDynamic :: (Reflex t, Eq a) => UniqDynamic t a -> Dynamic t a
- alreadyUniqDynamic :: Dynamic t a -> UniqDynamic t a
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
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