monad-choice-0.2.0.0: Monad, monad transformer, and typeclass representing choices.

Copyright(c) Eamon Olive 2020
(c) Louis Hyde 2020
LicenseAGPL-3
Maintainerejolive97@gmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Class.Choice

Description

 
Synopsis

Documentation

class Monad m => MonadChoice f m where Source #

A monad with a series of dependent choices. It is usually desirable to have f be a Foldable so that a selection can be made from it.

As an example here is a simple berry name generator:

berry :: MonadChoice NonEmpty m => m String
berry = do
  berryColor  <- choose $ "red"   :| ["blue", "orange", "yellow", "black"]
  berryFlavor <- choose $ "sweet" :| ["sour", "bitter"]
  (++ "berry") <$> choose ( berryColor :| [berryFlavor, berryColor ++ "-" ++ berryFlavor] )

Since this has a polymorphic type this could be used for a variety of purposes.

Methods

choose :: f a -> m a Source #

Makes a selection.

Instances
MonadChoice f m => MonadChoice f (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> MaybeT m a Source #

(Foldable f, MonadRandom m) => MonadChoice f (UniformRandom m) Source # 
Instance details

Defined in Control.Monad.Choice.Random

Methods

choose :: f a -> UniformRandom m a Source #

MonadChoice f m => MonadChoice f (SelectT r m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> SelectT r m a Source #

(Monoid w, MonadChoice f m) => MonadChoice f (AccumT w m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> AccumT w m a Source #

(Monoid w, MonadChoice f m) => MonadChoice f (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> WriterT w m a Source #

(Monoid w, MonadChoice f m) => MonadChoice f (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> WriterT w m a Source #

MonadChoice f m => MonadChoice f (StateT s m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> StateT s m a Source #

MonadChoice f m => MonadChoice f (StateT s m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> StateT s m a Source #

MonadChoice f m => MonadChoice f (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> IdentityT m a Source #

MonadChoice f m => MonadChoice f (ExceptT e m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> ExceptT e m a Source #

MonadChoice f (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Covariant

Methods

choose :: f a -> ChoiceT f m a Source #

Monad m => MonadChoice f (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

choose :: f a -> ChoiceT f m a Source #

MonadChoice f m => MonadChoice f (ContT r m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> ContT r m a Source #

MonadChoice f m => MonadChoice f (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> ReaderT r m a Source #

(Monoid w, MonadChoice f m) => MonadChoice f (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> RWST r w s m a Source #

(Monoid w, MonadChoice f m) => MonadChoice f (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Class.Choice

Methods

choose :: f a -> RWST r w s m a Source #

chooseM :: MonadChoice f m => f (m a) -> m a Source #

Makes a selection where options are themselves selections.