monad-choice-0.1.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.Trans.Choice.Invariant

Description

 
Synopsis

Documentation

newtype ChoiceT f m a Source #

The choice monad transformer It takes a monad and enriches it with choice.

Constructors

ChoiceT ((forall x. f x -> m x) -> m a) 
Instances
MonadWriter w m => MonadWriter w (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

writer :: (a, w) -> ChoiceT f m a #

tell :: w -> ChoiceT f m () #

listen :: ChoiceT f m a -> ChoiceT f m (a, w) #

pass :: ChoiceT f m (a, w -> w) -> ChoiceT f m a #

MonadState s m => MonadState s (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

get :: ChoiceT f m s #

put :: s -> ChoiceT f m () #

state :: (s -> (a, s)) -> ChoiceT f m a #

MonadReader r m => MonadReader r (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

ask :: ChoiceT f m r #

local :: (r -> r) -> ChoiceT f m a -> ChoiceT f m a #

reader :: (r -> a) -> ChoiceT f m a #

MonadError e m => MonadError e (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

throwError :: e -> ChoiceT f m a #

catchError :: ChoiceT f m a -> (e -> ChoiceT f m a) -> ChoiceT f m a #

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 #

MonadTrans (ChoiceT f) Source #

ChoiceT is a functor on the category of monads. However it is an invariant functor. Meaning the traditional mapChoiceT cannot be implemented.

Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

lift :: Monad m => m a -> ChoiceT f m a #

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

Defined in Control.Monad.Trans.Choice.Invariant

Methods

(>>=) :: ChoiceT f m a -> (a -> ChoiceT f m b) -> ChoiceT f m b #

(>>) :: ChoiceT f m a -> ChoiceT f m b -> ChoiceT f m b #

return :: a -> ChoiceT f m a #

fail :: String -> ChoiceT f m a #

Functor m => Functor (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

fmap :: (a -> b) -> ChoiceT f m a -> ChoiceT f m b #

(<$) :: a -> ChoiceT f m b -> ChoiceT f m a #

Applicative m => Applicative (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

pure :: a -> ChoiceT f m a #

(<*>) :: ChoiceT f m (a -> b) -> ChoiceT f m a -> ChoiceT f m b #

liftA2 :: (a -> b -> c) -> ChoiceT f m a -> ChoiceT f m b -> ChoiceT f m c #

(*>) :: ChoiceT f m a -> ChoiceT f m b -> ChoiceT f m b #

(<*) :: ChoiceT f m a -> ChoiceT f m b -> ChoiceT f m a #

MonadPlus m => MonadPlus (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

mzero :: ChoiceT f m a #

mplus :: ChoiceT f m a -> ChoiceT f m a -> ChoiceT f m a #

MonadIO m => MonadIO (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

liftIO :: IO a -> ChoiceT f m a #

Contravariant m => Contravariant (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

contramap :: (a -> b) -> ChoiceT f m b -> ChoiceT f m a #

(>$) :: b -> ChoiceT f m b -> ChoiceT f m a #

Alternative m => Alternative (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

empty :: ChoiceT f m a #

(<|>) :: ChoiceT f m a -> ChoiceT f m a -> ChoiceT f m a #

some :: ChoiceT f m a -> ChoiceT f m [a] #

many :: ChoiceT f m a -> ChoiceT f m [a] #

Invariant m => Invariant (ChoiceT f m) Source # 
Instance details

Defined in Control.Monad.Trans.Choice.Invariant

Methods

invmap :: (a -> b) -> (b -> a) -> ChoiceT f m a -> ChoiceT f m b #

runChoiceT Source #

Arguments

:: (forall x. f x -> m x)

A chooser which can perform selections over fs containing arbitrary xs. This will be used to determine the result of each selection.

This type proves the theorem :

chooser (fmap f x) = fmap f (chooser x)
-> ChoiceT f m a

A monad transformed by ChoiceT to contain choices

-> m a

The initial monad with the ChoiceT removed and thus the choices resolved.

Use a chooser to perform all the selections of a ChoiceT. This uses a sensible argument order unlike many of the other monad transformers.

invmapChoiceT :: (forall x. n x -> m x) -> (m a -> n b) -> ChoiceT f m a -> ChoiceT f n b Source #

Transforms the computation inside the ChoiceT. This function differs from other map functions over the monads in monad transformers in that it requires an additional function of type forall x . n x -> m x. This is because ChoiceT is not a covariant functor over the category of monads, but rather an invariant functor.