1
1
{-# LANGUAGE MultiWayIf #-}
2
+
2
3
{- |
3
4
Copyright : (c) Runtime Verification, 2023
4
5
License : BSD-3-Clause
@@ -246,8 +247,8 @@ mapUpdateAllHook :: BuiltinFunction
246
247
mapUpdateAllHook [KMap def1 _ _, KMap def2 _ _]
247
248
| def1 /= def2 =
248
249
throwE $
249
- " MAP.updateAll: incompatible maps " <>
250
- Text. pack (show (def1. mapSortName, def2. mapSortName))
250
+ " MAP.updateAll: incompatible maps "
251
+ <> Text. pack (show (def1. mapSortName, def2. mapSortName))
251
252
mapUpdateAllHook [original, KMap _ [] Nothing ] =
252
253
-- updates map is empty, result is original map
253
254
pure $ Just original
@@ -260,15 +261,19 @@ mapUpdateAllHook [KMap _ _ (Just _), _updates] =
260
261
mapUpdateAllHook [KMap def pairs1 Nothing , KMap _ pairs2 mbRest2]
261
262
-- performing the update requires all keys to be fully evaluated
262
263
-- (constructor-like) or syntactically equal.
263
- | Set. null origKeys = -- all keys in the original map were updated (syntactically)
264
+ | Set. null origKeys -- all keys in the original map were updated (syntactically)
265
+ =
264
266
pure $ Just $ KMap def updated mbRest2
265
267
| Set. null updateKeys
266
- , Nothing <- mbRest2 = -- all update keys were (syntactically) present
268
+ , Nothing <- mbRest2 -- all update keys were (syntactically) present
269
+ =
267
270
pure $ Just $ KMap def updated Nothing
268
271
| all isConstructorLike_ (updateKeys <> origKeys)
269
- , Nothing <- mbRest2 = -- all untouched or added keys are fully evaluated
272
+ , Nothing <- mbRest2 -- all untouched or added keys are fully evaluated
273
+ =
270
274
pure $ Just $ KMap def updated Nothing
271
- | otherwise = -- uncertain whether all keys updated, leave unevaluated
275
+ | otherwise -- uncertain whether all keys updated, leave unevaluated
276
+ =
272
277
pure Nothing
273
278
where
274
279
orig = Map. fromList pairs1
@@ -277,9 +282,9 @@ mapUpdateAllHook [KMap def pairs1 Nothing, KMap _ pairs2 mbRest2]
277
282
origKeys = Set. difference (Map. keysSet orig) (Map. keysSet update)
278
283
updateKeys = Set. difference (Map. keysSet update) (Map. keysSet orig)
279
284
mapUpdateAllHook [_, _] =
280
- pure Nothing -- at least one argument not an internalised map, leave unevaluated
285
+ pure Nothing -- at least one argument not an internalised map, leave unevaluated
281
286
mapUpdateAllHook args =
282
- throwE . renderText $ " MAP.update: wrong arity " <> pretty (length args)
287
+ throwE . renderText $ " MAP.update: wrong arity " <> pretty (length args)
283
288
284
289
mapRemoveHook :: BuiltinFunction
285
290
mapRemoveHook args
0 commit comments