HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelens-5.3.5Haskell2010

Control.Lens.At

  • 3 classes
  • 5 values
  • Packagelens-5.3.5
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceAt.hs

At

3 declarations
classclass Ixed m => At m where
#

At provides a Lens that can be used to read, write or delete the value associated with a key in a Map-like container on an ad hoc basis.

An instance of At should satisfy:

ix k ≡ at k . traverse

Methods

  • at :: Index m -> Lens' m (Maybe (IxValue m))
    Example1 expression
    Map.fromList [(1,"world")] ^.at 1Just "world"
    Example1 expression
    at 1 ?~ "hello" $ Map.emptyfromList [(1,"hello")]

    Note: Map-like containers form a reasonable instance, but not Array-like ones, where you cannot satisfy the Lens laws.

Instances7At, …
  • At IntSetDefined in lens-5.3.5 · Control.Lens.At
  • Ord k => At (Set k)Defined in lens-5.3.5 · Control.Lens.At
  • At (IntMap a)Defined in lens-5.3.5 · Control.Lens.At
  • At (Maybe a)Defined in lens-5.3.5 · Control.Lens.At
  • (Eq k, Hashable k) => At (HashSet k)Defined in lens-5.3.5 · Control.Lens.At
  • Ord k => At (Map k a)Defined in lens-5.3.5 · Control.Lens.At
  • (Eq k, Hashable k) => At (HashMap k a)Defined in lens-5.3.5 · Control.Lens.At
valuesans :: At m => Index m -> m -> m
#

Delete the value associated with a key in a Map-like container

sans k = at k .~ Nothing
valueiat :: At m => Index m -> IndexedLens' (Index m) m (Maybe (IxValue m))
#

An indexed version of at.

Example1 expression
Map.fromList [(1,"world")] ^@. iat 1(1,Just "world")
Example1 expression
iat 1 %@~ (\i x -> if odd i then Just "hello" else Nothing) $ Map.emptyfromList [(1,"hello")]
Example1 expression
iat 2 %@~ (\i x -> if odd i then Just "hello" else Nothing) $ Map.emptyfromList []

Ixed

5 declarations
familytype family Index s
#
Instances33Index, …
  • type Index ByteString = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index ByteString = Int64Defined in lens-5.3.5 · Control.Lens.At
  • type Index IntSet = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index Text = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index Text = Int64Defined in lens-5.3.5 · Control.Lens.At
  • type Index (UArray i e) = iDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Complex a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (IntMap a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Map k a) = kDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Seq a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Set a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Tree a) = [Int]Defined in lens-5.3.5 · Control.Lens.At
  • type Index (Array i e) = iDefined in lens-5.3.5 · Control.Lens.At
  • type Index (NonEmpty a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Identity a) = ()Defined in lens-5.3.5 · Control.Lens.At
  • type Index (Maybe a) = ()Defined in lens-5.3.5 · Control.Lens.At
  • type Index (HashMap k a) = kDefined in lens-5.3.5 · Control.Lens.At
  • type Index (HashSet a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Vector a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Vector a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Vector a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Vector a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (Vector a) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b, c) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b, c, d) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b, c, d, e) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b, c, d, e, f) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b, c, d, e, f, g) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b, c, d, e, f, g, h) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (a, b, c, d, e, f, g, h, i) = IntDefined in lens-5.3.5 · Control.Lens.At
  • type Index (e -> a) = eDefined in lens-5.3.5 · Control.Lens.At
  • type Index [a] = IntDefined in lens-5.3.5 · Control.Lens.At
familytype family IxValue m
#

This provides a common notion of a value at an index that is shared by both Ixed and At.

Instances32IxValue, …
  • type IxValue ByteString = Word8Defined in lens-5.3.5 · Control.Lens.At
  • type IxValue ByteString = Word8Defined in lens-5.3.5 · Control.Lens.At
  • type IxValue IntSet = ()Defined in lens-5.3.5 · Control.Lens.At
  • type IxValue Text = CharDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue Text = CharDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (UArray i e) = eDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (IntMap a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Map k a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Seq a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Set k) = ()Defined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Tree a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Array i e) = eDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (NonEmpty a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Identity a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Maybe a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (HashMap k a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (HashSet k) = ()Defined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Vector a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Vector a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Vector a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Vector a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (Vector a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue (a, a2) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a) a
  • type IxValue (a, a2, a3) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a,a) a
  • type IxValue (a, a2, a3, a4) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a,a,a) a
  • type IxValue (a, a2, a3, a4, a5) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a,a,a,a) a
  • type IxValue (a, a2, a3, a4, a5, a6) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a,a,a,a,a) a
  • type IxValue (a, a2, a3, a4, a5, a6, a7) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a,a,a,a,a,a) a
  • type IxValue (a, a2, a3, a4, a5, a6, a7, a8) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a,a,a,a,a,a,a) a
  • type IxValue (a, a2, a3, a4, a5, a6, a7, a8, a9) = aDefined in lens-5.3.5 · Control.Lens.At
    ix :: Int -> Traversal' (a,a,a,a,a,a,a,a,a) a
  • type IxValue (e -> a) = aDefined in lens-5.3.5 · Control.Lens.At
  • type IxValue [a] = aDefined in lens-5.3.5 · Control.Lens.At
classclass Ixed m where
#

Provides a simple Traversal lets you traverse the value at a given key in a Map or element at an ordinal position in a list or Seq.

Methods

  • ix :: Index m -> Traversal' m (IxValue m)

    NB: Setting the value of this Traversal will only set the value in at if it is already present.

    If you want to be able to insert missing values, you want at.

    Example1 expression
    Seq.fromList [a,b,c,d] & ix 2 %~ ffromList [a,b,f c,d]
    Example1 expression
    Seq.fromList [a,b,c,d] & ix 2 .~ efromList [a,b,e,d]
    Example1 expression
    Seq.fromList [a,b,c,d] ^? ix 2Just c
    Example1 expression
    Seq.fromList [] ^? ix 2Nothing
Instances32Ixed, …
  • Ixed ByteStringDefined in lens-5.3.5 · Control.Lens.At
  • Ixed ByteStringDefined in lens-5.3.5 · Control.Lens.At
  • Ixed IntSetDefined in lens-5.3.5 · Control.Lens.At
  • Ixed TextDefined in lens-5.3.5 · Control.Lens.At
  • Ixed TextDefined in lens-5.3.5 · Control.Lens.At
  • Storable a => Ixed (Vector a)Defined in lens-5.3.5 · Control.Lens.At
  • Ord k => Ixed (Set k)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (IntMap a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (Seq a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (Tree a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (NonEmpty a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (Identity a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (Maybe a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (Vector a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed (Vector a)Defined in lens-5.3.5 · Control.Lens.At
  • Ixed [a]Defined in lens-5.3.5 · Control.Lens.At
  • Prim a => Ixed (Vector a)Defined in lens-5.3.5 · Control.Lens.At
  • Unbox a => Ixed (Vector a)Defined in lens-5.3.5 · Control.Lens.At
  • (Eq k, Hashable k) => Ixed (HashSet k)Defined in lens-5.3.5 · Control.Lens.At
  • Ix i => Ixed (Array i e)Defined in lens-5.3.5 · Control.Lens.At
    arr ! i ≡ arr ^. ix i
    arr // [(i,e)] ≡ ix i .~ e $ arr
    
  • Eq e => Ixed (e -> a)Defined in lens-5.3.5 · Control.Lens.At
  • Ord k => Ixed (Map k a)Defined in lens-5.3.5 · Control.Lens.At
  • (IArray UArray e, Ix i) => Ixed (UArray i e)Defined in lens-5.3.5 · Control.Lens.At
    arr ! i ≡ arr ^. ix i
    arr // [(i,e)] ≡ ix i .~ e $ arr
    
  • (Eq k, Hashable k) => Ixed (HashMap k a)Defined in lens-5.3.5 · Control.Lens.At
  • a ~ a2 => Ixed (a, a2)Defined in lens-5.3.5 · Control.Lens.At
  • (a ~ a2, a ~ a3) => Ixed (a, a2, a3)Defined in lens-5.3.5 · Control.Lens.At
  • (a ~ a2, a ~ a3, a ~ a4) => Ixed (a, a2, a3, a4)Defined in lens-5.3.5 · Control.Lens.At
  • (a ~ a2, a ~ a3, a ~ a4, a ~ a5) => Ixed (a, a2, a3, a4, a5)Defined in lens-5.3.5 · Control.Lens.At
  • (a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6) => Ixed (a, a2, a3, a4, a5, a6)Defined in lens-5.3.5 · Control.Lens.At
  • (a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7) => Ixed (a, a2, a3, a4, a5, a6, a7)Defined in lens-5.3.5 · Control.Lens.At
  • (a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7, a ~ a8) => Ixed (a, a2, a3, a4, a5, a6, a7, a8)Defined in lens-5.3.5 · Control.Lens.At
  • (a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7, a ~ a8, a ~ a9) => Ixed (a, a2, a3, a4, a5, a6, a7, a8, a9)Defined in lens-5.3.5 · Control.Lens.At
valueiix :: Ixed m => Index m -> IndexedTraversal' (Index m) m (IxValue m)
#

An indexed version of ix.

Example1 expression
Seq.fromList [a,b,c,d] & iix 2 %@~ f'fromList [a,b,f' 2 c,d]
Example1 expression
Seq.fromList [a,b,c,d] & iix 2 .@~ hfromList [a,b,h 2,d]
Example1 expression
Seq.fromList [a,b,c,d] ^@? iix 2Just (2,c)
Example1 expression
Seq.fromList [] ^@? iix 2Nothing

Contains

2 declarations
classclass Contains m where
#

This class provides a simple Lens that lets you view (and modify) information about whether or not a container contains a given Index.

Methods

  • contains :: Index m -> Lens' m Bool
    Example1 expression
    IntSet.fromList [1,2,3,4] ^. contains 3True
    Example1 expression
    IntSet.fromList [1,2,3,4] ^. contains 5False
    Example1 expression
    IntSet.fromList [1,2,3,4] & contains 3 .~ FalsefromList [1,2,4]
Instances3Contains
valueicontains :: Contains m => Index m -> IndexedLens' (Index m) m Bool
#

An indexed version of contains.

Example1 expression
IntSet.fromList [1,2,3,4] ^@. icontains 3(3,True)
Example1 expression
IntSet.fromList [1,2,3,4] ^@. icontains 5(5,False)
Example1 expression
IntSet.fromList [1,2,3,4] & icontains 3 %@~ \i x -> if odd i then not x else xfromList [1,2,4]
Example1 expression
IntSet.fromList [1,2,3,4] & icontains 3 %@~ \i x -> if even i then not x else xfromList [1,2,3,4]