Portability | non-portable (multi-parameter type classes) |
---|---|
Stability | experimental |
Maintainer | dan.doel@gmail.com |
Safe Haskell | Safe-Inferred |
A backtracking, logic programming monad.
Adapted from the paper /Backtracking, Interleaving, and Terminating Monad Transformers/, by Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, Amr Sabry (http://www.cs.rutgers.edu/~ccshan/logicprog/LogicT-icfp2005.pdf).
- module Control.Monad.Logic.Class
- type Logic = LogicT Identity
- logic :: (forall r. (a -> r -> r) -> r -> r) -> Logic a
- runLogic :: Logic a -> (a -> r -> r) -> r -> r
- observe :: Logic a -> a
- observeMany :: Int -> Logic a -> [a]
- observeAll :: Logic a -> [a]
- newtype LogicT m a = LogicT {
- unLogicT :: forall r. (a -> m r -> m r) -> m r -> m r
- runLogicT :: LogicT m a -> (a -> m r -> m r) -> m r -> m r
- observeT :: Monad m => LogicT m a -> m a
- observeManyT :: Monad m => Int -> LogicT m a -> m [a]
- observeAllT :: Monad m => LogicT m a -> m [a]
- module Control.Monad
- module Control.Monad.Trans
Documentation
module Control.Monad.Logic.Class
The Logic monad
type Logic = LogicT IdentitySource
The basic Logic monad, for performing backtracking computations
returning values of type a
logic :: (forall r. (a -> r -> r) -> r -> r) -> Logic aSource
A smart constructor for Logic computations.
runLogic :: Logic a -> (a -> r -> r) -> r -> rSource
Runs a Logic computation with the specified initial success and failure continuations.
observeMany :: Int -> Logic a -> [a]Source
Extracts up to a given number of results from a Logic computation.
observeAll :: Logic a -> [a]Source
Extracts all results from a Logic computation.
The LogicT monad transformer
A monad transformer for performing backtracking computations
layered over another monad m
MonadTrans LogicT | |
(Monad (LogicT m), MonadError e m) => MonadError e (LogicT m) | |
(Monad (LogicT m), MonadReader r m) => MonadReader r (LogicT m) | |
(Monad (LogicT m), MonadState s m) => MonadState s (LogicT m) | |
Monad (LogicT m) | |
Functor (LogicT f) | |
Monad (LogicT m) => MonadPlus (LogicT m) | |
Functor (LogicT f) => Applicative (LogicT f) | |
(Monad m, Foldable m) => Foldable (LogicT m) | |
Traversable (LogicT Identity) | |
Applicative (LogicT f) => Alternative (LogicT f) | |
(Monad (LogicT m), MonadIO m) => MonadIO (LogicT m) | |
(MonadPlus (LogicT m), Monad m) => MonadLogic (LogicT m) |
runLogicT :: LogicT m a -> (a -> m r -> m r) -> m r -> m rSource
Runs a LogicT computation with the specified initial success and failure continuations.
observeT :: Monad m => LogicT m a -> m aSource
Extracts the first result from a LogicT computation, failing otherwise.
observeManyT :: Monad m => Int -> LogicT m a -> m [a]Source
Extracts up to a given number of results from a LogicT computation.
observeAllT :: Monad m => LogicT m a -> m [a]Source
Extracts all results from a LogicT computation.
module Control.Monad
module Control.Monad.Trans