Hoogle Search

Within LTS Haskell 22.22 (ghc-9.6.5)

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

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

    basement Basement.Compat.Base

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

    basement Basement.Imports

    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 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. maybe :: b -> (a -> b) -> Maybe a -> b

    relude Relude.Monad.Reexport

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

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

    Cabal-syntax Distribution.Compat.Prelude

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

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

    ghc-lib-parser GHC.Prelude.Basic

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

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

    classy-prelude ClassyPrelude

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

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

    numeric-prelude NumericPrelude

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

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

    numeric-prelude NumericPrelude.Base

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

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

    protolude Protolude

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

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

    basic-prelude CorePrelude

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

Page 2 of many | Previous | Next