lens-2.8: Lenses, Folds and Traversals

Portabilityportable
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone

Data.HashSet.Lens

Description

 

Synopsis

Documentation

setmapped :: (Eq i, Hashable i, Eq j, Hashable j) => Setter (HashSet i) (HashSet j) i jSource

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 setmap.

>>> :m + Data.HashSet Control.Lens
>>> over setmapped (+1) (fromList [1,2,3,4])
fromList [2,3,4,5]

setOf :: Hashable c => Getting (HashSet c) a b c d -> a -> HashSet cSource

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

>>> :m + Control.Lens
>>> setOf (folded._2) [("hello",1),("world",2),("!!!",3)]
fromList [1,2,3]
 setOf :: Hashable c         => Getter a c           -> a -> HashSet c
 setOf :: (Eq c, Hashable c) => Fold a c             -> a -> HashSet c
 setOf :: Hashable c         => Simple Iso a c       -> a -> HashSet c
 setOf :: Hashable c         => Simple Lens a c      -> a -> HashSet c
 setOf :: (Eq c, Hashable c) => Simple Traversal a c -> a -> HashSet c