{- | An effect modelling nondeterminism without choice (success or failure). This can be seen as similar to 'Control.Effect.Fail.Fail', but without an error message. The 'Control.Effect.NonDet.NonDet' effect is the composition of 'Empty' and 'Control.Effect.Choose.Choose'. Predefined carriers: * "Control.Carrier.Empty.Maybe". * If 'Empty' is the last effect in a stack, it can be interpreted directly to a 'Maybe'. @since 1.0.0.0 -} module Control.Effect.Empty ( -- * Empty effect Empty(..) , empty , guard -- * Re-exports , Algebra , Effect , Has , run ) where import Control.Algebra import Control.Effect.Empty.Internal (Empty(..)) -- | Abort the computation. -- -- 'empty' annihilates '>>=': -- -- @ -- 'empty' '>>=' k = 'empty' -- @ -- -- @since 1.0.0.0 empty :: Has Empty sig m => m a empty :: m a empty = Empty m a -> m a forall (eff :: (* -> *) -> * -> *) (sig :: (* -> *) -> * -> *) (m :: * -> *) a. (Member eff sig, Algebra sig m) => eff m a -> m a send Empty m a forall (m :: * -> *) k. Empty m k Empty -- | Conditional failure, returning only if the condition is 'True'. -- -- @since 1.0.0.0 guard :: Has Empty sig m => Bool -> m () guard :: Bool -> m () guard True = () -> m () forall (f :: * -> *) a. Applicative f => a -> f a pure () guard False = m () forall (sig :: (* -> *) -> * -> *) (m :: * -> *) a. Has Empty sig m => m a empty