@@ -96,32 +96,34 @@ unNumEntries (NumEntries x) = x
9696instance Semigroup v => Semigroup (Entry v b ) where
9797 e1 <> e2 = combine (<>) e1 e2
9898
99- -- | Given a value-merge function, combine entries
99+ -- | Given a value-merge function, combine entries. Only take a blob from the
100+ -- left entry.
100101combine :: (v -> v -> v ) -> Entry v b -> Entry v b -> Entry v b
101- combine _ e@ Delete _ = e
102- combine _ e@ Insert {} _ = e
103- combine _ e@ InsertWithBlob {} _ = e
104- combine _ (Mupdate u) Delete = Insert u
105- combine f (Mupdate u) (Insert v) = Insert (f u v)
106- combine f (Mupdate u) (InsertWithBlob v blob ) = InsertWithBlob (f u v) blob
107- combine f (Mupdate u) (Mupdate v) = Mupdate (f u v)
102+ combine _ e@ Delete _ = e
103+ combine _ e@ Insert {} _ = e
104+ combine _ e@ InsertWithBlob {} _ = e
105+ combine _ (Mupdate u) Delete = Insert u
106+ combine f (Mupdate u) (Insert v) = Insert (f u v)
107+ combine f (Mupdate u) (InsertWithBlob v _ ) = Insert (f u v)
108+ combine f (Mupdate u) (Mupdate v) = Mupdate (f u v)
108109
109110-- | Combine two entries of runs that have been 'union'ed together. If any one
110111-- has a value, the result should have a value (represented by 'Insert'). If
111- -- both have a value, these values get combined monoidally.
112+ -- both have a value, these values get combined monoidally. Only take a blob
113+ -- from the left entry.
112114combineUnion :: (v -> v -> v ) -> Entry v b -> Entry v b -> Entry v b
113115combineUnion f = go
114116 where
115117 go Delete e = e
116118 go e Delete = e
117119 go (Insert u) (Insert v) = Insert (f u v)
118- go (Insert u) (InsertWithBlob v b ) = InsertWithBlob (f u v) b
120+ go (Insert u) (InsertWithBlob v _ ) = Insert (f u v)
119121 go (Insert u) (Mupdate v) = Insert (f u v)
120122 go (InsertWithBlob u b) (Insert v) = InsertWithBlob (f u v) b
121123 go (InsertWithBlob u b) (InsertWithBlob v _) = InsertWithBlob (f u v) b
122124 go (InsertWithBlob u b) (Mupdate v) = InsertWithBlob (f u v) b
123125 go (Mupdate u) (Insert v) = Insert (f u v)
124- go (Mupdate u) (InsertWithBlob v b ) = InsertWithBlob (f u v) b
126+ go (Mupdate u) (InsertWithBlob v _ ) = Insert (f u v)
125127 go (Mupdate u) (Mupdate v) = Insert (f u v)
126128
127129combineMaybe :: (v -> v -> v ) -> Maybe (Entry v b ) -> Maybe (Entry v b ) -> Maybe (Entry v b )
0 commit comments