Skip to content

Commit

Permalink
Two small fixes
Browse files Browse the repository at this point in the history
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 <olshanskydr@gmail.com>
  • Loading branch information
Ericson2314 committed Sep 12, 2024
1 parent 9ec61a1 commit 1134f0d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Data/Patch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Control.Applicative (liftA2)
import Data.Semigroup (Semigroup (..))
#endif

import qualified Data.Semigroup.Commutative as X
import Data.Patch.Class as X
import Data.Patch.DMap as X hiding (getDeletions)
import Data.Patch.DMapWithMove as X
Expand Down
3 changes: 2 additions & 1 deletion src/Data/Patch/MapWithPatchingMove.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ patchThatSortsMapWith cmp m = PatchMapWithPatchingMove $ Map.fromList $ catMaybe
Just (from, to)
reverseMapping = Map.fromList $ catMaybes $ zipWith f unsorted sorted
g (to, _) (from, _) = if to == from then Nothing else
let Just movingTo = Map.lookup from reverseMapping
let movingTo = fromMaybe err $ Map.lookup from reverseMapping
in Just (to, NodeInfo (From_Move from mempty) $ Just movingTo)
err = error "IMPOSSIBLE happens in patchThatSortsMapWith"

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

0 comments on commit 1134f0d

Please sign in to comment.