Hoogle Search
Within LTS Haskell 24.26 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
mapMaybe :: (a -> Maybe b) -> [a] -> [b]basic-prelude CorePrelude 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]
mappend :: Monoid a => a -> a -> abasic-prelude CorePrelude 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.
mapAttrName :: AttrName -> AttrName -> AttrMap -> AttrMapbrick Brick.AttrMap Update an attribute map such that a lookup of ontoName returns the attribute value specified by fromName. This is useful for composite widgets with specific attribute names mapping those names to the sub-widget's expected name when calling that sub-widget's rendering function. See the ProgressBarDemo for an example usage, and overrideAttr for an alternate syntax.
mapAttrNames :: [(AttrName, AttrName)] -> AttrMap -> AttrMapbrick Brick.AttrMap Map several attributes to return the value associated with an alternate name. Applies mapAttrName across a list of mappings.
mapMaybe :: (a -> Maybe b) -> IMap a -> IMap bbrick Data.IMap No documentation available.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)classy-prelude ClassyPrelude Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see mapM_.
Examples
mapM is literally a traverse with a type signature restricted to Monad. Its implementation may be more efficient due to additional power of Monad.mapMaybe :: (a -> Maybe b) -> [a] -> [b]classy-prelude ClassyPrelude 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]
mappend :: Monoid a => a -> a -> aclassy-prelude ClassyPrelude 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.
mapAssocs :: Map key value -> Unfoldl (key, value)deferred-folds DeferredFolds.Unfoldl Associations of a map
mapFoldInput :: (forall x . () => Fold b x -> Fold a x) -> Unfoldl a -> Unfoldl bdeferred-folds DeferredFolds.Unfoldl Lift a fold input mapping function into a mapping of unfolds