Skip to content

Data.Set: add insertUnlessMember  #161

Closed
@andreasabel

Description

@andreasabel

For Data.Set, I am missing something comparable to Map.lookupInsertWithKey that combines a lookup and an insert. Suggestion (specification):

insertUnlessMember :: Ord a => a -> Set a -> Maybe (Set a)
insertUnlessMember a s = if member a s then Nothing else Just $ insert a s

Of course, that should have an efficient implementation that only traverses the tree once.

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