{-# 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 :: forall j i.
(Eq j, Hashable j) =>
IndexPreservingSetter (HashSet i) (HashSet j) i j
setmapped = forall a b s t.
((a -> b) -> s -> t) -> IndexPreservingSetter s t a b
setting 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 :: forall a s. Hashable a => Getting (HashSet a) s a -> s -> HashSet a
setOf Getting (HashSet a) s a
l = forall s (m :: * -> *) r a.
MonadReader s m =>
LensLike' (Const r) s a -> (a -> r) -> m r
views Getting (HashSet a) s a
l forall a. Hashable a => a -> HashSet a
HashSet.singleton
{-# INLINE setOf #-}
hashMap :: Iso' (HashSet a) (HashMap a ())
hashMap :: forall a. Iso' (HashSet a) (HashMap a ())
hashMap = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso forall a. HashSet a -> HashMap a ()
toMap forall a. HashMap a () -> HashSet a
fromMap