extensible-effects-2.5.1.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 where Source #

A different implementation, more directly mapping to MonadPlus interface

Constructors

MZero :: NdetEff a 
MPlus :: NdetEff Bool 

Instances

(MonadBase m m, SetMember (* -> *) (Lift *) (Lift * m) r, MonadBaseControl m (Eff r)) => MonadBaseControl m (Eff ((:) (* -> *) NdetEff r)) Source # 

Associated Types

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

Methods

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

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

type StM (Eff ((:) (* -> *) NdetEff r)) a Source # 
type StM (Eff ((:) (* -> *) NdetEff r)) a = StM (Eff r) [a]

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

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.

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

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

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

ifte :: Member NdetEff r => Eff r a -> (a -> Eff r b) -> Eff r b -> Eff r b Source #

once :: Member NdetEff r => Eff r a -> Eff r a Source #

Orphan instances

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

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 # 

Methods

mzero :: Eff r a #

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