module Control.Applicative.Extra
( orEmpty
, emptyIf
) where
import Control.Applicative (Alternative, empty)
orEmpty :: Alternative f => Bool -> a -> f a
orEmpty :: Bool -> a -> f a
orEmpty Bool
b a
a = if Bool
b then a -> f a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure a
a else f a
forall (f :: Type -> Type) a. Alternative f => f a
empty
emptyIf :: Alternative f => a -> Bool -> f a
emptyIf :: a -> Bool -> f a
emptyIf a
a Bool
b = if Bool
b then f a
forall (f :: Type -> Type) a. Alternative f => f a
empty else a -> f a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure a
a