Skip to content

alterF: No need to delete when the key is absent?! #287

Closed
@sjakobi

Description

@sjakobi

alterF f = \ !k !m ->
let
!h = hash k
mv = lookup' h k m
in (<$> f mv) $ \fres ->
case fres of
Nothing -> delete' h k m
Just v' -> insert' h k v' m

When fres is Nothing, we delete' k from m no matter whether m contained k in the first place. We could skip the deletion though if mv is Nothing.

I'm surprised that the code doesn't already do that. Are there reasons against doing it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions