on develop help sign in
Merge pull request #16 from reflex-frp/no-fromJust

Get rid of `fromJust` in other `PatchMapWith*Move` variant

commit33987bd492b55ee1b4ae61799915be6a13f36316 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateWed 5 Feb 2020, 17:35 (7 years ago) parente1e72689f0f5f9
2 files changed+6−2
src/Data/Patch/MapWithMove.hs+3−1 src/Data/Patch/MapWithPatchingMove.hs+3−1
src/Data/Patch/MapWithMove.hs+3−1
@@ -202,7 +202,9 @@ patchThatChangesMap oldByIndex newByIndex = patch
202202 putRemainingKeys $ Set.delete k fromKs
203203 return $ NodeInfo (From_Move k) $ Just undefined -- There's an existing value, and it's here, so no patch necessary
204204 else do
205− (fromK, remainingKeys) <- return . fromMaybe (error "patchThatChangesMap: impossible: fromKs was empty") $ Set.minView fromKs -- There's an existing value, but it's not here; move it here
205+ (fromK, remainingKeys) <- return $
206+ fromMaybe (error "PatchMapWithMove.patchThatChangesMap: impossible: fromKs was empty") $
207+ Set.minView fromKs -- There's an existing value, but it's not here; move it here
206208 putRemainingKeys remainingKeys
207209 return $ NodeInfo (From_Move fromK) $ Just undefined
208210 Map.traverseWithKey f newByIndex
src/Data/Patch/MapWithPatchingMove.hs+3−1
@@ -268,7 +268,9 @@ patchThatChangesMap oldByIndex newByIndex = patch
268268 putRemainingKeys $ Set.delete k fromKs
269269 return $ NodeInfo (From_Move k mempty) $ Just undefined -- There's an existing value, and it's here, so no patch necessary
270270 else do
271− (fromK, remainingKeys) <- return . fromJust $ Set.minView fromKs -- There's an existing value, but it's not here; move it here
271+ (fromK, remainingKeys) <- return $
272+ fromMaybe (error "PatchMapWithPatchingMove.patchThatChangesMap: impossible: fromKs was empty") $
273+ Set.minView fromKs -- There's an existing value, but it's not here; move it here
272274 putRemainingKeys remainingKeys
273275 return $ NodeInfo (From_Move fromK mempty) $ Just undefined
274276 Map.traverseWithKey f newByIndex