Skip to content

Alternative to keysSet that uses Arg to keep the value #814

@josephcsible

Description

@josephcsible
import qualified Data.Map.Internal as Map
import qualified Data.Set.Internal as Set
import Data.Semigroup (Arg(..))

mapToArgSet :: Map.Map k a -> Set.Set (Arg k a)
mapToArgSet Map.Tip = Set.Tip
mapToArgSet (Map.Bin sz k v l r) = Set.Bin sz (Arg k v) (mapToArgSet l) (mapToArgSet r)

This function seems safe to me, since Arg k a's Eq and Ord instances only care about k and not a. Assuming I'm right about that, would this be worth adding to Data.Map (or maybe Data.Set), as a more powerful alternative to keysSet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions