on develop help sign in
Fix hydration tests broken by new dependent-sum/map
commit54d1291e36b6ff609a8114c24c66c32c4f664acf authorAli Abrar <aliabrar@gmail.com> dateFri 17 May 2019, 22:37 (7 years ago) parenta274eb3
2 files changed+11−30
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+10−10 reflex-dom-core/test/hydration.hs+1−20
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+10−10
@@ -1555,13 +1555,13 @@ instance (Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, PrimMonad m, Ra
15551555 readIORef (_traverseChildImmediate_childReadyState immediate) >>= \case
15561556 ChildReadyState_Ready -> return PatchDMapWithMove.From_Delete
15571557 ChildReadyState_Unready _ -> do
1558− writeIORef (_traverseChildImmediate_childReadyState immediate) $ ChildReadyState_Unready $ Just $ This k
1558+ writeIORef (_traverseChildImmediate_childReadyState immediate) $ ChildReadyState_Unready $ Just $ Some k
15591559 return $ PatchDMapWithMove.From_Insert $ Constant (_traverseChildImmediate_childReadyState immediate)
15601560 PatchDMapWithMove.From_Delete -> return PatchDMapWithMove.From_Delete
15611561 PatchDMapWithMove.From_Move fromKey -> return $ PatchDMapWithMove.From_Move fromKey
15621562 deleteOrMove :: forall a. k a -> Product (Constant (IORef (ChildReadyState (Some k)))) (ComposeMaybe k) a -> IO (Constant () a)
15631563 deleteOrMove _ (Pair (Constant sRef) (ComposeMaybe mToKey)) = do
1564− writeIORef sRef $ ChildReadyState_Unready $ This <$> mToKey -- This will be Nothing if deleting, and Just if moving, so it works out in both cases
1564+ writeIORef sRef $ ChildReadyState_Unready $ Some <$> mToKey -- This will be Nothing if deleting, and Just if moving, so it works out in both cases
15651565 return $ Constant ()
15661566 p' <- fmap unsafePatchDMapWithMove $ DMap.traverseWithKey new $ unPatchDMapWithMove p
15671567 _ <- DMap.traverseWithKey deleteOrMove $ PatchDMapWithMove.getDeletionsAndMoves p old
@@ -1571,8 +1571,8 @@ instance (Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, PrimMonad m, Ra
15711571 phsBefore <- liftIO $ readIORef placeholders
15721572 let collectIfMoved :: forall a. k a -> PatchDMapWithMove.NodeInfo k (Compose (TraverseChild t m (Some k)) v') a -> JSM (Constant (Maybe DOM.DocumentFragment) a)
15731573 collectIfMoved k e = do
1574− let mThisPlaceholder = Map.lookup (This k) phsBefore -- Will be Nothing if this element wasn't present before
1575− nextPlaceholder = maybe lastPlaceholder snd $ Map.lookupGT (This k) phsBefore
1574+ let mThisPlaceholder = Map.lookup (Some k) phsBefore -- Will be Nothing if this element wasn't present before
1575+ nextPlaceholder = maybe lastPlaceholder snd $ Map.lookupGT (Some k) phsBefore
15761576 case isJust $ getComposeMaybe $ PatchDMapWithMove._nodeInfo_to e of
15771577 False -> do
15781578 mapM_ (`deleteUpTo` nextPlaceholder) mThisPlaceholder
@@ -1591,7 +1591,7 @@ instance (Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, PrimMonad m, Ra
15911591 PatchMapWithMove.From_Move k -> Just $ PatchMapWithMove.From_Move k
15921592 let placeFragment :: forall a. k a -> PatchDMapWithMove.NodeInfo k (Compose (TraverseChild t m (Some k)) v') a -> JSM (Constant () a)
15931593 placeFragment k e = do
1594− let nextPlaceholder = maybe lastPlaceholder snd $ Map.lookupGT (This k) phsAfter
1594+ let nextPlaceholder = maybe lastPlaceholder snd $ Map.lookupGT (Some k) phsAfter
15951595 case PatchDMapWithMove._nodeInfo_from e of
15961596 PatchDMapWithMove.From_Insert (Compose (TraverseChild x _)) -> case x of
15971597 Left _ -> pure ()
@@ -1622,7 +1622,7 @@ traverseDMapWithKeyWithAdjust' = do
16221622 readIORef (_traverseChildImmediate_childReadyState immediate) >>= \case
16231623 ChildReadyState_Ready -> return Nothing -- Delete this child, since it's ready
16241624 ChildReadyState_Unready _ -> do
1625− writeIORef (_traverseChildImmediate_childReadyState immediate) $ ChildReadyState_Unready $ Just $ This k
1625+ writeIORef (_traverseChildImmediate_childReadyState immediate) $ ChildReadyState_Unready $ Just $ Some k
16261626 return $ Just $ Constant (_traverseChildImmediate_childReadyState immediate)
16271627 delete _ (Constant sRef) = do
16281628 writeIORef sRef $ ChildReadyState_Unready Nothing
@@ -1633,9 +1633,9 @@ traverseDMapWithKeyWithAdjust' = do
16331633 hoistTraverseWithKeyWithAdjust traverseDMapWithKeyWithAdjust mapPatchDMap updateChildUnreadiness $ \placeholders lastPlaceholder (PatchDMap patch) -> do
16341634 phs <- liftIO $ readIORef placeholders
16351635 forM_ (DMap.toList patch) $ \(k :=> ComposeMaybe mv) -> do
1636− let nextPlaceholder = maybe lastPlaceholder snd $ Map.lookupGT (This k) phs
1636+ let nextPlaceholder = maybe lastPlaceholder snd $ Map.lookupGT (Some k) phs
16371637 -- Delete old node
1638− forM_ (Map.lookup (This k) phs) $ \thisPlaceholder -> do
1638+ forM_ (Map.lookup (Some k) phs) $ \thisPlaceholder -> do
16391639 thisPlaceholder `deleteUpTo` nextPlaceholder
16401640 -- Insert new node
16411641 forM_ mv $ \(Compose (TraverseChild e _)) -> case e of
@@ -1785,7 +1785,7 @@ hoistTraverseWithKeyWithAdjust base mapPatch updateChildUnreadiness applyDomUpda
17851785 liftIO $ writeIORef childReadyState ChildReadyState_Ready
17861786 case countedAt of
17871787 Nothing -> return ()
1788− Just (This k) -> do -- This child has been counted as unready, so we need to remove it from the unready set
1788+ Just (Some k) -> do -- This child has been counted as unready, so we need to remove it from the unready set
17891789 (oldUnready, p) <- liftIO $ readIORef pendingChange
17901790 when (not $ DMap.null oldUnready) $ do -- This shouldn't actually ever be null
17911791 let newUnready = DMap.delete k oldUnready
@@ -1800,7 +1800,7 @@ hoistTraverseWithKeyWithAdjust base mapPatch updateChildUnreadiness applyDomUpda
18001800 readIORef (_traverseChildImmediate_childReadyState immediate) >>= \case
18011801 ChildReadyState_Ready -> return Nothing
18021802 ChildReadyState_Unready _ -> do
1803− writeIORef (_traverseChildImmediate_childReadyState immediate) $ ChildReadyState_Unready $ Just $ This k
1803+ writeIORef (_traverseChildImmediate_childReadyState immediate) $ ChildReadyState_Unready $ Just $ Some k
18041804 return $ Just $ Constant (_traverseChildImmediate_childReadyState immediate)
18051805 initialUnready <- liftIO $ DMap.mapMaybeWithKey (\_ -> getComposeMaybe) <$> DMap.traverseWithKey processChild children0
18061806 liftIO $ if DMap.null initialUnready
reflex-dom-core/test/hydration.hs+1−20
@@ -6,6 +6,7 @@
66{-# LANGUAGE ConstraintKinds #-}
77{-# LANGUAGE CPP #-}
88{-# LANGUAGE FlexibleContexts #-}
9+{-# LANGUAGE FlexibleInstances #-}
910{-# LANGUAGE GADTs #-}
1011{-# LANGUAGE LambdaCase #-}
1112{-# LANGUAGE MultiParamTypeClasses #-}
@@ -116,17 +117,6 @@ deriveGEq ''DKey
116117deriveGCompare ''DKey
117118deriveGShow ''DKey
118119
119−instance ShowTag DKey Identity where
120− showTaggedPrec = \case
121− Key_Int -> showsPrec
122− Key_Char -> showsPrec
123− Key_Bool -> showsPrec
124−
125−instance EqTag DKey Identity where
126− eqTagged Key_Int Key_Int = (==)
127− eqTagged Key_Char Key_Char = (==)
128− eqTagged Key_Bool Key_Bool = (==)
129−
130120main :: IO ()
131121main = do
132122 unshareNetork
@@ -1420,12 +1410,3 @@ deriveGEq ''Key2
14201410deriveGCompare ''Key2
14211411deriveGShow ''Key2
14221412deriveArgDict ''Key2
1423−
1424−instance ShowTag Key2 Identity where
1425− showTaggedPrec = \case
1426− Key2_Int _ -> showsPrec
1427− Key2_Char _ -> showsPrec
1428−
1429−instance EqTag Key2 Identity where
1430− eqTagged (Key2_Int _) (Key2_Int _) = (==)
1431− eqTagged (Key2_Char _) (Key2_Char _) = (==)