on develop help sign in
Improve specialization
68a75c8Ryan Trinkle
reflex.cabal+1−1
@@ -105,7 +105,7 @@ library
105 Reflex.Spider.Internal,
105 Reflex.Spider.Internal,
106 Reflex.Widget.Basic
106 Reflex.Widget.Basic
107
107
108− ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2
108+ ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -fspecialise-aggressively -ddump-simpl -ddump-to-file -dsuppress-coercions -dsuppress-idinfo
109 ghc-prof-options: -fprof-auto
109 ghc-prof-options: -fprof-auto
110
110
111 if flag(specialize-to-spidertimeline-global)
111 if flag(specialize-to-spidertimeline-global)
src/Reflex/Class.hs+17−1
@@ -638,6 +638,8 @@ instance Reflex t => Bind (Event t) where
638instance Reflex t => Functor (Event t) where
638instance Reflex t => Functor (Event t) where
639 {-# INLINE fmap #-}
639 {-# INLINE fmap #-}
640 fmap f = fmapMaybe $ Just . f
640 fmap f = fmapMaybe $ Just . f
641+ {-# INLINE (<$) #-}
642+ x <$ e = fmapCheap (const x) e
641
643
642instance Reflex t => FunctorMaybe (Event t) where
644instance Reflex t => FunctorMaybe (Event t) where
643 {-# INLINE fmapMaybe #-}
645 {-# INLINE fmapMaybe #-}
@@ -956,12 +958,16 @@ mapAccumMaybeMDyn f z e = do
956 d' <- holdDyn z $ fmapMaybe fst e'
958 d' <- holdDyn z $ fmapMaybe fst e'
957 return (d', fmapMaybe snd e')
959 return (d', fmapMaybe snd e')
958
960
961+{-# INLINE accumB #-}
959accumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Behavior t a)
962accumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Behavior t a)
960accumB f = accumMaybeB $ \v o -> Just $ f v o
963accumB f = accumMaybeB $ \v o -> Just $ f v o
964+{-# INLINE accumMB #-}
961accumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (Behavior t a)
965accumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t a) -> a -> Event t b -> m (Behavior t a)
962accumMB f = accumMaybeMB $ \v o -> Just <$> f v o
966accumMB f = accumMaybeMB $ \v o -> Just <$> f v o
967+{-# INLINE accumMaybeB #-}
963accumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (Behavior t a)
968accumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> Maybe a) -> a -> Event t b -> m (Behavior t a)
964accumMaybeB f = accumMaybeMB $ \v o -> return $ f v o
969accumMaybeB f = accumMaybeMB $ \v o -> return $ f v o
970+{-# INLINE accumMaybeMB #-}
965accumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Behavior t a)
971accumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Behavior t a)
966accumMaybeMB f z e = do
972accumMaybeMB f z e = do
967 rec let e' = flip push e $ \o -> do
973 rec let e' = flip push e $ \o -> do
@@ -969,14 +975,17 @@ accumMaybeMB f z e = do
969 f v o
975 f v o
970 d' <- hold z e'
976 d' <- hold z e'
971 return d'
977 return d'
978+{-# INLINE mapAccumB #-}
972mapAccumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c)
979mapAccumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c)
973mapAccumB f = mapAccumMaybeB $ \v o -> bimap Just Just $ f v o
980mapAccumB f = mapAccumMaybeB $ \v o -> bimap Just Just $ f v o
981+{-# INLINE mapAccumMB #-}
974mapAccumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c)
982mapAccumMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (a, c)) -> a -> Event t b -> m (Behavior t a, Event t c)
975mapAccumMB f = mapAccumMaybeMB $ \v o -> bimap Just Just <$> f v o
983mapAccumMB f = mapAccumMaybeMB $ \v o -> bimap Just Just <$> f v o
984+{-# INLINE mapAccumMaybeB #-}
976mapAccumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Behavior t a, Event t c)
985mapAccumMaybeB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> (Maybe a, Maybe c)) -> a -> Event t b -> m (Behavior t a, Event t c)
977mapAccumMaybeB f = mapAccumMaybeMB $ \v o -> return $ f v o
986mapAccumMaybeB f = mapAccumMaybeMB $ \v o -> return $ f v o
978
987
979−{-# INLINABLE mapAccumMaybeMB #-}
988+{-# INLINE mapAccumMaybeMB #-}
980mapAccumMaybeMB :: (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)
989mapAccumMaybeMB :: (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)
981mapAccumMaybeMB f z e = do
990mapAccumMaybeMB f z e = do
982 rec let e' = flip push e $ \o -> do
991 rec let e' = flip push e $ \o -> do
@@ -990,6 +999,7 @@ mapAccumMaybeMB f z e = do
990
999
991-- | Accumulate occurrences of an 'Event', producing an output occurrence each
1000-- | Accumulate occurrences of an 'Event', producing an output occurrence each
992-- time. Discard the underlying 'Accumulator'.
1001-- time. Discard the underlying 'Accumulator'.
1002+{-# INLINE mapAccum_ #-}
993mapAccum_ :: 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)
1003mapAccum_ :: 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)
994mapAccum_ f z e = do
1004mapAccum_ f z e = do
995 (_, result) <- mapAccumB f z e
1005 (_, result) <- mapAccumB f z e
@@ -997,6 +1007,7 @@ mapAccum_ f z e = do
997
1007
998-- | Accumulate occurrences of an 'Event', possibly producing an output
1008-- | Accumulate occurrences of an 'Event', possibly producing an output
999-- occurrence each time. Discard the underlying 'Accumulator'.
1009-- occurrence each time. Discard the underlying 'Accumulator'.
1010+{-# INLINE mapAccumMaybe_ #-}
1000mapAccumMaybe_ :: 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)
1011mapAccumMaybe_ :: 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)
1001mapAccumMaybe_ f z e = do
1012mapAccumMaybe_ f z e = do
1002 (_, result) <- mapAccumMaybeB f z e
1013 (_, result) <- mapAccumMaybeB f z e
@@ -1004,6 +1015,7 @@ mapAccumMaybe_ f z e = do
1004
1015
1005-- | Accumulate occurrences of an 'Event', using a 'PushM' action and producing
1016-- | Accumulate occurrences of an 'Event', using a 'PushM' action and producing
1006-- an output occurrence each time. Discard the underlying 'Accumulator'.
1017-- an output occurrence each time. Discard the underlying 'Accumulator'.
1018+{-# INLINE mapAccumM_ #-}
1007mapAccumM_ :: 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)
1019mapAccumM_ :: 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)
1008mapAccumM_ f z e = do
1020mapAccumM_ f z e = do
1009 (_, result) <- mapAccumMB f z e
1021 (_, result) <- mapAccumMB f z e
@@ -1012,6 +1024,7 @@ mapAccumM_ f z e = do
1012-- | Accumulate occurrences of an 'Event', using a 'PushM' action and possibly
1024-- | Accumulate occurrences of an 'Event', using a 'PushM' action and possibly
1013-- producing an output occurrence each time. Discard the underlying
1025-- producing an output occurrence each time. Discard the underlying
1014-- 'Accumulator'.
1026-- 'Accumulator'.
1027+{-# INLINE mapAccumMaybeM_ #-}
1015mapAccumMaybeM_ :: 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)
1028mapAccumMaybeM_ :: 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)
1016mapAccumMaybeM_ f z e = do
1029mapAccumMaybeM_ f z e = do
1017 (_, result) <- mapAccumMaybeMB f z e
1030 (_, result) <- mapAccumMaybeMB f z e
@@ -1040,14 +1053,17 @@ zipListWithEvent f l e = do
1040 mapAccumMaybe_ f' l e
1053 mapAccumMaybe_ f' l e
1041
1054
1042-- | Assign a number to each occurence of the given 'Event', starting from 0
1055-- | Assign a number to each occurence of the given 'Event', starting from 0
1056+{-# INLINE numberOccurrences #-}
1043numberOccurrences :: (Reflex t, MonadHold t m, MonadFix m, Num b) => Event t a -> m (Event t (b, a))
1057numberOccurrences :: (Reflex t, MonadHold t m, MonadFix m, Num b) => Event t a -> m (Event t (b, a))
1044numberOccurrences = numberOccurrencesFrom 0
1058numberOccurrences = numberOccurrencesFrom 0
1045
1059
1046-- | Assign a number to each occurence of the given 'Event'
1060-- | Assign a number to each occurence of the given 'Event'
1061+{-# INLINE numberOccurrencesFrom #-}
1047numberOccurrencesFrom :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t (b, a))
1062numberOccurrencesFrom :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t (b, a))
1048numberOccurrencesFrom = mapAccum_ (\n a -> (n + 1, (n, a)))
1063numberOccurrencesFrom = mapAccum_ (\n a -> (n + 1, (n, a)))
1049
1064
1050-- | Assign a number to each occurence of the given 'Event'; discard the occurrences' values
1065-- | Assign a number to each occurence of the given 'Event'; discard the occurrences' values
1066+{-# INLINE numberOccurrencesFrom_ #-}
1051numberOccurrencesFrom_ :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t b)
1067numberOccurrencesFrom_ :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t b)
1052numberOccurrencesFrom_ = mapAccum_ (\n _ -> (n + 1, n))
1068numberOccurrencesFrom_ = mapAccum_ (\n _ -> (n + 1, n))
1053
1069
src/Reflex/Spider/Internal.hs+7−19
@@ -395,7 +395,7 @@ eventDyn :: (HasSpiderTimeline x, Patch p) => Dyn x p -> Event x p
395eventDyn !j = Event $ \sub -> getDynHold j >>= \h -> subscribeHoldEvent h sub
395eventDyn !j = Event $ \sub -> getDynHold j >>= \h -> subscribeHoldEvent h sub
396
396
397{-# INLINE subscribeCoincidenceInner #-}
397{-# INLINE subscribeCoincidenceInner #-}
398−subscribeCoincidenceInner :: CanSubscribe x m => Event x a -> Height -> CoincidenceSubscribed x a -> m (Maybe a, Height, EventSubscribed x)
398+subscribeCoincidenceInner :: HasSpiderTimeline x => Event x a -> Height -> CoincidenceSubscribed x a -> EventM x (Maybe a, Height, EventSubscribed x)
399subscribeCoincidenceInner inner outerHeight subscribedUnsafe = do
399subscribeCoincidenceInner inner outerHeight subscribedUnsafe = do
400 subInner <- liftIO $ newSubscriberCoincidenceInner subscribedUnsafe
400 subInner <- liftIO $ newSubscriberCoincidenceInner subscribedUnsafe
401 (subscription@(EventSubscription _ innerSubd), innerOcc) <- subscribeAndRead inner subInner
401 (subscription@(EventSubscription _ innerSubd), innerOcc) <- subscribeAndRead inner subInner
@@ -645,7 +645,7 @@ walkInvalidHeightParents s0 = do
645#endif
645#endif
646
646
647{-# INLINE subscribeHoldEvent #-}
647{-# INLINE subscribeHoldEvent #-}
648−subscribeHoldEvent :: CanSubscribe x m => Hold x p -> Subscriber x p -> m (EventSubscription x, Maybe p)
648+subscribeHoldEvent :: HasSpiderTimeline x => Hold x p -> Subscriber x p -> EventM x (EventSubscription x, Maybe p)
649subscribeHoldEvent = subscribeAndRead . holdEvent
649subscribeHoldEvent = subscribeAndRead . holdEvent
650
650
651--------------------------------------------------------------------------------
651--------------------------------------------------------------------------------
@@ -929,7 +929,7 @@ hold v0 e = do
929 return h
929 return h
930
930
931{-# INLINE getHoldEventSubscription #-}
931{-# INLINE getHoldEventSubscription #-}
932−getHoldEventSubscription :: forall m p x. (Defer (SomeAssignment x) m, Defer (SomeHoldInit x) m, Defer SomeClear m, Patch p, HasCurrentHeight x m, Defer (SomeMergeInit x) m, Defer (SomeResetCoincidence x) m, HasSpiderTimeline x, m ~ EventM x) => Hold x p -> m (EventSubscription x)
932+getHoldEventSubscription :: forall p x. (HasSpiderTimeline x, Patch p) => Hold x p -> EventM x (EventSubscription x)
933getHoldEventSubscription h = do
933getHoldEventSubscription h = do
934 ep <- liftIO $ readIORef $ holdParent h
934 ep <- liftIO $ readIORef $ holdParent h
935 case ep of
935 case ep of
@@ -1409,17 +1409,6 @@ getDynHold d = do
1409zeroRef :: IORef Height
1409zeroRef :: IORef Height
1410zeroRef = unsafePerformIO $ newIORef zeroHeight
1410zeroRef = unsafePerformIO $ newIORef zeroHeight
1411
1411
1412−type CanSubscribe x m =
1413− ( HasSpiderTimeline x
1414− , HasCurrentHeight x m
1415− , Defer (SomeHoldInit x) m, Defer (SomeMergeInit x) m -- The things we need to lazily initialize state
1416− , Defer SomeClear m -- Wiping out event firings
1417− , Defer SomeIntClear m
1418− , Defer (SomeAssignment x) m -- Updating state
1419− , Defer (SomeResetCoincidence x) m
1420− , m ~ EventM x
1421− )
1422−
1423getRootSubscribed :: GCompare k => k a -> Root x k -> Subscriber x a -> IO (WeakBagTicket, RootSubscribed x a, Maybe a)
1412getRootSubscribed :: GCompare k => k a -> Root x k -> Subscriber x a -> IO (WeakBagTicket, RootSubscribed x a, Maybe a)
1424getRootSubscribed k r sub = do
1413getRootSubscribed k r sub = do
1425 mSubscribed <- readIORef $ rootSubscribed r
1414 mSubscribed <- readIORef $ rootSubscribed r
@@ -1500,7 +1489,6 @@ unsafeNewFanInt b = unsafePerformIO $ do
1500 touch b
1489 touch b
1501 newFanInt
1490 newFanInt
1502
1491
1503−{-# NOINLINE fanInt #-}
1504fanInt :: HasSpiderTimeline x => Event x (IntMap a) -> EventSelectorInt x a
1492fanInt :: HasSpiderTimeline x => Event x (IntMap a) -> EventSelectorInt x a
1505fanInt p =
1493fanInt p =
1506 let self = unsafeNewFanInt p
1494 let self = unsafeNewFanInt p
@@ -1511,7 +1499,7 @@ fanInt p =
1511 { subscriberPropagate = \m -> do
1499 { subscriberPropagate = \m -> do
1512 liftIO $ writeIORef (_fanInt_occRef self) m
1500 liftIO $ writeIORef (_fanInt_occRef self) m
1513 scheduleIntClear $ _fanInt_occRef self
1501 scheduleIntClear $ _fanInt_occRef self
1514− FastMutableIntMap.forIntersectionWithImmutable_ (_fanInt_subscribers self) m $ \b v -> do
1502+ FastMutableIntMap.forIntersectionWithImmutable_ (_fanInt_subscribers self) m $ \b v -> do --TODO: Do we need to know that no subscribers are being added as we traverse?
1515 FastWeakBag.traverse b $ \s -> do
1503 FastWeakBag.traverse b $ \s -> do
1516 subscriberPropagate s v
1504 subscriberPropagate s v
1517 , subscriberInvalidateHeight = \old -> do
1505 , subscriberInvalidateHeight = \old -> do
@@ -1540,7 +1528,7 @@ fanInt p =
1540 return (EventSubscription (FastWeakBag.remove t) $! EventSubscribed heightRef $! toAny (_fanInt_subscriptionRef self, t), IntMap.lookup k currentOcc)
1528 return (EventSubscription (FastWeakBag.remove t) $! EventSubscribed heightRef $! toAny (_fanInt_subscriptionRef self, t), IntMap.lookup k currentOcc)
1541
1529
1542{-# INLINABLE getFanSubscribed #-}
1530{-# INLINABLE getFanSubscribed #-}
1543−getFanSubscribed :: (Defer (SomeAssignment x) m, Defer (SomeHoldInit x) m, Defer (SomeMergeInit x) m, Defer SomeClear m, HasCurrentHeight x m, Defer (SomeResetCoincidence x) m, HasSpiderTimeline x, m ~ EventM x, GCompare k) => k a -> Fan x k -> Subscriber x a -> m (WeakBagTicket, FanSubscribed x k, Maybe a)
1531+getFanSubscribed :: (HasSpiderTimeline x, GCompare k) => k a -> Fan x k -> Subscriber x a -> EventM x (WeakBagTicket, FanSubscribed x k, Maybe a)
1544getFanSubscribed k f sub = do
1532getFanSubscribed k f sub = do
1545 mSubscribed <- liftIO $ readIORef $ fanSubscribed f
1533 mSubscribed <- liftIO $ readIORef $ fanSubscribed f
1546 case mSubscribed of
1534 case mSubscribed of
@@ -1599,7 +1587,7 @@ subscribeFanSubscribed k subscribed sub = do
1599 Just (FanSubscribedChildren list _ weakSelf) -> {-# SCC "hitSubscribeFanSubscribed" #-} WeakBag.insert sub list weakSelf cleanupFanSubscribed
1587 Just (FanSubscribedChildren list _ weakSelf) -> {-# SCC "hitSubscribeFanSubscribed" #-} WeakBag.insert sub list weakSelf cleanupFanSubscribed
1600
1588
1601{-# INLINABLE getSwitchSubscribed #-}
1589{-# INLINABLE getSwitchSubscribed #-}
1602−getSwitchSubscribed :: (Defer (SomeHoldInit x) m, Defer (SomeAssignment x) m, Defer (SomeMergeInit x) m, Defer SomeClear m, Defer (SomeResetCoincidence x) m, HasCurrentHeight x m, HasSpiderTimeline x, m ~ EventM x) => Switch x a -> Subscriber x a -> m (WeakBagTicket, SwitchSubscribed x a, Maybe a)
1590+getSwitchSubscribed :: HasSpiderTimeline x => Switch x a -> Subscriber x a -> EventM x (WeakBagTicket, SwitchSubscribed x a, Maybe a)
1603getSwitchSubscribed s sub = do
1591getSwitchSubscribed s sub = do
1604 mSubscribed <- liftIO $ readIORef $ switchSubscribed s
1592 mSubscribed <- liftIO $ readIORef $ switchSubscribed s
1605 case mSubscribed of
1593 case mSubscribed of
@@ -1655,7 +1643,7 @@ subscribeSwitchSubscribed :: SwitchSubscribed x a -> Subscriber x a -> IO WeakBa
1655subscribeSwitchSubscribed subscribed sub = WeakBag.insert sub (switchSubscribedSubscribers subscribed) (switchSubscribedWeakSelf subscribed) cleanupSwitchSubscribed
1643subscribeSwitchSubscribed subscribed sub = WeakBag.insert sub (switchSubscribedSubscribers subscribed) (switchSubscribedWeakSelf subscribed) cleanupSwitchSubscribed
1656
1644
1657{-# INLINABLE getCoincidenceSubscribed #-}
1645{-# INLINABLE getCoincidenceSubscribed #-}
1658−getCoincidenceSubscribed :: forall x a m. (Defer (SomeAssignment x) m, Defer (SomeHoldInit x) m, Defer (SomeMergeInit x) m, Defer SomeClear m, HasCurrentHeight x m, Defer (SomeResetCoincidence x) m, HasSpiderTimeline x, m ~ EventM x) => Coincidence x a -> Subscriber x a -> m (WeakBagTicket, CoincidenceSubscribed x a, Maybe a)
1646+getCoincidenceSubscribed :: forall x a. HasSpiderTimeline x => Coincidence x a -> Subscriber x a -> EventM x (WeakBagTicket, CoincidenceSubscribed x a, Maybe a)
1659getCoincidenceSubscribed c sub = do
1647getCoincidenceSubscribed c sub = do
1660 mSubscribed <- liftIO $ readIORef $ coincidenceSubscribed c
1648 mSubscribed <- liftIO $ readIORef $ coincidenceSubscribed c
1661 case mSubscribed of
1649 case mSubscribed of
src/Reflex/Spider/SpiderTimeline.include.hs+6−1
@@ -57,6 +57,7 @@ instance HasSpiderTimeline x => Monad (Reflex.Class.Dynamic (SpiderTimeline x))
57 {-# INLINE fail #-}
57 {-# INLINE fail #-}
58 fail _ = error "Dynamic does not support 'fail'"
58 fail _ = error "Dynamic does not support 'fail'"
59
59
60+{-# INLINABLE newJoinDyn #-}
60newJoinDyn :: HasSpiderTimeline x => Reflex.Spider.Internal.Dynamic x (Identity (Reflex.Spider.Internal.Dynamic x (Identity a))) -> Reflex.Spider.Internal.Dyn x (Identity a)
61newJoinDyn :: HasSpiderTimeline x => Reflex.Spider.Internal.Dynamic x (Identity (Reflex.Spider.Internal.Dynamic x (Identity a))) -> Reflex.Spider.Internal.Dyn x (Identity a)
61newJoinDyn d =
62newJoinDyn d =
62 let readV0 = readBehaviorTracked . dynamicCurrent =<< readBehaviorTracked (dynamicCurrent d)
63 let readV0 = readBehaviorTracked . dynamicCurrent =<< readBehaviorTracked (dynamicCurrent d)
@@ -68,12 +69,16 @@ newJoinDyn d =
68
69
69instance HasSpiderTimeline x => Functor (Reflex.Class.Dynamic (SpiderTimeline x)) where
70instance HasSpiderTimeline x => Functor (Reflex.Class.Dynamic (SpiderTimeline x)) where
70 fmap f = SpiderDynamic . newMapDyn f . unSpiderDynamic
71 fmap f = SpiderDynamic . newMapDyn f . unSpiderDynamic
72+ x <$ _ = pure x
71
73
72instance HasSpiderTimeline x => Applicative (Reflex.Class.Dynamic (SpiderTimeline x)) where
74instance HasSpiderTimeline x => Applicative (Reflex.Class.Dynamic (SpiderTimeline x)) where
73 pure = SpiderDynamic . dynamicConst
75 pure = SpiderDynamic . dynamicConst
76+#if MIN_VERSION_base(4,10,0)
77+ liftA2 f a b = SpiderDynamic $ Reflex.Spider.Internal.zipDynWith f a b
78+#endif
74 SpiderDynamic a <*> SpiderDynamic b = SpiderDynamic $ Reflex.Spider.Internal.zipDynWith ($) a b
79 SpiderDynamic a <*> SpiderDynamic b = SpiderDynamic $ Reflex.Spider.Internal.zipDynWith ($) a b
75 _ *> b = b
80 _ *> b = b
76− a <* _ = a
81+ a <* _ = a --TODO: The semantics of *>, <*, and <$ might not be quite right - they drop changes
77
82
78holdSpiderEventM :: HasSpiderTimeline x => a -> Reflex.Class.Event (SpiderTimeline x) a -> EventM x (Reflex.Class.Behavior (SpiderTimeline x) a)
83holdSpiderEventM :: HasSpiderTimeline x => a -> Reflex.Class.Event (SpiderTimeline x) a -> EventM x (Reflex.Class.Behavior (SpiderTimeline x) a)
79holdSpiderEventM v0 e = fmap (SpiderBehavior . behaviorHoldIdentity) $ Reflex.Spider.Internal.hold v0 $ coerce $ unSpiderEvent e
84holdSpiderEventM v0 e = fmap (SpiderBehavior . behaviorHoldIdentity) $ Reflex.Spider.Internal.hold v0 $ coerce $ unSpiderEvent e