Hoogle Search

Within LTS Haskell 24.3 (ghc-9.10.2)

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

  1. mapMaybe :: forall s a b . (a -> Maybe b) -> IntMap s a -> SomeIntMapWith (SupersetProof 'Int s) b

    refined-containers Data.IntMap.Refined

    Apply a function to all values in a map and collect only the Just results, returning a potentially smaller map.

  2. mapMaybe :: forall s a b . (a -> Maybe b) -> IntMap s a -> SomeIntMapWith (SupersetProof 'Int s) b

    refined-containers Data.IntMap.Strict.Refined

    Apply a function to all values in a map and collect only the Just results, returning a potentially smaller map.

  3. mapMaybe :: forall s k a b . (a -> Maybe b) -> Map s k a -> SomeMapWith (SupersetProof 'Regular s) k b

    refined-containers Data.Map.Refined

    Apply a function to all values in a map and collect only the Just results, returning a potentially smaller map.

  4. mapMaybe :: forall s k a b . (a -> Maybe b) -> Map s k a -> SomeMapWith (SupersetProof 'Regular s) k b

    refined-containers Data.Map.Strict.Refined

    Apply a function to all values in a map and collect only the Just results, returning a potentially smaller map.

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

    verset Verset

    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]
    

  6. type family MapMaybe (a1 :: a ~> Maybe b) (a2 :: [a]) :: [b]

    singletons-base Data.Maybe.Singletons

    No documentation available.

  7. mapMaybeMissing :: forall (f :: Type -> Type) x y . Applicative f => (Key -> x -> Maybe y) -> WhenMissing f x y

    containers Data.IntMap.Internal

    Map over the entries whose keys are missing from the other map, optionally removing some. This is the most powerful SimpleWhenMissing tactic, but others are usually more efficient.

    mapMaybeMissing :: (Key -> x -> Maybe y) -> SimpleWhenMissing x y
    
    mapMaybeMissing f = traverseMaybeMissing (\k x -> pure (f k x))
    
    but mapMaybeMissing uses fewer unnecessary Applicative operations.

  8. mapMaybeWithKey :: (Key -> a -> Maybe b) -> IntMap a -> IntMap b

    containers Data.IntMap.Internal

    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"
    

  9. mapMaybeWithKey :: (Key -> a -> Maybe b) -> IntMap a -> IntMap b

    containers Data.IntMap.Lazy

    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"
    

  10. mapMaybeMissing :: forall (f :: Type -> Type) x y . Applicative f => (Key -> x -> Maybe y) -> WhenMissing f x y

    containers Data.IntMap.Merge.Lazy

    Map over the entries whose keys are missing from the other map, optionally removing some. This is the most powerful SimpleWhenMissing tactic, but others are usually more efficient.

    mapMaybeMissing :: (Key -> x -> Maybe y) -> SimpleWhenMissing x y
    
    mapMaybeMissing f = traverseMaybeMissing (\k x -> pure (f k x))
    
    but mapMaybeMissing uses fewer unnecessary Applicative operations.

Page 13 of many | Previous | Next