{-# LANGUAGE Rank2Types #-}
module Data.HashSet.Lens
( setmapped
, setOf
, hashMap
) where
import Control.Lens.Getter (Getting, views)
import Control.Lens.Iso (iso)
import Control.Lens.Setter (setting)
import Control.Lens.Type
import qualified Data.HashSet as HashSet
import Data.HashSet (HashSet, fromMap, toMap)
import Data.HashMap.Lazy (HashMap)
import Data.Hashable
setmapped :: (Eq j, Hashable j) => IndexPreservingSetter (HashSet i) (HashSet j) i j
setmapped :: IndexPreservingSetter (HashSet i) (HashSet j) i j
setmapped = ((i -> j) -> HashSet i -> HashSet j)
-> IndexPreservingSetter (HashSet i) (HashSet j) i j
forall a b s t.
((a -> b) -> s -> t) -> IndexPreservingSetter s t a b
setting (i -> j) -> HashSet i -> HashSet j
forall b a.
(Hashable b, Eq b) =>
(a -> b) -> HashSet a -> HashSet b
HashSet.map
{-# INLINE setmapped #-}
setOf :: Hashable a => Getting (HashSet a) s a -> s -> HashSet a
setOf :: Getting (HashSet a) s a -> s -> HashSet a
setOf Getting (HashSet a) s a
l = Getting (HashSet a) s a -> (a -> HashSet a) -> s -> HashSet a
forall s (m :: * -> *) r a.
MonadReader s m =>
LensLike' (Const r) s a -> (a -> r) -> m r
views Getting (HashSet a) s a
l a -> HashSet a
forall a. Hashable a => a -> HashSet a
HashSet.singleton
{-# INLINE setOf #-}
hashMap :: Iso' (HashSet a) (HashMap a ())
hashMap :: p (HashMap a ()) (f (HashMap a ()))
-> p (HashSet a) (f (HashSet a))
hashMap = (HashSet a -> HashMap a ())
-> (HashMap a () -> HashSet a)
-> Iso (HashSet a) (HashSet a) (HashMap a ()) (HashMap a ())
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso HashSet a -> HashMap a ()
forall a. HashSet a -> HashMap a ()
toMap HashMap a () -> HashSet a
forall a. HashMap a () -> HashSet a
fromMap