Hoogle Search

Within LTS Haskell 22.22 (ghc-9.6.5)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. ix :: Ixed m => Index m -> Traversal' m (IxValue m)

    lens Control.Lens.At

    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.

    >>> Seq.fromList [a,b,c,d] & ix 2 %~ f
    fromList [a,b,f c,d]
    
    >>> Seq.fromList [a,b,c,d] & ix 2 .~ e
    fromList [a,b,e,d]
    
    >>> Seq.fromList [a,b,c,d] ^? ix 2
    Just c
    
    >>> Seq.fromList [] ^? ix 2
    Nothing
    

  2. ix :: (Ixed m, At m) => Index m -> Traversal' m (IxValue m)

    lens Control.Lens.At

    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.

    >>> Seq.fromList [a,b,c,d] & ix 2 %~ f
    fromList [a,b,f c,d]
    
    >>> Seq.fromList [a,b,c,d] & ix 2 .~ e
    fromList [a,b,e,d]
    
    >>> Seq.fromList [a,b,c,d] ^? ix 2
    Just c
    
    >>> Seq.fromList [] ^? ix 2
    Nothing
    

  3. ix :: Ixed m => Index m -> Traversal' m (IxValue m)

    lens Control.Lens.Combinators

    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.

    >>> Seq.fromList [a,b,c,d] & ix 2 %~ f
    fromList [a,b,f c,d]
    
    >>> Seq.fromList [a,b,c,d] & ix 2 .~ e
    fromList [a,b,e,d]
    
    >>> Seq.fromList [a,b,c,d] ^? ix 2
    Just c
    
    >>> Seq.fromList [] ^? ix 2
    Nothing
    

  4. ix :: (Ixed m, At m) => Index m -> Traversal' m (IxValue m)

    lens Control.Lens.Combinators

    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.

    >>> Seq.fromList [a,b,c,d] & ix 2 %~ f
    fromList [a,b,f c,d]
    
    >>> Seq.fromList [a,b,c,d] & ix 2 .~ e
    fromList [a,b,e,d]
    
    >>> Seq.fromList [a,b,c,d] ^? ix 2
    Just c
    
    >>> Seq.fromList [] ^? ix 2
    Nothing
    

  5. ix :: Ixed m => Index m -> Traversal' m (IxValue m)

    microlens Lens.Micro

    This traversal lets you access (and update) an arbitrary element in a list, array, Map, etc. (If you want to insert or delete elements as well, look at at.) An example for lists:

    >>> [0..5] & ix 3 .~ 10
    [0,1,2,10,4,5]
    
    You can use it for getting, too:
    >>> [0..5] ^? ix 3
    Just 3
    
    Of course, the element may not be present (which means that you can use ix as a safe variant of (!!)):
    >>> [0..5] ^? ix 10
    Nothing
    
    Another useful instance is the one for functions – it lets you modify their outputs for specific inputs. For instance, here's maximum that returns 0 when the list is empty (instead of throwing an exception):
    maximum0 = maximum & ix [] .~ 0
    
    The following instances are provided in this package:
    ix :: Int -> Traversal' [a] a
    
    ix :: Int -> Traversal' (NonEmpty a) a
    
    ix :: (Eq e) => e -> Traversal' (e -> a) a
    
    You can also use ix with types from array, bytestring, and containers by using microlens-ghc, or additionally with types from vector, text, and unordered-containers by using microlens-platform.

  6. ix :: Ixed m => Index m -> Traversal' m (IxValue m)

    microlens Lens.Micro.Internal

    This traversal lets you access (and update) an arbitrary element in a list, array, Map, etc. (If you want to insert or delete elements as well, look at at.) An example for lists:

    >>> [0..5] & ix 3 .~ 10
    [0,1,2,10,4,5]
    
    You can use it for getting, too:
    >>> [0..5] ^? ix 3
    Just 3
    
    Of course, the element may not be present (which means that you can use ix as a safe variant of (!!)):
    >>> [0..5] ^? ix 10
    Nothing
    
    Another useful instance is the one for functions – it lets you modify their outputs for specific inputs. For instance, here's maximum that returns 0 when the list is empty (instead of throwing an exception):
    maximum0 = maximum & ix [] .~ 0
    
    The following instances are provided in this package:
    ix :: Int -> Traversal' [a] a
    
    ix :: Int -> Traversal' (NonEmpty a) a
    
    ix :: (Eq e) => e -> Traversal' (e -> a) a
    
    You can also use ix with types from array, bytestring, and containers by using microlens-ghc, or additionally with types from vector, text, and unordered-containers by using microlens-platform.

  7. ix :: Ixed m => Index m -> Traversal' m (IxValue m)

    rio RIO.Lens

    This traversal lets you access (and update) an arbitrary element in a list, array, Map, etc. (If you want to insert or delete elements as well, look at at.) An example for lists:

    >>> [0..5] & ix 3 .~ 10
    [0,1,2,10,4,5]
    
    You can use it for getting, too:
    >>> [0..5] ^? ix 3
    Just 3
    
    Of course, the element may not be present (which means that you can use ix as a safe variant of (!!)):
    >>> [0..5] ^? ix 10
    Nothing
    
    Another useful instance is the one for functions – it lets you modify their outputs for specific inputs. For instance, here's maximum that returns 0 when the list is empty (instead of throwing an exception):
    maximum0 = maximum & ix [] .~ 0
    
    The following instances are provided in this package:
    ix :: Int -> Traversal' [a] a
    
    ix :: Int -> Traversal' (NonEmpty a) a
    
    ix :: (Eq e) => e -> Traversal' (e -> a) a
    
    You can also use ix with types from array, bytestring, and containers by using microlens-ghc, or additionally with types from vector, text, and unordered-containers by using microlens-platform.

  8. ix :: Ixed m => Index m -> Optic' (IxKind m) NoIx m (IxValue m)

    optics-core Optics.At.Core

    NB: Setting the value of this AffineTraversal 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.

    >>> [1,2,3,4] & ix 2 %~ (*10)
    [1,2,30,4]
    
    >>> "abcd" & ix 2 .~ 'e'
    "abed"
    
    >>> "abcd" ^? ix 2
    Just 'c'
    
    >>> [] ^? ix 2
    Nothing
    

  9. ix :: (Ixed m, At m, IxKind m ~ An_AffineTraversal) => Index m -> Optic' (IxKind m) NoIx m (IxValue m)

    optics-core Optics.At.Core

    NB: Setting the value of this AffineTraversal 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.

    >>> [1,2,3,4] & ix 2 %~ (*10)
    [1,2,30,4]
    
    >>> "abcd" & ix 2 .~ 'e'
    "abed"
    
    >>> "abcd" ^? ix 2
    Just 'c'
    
    >>> [] ^? ix 2
    Nothing
    

  10. ix :: Ixed m => Index m -> Traversal' m (IxValue m)

    diagrams-lib Diagrams.Prelude

    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.

    >>> Seq.fromList [a,b,c,d] & ix 2 %~ f
    fromList [a,b,f c,d]
    
    >>> Seq.fromList [a,b,c,d] & ix 2 .~ e
    fromList [a,b,e,d]
    
    >>> Seq.fromList [a,b,c,d] ^? ix 2
    Just c
    
    >>> Seq.fromList [] ^? ix 2
    Nothing
    

Page 1 of many | Next