Hoogle Search

Within LTS Haskell 24.4 (ghc-9.10.2)

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

  1. mapMaybe :: (a -> Maybe b) -> [a] -> [b]

    cabal-install-solver Distribution.Solver.Compat.Prelude

    The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Nothing, no element is added on to the result list. If it is Just b, then b is included in the result list.

    Examples

    Using mapMaybe f x is a shortcut for catMaybes $ map f x in most cases:
    >>> import GHC.Internal.Text.Read ( readMaybe )
    
    >>> let readMaybeInt = readMaybe :: String -> Maybe Int
    
    >>> mapMaybe readMaybeInt ["1", "Foo", "3"]
    [1,3]
    
    >>> catMaybes $ map readMaybeInt ["1", "Foo", "3"]
    [1,3]
    
    If we map the Just constructor, the entire list should be returned:
    >>> mapMaybe Just [1,2,3]
    [1,2,3]
    

  2. mappend :: Monoid a => a -> a -> a

    cabal-install-solver Distribution.Solver.Compat.Prelude

    An associative operation NOTE: This method is redundant and has the default implementation mappend = (<>) since base-4.11.0.0. Should it be implemented manually, since mappend is a synonym for (<>), it is expected that the two functions are defined the same way. In a future GHC release mappend will be removed from Monoid.

  3. mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()

    calligraphy Calligraphy.Prelude

    Map each element of a structure to a monadic action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see mapM. mapM_ is just like traverse_, but specialised to monadic actions.

  4. mappend :: Monoid a => a -> a -> a

    calligraphy Calligraphy.Prelude

    An associative operation NOTE: This method is redundant and has the default implementation mappend = (<>) since base-4.11.0.0. Should it be implemented manually, since mappend is a synonym for (<>), it is expected that the two functions are defined the same way. In a future GHC release mappend will be removed from Monoid.

  5. mapAccumL :: forall acc x y (n :: Nat) . (acc -> x -> (acc, y)) -> acc -> Vec n x -> (acc, Vec n y)

    clash-prelude Clash.Explicit.Prelude

    The mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a vector, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new vector.

    >>> mapAccumL (\acc x -> (acc + x,acc + 1)) 0 (1 :> 2 :> 3 :> 4 :> Nil)
    (10,1 :> 2 :> 4 :> 7 :> Nil)
    
    "mapAccumL f acc xs" corresponds to the following circuit layout:

  6. mapAccumR :: forall acc x y (n :: Nat) . (acc -> x -> (acc, y)) -> acc -> Vec n x -> (acc, Vec n y)

    clash-prelude Clash.Explicit.Prelude

    The mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a vector, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new vector.

    >>> mapAccumR (\acc x -> (acc + x,acc + 1)) 0 (1 :> 2 :> 3 :> 4 :> Nil)
    (10,10 :> 8 :> 5 :> 1 :> Nil)
    
    "mapAccumR f acc xs" corresponds to the following circuit layout:

  7. mapAccumL :: forall acc x y (n :: Nat) . (acc -> x -> (acc, y)) -> acc -> Vec n x -> (acc, Vec n y)

    clash-prelude Clash.Explicit.Prelude.Safe

    The mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a vector, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new vector.

    >>> mapAccumL (\acc x -> (acc + x,acc + 1)) 0 (1 :> 2 :> 3 :> 4 :> Nil)
    (10,1 :> 2 :> 4 :> 7 :> Nil)
    
    "mapAccumL f acc xs" corresponds to the following circuit layout:

  8. mapAccumR :: forall acc x y (n :: Nat) . (acc -> x -> (acc, y)) -> acc -> Vec n x -> (acc, Vec n y)

    clash-prelude Clash.Explicit.Prelude.Safe

    The mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a vector, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new vector.

    >>> mapAccumR (\acc x -> (acc + x,acc + 1)) 0 (1 :> 2 :> 3 :> 4 :> Nil)
    (10,10 :> 8 :> 5 :> 1 :> Nil)
    
    "mapAccumR f acc xs" corresponds to the following circuit layout:

  9. mapAccumL :: forall acc x y (n :: Nat) . (acc -> x -> (acc, y)) -> acc -> Vec n x -> (acc, Vec n y)

    clash-prelude Clash.Prelude

    The mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a vector, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new vector.

    >>> mapAccumL (\acc x -> (acc + x,acc + 1)) 0 (1 :> 2 :> 3 :> 4 :> Nil)
    (10,1 :> 2 :> 4 :> 7 :> Nil)
    
    "mapAccumL f acc xs" corresponds to the following circuit layout:

  10. mapAccumR :: forall acc x y (n :: Nat) . (acc -> x -> (acc, y)) -> acc -> Vec n x -> (acc, Vec n y)

    clash-prelude Clash.Prelude

    The mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a vector, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new vector.

    >>> mapAccumR (\acc x -> (acc + x,acc + 1)) 0 (1 :> 2 :> 3 :> 4 :> Nil)
    (10,10 :> 8 :> 5 :> 1 :> Nil)
    
    "mapAccumR f acc xs" corresponds to the following circuit layout:

Page 12 of many | Previous | Next