@@ -9,7 +9,6 @@
9{-# LANGUAGE GADTs #-}
9{-# LANGUAGE GADTs #-}
10{-# LANGUAGE GeneralizedNewtypeDeriving #-}
10{-# LANGUAGE GeneralizedNewtypeDeriving #-}
11{-# LANGUAGE LambdaCase #-}
11{-# LANGUAGE LambdaCase #-}
12−{-# LANGUAGE MultiWayIf #-}
13{-# LANGUAGE RankNTypes #-}
12{-# LANGUAGE RankNTypes #-}
14{-# LANGUAGE RoleAnnotations #-}
13{-# LANGUAGE RoleAnnotations #-}
15{-# LANGUAGE ScopedTypeVariables #-}
14{-# LANGUAGE ScopedTypeVariables #-}
@@ -20,6 +19,7 @@
20{-# LANGUAGE DeriveFunctor #-}
19{-# LANGUAGE DeriveFunctor #-}
21{-# LANGUAGE StandaloneDeriving #-}
20{-# LANGUAGE StandaloneDeriving #-}
22{-# LANGUAGE InstanceSigs #-}
21{-# LANGUAGE InstanceSigs #-}
22+{-# LANGUAGE MultiWayIf #-}
24#ifdef USE_REFLEX_OPTIMIZER
24#ifdef USE_REFLEX_OPTIMIZER
25{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
25{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
@@ -38,15 +38,17 @@ import Control.Monad hiding (forM, forM_, mapM, mapM_)
38import Control.Monad.Exception
38import Control.Monad.Exception
39import Control.Monad.Identity hiding (forM, forM_, mapM, mapM_)
39import Control.Monad.Identity hiding (forM, forM_, mapM, mapM_)
40import Control.Monad.Primitive
40import Control.Monad.Primitive
41−--import Control.Monad.Reader hiding (forM, forM_, mapM, mapM_)
42import Control.Monad.Reader.Class
41import Control.Monad.Reader.Class
43import Control.Monad.IO.Class
42import Control.Monad.IO.Class
44import Control.Monad.ReaderIO
43import Control.Monad.ReaderIO
45import Control.Monad.Ref
44import Control.Monad.Ref
45+import Control.Monad.Fail (MonadFail)
46+import qualified Control.Monad.Fail as MonadFail
46import Data.Align
47import Data.Align
47import Data.Coerce
48import Data.Coerce
48−import Data.Dependent.Map (DMap, DSum (..))
49+import Data.Dependent.Map (DMap)
49import qualified Data.Dependent.Map as DMap
50import qualified Data.Dependent.Map as DMap
51+import Data.Dependent.Sum (DSum (..))
50import Data.FastMutableIntMap (FastMutableIntMap, PatchIntMap (..))
52import Data.FastMutableIntMap (FastMutableIntMap, PatchIntMap (..))
51import qualified Data.FastMutableIntMap as FastMutableIntMap
53import qualified Data.FastMutableIntMap as FastMutableIntMap
52import Data.Foldable hiding (concat, elem, sequence_)
54import Data.Foldable hiding (concat, elem, sequence_)
@@ -63,6 +65,7 @@ import Data.Monoid (mempty, (<>))
63import Data.Proxy
65import Data.Proxy
64import Data.These
66import Data.These
65import Data.Traversable
67import Data.Traversable
68+import Data.Type.Equality ((:~:)(Refl))
66import Data.Witherable (Filterable, mapMaybe)
69import Data.Witherable (Filterable, mapMaybe)
67import GHC.Exts hiding (toList)
70import GHC.Exts hiding (toList)
68import GHC.IORef (IORef (..))
71import GHC.IORef (IORef (..))
@@ -103,15 +106,21 @@ import qualified Reflex.Class
103import qualified Reflex.Class as R
106import qualified Reflex.Class as R
104import qualified Reflex.Host.Class
107import qualified Reflex.Host.Class
105import Reflex.NotReady.Class
108import Reflex.NotReady.Class
106−import Reflex.Patch
109+import Data.Patch
107−import qualified Reflex.Patch.DMapWithMove as PatchDMapWithMove
110+import qualified Data.Patch.DMapWithMove as PatchDMapWithMove
108import Reflex.PerformEvent.Base (PerformEventT)
111import Reflex.PerformEvent.Base (PerformEventT)
110#ifdef DEBUG_TRACE_EVENTS
113#ifdef DEBUG_TRACE_EVENTS
111import qualified Data.ByteString.Char8 as BS8
114import qualified Data.ByteString.Char8 as BS8
112import System.IO (stderr)
115import System.IO (stderr)
113import Data.List (isPrefixOf)
116import 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
115withStackOneLine :: (BS8.ByteString -> a) -> a
124withStackOneLine :: (BS8.ByteString -> a) -> a
116withStackOneLine expr = unsafePerformIO $ do
125withStackOneLine expr = unsafePerformIO $ do
117 stack <- currentCallStack
126 stack <- currentCallStack
@@ -120,9 +129,33 @@ withStackOneLine expr = unsafePerformIO $ do
132+debugPropagate :: Bool
134+debugInvalidateHeight :: Bool
136+debugInvalidate :: Bool
123#ifdef DEBUG
138#ifdef DEBUG
124#define DEBUG_NODEIDS
139#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
126class HasNodeId a where
159class HasNodeId a where
127 getNodeId :: a -> Int
160 getNodeId :: a -> Int
@@ -160,6 +193,10 @@ showNodeId' = ("#"<>) . show
196+debugPropagate = False
197+debugInvalidateHeight = False
198+debugInvalidate = False
163-- This must be inline, or error messages will cause memory leaks due to retaining the node in question
200-- This must be inline, or error messages will cause memory leaks due to retaining the node in question
164{-# INLINE showNodeId #-}
201{-# INLINE showNodeId #-}
165showNodeId :: a -> String
202showNodeId :: a -> String
@@ -216,11 +253,11 @@ subscribeAndRead = unEvent
216{-# INLINE [1] pushCheap #-}
253{-# INLINE [1] pushCheap #-}
217pushCheap :: HasSpiderTimeline x => (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
254pushCheap :: HasSpiderTimeline x => (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
218pushCheap !f e = Event $ \sub -> do
255pushCheap !f e = Event $ \sub -> do
219− (subscription, occ) <- subscribeAndRead e $ debugSubscriber' "push" (sub
256+ (subscription, occ) <- subscribeAndRead e $ debugSubscriber' "push" $ sub
220 { subscriberPropagate = \a -> do
257 { subscriberPropagate = \a -> do
221 mb <- f a
258 mb <- f a
222 mapM_ (subscriberPropagate sub) mb
259 mapM_ (subscriberPropagate sub) mb
224 occ' <- join <$> mapM f occ
261 occ' <- join <$> mapM f occ
225 return (subscription, occ')
262 return (subscription, occ')
@@ -270,7 +307,20 @@ data CacheSubscribed x a
273−
310+nowSpiderEventM :: (HasSpiderTimeline x) => EventM x (R.Event (SpiderTimeline x) ())
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
275-- | Construct an 'Event' whose value is guaranteed not to be recomputed
325-- | Construct an 'Event' whose value is guaranteed not to be recomputed
276-- repeatedly
326-- repeatedly
@@ -414,16 +464,6 @@ data Subscriber x a = Subscriber
414 , subscriberRecalculateHeight :: !(Height -> IO ())
464 , subscriberRecalculateHeight :: !(Height -> IO ())
417−--TODO: Move this comment to WeakBag
418−-- These function are constructor functions that are marked NOINLINE so they are
419−-- opaque to GHC. If we do not do this, then GHC will sometimes fuse the constructor away
420−-- so any weak references that are attached to the constructors will have their
421−-- finalizer run. Using the opaque constructor, does not see the
422−-- constructor application, so it behaves like an IORef and cannot be fused away.
424−-- The result is also evaluated to WHNF, since forcing a thunk invalidates
425−-- the weak pointer to it in some cases.
427newSubscriberHold :: (HasSpiderTimeline x, Patch p) => Hold x p -> IO (Subscriber x p)
467newSubscriberHold :: (HasSpiderTimeline x, Patch p) => Hold x p -> IO (Subscriber x p)
428newSubscriberHold h = return $ Subscriber
468newSubscriberHold h = return $ Subscriber
429 { subscriberPropagate = {-# SCC "traverseHold" #-} propagateSubscriberHold h
469 { subscriberPropagate = {-# SCC "traverseHold" #-} propagateSubscriberHold h
@@ -567,6 +607,16 @@ eventSubscribedNever = EventSubscribed
567 , eventSubscribedWhoCreated = return ["never"]
607 , 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"]
571eventSubscribedFan :: FanSubscribed x k v -> EventSubscribed x
621eventSubscribedFan :: FanSubscribed x k v -> EventSubscribed x
572eventSubscribedFan !subscribed = EventSubscribed
622eventSubscribedFan !subscribed = EventSubscribed
@@ -944,8 +994,10 @@ instance Monad (BehaviorM x) where
944 BehaviorM x >> BehaviorM y = BehaviorM $ x >> y
994 BehaviorM x >> BehaviorM y = BehaviorM $ x >> y
945 {-# INLINE return #-}
995 {-# INLINE return #-}
946 return x = BehaviorM $ return x
996 return x = BehaviorM $ return x
997+#if !MIN_VERSION_base(4,13,0)
947 {-# INLINE fail #-}
998 {-# INLINE fail #-}
948 fail s = BehaviorM $ fail s
999 fail s = BehaviorM $ fail s
950data BehaviorSubscribed x a
1002data BehaviorSubscribed x a
951 = forall p. BehaviorSubscribedHold (Hold x p)
1003 = forall p. BehaviorSubscribedHold (Hold x p)
@@ -1294,7 +1346,7 @@ mkWeakPtrWithDebug x debugNote = do
1294 x' <- evaluate x
1346 x' <- evaluate x
1295 mkWeakPtr x' $
1347 mkWeakPtr x' $
1296 if debugFinalize
1348 if debugFinalize
1297− then Just $ putStrLn $ "finalizing: " ++ debugNote
1349+ then Just $ debugStrLn $ "finalizing: " ++ debugNote
1298 else Nothing
1350 else Nothing
1300type WeakList a = [Weak a]
1352type WeakList a = [Weak a]
@@ -1316,13 +1368,13 @@ debugSubscriber' description subscribed = Subscriber
1316 tracePropagate (Proxy :: Proxy x) ("subscriberPropagate: " <> description)
1368 tracePropagate (Proxy :: Proxy x) ("subscriberPropagate: " <> description)
1317 subscriberPropagate subscribed m
1369 subscriberPropagate subscribed m
1318 , subscriberInvalidateHeight = \old -> do
1370 , subscriberInvalidateHeight = \old -> do
1319− putStrLn $ "invalidateSubscriberHeight: " <> description <> ", old = " <> show (unHeight old)
1371+ traceInvalidateHeight $ "invalidateSubscriberHeight: " <> description <> ", old = " <> show (unHeight old)
1320 subscriberInvalidateHeight subscribed old
1372 subscriberInvalidateHeight subscribed old
1321− putStrLn $ "invalidateSubscriberHeight: " <> description <> ", done"
1373+ traceInvalidateHeight $ "invalidateSubscriberHeight: " <> description <> ", done"
1322 , subscriberRecalculateHeight = \new -> do
1374 , subscriberRecalculateHeight = \new -> do
1323− putStrLn $ "subscriberRecalculateHeight: " <> description <> ", new = " <> show (unHeight new)
1375+ traceInvalidateHeight $ "subscriberRecalculateHeight: " <> description <> ", new = " <> show (unHeight new)
1324 subscriberRecalculateHeight subscribed new
1376 subscriberRecalculateHeight subscribed new
1325− putStrLn $ "subscriberRecalculateHeight: " <> description <> ", done"
1377+ traceInvalidateHeight $ "subscriberRecalculateHeight: " <> description <> ", done"
@@ -1336,11 +1388,15 @@ withIncreasedDepth _ a = do
1337{-# INLINE tracePropagate #-}
1389{-# INLINE tracePropagate #-}
1338tracePropagate :: (CanTrace x m) => proxy x -> String -> m ()
1390tracePropagate :: (CanTrace x m) => proxy x -> String -> m ()
1339−tracePropagate p = trace p
1391+tracePropagate p = when debugPropagate . trace p
1341{-# INLINE traceInvalidate #-}
1393{-# INLINE traceInvalidate #-}
1342traceInvalidate :: String -> IO ()
1394traceInvalidate :: String -> IO ()
1343−traceInvalidate = liftIO . putStrLn
1395+traceInvalidate = when debugInvalidate . liftIO . debugStrLn
1397+{-# INLINE traceInvalidateHeight #-}
1398+traceInvalidateHeight :: String -> IO ()
1399+traceInvalidateHeight = when debugInvalidateHeight . liftIO . debugStrLn
1345{-# INLINE trace #-}
1401{-# INLINE trace #-}
1346trace :: (CanTrace x m) => proxy x -> String -> m ()
1402trace :: (CanTrace x m) => proxy x -> String -> m ()
@@ -1351,7 +1407,7 @@ traceM :: forall x proxy m. (CanTrace x m) => proxy x -> m String -> m ()
1351traceM _ getMessage = do
1407traceM _ getMessage = do
1352 message <- getMessage
1408 message <- getMessage
1353 d <- liftIO $ readIORef $ _spiderTimeline_depth $ unSTE (spiderTimeline :: SpiderTimelineEnv x)
1409 d <- liftIO $ readIORef $ _spiderTimeline_depth $ unSTE (spiderTimeline :: SpiderTimelineEnv x)
1354− liftIO $ putStrLn $ replicate d ' ' <> message
1410+ liftIO $ debugStrLn $ replicate d ' ' <> message
@@ -1367,6 +1423,10 @@ tracePropagate _ _ = return ()
1367traceInvalidate :: String -> IO ()
1423traceInvalidate :: String -> IO ()
1368traceInvalidate _ = return ()
1424traceInvalidate _ = return ()
1426+{-# INLINE traceInvalidateHeight #-}
1427+traceInvalidateHeight :: String -> IO ()
1428+traceInvalidateHeight _ = return ()
1370{-# INLINE debugSubscriber #-}
1430{-# INLINE debugSubscriber #-}
1371debugSubscriber :: String -> Subscriber x a -> IO (Subscriber x a)
1431debugSubscriber :: String -> Subscriber x a -> IO (Subscriber x a)
1372debugSubscriber _ = return
1432debugSubscriber _ = return
@@ -1407,8 +1467,11 @@ showStacks :: [[String]] -> String
1407showStacks = drawForest . listsToForest . fmap (filterStack "Reflex.Spider.Internal")
1467showStacks = drawForest . listsToForest . fmap (filterStack "Reflex.Spider.Internal")
1409filterStack :: String -> [String] -> [String]
1469filterStack :: String -> [String] -> [String]
1470+#ifdef DEBUG_HIDE_INTERNALS
1410filterStack prefix = filter (not . (prefix `isPrefixOf`))
1471filterStack prefix = filter (not . (prefix `isPrefixOf`))
1473+filterStack prefix = id
1413#ifdef DEBUG_CYCLES
1476#ifdef DEBUG_CYCLES
@@ -1435,7 +1498,7 @@ instance Show EventLoopException where
1435{-# INLINE propagateSubscriberHold #-}
1498{-# INLINE propagateSubscriberHold #-}
1436propagateSubscriberHold :: forall x p. (HasSpiderTimeline x, Patch p) => Hold x p -> p -> EventM x ()
1499propagateSubscriberHold :: forall x p. (HasSpiderTimeline x, Patch p) => Hold x p -> p -> EventM x ()
1437propagateSubscriberHold h a = do
1500propagateSubscriberHold h a = do
1438− traceM (Proxy :: Proxy x) $ liftIO $ do
1501+ {-# SCC "trace" #-} when debugPropagate $ traceM (Proxy :: Proxy x) $ liftIO $ do
1439 invalidators <- liftIO $ readIORef $ holdInvalidators h
1502 invalidators <- liftIO $ readIORef $ holdInvalidators h
1440 return $ "SubscriberHold" <> showNodeId h <> ": " ++ show (length invalidators)
1503 return $ "SubscriberHold" <> showNodeId h <> ": " ++ show (length invalidators)
@@ -1443,7 +1506,7 @@ propagateSubscriberHold h a = do
1443 case {-# SCC "apply" #-} apply a v of
1506 case {-# SCC "apply" #-} apply a v of
1444 Nothing -> return ()
1507 Nothing -> return ()
1445 Just v' -> do
1508 Just v' -> do
1446− withIncreasedDepth (Proxy :: Proxy x) $
1509+ {-# SCC "trace2" #-} withIncreasedDepth (Proxy :: Proxy x) $
1447 tracePropagate (Proxy :: Proxy x) ("propagateSubscriberHold: assigning Hold" <> showNodeId h)
1510 tracePropagate (Proxy :: Proxy x) ("propagateSubscriberHold: assigning Hold" <> showNodeId h)
1448 vRef <- {-# SCC "vRef" #-} liftIO $ evaluate $ holdValue h
1511 vRef <- {-# SCC "vRef" #-} liftIO $ evaluate $ holdValue h
1449 iRef <- {-# SCC "iRef" #-} liftIO $ evaluate $ holdInvalidators h
1512 iRef <- {-# SCC "iRef" #-} liftIO $ evaluate $ holdInvalidators h
@@ -1975,7 +2038,7 @@ revalidateMergeHeight m = do
1975 LT -> return ()
2038 LT -> return ()
1976 EQ -> do
2039 EQ -> do
1977 let height = succHeight $ heightBagMax heights
2040 let height = succHeight $ heightBagMax heights
1978− traceInvalidate $ "recalculateSubscriberHeight: height: " <> show height
2041+ traceInvalidateHeight $ "recalculateSubscriberHeight: height: " <> show height
1979 writeIORef (_merge_heightRef m) $! height
2042 writeIORef (_merge_heightRef m) $! height
1980 subscriberRecalculateHeight (_merge_sub m) height
2043 subscriberRecalculateHeight (_merge_sub m) height
1981 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show (DMap.size parents) <> ") for Merge"
2044 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show (DMap.size parents) <> ") for Merge"
@@ -2139,7 +2202,7 @@ mergeIntCheap d = Event $ \sub -> do
2139 LT -> return ()
2202 LT -> return ()
2140 EQ -> do
2203 EQ -> do
2141 let height = succHeight $ heightBagMax heights
2204 let height = succHeight $ heightBagMax heights
2142− traceInvalidate $ "recalculateSubscriberHeight: height: " <> show height
2205+ traceInvalidateHeight $ "recalculateSubscriberHeight: height: " <> show height
2143 writeIORef heightRef $! height
2206 writeIORef heightRef $! height
2144 subscriberRecalculateHeight sub height
2207 subscriberRecalculateHeight sub height
2145 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show numParents <> ") for Merge"
2208 GT -> error $ "revalidateMergeHeight: more heights (" <> show (heightBagSize heights) <> ") than parents (" <> show numParents <> ") for Merge"
@@ -2322,7 +2385,7 @@ runFrame a = SpiderHost $ do
2322 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
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
2324 stackTrace <- liftIO $ fmap renderStack $ ccsToStrings =<< (getCCSOf $! switchSubscribedParent subscribed)
2387 stackTrace <- liftIO $ fmap renderStack $ ccsToStrings =<< (getCCSOf $! switchSubscribedParent subscribed)
2325− liftIO $ putStrLn $ (++stackTrace) $ "subd' subscribed to " ++ case e of
2388+ liftIO $ debugStrLn $ (++stackTrace) $ "subd' subscribed to " ++ case e of
2326 EventRoot _ -> "EventRoot"
2389 EventRoot _ -> "EventRoot"
2327 EventNever -> "EventNever"
2390 EventNever -> "EventNever"
2328 _ -> "something else"
2391 _ -> "something else"
@@ -2457,6 +2520,8 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Event
2457 {-# INLINABLE headE #-}
2520 {-# INLINABLE headE #-}
2458 headE = R.slowHeadE
2521 headE = R.slowHeadE
2459-- headE (SpiderEvent e) = SpiderEvent <$> Reflex.Spider.Internal.headE e
2522-- headE (SpiderEvent e) = SpiderEvent <$> Reflex.Spider.Internal.headE e
2523+ {-# INLINABLE now #-}
2524+ now = nowSpiderEventM
2461instance Reflex.Class.MonadSample (SpiderTimeline x) (SpiderPullM x) where
2526instance Reflex.Class.MonadSample (SpiderTimeline x) (SpiderPullM x) where
2462 {-# INLINABLE sample #-}
2527 {-# INLINABLE sample #-}
@@ -2478,6 +2543,9 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Spide
2478 {-# INLINABLE headE #-}
2543 {-# INLINABLE headE #-}
2479 headE = R.slowHeadE
2544 headE = R.slowHeadE
2480-- headE (SpiderEvent e) = SpiderPushM $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2545-- headE (SpiderEvent e) = SpiderPushM $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2546+ {-# INLINABLE now #-}
2547+ now = SpiderPushM nowSpiderEventM
2482instance HasSpiderTimeline x => Monad (Reflex.Class.Dynamic (SpiderTimeline x)) where
2550instance HasSpiderTimeline x => Monad (Reflex.Class.Dynamic (SpiderTimeline x)) where
2483 {-# INLINE return #-}
2551 {-# INLINE return #-}
@@ -2486,8 +2554,10 @@ instance HasSpiderTimeline x => Monad (Reflex.Class.Dynamic (SpiderTimeline x))
2486 x >>= f = SpiderDynamic $ dynamicDynIdentity $ newJoinDyn $ newMapDyn (unSpiderDynamic . f) $ unSpiderDynamic x
2554 x >>= f = SpiderDynamic $ dynamicDynIdentity $ newJoinDyn $ newMapDyn (unSpiderDynamic . f) $ unSpiderDynamic x
2487 {-# INLINE (>>) #-}
2555 {-# INLINE (>>) #-}
2488 (>>) = (*>)
2556 (>>) = (*>)
2557+#if !MIN_VERSION_base(4,13,0)
2489 {-# INLINE fail #-}
2558 {-# INLINE fail #-}
2490 fail _ = error "Dynamic does not support 'fail'"
2559 fail _ = error "Dynamic does not support 'fail'"
2492{-# INLINABLE newJoinDyn #-}
2562{-# INLINABLE newJoinDyn #-}
2493newJoinDyn :: HasSpiderTimeline x => DynamicS x (Identity (DynamicS x (Identity a))) -> Reflex.Spider.Internal.Dyn x (Identity a)
2563newJoinDyn :: HasSpiderTimeline x => DynamicS x (Identity (DynamicS x (Identity a))) -> Reflex.Spider.Internal.Dyn x (Identity a)
@@ -2539,6 +2609,9 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Spide
2539 buildDynamic getV0 e = runFrame . runSpiderHostFrame $ Reflex.Class.buildDynamic getV0 e
2609 buildDynamic getV0 e = runFrame . runSpiderHostFrame $ Reflex.Class.buildDynamic getV0 e
2540 {-# INLINABLE headE #-}
2610 {-# INLINABLE headE #-}
2541 headE e = runFrame . runSpiderHostFrame $ Reflex.Class.headE e
2611 headE e = runFrame . runSpiderHostFrame $ Reflex.Class.headE e
2612+ {-# INLINABLE now #-}
2613+ now = runFrame . runSpiderHostFrame $ Reflex.Class.now
2543instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHostFrame x) where
2616instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHostFrame x) where
2544 sample = SpiderHostFrame . readBehaviorUntracked . unSpiderBehavior --TODO: This can cause problems with laziness, so we should get rid of it if we can
2617 sample = SpiderHostFrame . readBehaviorUntracked . unSpiderBehavior --TODO: This can cause problems with laziness, so we should get rid of it if we can
@@ -2555,6 +2628,8 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Spide
2555 {-# INLINABLE headE #-}
2628 {-# INLINABLE headE #-}
2556 headE = R.slowHeadE
2629 headE = R.slowHeadE
2557-- headE (SpiderEvent e) = SpiderHostFrame $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2630-- headE (SpiderEvent e) = SpiderHostFrame $ SpiderEvent <$> Reflex.Spider.Internal.headE e
2631+ {-# INLINABLE now #-}
2632+ now = SpiderHostFrame Reflex.Class.now
2559instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHost x) where
2634instance HasSpiderTimeline x => Reflex.Class.MonadSample (SpiderTimeline x) (SpiderHost x) where
2560 {-# INLINABLE sample #-}
2635 {-# INLINABLE sample #-}
@@ -2575,6 +2650,8 @@ instance HasSpiderTimeline x => Reflex.Class.MonadHold (SpiderTimeline x) (Refle
2575 buildDynamic getV0 e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.buildDynamic getV0 e
2650 buildDynamic getV0 e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.buildDynamic getV0 e
2576 {-# INLINABLE headE #-}
2651 {-# INLINABLE headE #-}
2577 headE e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.headE e
2652 headE e = Reflex.Spider.Internal.ReadPhase $ Reflex.Class.headE e
2653+ {-# INLINABLE now #-}
2654+ now = Reflex.Spider.Internal.ReadPhase Reflex.Class.now
2579--------------------------------------------------------------------------------
2656--------------------------------------------------------------------------------
2580-- Deprecated items
2657-- Deprecated items
@@ -2698,7 +2775,7 @@ instance HasSpiderTimeline x => R.Reflex (SpiderTimeline x) where
2698 fanG e = R.EventSelectorG $ SpiderEvent . selectG (fanG (unSpiderEvent e))
2775 fanG e = R.EventSelectorG $ SpiderEvent . selectG (fanG (unSpiderEvent e))
2699 {-# INLINABLE mergeG #-}
2776 {-# INLINABLE mergeG #-}
2701− :: forall (k :: k2 -> *) q (v :: k2 -> *). GCompare k
2778+ :: forall k2 (k :: k2 -> *) q (v :: k2 -> *). GCompare k
2702 => (forall a. q a -> R.Event (SpiderTimeline x) (v a))
2779 => (forall a. q a -> R.Event (SpiderTimeline x) (v a))
2703 -> DMap k q
2780 -> DMap k q
2704 -> R.Event (SpiderTimeline x) (DMap k v)
2781 -> R.Event (SpiderTimeline x) (DMap k v)
@@ -2766,8 +2843,14 @@ instance Monad (SpiderHost x) where
2766 SpiderHost x >> SpiderHost y = SpiderHost $ x >> y
2843 SpiderHost x >> SpiderHost y = SpiderHost $ x >> y
2767 {-# INLINABLE return #-}
2844 {-# INLINABLE return #-}
2768 return x = SpiderHost $ return x
2845 return x = SpiderHost $ return x
2846+#if !MIN_VERSION_base(4,13,0)
2769 {-# INLINABLE fail #-}
2847 {-# INLINABLE fail #-}
2848+ fail = MonadFail.fail
2851+instance MonadFail (SpiderHost x) where
2852+ {-# INLINABLE fail #-}
2770− fail s = SpiderHost $ fail s
2853+ fail s = SpiderHost $ MonadFail.fail s
2772-- | Run an action affecting the global Spider timeline; this will be guarded by
2855-- | Run an action affecting the global Spider timeline; this will be guarded by
2773-- a mutex for that timeline
2856-- a mutex for that timeline
@@ -2789,8 +2872,10 @@ instance Monad (SpiderHostFrame x) where
2789 SpiderHostFrame x >> SpiderHostFrame y = SpiderHostFrame $ x >> y
2872 SpiderHostFrame x >> SpiderHostFrame y = SpiderHostFrame $ x >> y
2790 {-# INLINABLE return #-}
2873 {-# INLINABLE return #-}
2791 return x = SpiderHostFrame $ return x
2874 return x = SpiderHostFrame $ return x
2875+#if !MIN_VERSION_base(4,13,0)
2792 {-# INLINABLE fail #-}
2876 {-# INLINABLE fail #-}
2793 fail s = SpiderHostFrame $ fail s
2877 fail s = SpiderHostFrame $ fail s
2795instance NotReady (SpiderTimeline x) (SpiderHostFrame x) where
2880instance NotReady (SpiderTimeline x) (SpiderHostFrame x) where
2796 notReadyUntil _ = pure ()
2881 notReadyUntil _ = pure ()