Skip to content

Commit 7494f05

Browse files
author
Ken Micklas
committed
Use maskMempty even for non-difference cases
1 parent 538e879 commit 7494f05

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Reflex/Query/Base.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ instance (Reflex t, MonadFix m, Group q, Additive q, Query q, Eq q, MonadHold t
110110
-- If the update is to delete the state for a child that doesn't exist, the patch is mempty.
111111
Nothing -> return Nothing
112112
-- If the update is to update the state for a child that doesn't exist, the patch is the sample of the new state.
113-
Just newBs -> Just <$> sampleBs newBs
113+
Just newBs -> maskMempty <$> sampleBs newBs
114114
Just oldBs -> case bs of
115115
-- If the update is to delete the state for a child that already exists, the patch is the negation of the child's current state
116-
Nothing -> Just . negateG <$> sampleBs oldBs
116+
Nothing -> maskMempty . negateG <$> sampleBs oldBs
117117
-- If the update is to update the state for a child that already exists, the patch is the negation of sampling the child's current state
118118
-- composed with the sampling the child's new state.
119119
Just newBs -> maskMempty <$> ((~~) <$> sampleBs newBs <*> sampleBs oldBs)
@@ -154,21 +154,21 @@ instance (Reflex t, MonadFix m, Group q, Additive q, Query q, Eq q, MonadHold t
154154
-- If the update is to delete the state for a child that doesn't exist, the patch is mempty.
155155
MapWithMove.From_Delete -> return Nothing
156156
-- If the update is to update the state for a child that doesn't exist, the patch is the sample of the new state.
157-
MapWithMove.From_Insert newBs -> Just <$> sampleBs newBs
157+
MapWithMove.From_Insert newBs -> maskMempty <$> sampleBs newBs
158158
MapWithMove.From_Move k' -> case Map.lookup k' bs0 of
159159
Nothing -> return Nothing
160-
Just newBs -> Just <$> sampleBs newBs
160+
Just newBs -> maskMempty <$> sampleBs newBs
161161
Just oldBs -> case MapWithMove._nodeInfo_from bs of
162162
-- If the update is to delete the state for a child that already exists, the patch is the negation of the child's current state
163-
MapWithMove.From_Delete -> Just . negateG <$> sampleBs oldBs
163+
MapWithMove.From_Delete -> maskMempty . negateG <$> sampleBs oldBs
164164
-- If the update is to update the state for a child that already exists, the patch is the negation of sampling the child's current state
165165
-- composed with the sampling the child's new state.
166166
MapWithMove.From_Insert newBs -> maskMempty <$> ((~~) <$> sampleBs newBs <*> sampleBs oldBs)
167167
MapWithMove.From_Move k'
168168
| k' == k -> return Nothing
169169
| otherwise -> case Map.lookup k' bs0 of
170170
-- If we are moving from a non-existent key, that is a delete
171-
Nothing -> Just . negateG <$> sampleBs oldBs
171+
Nothing -> maskMempty . negateG <$> sampleBs oldBs
172172
Just newBs -> maskMempty <$> ((~~) <$> sampleBs newBs <*> sampleBs oldBs)
173173
-- we compute the patch by iterating over the update PatchMap and proceeding by cases. Then we fold over the
174174
-- child patches and wrap them in AdditivePatch.

0 commit comments

Comments
 (0)