Skip to content

Commit 1134f0d

Browse files
committed
Two small fixes
1. Restore a `Data.Semigroup.Commutative` reexport accidentally removed in #56. (I accidentally forgot to notice during review.) 2. Replace partial `Map.lookup` with proper custom error for internal error. (This would make debugging a bug in the implementation easier.) This was part of #55. Co-Authoredy-By: Dmitry Olshansky <[email protected]>
1 parent 9ec61a1 commit 1134f0d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Data/Patch.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import Control.Applicative (liftA2)
2828
import Data.Semigroup (Semigroup (..))
2929
#endif
3030

31+
import qualified Data.Semigroup.Commutative as X
3132
import Data.Patch.Class as X
3233
import Data.Patch.DMap as X hiding (getDeletions)
3334
import Data.Patch.DMapWithMove as X

src/Data/Patch/MapWithPatchingMove.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ patchThatSortsMapWith cmp m = PatchMapWithPatchingMove $ Map.fromList $ catMaybe
231231
Just (from, to)
232232
reverseMapping = Map.fromList $ catMaybes $ zipWith f unsorted sorted
233233
g (to, _) (from, _) = if to == from then Nothing else
234-
let Just movingTo = Map.lookup from reverseMapping
234+
let movingTo = fromMaybe err $ Map.lookup from reverseMapping
235235
in Just (to, NodeInfo (From_Move from mempty) $ Just movingTo)
236+
err = error "IMPOSSIBLE happens in patchThatSortsMapWith"
236237

237238
-- | Create a 'PatchMapWithPatchingMove' that, if applied to the first 'Map' provided,
238239
-- will produce a 'Map' with the same values as the second 'Map' but with the

0 commit comments

Comments
 (0)