on develop help sign in
implement PR suggestions
commit26eea3636c4ad857e34bd495e71248d915becb91 authorDaniel Haraj <dan@obsidian.systems> dateWed 25 Jan 2017, 14:06 (10 years ago) parentae137ed
4 files changed+11−6
src/Reflex/Class.hs+1−1 src/Reflex/Patch.hs+6−2 src/Reflex/Pure.hs+1 src/Reflex/Spider/Internal.hs+3−3
src/Reflex/Class.hs+1−1
@@ -234,7 +234,7 @@ class ( MonadHold t (PushM t)
234234 -- 'Behavior's and hold 'Event's, and use the results to produce a occurring
235235 -- (Just) or non-occurring (Nothing) result
236236 push :: (a -> PushM t (Maybe b)) -> Event t a -> Event t b
237− -- | Like 'push' but intended for functions that the implementation can consider cheap to compute for performance considerations.
237+ -- | 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.
238238 pushCheap :: (a -> PushM t (Maybe b)) -> Event t a -> Event t b
239239 -- | Create a 'Behavior' by reading from other 'Behavior's; the result will be
240240 -- recomputed whenever any of the read 'Behavior's changes
src/Reflex/Patch.hs+6−2
@@ -11,7 +11,8 @@ module Reflex.Patch
1111 , PatchDMap (..)
1212 , ComposeMaybe (..)
1313 , PatchMap (..)
14− , Group (..), Additive
14+ , Group (..)
15+ , Additive
1516 , AdditivePatch (..)
1617 ) where
1718
@@ -87,15 +88,18 @@ instance Ord k => Monoid (PatchMap k v) where
8788 mempty = PatchMap mempty
8889 mappend = (<>)
8990
90−-- Patches based on commutative groups
91+---- Patches based on commutative groups
9192
93+-- | A 'Group' is a 'Monoid' where every element has an inverse.
9294class (Semigroup q, Monoid q) => Group q where
9395 negateG :: q -> q
9496 (~~) :: q -> q -> q
9597 r ~~ s = r <> negateG s
9698
99+-- | An 'Additive' 'Semigroup' is one where the multiplication is commutative
97100class Semigroup q => Additive q where
98101
102+-- | The elements of an 'Additive' 'Semigroup' can be considered as patches of their own type.
99103newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p }
100104
101105instance Additive p => Patch (AdditivePatch p) where
src/Reflex/Pure.hs+1
@@ -66,6 +66,7 @@ instance (Enum t, HasTrie t, Ord t) => Reflex (Pure t) where
6666 push :: (a -> PushM (Pure t) (Maybe b)) -> Event (Pure t) a -> Event (Pure t) b
6767 push f e = Event $ memo $ \t -> unEvent e t >>= \o -> f o t
6868
69+ pushCheap :: (a -> PushM (Pure t) (Maybe b)) -> Event (Pure t) a -> Event (Pure t) b
6970 pushCheap = push
7071
7172 pull :: PullM (Pure t) a -> Behavior (Pure t) a
src/Reflex/Spider/Internal.hs+3−3
@@ -1666,12 +1666,12 @@ mergeCheap d = Event $ \sub -> do
16661666 , subscriberInvalidateHeight = \_ -> return ()
16671667 , subscriberRecalculateHeight = \_ -> return ()
16681668 }
1669− (EventSubscription sln changeSubscription, change) <- subscribeAndRead (dynamicUpdated d) s
1669+ (changeSubscription, change) <- subscribeAndRead (dynamicUpdated d) s
16701670 forM_ change $ \c -> defer $ SomeMergeUpdate (updateMe c) invalidateMyHeight revalidateMyHeight
16711671 -- We explicitly hold on to the unsubscribe function from subscribing to the update event.
16721672 -- If we don't do this, there are certain cases where mergeCheap will fail to properly retain
16731673 -- its subscription.
1674− liftIO $ writeIORef changeSubdRef (s, sln, changeSubscription)
1674+ liftIO $ writeIORef changeSubdRef (s, changeSubscription)
16751675 let unsubscribeAll = do
16761676 parents <- readIORef parentsRef
16771677 forM_ (DMap.toList parents) $ \(_ :=> MergeSubscribedParent s) -> unsubscribe s
@@ -1965,7 +1965,7 @@ instance HasSpiderTimeline x => R.Reflex (SpiderTimeline x) where
19651965 {-# INLINABLE current #-}
19661966 current = SpiderBehavior . dynamicCurrent . unSpiderDynamic
19671967 {-# INLINABLE updated #-}
1968− updated = coerceWith Coercion $ SpiderEvent . dynamicUpdated . unSpiderDynamic
1968+ updated = coerce $ SpiderEvent . dynamicUpdated . unSpiderDynamic
19691969 {-# INLINABLE unsafeBuildDynamic #-}
19701970 unsafeBuildDynamic readV0 v' = SpiderDynamic $ dynamicDynIdentity $ unsafeDyn (coerce readV0) $ coerce $ unSpiderEvent v'
19711971 {-# INLINABLE unsafeBuildIncremental #-}