Hoogle Search
Within LTS Haskell 24.39 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
dependent-monoidal-map Data.Dependent.Map.Monoidal O(n). Map keys/values and collect the Just results.
fromMaybe :: a -> Maybe a -> adistribution-opensuse OpenSuse.Prelude The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.
Examples
Basic usage:>>> fromMaybe "" (Just "Hello, World!") "Hello, World!"
>>> fromMaybe "" Nothing ""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:>>> import GHC.Internal.Text.Read ( readMaybe ) >>> fromMaybe 0 (readMaybe "5") 5 >>> fromMaybe 0 (readMaybe "") 0
fromMaybeM :: Monad m => m a -> m (Maybe a) -> m adistribution-opensuse OpenSuse.Prelude Monadic generalisation of fromMaybe.
mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]distribution-opensuse OpenSuse.Prelude A version of mapMaybe that works with a monadic predicate.
whenMaybe :: Applicative m => Bool -> m a -> m (Maybe a)distribution-opensuse OpenSuse.Prelude Like when, but return either Nothing if the predicate was False, or Just with the result of the computation.
whenMaybe True (print 1) == fmap Just (print 1) whenMaybe False (print 1) == pure Nothing
whenMaybeM :: Monad m => m Bool -> m a -> m (Maybe a)distribution-opensuse OpenSuse.Prelude Like whenMaybe, but where the test can be monadic.
toMaybe :: Bool -> a -> Maybe adsp DSP.Basic generates a Just if the given condition holds
throwMaybe :: forall (m :: Type -> Type) e a . Monad m => MSF (ExceptT e m) (Maybe e) (Maybe a)dunai Control.Monad.Trans.MSF.Except When the input is Just e, throw the exception e. (Does not output any actual data.)
-
dunai Control.Monad.Trans.MSF.Maybe When an exception occurs in the first msf, the second msf is executed from there.
-
dunai Control.Monad.Trans.MSF.Maybe Convert exceptions into Nothing, discarding the exception value.