on develop help sign in
Make core BehaviorM primitives strict

* Otherwise, thunks can build up

commit16092bfa9a295ba94a1dc5e78003f4057b30ec72 authorRyan Trinkle <ryan.trinkle@gmail.com> dateSat 23 Jul 2016, 22:42 (10 years ago) parent4aec2dc
1 file changed+13−3
src/Reflex/Spider/Internal.hs+13−3
src/Reflex/Spider/Internal.hs+13−3
@@ -1090,13 +1090,23 @@ runBehaviorM :: BehaviorM a -> Maybe (Weak Invalidator, IORef [SomeBehaviorSubsc
10901090runBehaviorM a mwi holdInits = runReaderT (unBehaviorM a) (mwi, holdInits)
10911091
10921092askInvalidator :: BehaviorM (Maybe (Weak Invalidator))
1093−askInvalidator = fmap fst . fst <$> BehaviorM ask
1093+askInvalidator = do
1094+ (!m, _) <- BehaviorM ask
1095+ case m of
1096+ Nothing -> return Nothing
1097+ Just (!wi, _) -> return $ Just wi
10941098
10951099askParentsRef :: BehaviorM (Maybe (IORef [SomeBehaviorSubscribed]))
1096−askParentsRef = fmap snd . fst <$> BehaviorM ask
1100+askParentsRef = do
1101+ (!m, _) <- BehaviorM ask
1102+ case m of
1103+ Nothing -> return Nothing
1104+ Just (_, !p) -> return $ Just p
10971105
10981106askBehaviorHoldInits :: BehaviorM (IORef [SomeHoldInit])
1099−askBehaviorHoldInits = snd <$> BehaviorM ask
1107+askBehaviorHoldInits = do
1108+ (_, !his) <- BehaviorM ask
1109+ return his
11001110
11011111readBehaviorTracked :: Behavior a -> BehaviorM a
11021112readBehaviorTracked b = case b of