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. maybeAt :: Int -> [a] -> Maybe a

    relude Relude.List

    !!? with its arguments flipped. Get element from list using index value starting from `0`.

    >>> maybeAt 0 []
    Nothing
    
    >>> maybeAt 3 ["a", "b", "c"]
    Nothing
    
    >>> maybeAt (-1) [1, 2, 3]
    Nothing
    
    >>> maybeAt 2 ["a", "b", "c"]
    Just "c"
    

  2. maybeToLeft :: r -> Maybe l -> Either l r

    relude Relude.Monad.Either

    Maps Maybe to Either wrapping default value into Right.

    >>> maybeToLeft True (Just "aba")
    Left "aba"
    
    >>> maybeToLeft True Nothing
    Right True
    

  3. maybeToRight :: l -> Maybe r -> Either l r

    relude Relude.Monad.Either

    Maps Maybe to Either wrapping default value into Left.

    >>> maybeToRight True (Just "aba")
    Right "aba"
    
    >>> maybeToRight True Nothing
    Left True
    

  4. maybeToExceptT :: forall (m :: Type -> Type) e a . Functor m => e -> MaybeT m a -> ExceptT e m a

    relude Relude.Monad.Reexport

    Convert a MaybeT computation to ExceptT, with a default exception value.

  5. maybeToList :: Maybe a -> [a]

    relude Relude.Monad.Reexport

    The maybeToList function returns an empty list when given Nothing or a singleton list when given Just.

    Examples

    Basic usage:
    >>> maybeToList (Just 7)
    [7]
    
    >>> maybeToList Nothing
    []
    
    One can use maybeToList to avoid pattern matching when combined with a function that (safely) works on lists:
    >>> import GHC.Internal.Text.Read ( readMaybe )
    
    >>> sum $ maybeToList (readMaybe "3")
    3
    
    >>> sum $ maybeToList (readMaybe "")
    0
    

  6. maybeToMonoid :: Monoid m => Maybe m -> m

    relude Relude.Monoid

    Extracts Monoid value from Maybe returning mempty if Nothing.

    >>> maybeToMonoid (Just [1,2,3] :: Maybe [Int])
    [1,2,3]
    
    >>> maybeToMonoid (Nothing :: Maybe [Int])
    []
    

  7. maybeF :: Buildable a => Maybe a -> Builder

    fmt Fmt

    Like build for Maybe, but displays Nothing as <Nothing> instead of an empty string. build:

    >>> build (Nothing :: Maybe Int)
    ""
    
    >>> build (Just 1 :: Maybe Int)
    "1"
    
    maybeF:
    >>> maybeF (Nothing :: Maybe Int)
    "<Nothing>"
    
    >>> maybeF (Just 1 :: Maybe Int)
    "1"
    

  8. maybeF :: Buildable a => Maybe a -> Builder

    fmt Fmt.Internal.Formatters

    Like build for Maybe, but displays Nothing as <Nothing> instead of an empty string. build:

    >>> build (Nothing :: Maybe Int)
    ""
    
    >>> build (Just 1 :: Maybe Int)
    "1"
    
    maybeF:
    >>> maybeF (Nothing :: Maybe Int)
    "<Nothing>"
    
    >>> maybeF (Just 1 :: Maybe Int)
    "1"
    

  9. maybeRead :: Read a => String -> Maybe a

    ghc-boot GHC.Settings.Utils

    No documentation available.

  10. maybeReadFuzzy :: Read a => String -> Maybe a

    ghc-boot GHC.Settings.Utils

    No documentation available.

Page 25 of many | Previous | Next