@@ -9,6 +9,7 @@
9{-# LANGUAGE GADTs #-}
9{-# LANGUAGE GADTs #-}
10{-# LANGUAGE GeneralizedNewtypeDeriving #-}
10{-# LANGUAGE GeneralizedNewtypeDeriving #-}
11{-# LANGUAGE LambdaCase #-}
11{-# LANGUAGE LambdaCase #-}
12+{-# LANGUAGE MultiWayIf #-}
12{-# LANGUAGE RankNTypes #-}
13{-# LANGUAGE RankNTypes #-}
13{-# LANGUAGE RoleAnnotations #-}
14{-# LANGUAGE RoleAnnotations #-}
14{-# LANGUAGE ScopedTypeVariables #-}
15{-# LANGUAGE ScopedTypeVariables #-}
@@ -19,7 +20,7 @@
19{-# LANGUAGE DeriveFunctor #-}
20{-# LANGUAGE DeriveFunctor #-}
20{-# LANGUAGE StandaloneDeriving #-}
21{-# LANGUAGE StandaloneDeriving #-}
21{-# LANGUAGE InstanceSigs #-}
22{-# LANGUAGE InstanceSigs #-}
22−{-# LANGUAGE MultiWayIf #-}
23+{-# LANGUAGE RecursiveDo #-}
24#ifdef USE_REFLEX_OPTIMIZER
25#ifdef USE_REFLEX_OPTIMIZER
25{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
26{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
@@ -38,17 +39,15 @@ import Control.Monad hiding (forM, forM_, mapM, mapM_)
38import Control.Monad.Exception
39import Control.Monad.Exception
39import Control.Monad.Identity hiding (forM, forM_, mapM, mapM_)
40import Control.Monad.Identity hiding (forM, forM_, mapM, mapM_)
40import Control.Monad.Primitive
41import Control.Monad.Primitive
42+--import Control.Monad.Reader hiding (forM, forM_, mapM, mapM_)
41import Control.Monad.Reader.Class
43import Control.Monad.Reader.Class
42import Control.Monad.IO.Class
44import Control.Monad.IO.Class
43import Control.Monad.ReaderIO
45import Control.Monad.ReaderIO
44import Control.Monad.Ref
46import Control.Monad.Ref
45−import Control.Monad.Fail (MonadFail)
46−import qualified Control.Monad.Fail as MonadFail
47import Data.Align
47import Data.Align
48import Data.Coerce
48import Data.Coerce
49−import Data.Dependent.Map (DMap)
49+import Data.Dependent.Map (DMap, DSum (..))
50import qualified Data.Dependent.Map as DMap
50import qualified Data.Dependent.Map as DMap
51−import Data.Dependent.Sum (DSum (..))
52import Data.FastMutableIntMap (FastMutableIntMap, PatchIntMap (..))
51import Data.FastMutableIntMap (FastMutableIntMap, PatchIntMap (..))
53import qualified Data.FastMutableIntMap as FastMutableIntMap
52import qualified Data.FastMutableIntMap as FastMutableIntMap
54import Data.Foldable hiding (concat, elem, sequence_)
53import Data.Foldable hiding (concat, elem, sequence_)
@@ -65,7 +64,6 @@ import Data.Monoid (mempty, (<>))
65import Data.Proxy
64import Data.Proxy
66import Data.These
65import Data.These
67import Data.Traversable
66import Data.Traversable
68−import Data.Type.Equality ((:~:)(Refl))
69import Data.Witherable (Filterable, mapMaybe)
67import Data.Witherable (Filterable, mapMaybe)
70import GHC.Exts hiding (toList)
68import GHC.Exts hiding (toList)
71import GHC.IORef (IORef (..))
69import GHC.IORef (IORef (..))
@@ -86,9 +84,9 @@ import Data.Zip (Zip (..))
87#ifdef DEBUG_CYCLES
85#ifdef DEBUG_CYCLES
88import Control.Monad.State hiding (forM, forM_, mapM, mapM_, sequence)
86import Control.Monad.State hiding (forM, forM_, mapM, mapM_, sequence)
87+import Data.List.NonEmpty (NonEmpty (..), nonEmpty)
91−import Data.List.NonEmpty (NonEmpty (..), nonEmpty)
92import qualified Data.List.NonEmpty as NonEmpty
90import qualified Data.List.NonEmpty as NonEmpty
93import Data.Tree (Forest, Tree (..), drawForest)
91import Data.Tree (Forest, Tree (..), drawForest)
94import Data.List (isPrefixOf)
92import Data.List (isPrefixOf)
@@ -106,21 +104,15 @@ import qualified Reflex.Class
106import qualified Reflex.Class as R
104import qualified Reflex.Class as R
107import qualified Reflex.Host.Class
105import qualified Reflex.Host.Class
108import Reflex.NotReady.Class
106import Reflex.NotReady.Class
109−import Data.Patch
107+import Reflex.Patch
110−import qualified Data.Patch.DMapWithMove as PatchDMapWithMove
108+import qualified Reflex.Patch.DMapWithMove as PatchDMapWithMove
111import Reflex.PerformEvent.Base (PerformEventT)
109import Reflex.PerformEvent.Base (PerformEventT)
113#ifdef DEBUG_TRACE_EVENTS
111#ifdef DEBUG_TRACE_EVENTS
114import qualified Data.ByteString.Char8 as BS8
112import qualified Data.ByteString.Char8 as BS8
115import System.IO (stderr)
113import System.IO (stderr)
116import Data.List (isPrefixOf)
114import Data.List (isPrefixOf)
119−-- TODO stdout might not be the best channel for debug output
120−debugStrLn :: String -> IO ()
121−debugStrLn = putStrLn
123−#ifdef DEBUG_TRACE_EVENTS
124withStackOneLine :: (BS8.ByteString -> a) -> a
116withStackOneLine :: (BS8.ByteString -> a) -> a
125withStackOneLine expr = unsafePerformIO $ do
117withStackOneLine expr = unsafePerformIO $ do
126 stack <- currentCallStack
118 stack <- currentCallStack
@@ -129,33 +121,9 @@ withStackOneLine expr = unsafePerformIO $ do
132−debugPropagate :: Bool
134−debugInvalidateHeight :: Bool
136−debugInvalidate :: Bool
138#ifdef DEBUG
124#ifdef DEBUG
139#define DEBUG_NODEIDS
125#define DEBUG_NODEIDS
141−#ifdef DEBUG_TRACE_PROPAGATION
142−debugPropagate = True
144−debugPropagate = False
147−#ifdef DEBUG_TRACE_HEIGHT
148−debugInvalidateHeight = True
150−debugInvalidateHeight = False
153−#ifdef DEBUG_TRACE_INVALIDATION
154−debugInvalidate = True
156−debugInvalidate = False
159class HasNodeId a where
127class HasNodeId a where
160 getNodeId :: a -> Int
128 getNodeId :: a -> Int
@@ -193,19 +161,11 @@ showNodeId' = ("#"<>) . show
196−debugPropagate = False
197−debugInvalidateHeight = False
198−debugInvalidate = False
200-- This must be inline, or error messages will cause memory leaks due to retaining the node in question
164-- This must be inline, or error messages will cause memory leaks due to retaining the node in question
201{-# INLINE showNodeId #-}
165{-# INLINE showNodeId #-}
202showNodeId :: a -> String
166showNodeId :: a -> String
203showNodeId _ = ""
167showNodeId _ = ""
205−{-# INLINE showNodeId' #-}
206−showNodeId' :: Int -> String
211#ifdef DEBUG_NODEIDS
171#ifdef DEBUG_NODEIDS
@@ -253,11 +213,11 @@ subscribeAndRead = unEvent
253{-# INLINE [1] pushCheap #-}
213{-# INLINE [1] pushCheap #-}
254pushCheap :: HasSpiderTimeline x => (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
214pushCheap :: HasSpiderTimeline x => (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
255pushCheap !f e = Event $ \sub -> do
215pushCheap !f e = Event $ \sub -> do
256− (subscription, occ) <- subscribeAndRead e $ debugSubscriber' "push" $ sub
216+ (subscription, occ) <- subscribeAndRead e $ debugSubscriber' "push" (sub
257 { subscriberPropagate = \a -> do
217 { subscriberPropagate = \a -> do
258 mb <- f a
218 mb <- f a
259 mapM_ (subscriberPropagate sub) mb
219 mapM_ (subscriberPropagate sub) mb
261 occ' <- join <$> mapM f occ
221 occ' <- join <$> mapM f occ
262 return (subscription, occ')
222 return (subscription, occ')
@@ -307,20 +267,7 @@ data CacheSubscribed x a
310−nowSpiderEventM :: (HasSpiderTimeline x) => EventM x (R.Event (SpiderTimeline x) ())
270+
314−now :: (MonadIO m, Defer (Some Clear) m, HasSpiderTimeline x
317− nowOrNot <- liftIO $ newIORef $ Just ()
318− scheduleClear nowOrNot
319− return . Event $ \_ -> do
320− occ <- liftIO . readIORef $ nowOrNot
321− return ( EventSubscription (return ()) eventSubscribedNow
325-- | Construct an 'Event' whose value is guaranteed not to be recomputed
272-- | Construct an 'Event' whose value is guaranteed not to be recomputed
326-- repeatedly
273-- repeatedly
@@ -351,18 +298,39 @@ cacheEvent e =
352 subscribers <- liftIO FastWeakBag.empty
299 subscribers <- liftIO FastWeakBag.empty
353 occRef <- liftIO $ newIORef Nothing -- This should never be read prior to being set below
300 occRef <- liftIO $ newIORef Nothing -- This should never be read prior to being set below
354−#ifdef DEBUG_NODEIDS
301+<<<<<<< HEAD
355 (parentSub, occ) <- subscribeAndRead e $ debugSubscriber' ("cacheEvent" <> showNodeId' nodeId) $ Subscriber
302 (parentSub, occ) <- subscribeAndRead e $ debugSubscriber' ("cacheEvent" <> showNodeId' nodeId) $ Subscriber
357− (parentSub, occ) <- subscribeAndRead e $ Subscriber
359 { subscriberPropagate = \a -> do
303 { subscriberPropagate = \a -> do
304+ -- checkCycle (_eventSubscription_subscribed parentSub)
360 liftIO $ writeIORef occRef (Just a)
305 liftIO $ writeIORef occRef (Just a)
361 scheduleClear occRef
306 scheduleClear occRef
362 propagateFast a subscribers
307 propagateFast a subscribers
363− , subscriberInvalidateHeight = FastWeakBag.traverse_ subscribers . invalidateSubscriberHeight
308+ , subscriberInvalidateHeight = FastWeakBag.traverse subscribers . invalidateSubscriberHeight
364− , subscriberRecalculateHeight = FastWeakBag.traverse_ subscribers . recalculateSubscriberHeight
309+ , subscriberRecalculateHeight = FastWeakBag.traverse subscribers . recalculateSubscriberHeight
311+||||||| merged common ancestors
312+ (parentSub, occ) <- subscribeAndRead e $ Subscriber
313+ { subscriberPropagate = \a -> do
314+ liftIO $ writeIORef occRef $ Just a
315+ scheduleClear occRef
316+ propagateFast a subscribers
317+ , subscriberInvalidateHeight = \old -> do
318+ FastWeakBag.traverse subscribers $ invalidateSubscriberHeight old
319+ , subscriberRecalculateHeight = \new -> do
320+ FastWeakBag.traverse subscribers $ recalculateSubscriberHeight new
323+ (parentSub, occ) <- subscribeAndRead e $ Subscriber
324+ { subscriberPropagate = \a -> do
325+ liftIO $ writeIORef occRef $ Just a
326+ scheduleClear occRef
327+ propagateFast a subscribers
328+ , subscriberInvalidateHeight = \old -> do
329+ FastWeakBag.traverse_ subscribers $ invalidateSubscriberHeight old
330+ , subscriberRecalculateHeight = \new -> do
331+ FastWeakBag.traverse_ subscribers $ recalculateSubscriberHeight new
366 when (isJust occ) $ do
334 when (isJust occ) $ do
367 liftIO $ writeIORef occRef occ -- Set the initial value of occRef; we don't need to do this if occ is Nothing
335 liftIO $ writeIORef occRef occ -- Set the initial value of occRef; we don't need to do this if occ is Nothing
368 scheduleClear occRef
336 scheduleClear occRef
@@ -464,6 +432,16 @@ data Subscriber x a = Subscriber
464 , subscriberRecalculateHeight :: !(Height -> IO ())
432 , subscriberRecalculateHeight :: !(Height -> IO ())
435+--TODO: Move this comment to WeakBag
436+-- These function are constructor functions that are marked NOINLINE so they are
437+-- opaque to GHC. If we do not do this, then GHC will sometimes fuse the constructor away
438+-- so any weak references that are attached to the constructors will have their
439+-- finalizer run. Using the opaque constructor, does not see the
440+-- constructor application, so it behaves like an IORef and cannot be fused away.
442+-- The result is also evaluated to WHNF, since forcing a thunk invalidates
443+-- the weak pointer to it in some cases.
467newSubscriberHold :: (HasSpiderTimeline x, Patch p) => Hold x p -> IO (Subscriber x p)
445newSubscriberHold :: (HasSpiderTimeline x, Patch p) => Hold x p -> IO (Subscriber x p)
468newSubscriberHold h = return $ Subscriber
446newSubscriberHold h = return $ Subscriber
469 { subscriberPropagate = {-# SCC "traverseHold" #-} propagateSubscriberHold h
447 { subscriberPropagate = {-# SCC "traverseHold" #-} propagateSubscriberHold h
@@ -607,16 +585,6 @@ eventSubscribedNever = EventSubscribed
607 , eventSubscribedWhoCreated = return ["never"]
585 , eventSubscribedWhoCreated = return ["never"]
610−eventSubscribedNow :: EventSubscribed x
611−eventSubscribedNow = EventSubscribed
612− { eventSubscribedHeightRef = zeroRef
613− , eventSubscribedRetained = toAny ()
615− , eventSubscribedGetParents = return []
616− , eventSubscribedHasOwnHeightRef = False
617− , eventSubscribedWhoCreated = return ["now"]
621eventSubscribedFan :: FanSubscribed x k v -> EventSubscribed x
589eventSubscribedFan :: FanSubscribed x k v -> EventSubscribed x
622eventSubscribedFan !subscribed = EventSubscribed
590eventSubscribedFan !subscribed = EventSubscribed
@@ -994,10 +962,8 @@ instance Monad (BehaviorM x) where
994 BehaviorM x >> BehaviorM y = BehaviorM $ x >> y
962 BehaviorM x >> BehaviorM y = BehaviorM $ x >> y
995 {-# INLINE return #-}
963 {-# INLINE return #-}
996 return x = BehaviorM $ return x
964 return x = BehaviorM $ return x
997−#if !MIN_VERSION_base(4,13,0)
998 {-# INLINE fail #-}
965 {-# INLINE fail #-}
999 fail s = BehaviorM $ fail s
966 fail s = BehaviorM $ fail s
1002data BehaviorSubscribed x a
968data BehaviorSubscribed x a
1003 = forall p. BehaviorSubscribedHold (Hold x p)
969 = forall p. BehaviorSubscribedHold (Hold x p)
@@ -1346,7 +1312,7 @@ mkWeakPtrWithDebug x debugNote = do
1346 x' <- evaluate x
1312 x' <- evaluate x
1347 mkWeakPtr x' $
1313 mkWeakPtr x' $
1348 if debugFinalize
1314 if debugFinalize
1349− then Just $ debugStrLn $ "finalizing: " ++ debugNote
1315+ then Just $ putStrLn $ "finalizing: " ++ debugNote
1350 else Nothing
1316 else Nothing
1352type WeakList a = [Weak a]
1318type WeakList a = [Weak a]
@@ -1368,13 +1334,13 @@ debugSubscriber' description subscribed = Subscriber
1368 tracePropagate (Proxy :: Proxy x) ("subscriberPropagate: " <> description)
1334 tracePropagate (Proxy :: Proxy x) ("subscriberPropagate: " <> description)
1369 subscriberPropagate subscribed m
1335 subscriberPropagate subscribed m
1370 , subscriberInvalidateHeight = \old -> do
1336 , subscriberInvalidateHeight = \old -> do
1371− traceInvalidateHeight $ "invalidateSubscriberHeight: " <> description <> ", old = " <> show (unHeight old)
1337+ putStrLn $ "invalidateSubscriberHeight: " <> description <> ", old = " <> show (unHeight old)
1372 subscriberInvalidateHeight subscribed old
1338 subscriberInvalidateHeight subscribed old
1373− traceInvalidateHeight $ "invalidateSubscriberHeight: " <> description <> ", done"
1339+ putStrLn $ "invalidateSubscriberHeight: " <> description <> ", done"
1374 , subscriberRecalculateHeight = \new -> do
1340 , subscriberRecalculateHeight = \new -> do
1375− traceInvalidateHeight $ "subscriberRecalculateHeight: " <> description <> ", new = " <> show (unHeight new)
1341+ putStrLn $ "subscriberRecalculateHeight: " <> description <> ", new = " <> show (unHeight new)
1376 subscriberRecalculateHeight subscribed new
1342 subscriberRecalculateHeight subscribed new
1377− traceInvalidateHeight $ "subscriberRecalculateHeight: " <> description <> ", done"
1343+ putStrLn $ "subscriberRecalculateHeight: " <> description <> ", done"
@@ -1388,15 +1354,11 @@ withIncreasedDepth _ a = do
1389{-# INLINE tracePropagate #-}
1355{-# INLINE tracePropagate #-}
1390tracePropagate :: (CanTrace x m) => proxy x -> String -> m ()
1356tracePropagate :: (CanTrace x m) => proxy x -> String -> m ()
1391−tracePropagate p = when debugPropagate . trace p
1357+tracePropagate p = trace p
1393{-# INLINE traceInvalidate #-}
1359{-# INLINE traceInvalidate #-}
1394traceInvalidate :: String -> IO ()
1360traceInvalidate :: String -> IO ()
1395−traceInvalidate = when debugInvalidate . liftIO . debugStrLn
1361+traceInvalidate = liftIO . putStrLn
1397−{-# INLINE traceInvalidateHeight #-}
1398−traceInvalidateHeight :: String -> IO ()
1399−traceInvalidateHeight = when debugInvalidateHeight . liftIO . debugStrLn
1401{-# INLINE trace #-}
1363{-# INLINE trace #-}
1402trace :: (CanTrace x m) => proxy x -> String -> m ()
1364trace :: (CanTrace x m) => proxy x -> String -> m ()
@@ -1407,7 +1369,7 @@ traceM :: forall x proxy m. (CanTrace x m) => proxy x -> m String -> m ()
1407traceM _ getMessage = do
1369traceM _ getMessage = do
1408 message <- getMessage
1370 message <- getMessage
1409 d <- liftIO $ readIORef $ _spiderTimeline_depth $ unSTE (spiderTimeline :: SpiderTimelineEnv x)
1371 d <- liftIO $ readIORef $ _spiderTimeline_depth $ unSTE (spiderTimeline :: SpiderTimelineEnv x)
1410− liftIO $ debugStrLn $ replicate d ' ' <> message
1372+ liftIO $ putStrLn $ replicate d ' ' <> message
@@ -1423,10 +1385,6 @@ tracePropagate _ _ = return ()
1423traceInvalidate :: String -> IO ()
1385traceInvalidate :: String -> IO ()
1424traceInvalidate _ = return ()
1386traceInvalidate _ = return ()
1426−{-# INLINE traceInvalidateHeight #-}
1427−traceInvalidateHeight :: String -> IO ()
1428−traceInvalidateHeight _ = return ()
1430{-# INLINE debugSubscriber #-}
1388{-# INLINE debugSubscriber #-}
1431debugSubscriber :: String -> Subscriber x a -> IO (Subscriber x a)
1389debugSubscriber :: String -> Subscriber x a -> IO (Subscriber x a)
1432debugSubscriber _ = return
1390debugSubscriber _ = return
@@ -1467,11 +1425,8 @@ showStacks :: [[String]] -> String
1467showStacks = drawForest . listsToForest . fmap (filterStack "Reflex.Spider.Internal")
1425showStacks = drawForest . listsToForest . fmap (filterStack "Reflex.Spider.Internal")
1469filterStack :: String -> [String] -> [String]
1427filterStack :: String -> [String] -> [String]
1470−#ifdef DEBUG_HIDE_INTERNALS
1471filterStack prefix = filter (not . (prefix `isPrefixOf`))
1428filterStack prefix = filter (not . (prefix `isPrefixOf`))
1473−filterStack prefix = id
1476#ifdef DEBUG_CYCLES
1431#ifdef DEBUG_CYCLES
@@ -1498,7 +1453,7 @@ instance Show EventLoopException where
1498{-# INLINE propagateSubscriberHold #-}
1453{-# INLINE propagateSubscriberHold #-}
1499propagateSubscriberHold :: forall x p. (HasSpiderTimeline x, Patch p) => Hold x p -> p -> EventM x ()
1454propagateSubscriberHold :: forall x p. (HasSpiderTimeline x, Patch p) => Hold x p -> p -> EventM x ()
1500propagateSubscriberHold h a = do
1455propagateSubscriberHold h a = do
1501− {-# SCC "trace" #-} when debugPropagate $ traceM (Proxy :: Proxy x) $ liftIO $ do
1456+ traceM (Proxy :: Proxy x) $ liftIO $ do
1502 invalidators <- liftIO $ readIORef $ holdInvalidators h
1457 invalidators <- liftIO $ readIORef $ holdInvalidators h
1503 return $ "SubscriberHold" <> showNodeId h <> ": " ++ show (length invalidators)
1458 return $ "SubscriberHold" <> showNodeId h <> ": " ++ show (length invalidators)
@@ -1506,7 +1461,7 @@ propagateSubscriberHold h a = do
1506 case {-# SCC "apply" #-} apply a v of
1461 case {-# SCC "apply" #-} apply a v of
1507 Nothing -> return ()
1462 Nothing -> return ()
1508 Just v' -> do
1463 Just v' -> do
1509− {-# SCC "trace2" #-} withIncreasedDepth (Proxy :: Proxy x) $
1464+ withIncreasedDepth (Proxy :: Proxy x) $
1510 tracePropagate (Proxy :: Proxy x) ("propagateSubscriberHold: assigning Hold" <> showNodeId h)
1465 tracePropagate (Proxy :: Proxy x) ("propagateSubscriberHold: assigning Hold" <> showNodeId h)
1511 vRef <- {-# SCC "vRef" #-} liftIO $ evaluate $ holdValue h
1466 vRef <- {-# SCC "vRef" #-} liftIO $ evaluate $ holdValue h
1512 iRef <- {-# SCC "iRef" #-} liftIO $ evaluate $ holdInvalidators h
1467 iRef <- {-# SCC "iRef" #-} liftIO $ evaluate $ holdInvalidators h
@@ -2038,7 +1993,7 @@ revalidateMergeHeight m = do
2038 LT -> return ()
1993 LT -> return ()
2039 EQ -> do
1994 EQ -> do
2040 let height = succHeight $ heightBagMax heights
1995 let height = succHeight $ heightBagMax heights
2041− traceInvalidateHeight $ "recalculateSubscriberHeight: height: " <> show height
1996+ traceInvalidate $ "recalculateSubscriberHeight: height: " <> show height
2042 writeIORef (_merge_heightRef m) $! height
1997 writeIORef (_merge_heightRef m) $! height
2043 subscriberRecalculateHeight (_merge_sub m) height
1998 subscriberRecalculateHeight (_merge_sub m) height
2044 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show (DMap.size parents) <> ") for Merge"
1999 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show (DMap.size parents) <> ") for Merge"
@@ -2202,7 +2157,7 @@ mergeIntCheap d = Event $ \sub -> do
2202 LT -> return ()
2157 LT -> return ()
2203 EQ -> do
2158 EQ -> do
2204 let height = succHeight $ heightBagMax heights
2159 let height = succHeight $ heightBagMax heights
2205− traceInvalidateHeight $ "recalculateSubscriberHeight: height: " <> show height
2160+ traceInvalidate $ "recalculateSubscriberHeight: height: " <> show height
2206 writeIORef heightRef $! height
2161 writeIORef heightRef $! height
2207 subscriberRecalculateHeight sub height
2162 subscriberRecalculateHeight sub height
2208 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show numParents <> ") for Merge"
2163 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show numParents <> ") for Merge"
@@ -2385,7 +2340,7 @@ runFrame a = SpiderHost $ do
2385 subscription <- unSpiderHost $ runFrame $ {-# SCC "subscribeSwitch" #-} subscribe e sub --TODO: Assert that the event isn't firing --TODO: This should not loop because none of the events should be firing, but still, it is inefficient
2340 subscription <- unSpiderHost $ runFrame $ {-# SCC "subscribeSwitch" #-} subscribe e sub --TODO: Assert that the event isn't firing --TODO: This should not loop because none of the events should be firing, but still, it is inefficient
2387 stackTrace <- liftIO $ fmap renderStack $ ccsToStrings =<< (getCCSOf $! switchSubscribedParent subscribed)
2342 stackTrace <- liftIO $ fmap renderStack $ ccsToStrings =<< (getCCSOf $! switchSubscribedParent subscribed)
2388− liftIO $ debugStrLn $ (++stackTrace) $ "subd' subscribed to " ++ case e of
2343+ liftIO $ putStrLn $ (++stackTrace) $ "subd' subscribed to " ++ case e of
2389 EventRoot _ -> "EventRoot"
2344 EventRoot _ -> "EventRoot"
2390 EventNever -> "EventNever"
2345 EventNever -> "EventNever"
2391 _ -> "something else"
2346 _ -> "something else"
@@ -2520,8 +2475,6 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Event
2520 {-# INLINABLE headE #-}
2475 {-# INLINABLE headE #-}
2521 headE = R.slowHeadE
2476 headE = R.slowHeadE
2522-- headE (SpiderEvent e) = SpiderEvent <$> Reflex.Spider.Internal.headE e
2477-- headE (SpiderEvent e) = SpiderEvent <$> Reflex.Spider.Internal.headE e
2523− {-# INLINABLE now #-}
2524− now = nowSpiderEventM
2526instance Reflex.Class.MonadSample (SpiderTimeline x) (SpiderPullM x) where
2479instance Reflex.Class.MonadSample (SpiderTimeline x) (SpiderPullM x) where
2527 {-# INLINABLE sample #-}
2480 {-# INLINABLE sample #-}
@@ -2543,9 +2496,6 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Spide
2543 {-# INLINABLE headE #-}
2496 {-# INLINABLE headE #-}
2544 headE = R.slowHeadE
2497 headE = R.slowHeadE
2545-- headE (SpiderEvent e) = SpiderPushM $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2498-- headE (SpiderEvent e) = SpiderPushM $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2546− {-# INLINABLE now #-}
2547− now = SpiderPushM nowSpiderEventM
2550instance HasSpiderTimeline x => Monad (Reflex.Class.Dynamic (SpiderTimeline x)) where
2500instance HasSpiderTimeline x => Monad (Reflex.Class.Dynamic (SpiderTimeline x)) where
2551 {-# INLINE return #-}
2501 {-# INLINE return #-}
@@ -2554,10 +2504,8 @@ instance HasSpiderTimeline x => Monad (Reflex.Class.Dynamic (SpiderTimeline x))
2554 x >>= f = SpiderDynamic $ dynamicDynIdentity $ newJoinDyn $ newMapDyn (unSpiderDynamic . f) $ unSpiderDynamic x
2504 x >>= f = SpiderDynamic $ dynamicDynIdentity $ newJoinDyn $ newMapDyn (unSpiderDynamic . f) $ unSpiderDynamic x
2555 {-# INLINE (>>) #-}
2505 {-# INLINE (>>) #-}
2556 (>>) = (*>)
2506 (>>) = (*>)
2557−#if !MIN_VERSION_base(4,13,0)
2558 {-# INLINE fail #-}
2507 {-# INLINE fail #-}
2559 fail _ = error "Dynamic does not support 'fail'"
2508 fail _ = error "Dynamic does not support 'fail'"
2562{-# INLINABLE newJoinDyn #-}
2510{-# INLINABLE newJoinDyn #-}
2563newJoinDyn :: HasSpiderTimeline x => DynamicS x (Identity (DynamicS x (Identity a))) -> Reflex.Spider.Internal.Dyn x (Identity a)
2511newJoinDyn :: HasSpiderTimeline x => DynamicS x (Identity (DynamicS x (Identity a))) -> Reflex.Spider.Internal.Dyn x (Identity a)
@@ -2609,9 +2557,6 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Spide
2609 buildDynamic getV0 e = runFrame . runSpiderHostFrame $ Reflex.Class.buildDynamic getV0 e
2557 buildDynamic getV0 e = runFrame . runSpiderHostFrame $ Reflex.Class.buildDynamic getV0 e
2610 {-# INLINABLE headE #-}
2558 {-# INLINABLE headE #-}
2611 headE e = runFrame . runSpiderHostFrame $ Reflex.Class.headE e
2559 headE e = runFrame . runSpiderHostFrame $ Reflex.Class.headE e
2612− {-# INLINABLE now #-}
2613− now = runFrame . runSpiderHostFrame $ Reflex.Class.now
2616instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHostFrame x) where
2561instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHostFrame x) where
2617 sample = SpiderHostFrame . readBehaviorUntracked . unSpiderBehavior --TODO: This can cause problems with laziness, so we should get rid of it if we can
2562 sample = SpiderHostFrame . readBehaviorUntracked . unSpiderBehavior --TODO: This can cause problems with laziness, so we should get rid of it if we can
@@ -2628,8 +2573,6 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Spide
2628 {-# INLINABLE headE #-}
2573 {-# INLINABLE headE #-}
2629 headE = R.slowHeadE
2574 headE = R.slowHeadE
2630-- headE (SpiderEvent e) = SpiderHostFrame $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2575-- headE (SpiderEvent e) = SpiderHostFrame $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2631− {-# INLINABLE now #-}
2632− now = SpiderHostFrame Reflex.Class.now
2634instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHost x) where
2577instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHost x) where
2635 {-# INLINABLE sample #-}
2578 {-# INLINABLE sample #-}
@@ -2650,8 +2593,6 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Refle
2650 buildDynamic getV0 e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.buildDynamic getV0 e
2593 buildDynamic getV0 e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.buildDynamic getV0 e
2651 {-# INLINABLE headE #-}
2594 {-# INLINABLE headE #-}
2652 headE e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.headE e
2595 headE e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.headE e
2653− {-# INLINABLE now #-}
2654− now = Reflex.Spider.Internal.ReadPhase Reflex.Class.now
2656--------------------------------------------------------------------------------
2597--------------------------------------------------------------------------------
2657-- Deprecated items
2598-- Deprecated items
@@ -2775,7 +2716,7 @@ instance HasSpiderTimeline x => R.Reflex (SpiderTimeline x) where
2775 fanG e = R.EventSelectorG $ SpiderEvent . selectG (fanG (unSpiderEvent e))
2716 fanG e = R.EventSelectorG $ SpiderEvent . selectG (fanG (unSpiderEvent e))
2776 {-# INLINABLE mergeG #-}
2717 {-# INLINABLE mergeG #-}
2778− :: forall k2 (k :: k2 -> *) q (v :: k2 -> *). GCompare k
2719+ :: forall (k :: k2 -> *) q (v :: k2 -> *). GCompare k
2779 => (forall a. q a -> R.Event (SpiderTimeline x) (v a))
2720 => (forall a. q a -> R.Event (SpiderTimeline x) (v a))
2780 -> DMap k q
2721 -> DMap k q
2781 -> R.Event (SpiderTimeline x) (DMap k v)
2722 -> R.Event (SpiderTimeline x) (DMap k v)
@@ -2843,14 +2784,8 @@ instance Monad (SpiderHost x) where
2843 SpiderHost x >> SpiderHost y = SpiderHost $ x >> y
2784 SpiderHost x >> SpiderHost y = SpiderHost $ x >> y
2844 {-# INLINABLE return #-}
2785 {-# INLINABLE return #-}
2845 return x = SpiderHost $ return x
2786 return x = SpiderHost $ return x
2846−#if !MIN_VERSION_base(4,13,0)
2847− {-# INLINABLE fail #-}
2848− fail = MonadFail.fail
2851−instance MonadFail (SpiderHost x) where
2852 {-# INLINABLE fail #-}
2787 {-# INLINABLE fail #-}
2853− fail s = SpiderHost $ MonadFail.fail s
2788+ fail s = SpiderHost $ fail s
2855-- | Run an action affecting the global Spider timeline; this will be guarded by
2790-- | Run an action affecting the global Spider timeline; this will be guarded by
2856-- a mutex for that timeline
2791-- a mutex for that timeline
@@ -2872,10 +2807,8 @@ instance Monad (SpiderHostFrame x) where
2872 SpiderHostFrame x >> SpiderHostFrame y = SpiderHostFrame $ x >> y
2807 SpiderHostFrame x >> SpiderHostFrame y = SpiderHostFrame $ x >> y
2873 {-# INLINABLE return #-}
2808 {-# INLINABLE return #-}
2874 return x = SpiderHostFrame $ return x
2809 return x = SpiderHostFrame $ return x
2875−#if !MIN_VERSION_base(4,13,0)
2876 {-# INLINABLE fail #-}
2810 {-# INLINABLE fail #-}
2877 fail s = SpiderHostFrame $ fail s
2811 fail s = SpiderHostFrame $ fail s
2880instance NotReady (SpiderTimeline x) (SpiderHostFrame x) where
2813instance NotReady (SpiderTimeline x) (SpiderHostFrame x) where
2881 notReadyUntil _ = pure ()
2814 notReadyUntil _ = pure ()