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 = (a -> m a) -> t a -> m a
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Alternative m) =>
(a -> m b) -> t a -> m b
foldMapA a -> m a
forall a. a -> m a
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 = Alt m b -> m b
forall {k} (f :: k -> *) (a :: k). Alt f a -> f a
getAlt (Alt m b -> m b) -> (t a -> Alt m b) -> t a -> m b
forall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c
#. (a -> Alt m b) -> t a -> Alt m b
forall m a. Monoid m => (a -> m) -> t a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (m b -> Alt m b
forall {k} (f :: k -> *) (a :: k). f a -> Alt f a
Alt (m b -> Alt m b) -> (a -> m b) -> a -> Alt m b
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
_ = (a -> b) -> a -> c
forall a b. Coercible a b => a -> b
coerce
{-# INLINE (#.) #-}