Hoogle Search
Within LTS Haskell 24.41 (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]incipit-base Incipit.Base 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]
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()incipit-base Incipit.Foldable 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.
-
incremental-parser Text.ParserCombinators.Incremental Converts a parser accepting one input type to another, just like 'mapMaybeInput except the two argument functions can demand more input by returning Nothing. If 'mapMaybeInput is defined for the two input inputs, then
mapInput f g == mapMaybeInput (Just . f) (Just . g)
-
incremental-parser Text.ParserCombinators.Incremental.LeftBiasedLocal Converts a parser accepting one input type to another, just like 'mapMaybeInput except the two argument functions can demand more input by returning Nothing. If 'mapMaybeInput is defined for the two input inputs, then
mapInput f g == mapMaybeInput (Just . f) (Just . g)
-
incremental-parser Text.ParserCombinators.Incremental.Symmetric Converts a parser accepting one input type to another, just like 'mapMaybeInput except the two argument functions can demand more input by returning Nothing. If 'mapMaybeInput is defined for the two input inputs, then
mapInput f g == mapMaybeInput (Just . f) (Just . g)
mapMSEnv :: Monad m => (a -> m b) -> SEnv a -> m (SEnv b)liquid-fixpoint Language.Fixpoint.Types.Environments No documentation available.
mapMExpr :: Monad m => (Expr -> m Expr) -> Expr -> m Exprliquid-fixpoint Language.Fixpoint.Types.Visitor No documentation available.
-
liquidhaskell-boot Language.Haskell.Liquid.Types.Names No documentation available.
mapMeasureTy :: (ty0 -> ty1) -> MeasureV v ty0 ctor -> MeasureV v ty1 ctorliquidhaskell-boot Language.Haskell.Liquid.Types.Types No documentation available.
mapMeasureV :: (v -> v') -> MeasureV v ty ctor -> MeasureV v' ty ctorliquidhaskell-boot Language.Haskell.Liquid.Types.Types No documentation available.