module Control.Effect.NonDet
(
NonDet(..)
, Cull(..)
, Cut(..)
, Split(..)
, Logic
, choose
, lose
, fromList
, cull
, cutfail
, cut
, call
, split
, runNonDet
, runNonDet1
, runCullCut
, runLogic
, NonDetThreads
, NonDetC
, CullCutC
, LogicC
) where
import Control.Monad
import Control.Effect
import Control.Effect.Internal.NonDet
import Control.Effect.Internal.Utils
import Control.Effect.Type.Split
fromList :: Eff NonDet m => [a] -> m a
fromList :: [a] -> m a
fromList = NonDet m a -> m a
forall (e :: Effect) (m :: * -> *) a.
(Member e (Derivs m), Carrier m) =>
e m a -> m a
send (NonDet m a -> m a) -> ([a] -> NonDet m a) -> [a] -> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# [a] -> NonDet m a
forall a (m :: * -> *). [a] -> NonDet m a
FromList
choose :: Eff NonDet m => m a -> m a -> m a
choose :: m a -> m a -> m a
choose m a
ma m a
mb = m (m a) -> m a
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (m (m a) -> m a) -> m (m a) -> m a
forall a b. (a -> b) -> a -> b
$ [m a] -> m (m a)
forall (m :: * -> *) a. Eff NonDet m => [a] -> m a
fromList [m a
ma, m a
mb]
{-# INLINE choose #-}
lose :: Eff NonDet m => m a
lose :: m a
lose = [a] -> m a
forall (m :: * -> *) a. Eff NonDet m => [a] -> m a
fromList []
{-# INLINE lose #-}
cull :: Eff Cull m => m a -> m a
cull :: m a -> m a
cull = Cull m a -> m a
forall (e :: Effect) (m :: * -> *) a.
(Member e (Derivs m), Carrier m) =>
e m a -> m a
send (Cull m a -> m a) -> (m a -> Cull m a) -> m a -> m a
forall b a c. Coercible b a => (b -> c) -> (a -> b) -> a -> c
.# m a -> Cull m a
forall (m :: * -> *) a. m a -> Cull m a
Cull
{-# INLINE cull #-}
cutfail :: Eff Cut m => m a
cutfail :: m a
cutfail = Cut m a -> m a
forall (e :: Effect) (m :: * -> *) a.
(Member e (Derivs m), Carrier m) =>
e m a -> m a
send Cut m a
forall (m :: * -> *) a. Cut m a
Cutfail
{-# INLINE cutfail #-}
cut :: Effs '[NonDet, Cut] m => m ()
cut :: m ()
cut = () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure () m () -> m () -> m ()
forall (m :: * -> *) a. Eff NonDet m => m a -> m a -> m a
`choose` m ()
forall (m :: * -> *) a. Eff Cut m => m a
cutfail
{-# INLINE cut #-}
call :: Eff Cut m => m a -> m a
call :: m a -> m a
call = Cut m a -> m a
forall (e :: Effect) (m :: * -> *) a.
(Member e (Derivs m), Carrier m) =>
e m a -> m a
send (Cut m a -> m a) -> (m a -> Cut m a) -> m a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a -> Cut m a
forall (m :: * -> *) a. m a -> Cut m a
Call
{-# INLINE call #-}
split :: Eff Split m => m a -> m (Maybe (a, m a))
split :: m a -> m (Maybe (a, m a))
split = Split m (Maybe (a, m a)) -> m (Maybe (a, m a))
forall (e :: Effect) (m :: * -> *) a.
(Member e (Derivs m), Carrier m) =>
e m a -> m a
send (Split m (Maybe (a, m a)) -> m (Maybe (a, m a)))
-> (m a -> Split m (Maybe (a, m a))) -> m a -> m (Maybe (a, m a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe (a, m a) -> Maybe (a, m a))
-> m a -> Split m (Maybe (a, m a))
forall a (m :: * -> *) b. (Maybe (a, m a) -> b) -> m a -> Split m b
Split Maybe (a, m a) -> Maybe (a, m a)
forall a. a -> a
id
{-# INLINE split #-}