Hoogle Search

Within LTS Haskell 24.4 (ghc-9.10.2)

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

  1. maybe :: b -> (a -> b) -> Maybe a -> b

    verset Verset

    The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing, the function returns the default value. Otherwise, it applies the function to the value inside the Just and returns the result.

    Examples

    Basic usage:
    >>> maybe False odd (Just 3)
    True
    
    >>> maybe False odd Nothing
    False
    
    Read an integer from a string using readMaybe. If we succeed, return twice the integer; that is, apply (*2) to it. If instead we fail to parse an integer, return 0 by default:
    >>> import GHC.Internal.Text.Read ( readMaybe )
    
    >>> maybe 0 (*2) (readMaybe "5")
    10
    
    >>> maybe 0 (*2) (readMaybe "")
    0
    
    Apply show to a Maybe Int. If we have Just n, we want to show the underlying Int n. But if we have Nothing, we return the empty string instead of (for example) "Nothing":
    >>> maybe "" show (Just 5)
    "5"
    
    >>> maybe "" show Nothing
    ""
    

  2. maybe :: b -> (a -> b) -> Maybe a -> b

    xmonad-contrib XMonad.Config.Prime

    The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing, the function returns the default value. Otherwise, it applies the function to the value inside the Just and returns the result.

    Examples

    Basic usage:
    >>> maybe False odd (Just 3)
    True
    
    >>> maybe False odd Nothing
    False
    
    Read an integer from a string using readMaybe. If we succeed, return twice the integer; that is, apply (*2) to it. If instead we fail to parse an integer, return 0 by default:
    >>> import GHC.Internal.Text.Read ( readMaybe )
    
    >>> maybe 0 (*2) (readMaybe "5")
    10
    
    >>> maybe 0 (*2) (readMaybe "")
    0
    
    Apply show to a Maybe Int. If we have Just n, we want to show the underlying Int n. But if we have Nothing, we return the empty string instead of (for example) "Nothing":
    >>> maybe "" show (Just 5)
    "5"
    
    >>> maybe "" show Nothing
    ""
    

  3. data Maybe a

    base Prelude

    The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error. The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.

  4. module Data.Maybe

    The Maybe type, and associated operations.

  5. data Maybe a

    base Data.Maybe

    The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error. The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.

  6. module GHC.Maybe

    The Maybe type.

  7. data Maybe a

    base GHC.Maybe

    The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error. The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.

  8. module Control.Monad.Trans.Maybe

    The MaybeT monad transformer extends a monad with the ability to exit the computation without returning a value. A sequence of actions produces a value only if all the actions in the sequence do. If one exits, the rest of the sequence is skipped and the composite action exits. For a variant allowing a range of exception values, see Control.Monad.Trans.Except.

  9. data Maybe a

    hedgehog Hedgehog.Internal.Prelude

    The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error. The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing. A richer error monad can be built using the Either type.

  10. module GHC.Data.Maybe

    No documentation available.

Page 6 of many | Previous | Next