lens-5.3.3: Lenses, Folds and Traversals

Copyright | (C) 2012-16 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.HashSet.Lens

Description

Synopsis

- setmapped :: (Eq j, Hashable j) => IndexPreservingSetter (HashSet i) (HashSet j) i j
- setOf :: Hashable a => Getting (HashSet a) s a -> s -> HashSet a
- hashMap :: forall a p f. (Profunctor p, Functor f) => p (HashMap a ()) (f (HashMap a ())) -> p (HashSet a) (f (HashSet a))

# Documentation

setmapped :: (Eq j, Hashable j) => IndexPreservingSetter (HashSet i) (HashSet j) i j #

This `Setter` can be used to change the type of a `HashSet` by mapping the elements to new values.

Sadly, you can't create a valid `Traversal` for a `Set`, but you can manipulate it by reading using `folded` and reindexing it via `setmapped`.

setOf :: Hashable a => Getting (HashSet a) s a -> s -> HashSet a #

Construct a set from a `Getter`, `Fold`, `Traversal`, `Lens` or `Iso`.

    setOf :: Hashable a         => Getter s a     -> s -> HashSet a
    setOf :: (Eq a, Hashable a) => Fold s a       -> s -> HashSet a
    setOf :: Hashable a         => Iso' s a       -> s -> HashSet a
    setOf :: Hashable a         => Lens' s a      -> s -> HashSet a
    setOf :: (Eq a, Hashable a) => Traversal' s a -> s -> HashSet a

hashMap :: forall a p f. (Profunctor p, Functor f) => p (HashMap a ()) (f (HashMap a ())) -> p (HashSet a) (f (HashSet a)) #

An `Iso` between a `HashSet` and a `HashMap` with unit values. \(\mathcal{O}(1)\).