Handling bounds errors safely whilst keeping a relaxed type

This gives me an idea of a function that could be added to elm-community/dict-extra and array-extra if there was one:

swap : Int -> Int -> Array a -> Array a
swap : comparable -> comparable -> Dict comparable v -> Dict comparable v

The contract would be, the functions swaps the data values located by the keys, if the keys are both valid, otherwise it just returns the data structure unchanged. There may be other dict-like data structures where swap operations are handy.