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