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. fromMaybeMM :: Monad m => m a -> m (Maybe a) -> m a

    from-sum Control.FromSum

    Similar to fromMaybeM but the Maybe argument is also a monadic value.

    >>> fromMaybeMM [] [Just 6, Just 5]
    [6,5]
    
    >>> fromMaybeMM [] [Just 6, Nothing, Just 7]
    [6,7]
    
    NOTE: I don't particularly like the name of this function. If you have a suggestion for a better name, please submit a PR or issue.

  2. fromMaybeM_ :: (Applicative m, Monoid b) => m b -> Maybe a -> m b

    from-sum Control.FromSum

    Similar to fromMaybeM, but only run the monadic nothingAction if the Maybe argument is Nothing. Otherwise, return pure mempty.

    fromMaybeM_ nothingAction === maybe nothingAction (const $ pure mempty)
    
    >>> fromMaybeM_ (putStrLn "hello" >> pure "bye") $ Just 5
    ""
    
    >>> fromMaybeM_ (putStrLn "hello" >> pure "bye") Nothing
    hello
    "bye"
    
    This can be convenient when you want to run some sort of logging function whenever a Maybe is Nothing. If you imagine the logging function is IO (), then the effective type of fromMaybeM_ becomes fromMaybeM_ :: IO () -> Maybe a -> IO (), because () has a Monoid instance, and IO, has an Applicative instance.
    >>> fromMaybeM_ (putStrLn "hello") Nothing
    hello
    

  3. fromMaybeOr :: Maybe a -> a -> a

    from-sum Control.FromSum

    A fliped version of fromMaybe.

  4. fromMaybeOrExceptT :: forall (m :: Type -> Type) a x . Monad m => Maybe a -> x -> ExceptT x m a

    from-sum Control.FromSum

    Just like fromMaybeExceptT but with the arguments flipped.

  5. fromMaybeOrM :: Applicative m => Maybe a -> m a -> m a

    from-sum Control.FromSum

    A fliped version of fromMaybeM.

    >>> fromMaybeOrM (Just 5) []
    [5]
    
    This can be nice to use as an error handler.
    >>> fromMaybeOrM (Just 5) $ putStrLn "some error occurred" >> undefined
    5
    
    >>> fromMaybeOrM (Nothing) $ putStrLn "some error occurred" >> undefined
    some error occurred
    ...
    

  6. fromMaybeOrMExceptT :: Monad m => m (Maybe a) -> x -> ExceptT x m a

    from-sum Control.FromSum

    Just like fromMaybeMExceptT but with the arguments flipped.

  7. fromMaybeOrMM :: Monad m => m (Maybe a) -> m a -> m a

    from-sum Control.FromSum

    A fliped version of fromMaybeMM.

  8. fromMaybeOrM_ :: (Applicative m, Monoid b) => Maybe a -> m b -> m b

    from-sum Control.FromSum

    A fliped version of fromMaybeM.

  9. parseFrontmatterMaybe :: ByteString -> Maybe ByteString

    frontmatter Data.Frontmatter

    parseFrontmatter but returning a Maybe

  10. parseYamlFrontmatterMaybe :: FromJSON a => ByteString -> Maybe a

    frontmatter Data.Frontmatter

    parseYamlFrontmatter but returning a Maybe

Page 270 of many | Previous | Next