Hoogle Search

Within LTS Haskell 24.6 (ghc-9.10.2)

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

  1. mapMaybe :: (a -> Maybe b) -> InputStream a -> IO (InputStream b)

    io-streams System.IO.Streams.Combinators

    A version of map that discards elements mapMaybe f s passes all output from s through the function f and discards elements for which f s evaluates to Nothing. Example:

    ghci> Streams.fromList [Just 1, None, Just 3] >>=
    Streams.mapMaybe id >>=
    Streams.toList
    [1,3]
    
    Since: 1.2.1.0

  2. mapM_ :: (MonoFoldable mono, Applicative m) => (Element mono -> m ()) -> mono -> m ()

    mono-traversable Data.MonoTraversable.Unprefixed

    Synonym for omapM_

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

    strict Data.Strict.Maybe

    Analogous to mapMaybe in Data.Maybe.

  4. mapMaybe :: (v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2

    rio RIO.HashMap

    Transform this map by applying a function to every value and retaining only some of them.

  5. mapMaybeWithKey :: (k -> v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2

    rio RIO.HashMap

    Transform this map by applying a function to every value and retaining only some of them.

  6. mapMaybe :: (a -> Maybe b) -> Map k a -> Map k b

    rio RIO.Map

    Map values and collect the Just results.

    let f x = if x == "a" then Just "new a" else Nothing
    mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"
    

  7. mapMaybeWithKey :: (k -> a -> Maybe b) -> Map k a -> Map k b

    rio RIO.Map

    Map keys/values and collect the Just results.

    let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing
    mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"
    

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

    rio RIO.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.

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

    rio RIO.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]
    

  10. mapMaybeA :: Applicative f => (a -> f (Maybe b)) -> [a] -> f [b]

    rio RIO.Prelude

    Applicative mapMaybe.

Page 25 of many | Previous | Next