module Control.Effect.NonDet
(
NonDet
, module Control.Effect.Choose
, module Control.Effect.Empty
, oneOf
, foldMapA
, Alternative(..)
, Algebra
, Has
, MonadPlus(..)
, guard
, optional
, run
) where
import Control.Algebra
import Control.Applicative (Alternative(..), optional)
import Control.Effect.Choose (Choose(..))
import Control.Effect.Empty (Empty(..))
import Control.Effect.NonDet.Internal (NonDet)
import Control.Monad (MonadPlus(..), guard)
import Data.Coerce
import Data.Monoid (Alt(..))
oneOf :: (Foldable t, Alternative m) => t a -> m a
oneOf :: forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, Alternative m) =>
t a -> m a
oneOf = forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Alternative m) =>
(a -> m b) -> t a -> m b
foldMapA forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE oneOf #-}
foldMapA :: (Foldable t, Alternative m) => (a -> m b) -> t a -> m b
foldMapA :: forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Alternative m) =>
(a -> m b) -> t a -> m b
foldMapA a -> m b
f = forall {k} (f :: k -> *) (a :: k). Alt f a -> f a
getAlt forall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c
#. forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (forall {k} (f :: k -> *) (a :: k). f a -> Alt f a
Alt forall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c
#. a -> m b
f)
{-# INLINE foldMapA #-}
(#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c)
#. :: forall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c
(#.) b -> c
_ = coerce :: forall a b. Coercible a b => a -> b
coerce
{-# INLINE (#.) #-}