Control.Monad.Trans.Select

transformers-0.5.5.0: Concrete functor and monad transformers

Copyright | (c) Ross Paterson 2017
License | BSD-style (see the file LICENSE)
Maintainer | R.Paterson@city.ac.uk
Stability | experimental
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Control.Monad.Trans.Select

Contents

- The Select monad
- The SelectT monad transformer
- Monad transformation

Description

Selection monad transformer, modelling search algorithms.

- Martin Escardo and Paulo Oliva. "Selection functions, bar recursion and backward induction", Mathematical Structures in Computer Science 20:2 (2010), pp. 127-168. https://www.cs.bham.ac.uk/~mhe/papers/selection-escardo-oliva.pdf
- Jules Hedges. "Monad transformers for backtracking search". In Proceedings of MSFP 2014. https://arxiv.org/abs/1406.2058

Synopsis

- type Select r = SelectT r Identity
- select :: ((a -> r) -> a) -> Select r a
- runSelect :: Select r a -> (a -> r) -> a
- mapSelect :: (a -> a) -> Select r a -> Select r a
- newtype SelectT r m a = SelectT ((a -> m r) -> m a)
- runSelectT :: SelectT r m a -> (a -> m r) -> m a
- mapSelectT :: (m a -> m a) -> SelectT r m a -> SelectT r m a
- selectToContT :: Monad m => SelectT r m a -> ContT r m a
- selectToCont :: Monad m => SelectT r m a -> ContT r m a

# The Select monad

type Select r = SelectT r Identity #

Selection monad.

select :: ((a -> r) -> a) -> Select r a #

Constructor for computations in the selection monad.

runSelect :: Select r a -> (a -> r) -> a #

Runs a `Select` computation with a function for evaluating answers to select a particular answer. (The inverse of `select`.)

mapSelect :: (a -> a) -> Select r a -> Select r a #

Apply a function to transform the result of a selection computation.

-     runSelect (mapSelect f m) = f . runSelect m

# The SelectT monad transformer

newtype SelectT r m a #

Selection monad transformer.

`SelectT` is not a functor on the category of monads, and many operations cannot be lifted through it.

Constructors

SelectT ((a -> m r) -> m a) |

Instances

MonadTrans (SelectT r) # |
Instance details Defined in Control.Monad.Trans.Select Methods lift :: Monad m => m a -> SelectT r m a #
Monad m => Monad (SelectT r m) # |
Instance details Defined in Control.Monad.Trans.Select Methods (>>=) :: SelectT r m a -> (a -> SelectT r m b) -> SelectT r m b Source # (>>) :: SelectT r m a -> SelectT r m b -> SelectT r m b Source # return :: a -> SelectT r m a Source # fail :: String -> SelectT r m a Source #
Functor m => Functor (SelectT r m) # |
Instance details Defined in Control.Monad.Trans.Select Methods fmap :: (a -> b) -> SelectT r m a -> SelectT r m b Source # (<$) :: a -> SelectT r m b -> SelectT r m a Source #
MonadFail m => MonadFail (SelectT r m) # |
Instance details Defined in Control.Monad.Trans.Select Methods fail :: String -> SelectT r m a Source #
(Functor m, Monad m) => Applicative (SelectT r m) # |
Instance details Defined in Control.Monad.Trans.Select Methods pure :: a -> SelectT r m a Source # (<*>) :: SelectT r m (a -> b) -> SelectT r m a -> SelectT r m b Source # liftA2 :: (a -> b -> c) -> SelectT r m a -> SelectT r m b -> SelectT r m c Source # (*>) :: SelectT r m a -> SelectT r m b -> SelectT r m b Source # (<*) :: SelectT r m a -> SelectT r m b -> SelectT r m a Source #
MonadIO m => MonadIO (SelectT r m) # |
Instance details Defined in Control.Monad.Trans.Select Methods liftIO :: IO a -> SelectT r m a Source #
(Functor m, MonadPlus m) => Alternative (SelectT r m) # |
Instance details Defined in Control.Monad.Trans.Select Methods empty :: SelectT r m a Source # (<|>) :: SelectT r m a -> SelectT r m a -> SelectT r m a Source # some :: SelectT r m a -> SelectT r m [a] Source # many :: SelectT r m a -> SelectT r m [a] Source #
MonadPlus m => MonadPlus (SelectT r m) # |
Instance details Defined in Control.Monad.Trans.Select Methods mzero :: SelectT r m a Source # mplus :: SelectT r m a -> SelectT r m a -> SelectT r m a Source #

runSelectT :: SelectT r m a -> (a -> m r) -> m a #

Runs a `SelectT` computation with a function for evaluating answers to select a particular answer. (The inverse of `select`.)

mapSelectT :: (m a -> m a) -> SelectT r m a -> SelectT r m a #

Apply a function to transform the result of a selection computation. This has a more restricted type than the `map` operations for other monad transformers, because `SelectT` does not define a functor in the category of monads.

-     runSelectT (mapSelectT f m) = f . runSelectT m

# Monad transformation

selectToContT :: Monad m => SelectT r m a -> ContT r m a #

Convert a selection computation to a continuation-passing computation.

selectToCont :: Monad m => SelectT r m a -> ContT r m a #

Deprecated: Use selectToContT instead

Deprecated name for `selectToContT`.