Hoogle Search

Within LTS Haskell 24.34 (ghc-9.10.3)

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

  1. foldlMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (b -> a -> m b) -> t a -> m b

    base Data.Foldable1

    Map variant of foldlM1.

  2. foldrMap1 :: Foldable1 t => (a -> b) -> (a -> b -> b) -> t a -> b

    base Data.Foldable1

    Right-associative fold of a structure, lazy in the accumulator. In case of NonEmpty lists, foldrMap1, when given a function f, a binary operator g, and a list, reduces the list using g from right to left applying f to the rightmost element:

    foldrMap1 f g (x1 :| [x2, ..., xn1, xn]) == x1 `g` (x2 `g` ... (xn1 `g` (f xn))...)
    
    Note that since the head of the resulting expression is produced by an application of g to the first element of the list, if g is lazy in its right argument, foldrMap1 can produce a terminating expression from an unbounded list. For a general Foldable1 structure this should be semantically identical to:
    foldrMap1 f g = foldrMap1 f g . toNonEmpty
    

  3. foldrMap1' :: Foldable1 t => (a -> b) -> (a -> b -> b) -> t a -> b

    base Data.Foldable1

    foldrMap1' is a variant of foldrMap1 that performs strict reduction from right to left, i.e. starting with the right-most element. The input structure must be finite, otherwise foldrMap1' runs out of space (diverges). If you want a strict right fold in constant space, you need a structure that supports faster than <math> access to the right-most element. This method does not run in constant space for structures such as NonEmpty lists that don't support efficient right-to-left iteration and so require <math> space to perform right-to-left reduction. Use of this method with such a structure is a hint that the chosen structure may be a poor fit for the task at hand. If the order in which the elements are combined is not important, use foldlMap1' instead.

  4. foldrMapM1 :: (Foldable1 t, Monad m) => (a -> m b) -> (a -> b -> m b) -> t a -> m b

    base Data.Foldable1

    Map variant of foldrM1.

  5. fmap :: Functor f => (a -> b) -> f a -> f b

    base Data.Functor

    fmap is used to apply a function of type (a -> b) to a value of type f a, where f is a functor, to produce a value of type f b. Note that for any type constructor with more than one parameter (e.g., Either), only the last type parameter can be modified with fmap (e.g., b in `Either a b`). Some type constructors with two parameters or more have a Bifunctor instance that allows both the last and the penultimate parameters to be mapped over.

    Examples

    Convert from a Maybe Int to a Maybe String using show:
    >>> fmap show Nothing
    Nothing
    
    >>> fmap show (Just 3)
    Just "3"
    
    Convert from an Either Int Int to an Either Int String using show:
    >>> fmap show (Left 17)
    Left 17
    
    >>> fmap show (Right 17)
    Right "17"
    
    Double each element of a list:
    >>> fmap (*2) [1,2,3]
    [2,4,6]
    
    Apply even to the second element of a pair:
    >>> fmap even (2,2)
    (2,True)
    
    It may seem surprising that the function is only applied to the last element of the tuple compared to the list example above which applies it to every element in the list. To understand, remember that tuples are type constructors with multiple type parameters: a tuple of 3 elements (a,b,c) can also be written (,,) a b c and its Functor instance is defined for Functor ((,,) a b) (i.e., only the third parameter is free to be mapped over with fmap). It explains why fmap can be used with tuples containing values of different types as in the following example:
    >>> fmap even ("hello", 1.0, 4)
    ("hello",1.0,True)
    

  6. contramap :: Contravariant f => (a' -> a) -> f a -> f a'

    base Data.Functor.Contravariant

    No documentation available.

  7. fmapDefault :: Traversable t => (a -> b) -> t a -> t b

    base Data.Traversable

    This function may be used as a value for fmap in a Functor instance, provided that traverse is defined. (Using fmapDefault with a Traversable instance defined only by sequenceA will result in infinite recursion.)

    fmapDefault f ≡ runIdentity . traverse (Identity . f)
    

  8. foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m

    base Data.Traversable

    This function may be used as a value for foldMap in a Foldable instance.

    foldMapDefault f ≡ getConst . traverse (Const . f)
    

  9. amap :: (a -> b) -> Array i a -> Array i b

    base GHC.Arr

    No documentation available.

  10. ixmap :: (Ix i, Ix j) => (i, i) -> (i -> j) -> Array j e -> Array i e

    base GHC.Arr

    ixmap allows for transformations on array indices. It may be thought of as providing function composition on the right with the mapping that the original array embodies. A similar transformation of array values may be achieved using fmap from the Array instance of the Functor class.

Page 400 of many | Previous | Next