module Data.Maybe.HT where
import Data.Maybe (fromMaybe, )
import Control.Monad (msum, )
{-# INLINE toMaybe #-}
toMaybe :: Bool -> a -> Maybe a
toMaybe :: forall a. Bool -> a -> Maybe a
toMaybe Bool
False a
_ = forall a. Maybe a
Nothing
toMaybe Bool
True a
x = forall a. a -> Maybe a
Just a
x
infixl 6 ?->
(?->) :: Maybe a -> (a -> b) -> Maybe b
?-> :: forall a b. Maybe a -> (a -> b) -> Maybe b
(?->) = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
alternatives :: a -> [Maybe a] -> a
alternatives :: forall a. a -> [Maybe a] -> a
alternatives a
deflt = forall a. a -> Maybe a -> a
fromMaybe a
deflt forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum