@@ -34,10 +34,9 @@ module Reflex.Class
34 , coerceDynamic
34 , coerceDynamic
35 , MonadSample (..)
35 , MonadSample (..)
36 , MonadHold (..)
36 , MonadHold (..)
37− -- ** 'fan'-related types
37+ -- ** 'fan' related types
38 , EventSelector (..)
38 , EventSelector (..)
39 , EventSelectorInt (..)
39 , EventSelectorInt (..)
40− -- ** 'Incremental'-related types
41 -- * Convenience functions
40 -- * Convenience functions
42 , constDyn
41 , constDyn
43 , pushAlways
42 , pushAlways
@@ -201,7 +200,7 @@ import qualified Reflex.Patch.MapWithMove as PatchMapWithMove
201import Debug.Trace (trace)
200import Debug.Trace (trace)
203-- | The 'Reflex' class contains all the primitive functionality needed for
202-- | The 'Reflex' class contains all the primitive functionality needed for
204−-- Functional Reactive Programming (FRP). The @t@ type parameter indicates
203+-- Functional Reactive Programming (FRP). The @/t/@ type parameter indicates
205-- which "timeline" is in use. Timelines are fully-independent FRP contexts,
204-- which "timeline" is in use. Timelines are fully-independent FRP contexts,
206-- and the type of the timeline determines the FRP engine to be used. For most
205-- and the type of the timeline determines the FRP engine to be used. For most
207-- purposes, the 'Reflex.Spider' implementation is recommended.
206-- purposes, the 'Reflex.Spider' implementation is recommended.
@@ -267,7 +266,7 @@ class ( MonadHold t (PushM t)
267 -- | Create a new 'Dynamic'. The given 'PullM' must always return the most
266 -- | Create a new 'Dynamic'. The given 'PullM' must always return the most
268 -- recent firing of the given 'Event', if any.
267 -- recent firing of the given 'Event', if any.
269 unsafeBuildDynamic :: PullM t a -> Event t a -> Dynamic t a
268 unsafeBuildDynamic :: PullM t a -> Event t a -> Dynamic t a
270− -- | Create a new 'Incremental'. The given 'PullM''s value must always change
269+ -- | Create a new 'Incremental'. The given "PullM"'s value must always change
271 -- in the same way that the accumulated application of patches would change
270 -- in the same way that the accumulated application of patches would change
272 -- that value.
271 -- that value.
273 unsafeBuildIncremental :: Patch p => PullM t (PatchTarget p) -> Event t p -> Incremental t p
272 unsafeBuildIncremental :: Patch p => PullM t (PatchTarget p) -> Event t p -> Incremental t p
@@ -310,7 +309,7 @@ coerceDynamic :: (Reflex t, Coercible a b) => Dynamic t a -> Dynamic t b
310coerceDynamic = coerceWith $ dynamicCoercion Coercion
309coerceDynamic = coerceWith $ dynamicCoercion Coercion
312-- | Construct a 'Dynamic' from a 'Behavior' and an 'Event'. The 'Behavior'
311-- | Construct a 'Dynamic' from a 'Behavior' and an 'Event'. The 'Behavior'
313−-- _must_ change when and only when the 'Event' fires, such that the
312+-- __must__ change when and only when the 'Event' fires, such that the
314-- 'Behavior''s value is always equal to the most recent firing of the 'Event';
313-- 'Behavior''s value is always equal to the most recent firing of the 'Event';
315-- if this is not the case, the resulting 'Dynamic' will behave
314-- if this is not the case, the resulting 'Dynamic' will behave
316-- nondeterministically.
315-- nondeterministically.
@@ -338,7 +337,7 @@ class MonadSample t m => MonadHold t m where
338 -- value and will be updated whenever the given 'Event' occurs. The update
337 -- value and will be updated whenever the given 'Event' occurs. The update
339 -- takes effect immediately after the 'Event' occurs; if the occurrence that
338 -- takes effect immediately after the 'Event' occurs; if the occurrence that
340 -- sets the 'Behavior' (or one that is simultaneous with it) is used to sample
339 -- sets the 'Behavior' (or one that is simultaneous with it) is used to sample
341− -- the 'Behavior', it will see the _old_ value of the 'Behavior', not the new
340+ -- the 'Behavior', it will see the __old__ value of the 'Behavior', not the new
343 hold :: a -> Event t a -> m (Behavior t a)
342 hold :: a -> Event t a -> m (Behavior t a)
344 default hold :: (m ~ f m', MonadTrans f, MonadHold t m') => a -> Event t a -> m (Behavior t a)
343 default hold :: (m ~ f m', MonadTrans f, MonadHold t m') => a -> Event t a -> m (Behavior t a)
@@ -641,7 +640,7 @@ headTailE e = do
641-- event returns 'True'.
640-- event returns 'True'.
643-- Starting at the current time, fire all the occurrences of the 'Event' for
642-- Starting at the current time, fire all the occurrences of the 'Event' for
644−-- which the given predicate returns 'True'. When 'False' first is returned,
643+-- which the given predicate returns 'True'. When first 'False' is returned,
645-- do not fire, and permanently stop firing, even if 'True' values would have
644-- do not fire, and permanently stop firing, even if 'True' values would have
646-- been encountered later.
645-- been encountered later.
647takeWhileE
646takeWhileE
@@ -656,7 +655,7 @@ takeWhileE f = takeWhileJustE $ \v -> guard (f v) $> v
656-- event returns 'Just b'.
655-- event returns 'Just b'.
658-- Starting at the current time, fire all the occurrences of the 'Event' for
657-- Starting at the current time, fire all the occurrences of the 'Event' for
659−-- which the given predicate returns 'Just b'. When 'Nothing' first is returned,
658+-- which the given predicate returns 'Just b'. When first 'Nothing' is returned,
660-- do not fire, and permanently stop firing, even if 'Just b' values would have
659-- do not fire, and permanently stop firing, even if 'Just b' values would have
661-- been encountered later.
660-- been encountered later.
662takeWhileJustE
661takeWhileJustE
@@ -829,7 +828,7 @@ fanMap = fan . fmap mapToDMap
830-- | Switches to the new event whenever it receives one. Only the old event is
829-- | Switches to the new event whenever it receives one. Only the old event is
831-- considered the moment a new one is switched in; the output event will fire at
830-- considered the moment a new one is switched in; the output event will fire at
832−-- that moment if only if the old event does.
831+-- that moment only if the old event does.
834-- Because the simultaneous firing case is irrelevant, this function imposes
833-- Because the simultaneous firing case is irrelevant, this function imposes
835-- laxer "timing requirements" on the overall circuit, avoiding many potential
834-- laxer "timing requirements" on the overall circuit, avoiding many potential
@@ -875,13 +874,13 @@ coincidencePatchMap e = fmapCheap PatchMap $ coincidence $ ffor e $ \(PatchMap m
875 Nothing -> fmapCheap (const Nothing) e
874 Nothing -> fmapCheap (const Nothing) e
876 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
875 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
878−-- | See 'coincicencePatchMap'
877+-- | See 'coincidencePatchMap'
879coincidencePatchIntMap :: Reflex t => Event t (PatchIntMap (Event t v)) -> Event t (PatchIntMap v)
878coincidencePatchIntMap :: Reflex t => Event t (PatchIntMap (Event t v)) -> Event t (PatchIntMap v)
880coincidencePatchIntMap e = fmapCheap PatchIntMap $ coincidence $ ffor e $ \(PatchIntMap m) -> mergeIntMap $ ffor m $ \case
879coincidencePatchIntMap e = fmapCheap PatchIntMap $ coincidence $ ffor e $ \(PatchIntMap m) -> mergeIntMap $ ffor m $ \case
881 Nothing -> fmapCheap (const Nothing) e
880 Nothing -> fmapCheap (const Nothing) e
882 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
881 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
884−-- | See 'coincicencePatchMap'
883+-- | See 'coincidencePatchMap'
885coincidencePatchMapWithMove :: (Reflex t, Ord k) => Event t (PatchMapWithMove k (Event t v)) -> Event t (PatchMapWithMove k v)
884coincidencePatchMapWithMove :: (Reflex t, Ord k) => Event t (PatchMapWithMove k (Event t v)) -> Event t (PatchMapWithMove k v)
886coincidencePatchMapWithMove e = fmapCheap unsafePatchMapWithMove $ coincidence $ ffor e $ \p -> mergeMap $ ffor (unPatchMapWithMove p) $ \ni -> case PatchMapWithMove._nodeInfo_from ni of
885coincidencePatchMapWithMove e = fmapCheap unsafePatchMapWithMove $ coincidence $ ffor e $ \p -> mergeMap $ ffor (unPatchMapWithMove p) $ \ni -> case PatchMapWithMove._nodeInfo_from ni of
887 PatchMapWithMove.From_Delete -> fforCheap e $ \_ ->
886 PatchMapWithMove.From_Delete -> fforCheap e $ \_ ->
@@ -942,7 +941,7 @@ zipDyn = zipDynWith (,)
943-- | Combine two 'Dynamic's with a combining function. The result will change
942-- | Combine two 'Dynamic's with a combining function. The result will change
944-- whenever either (or both) input 'Dynamic' changes.
943-- whenever either (or both) input 'Dynamic' changes.
945−-- More efficient than liftA2.
944+-- More efficient than 'liftA2'.
946zipDynWith :: Reflex t => (a -> b -> c) -> Dynamic t a -> Dynamic t b -> Dynamic t c
945zipDynWith :: Reflex t => (a -> b -> c) -> Dynamic t a -> Dynamic t b -> Dynamic t c
947zipDynWith f da db =
946zipDynWith f da db =
948 let eab = align (updated da) (updated db)
947 let eab = align (updated da) (updated db)
@@ -973,7 +972,7 @@ instance (Reflex t, Monoid a) => Monoid (Dynamic t a) where
974-- | This function converts a 'DMap' whose elements are 'Dynamic's into a
973-- | This function converts a 'DMap' whose elements are 'Dynamic's into a
975-- 'Dynamic' 'DMap'. Its implementation is more efficient than doing the same
974-- 'Dynamic' 'DMap'. Its implementation is more efficient than doing the same
976−-- through the use of multiple uses of 'zipWithDyn' or 'Applicative' operators.
975+-- through the use of multiple uses of 'zipDynWith' or 'Applicative' operators.
977distributeDMapOverDynPure :: forall t k. (Reflex t, GCompare k) => DMap k (Dynamic t) -> Dynamic t (DMap k Identity)
976distributeDMapOverDynPure :: forall t k. (Reflex t, GCompare k) => DMap k (Dynamic t) -> Dynamic t (DMap k Identity)
978distributeDMapOverDynPure dm = case DMap.toList dm of
977distributeDMapOverDynPure dm = case DMap.toList dm of
979 [] -> constDyn DMap.empty
978 [] -> constDyn DMap.empty