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.

  1. mapMaybeWithKey :: GCompare k2 => (forall (v :: k1) . () => k2 v -> f v -> Maybe (g v)) -> MonoidalDMap k2 f -> MonoidalDMap k2 g

    dependent-monoidal-map Data.Dependent.Map.Monoidal

    O(n). Map keys/values and collect the Just results.

  2. fromMaybe :: a -> Maybe a -> a

    distribution-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
    

  3. fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a

    distribution-opensuse OpenSuse.Prelude

    Monadic generalisation of fromMaybe.

  4. mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]

    distribution-opensuse OpenSuse.Prelude

    A version of mapMaybe that works with a monadic predicate.

  5. 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
    

  6. whenMaybeM :: Monad m => m Bool -> m a -> m (Maybe a)

    distribution-opensuse OpenSuse.Prelude

    Like whenMaybe, but where the test can be monadic.

  7. toMaybe :: Bool -> a -> Maybe a

    dsp DSP.Basic

    generates a Just if the given condition holds

  8. 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.)

  9. catchMaybe :: forall (m :: Type -> Type) a b . (Functor m, Monad m) => MSF (MaybeT m) a b -> MSF m a b -> MSF m a b

    dunai Control.Monad.Trans.MSF.Maybe

    When an exception occurs in the first msf, the second msf is executed from there.

  10. exceptToMaybeS :: forall (m :: Type -> Type) e a b . (Functor m, Monad m) => MSF (ExceptT e m) a b -> MSF (MaybeT m) a b

    dunai Control.Monad.Trans.MSF.Maybe

    Convert exceptions into Nothing, discarding the exception value.

Page 267 of many | Previous | Next