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.
fromMaybeMM :: Monad m => m a -> m (Maybe a) -> m afrom-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.fromMaybeM_ :: (Applicative m, Monoid b) => m b -> Maybe a -> m bfrom-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
fromMaybeOr :: Maybe a -> a -> afrom-sum Control.FromSum fromMaybeOrExceptT :: forall (m :: Type -> Type) a x . Monad m => Maybe a -> x -> ExceptT x m afrom-sum Control.FromSum Just like fromMaybeExceptT but with the arguments flipped.
fromMaybeOrM :: Applicative m => Maybe a -> m a -> m afrom-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 ...
fromMaybeOrMExceptT :: Monad m => m (Maybe a) -> x -> ExceptT x m afrom-sum Control.FromSum Just like fromMaybeMExceptT but with the arguments flipped.
fromMaybeOrMM :: Monad m => m (Maybe a) -> m a -> m afrom-sum Control.FromSum A fliped version of fromMaybeMM.
fromMaybeOrM_ :: (Applicative m, Monoid b) => Maybe a -> m b -> m bfrom-sum Control.FromSum A fliped version of fromMaybeM.
parseFrontmatterMaybe :: ByteString -> Maybe ByteStringfrontmatter Data.Frontmatter parseFrontmatter but returning a Maybe
parseYamlFrontmatterMaybe :: FromJSON a => ByteString -> Maybe afrontmatter Data.Frontmatter parseYamlFrontmatter but returning a Maybe