extensible-effects-4.0.0.0: An Alternative to Monad Transformers

Safe HaskellSafe
LanguageHaskell2010

Control.Eff.NdetEff

Contents

Description

Another implementation of nondeterministic choice effect

Synopsis

Documentation

data NdetEff a Source #

A different implementation, more directly mapping to MonadPlus interface

Instances
(MonadBase m m, LiftedBase m r) => MonadBaseControl m (Eff (NdetEff ': r)) Source # 
Instance details

Defined in Control.Eff.NdetEff

Associated Types

type StM (Eff (NdetEff ': r)) a :: Type #

Methods

liftBaseWith :: (RunInBase (Eff (NdetEff ': r)) m -> m a) -> Eff (NdetEff ': r) a #

restoreM :: StM (Eff (NdetEff ': r)) a -> Eff (NdetEff ': r) a #

(Alternative f, Monad m) => Handle NdetEff (m (f a)) Source #

Given a callback and NdetEff requests respond to them

Instance details

Defined in Control.Eff.NdetEff

Methods

handle :: (v -> m (f a)) -> NdetEff v -> m (f a) Source #

type StM (Eff (NdetEff ': r)) a Source # 
Instance details

Defined in Control.Eff.NdetEff

type StM (Eff (NdetEff ': r)) a = StM (Eff r) [a]

withNdetEff :: Alternative f => Monad m => a -> m (f a) Source #

How to embed a pure value in non-deterministic context

left :: (Bool -> k) -> k Source #

The left branch

right :: (Bool -> k) -> k Source #

The right branch

makeChoiceA :: Alternative f => Eff (NdetEff ': r) a -> Eff r (f a) Source #

A different implementation, more involved but faster and taking much less (100 times) less memory. The benefit of the effect framework is that we can have many interpreters.

makeChoiceA0 :: Alternative f => Eff (NdetEff ': r) a -> Eff r (f a) Source #

An interpreter The following is very simple, but leaks a lot of memory The cause probably is mapping every failure to empty It takes then a lot of timne and space to store those empty

makeChoiceLst :: Eff (NdetEff ': r) a -> Eff r [a] Source #

Same as makeChoiceA, except it has the type hardcoded. Required for MonadBaseControl instance.

msplit1 :: Member NdetEff r => Eff r a -> Eff r (Maybe (a, Eff r a)) Source #

A different implementation, more involved. Unclear whether this is faster or not.

Orphan instances

Member NdetEff r => Alternative (Eff r) Source # 
Instance details

Methods

empty :: Eff r a #

(<|>) :: Eff r a -> Eff r a -> Eff r a #

some :: Eff r a -> Eff r [a] #

many :: Eff r a -> Eff r [a] #

Member NdetEff r => MonadPlus (Eff r) Source # 
Instance details

Methods

mzero :: Eff r a #

mplus :: Eff r a -> Eff r a -> Eff r a #

Member NdetEff r => MSplit (Eff r) Source #

We actually implement LogicT, the non-determinism reflection, of which soft-cut is one instance. Straightforward implementation using respond_relay. See the LogicT paper for an explanation.

Instance details

Methods

msplit :: Eff r a -> Eff r (Maybe (a, Eff r a)) Source #