@@ -884,10 +884,7 @@ instance Defer (SomeHoldInit x) (ComputeM x) where
884884runComputeM :: Defer (SomeHoldInit x) m => ComputeM x a -> m a
885885runComputeM (ComputeM a) = liftIO . runReaderT a =<< getDeferralQueue
886886
887−data MergeSubscribedParent (x :: *) (k :: * -> *) a = MergeSubscribedParent !(EventSubscription x) !(Subscriber x a)
888−
889−mergeSubscribedParentSubscription :: MergeSubscribedParent x k a -> EventSubscription x
890−mergeSubscribedParentSubscription (MergeSubscribedParent es _) = es
887+newtype MergeSubscribedParent x a = MergeSubscribedParent { unMergeSubscribedParent :: EventSubscription x }
891888
892889data HeightBag = HeightBag
893890 { _heightBag_size :: {-# UNPACK #-} !Int
@@ -1553,11 +1550,11 @@ merge d = cacheEvent $ Event $ \sub -> do
15531550 modifyIORef' heightBagRef $ heightBagAdd new
15541551 revalidateMyHeight
15551552 }
1556− subscribers :: [(Maybe (DSum k Identity), Height, DSum k (MergeSubscribedParent x k))] <- forM (DMap.toList initialParents) $ \(k :=> e) -> do
1553+ subscribers :: [(Maybe (DSum k Identity), Height, DSum k (MergeSubscribedParent x))] <- forM (DMap.toList initialParents) $ \(k :=> e) -> do
15571554 let s = subscriber k
15581555 (subscription@(EventSubscription _ parentSubd), parentOcc) <- subscribeAndRead e s
15591556 height <- liftIO $ getEventSubscribedHeight parentSubd
1560− return $ (fmap (\x -> k :=> Identity x) parentOcc, height, k :=> MergeSubscribedParent subscription s)
1557+ return $ (fmap (\x -> k :=> Identity x) parentOcc, height, k :=> MergeSubscribedParent subscription)
15611558 let dm = DMap.fromDistinctAscList $ mapMaybe (\(x, _, _) -> x) subscribers
15621559 heights = fmap (\(_, h, _) -> h) subscribers --TODO: Assert that there's no invalidHeight in here
15631560 myHeightBag = heightBagFromList $ filter (/= invalidHeight) heights
@@ -1586,13 +1583,13 @@ merge d = cacheEvent $ Event $ \sub -> do
15861583 let s = subscriber k
15871584 subscription@(EventSubscription _ subd) <- subscribe e s
15881585 newParentHeight <- liftIO $ getEventSubscribedHeight subd
1589− let newParent = MergeSubscribedParent subscription s
1586+ let newParent = MergeSubscribedParent subscription
15901587 liftIO $ modifyIORef' heightBagRef $ heightBagAdd newParentHeight
15911588 return $ DMap.insertLookupWithKey' (\_ new _ -> new) k newParent ps
15921589 forM_ mOldSubd $ \oldSubd -> do
1593− oldHeight <- liftIO $ getEventSubscribedHeight $ _eventSubscription_subscribed $ mergeSubscribedParentSubscription oldSubd
1590+ oldHeight <- liftIO $ getEventSubscribedHeight $ _eventSubscription_subscribed $ unMergeSubscribedParent oldSubd
15941591 liftIO $ modifyIORef heightBagRef $ heightBagRemove oldHeight
1595− return (maybeToList (mergeSubscribedParentSubscription <$> mOldSubd) ++ subscriptionsToKill, newPs)
1592+ return (maybeToList (unMergeSubscribedParent <$> mOldSubd) ++ subscriptionsToKill, newPs)
15961593 (subscriptionsToKill, newParents) <- foldM f ([], oldParents) $ DMap.toList p --TODO: I think this runEventM is OK, since no events are firing at this time, but it might not be
15971594 liftIO $ writeIORef parentsRef $! newParents
15981595 return subscriptionsToKill
@@ -1609,7 +1606,7 @@ merge d = cacheEvent $ Event $ \sub -> do
16091606 liftIO $ writeIORef changeSubdRef (s, changeSubd)
16101607 let unsubscribeAll = do
16111608 parents <- readIORef parentsRef
1612− forM_ (DMap.toList parents) $ \(_ :=> MergeSubscribedParent s _) -> unsubscribe s
1609+ forM_ (DMap.toList parents) $ \(_ :=> MergeSubscribedParent s) -> unsubscribe s
16131610 return ( EventSubscription unsubscribeAll $ EventSubscribed heightRef $ toAny (parentsRef, changeSubdRef)
16141611 , occ
16151612 )