Copyright | (c) Atze Dijkstra |
---|---|
License | BSD3 |
Maintainer | atzedijkstra@gmail.com |
Stability | experimental, (as of 20160218) under development |
Portability | non-portable |
Safe Haskell | Safe |
Language | Haskell2010 |
A backtracking, logic programming monad partially derived and on top of logict, adding backtrackable state.
LogicT (and thus this library as well) is 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).
Synopsis
- module Control.Monad.Logic.Class
- module Control.Monad
- module Control.Monad.Trans
- module Control.Monad.LogicState.Class
- module Control.Monad.TransLogicState.Class
- type LogicState gs bs = LogicStateT gs bs Identity
- newtype LogicStateT gs bs m a = LogicStateT {
- unLogicStateT :: forall r. LogicContS gs bs r m a
Documentation
module Control.Monad.Logic.Class
module Control.Monad
module Control.Monad.Trans
The LogicState monad
type LogicState gs bs = LogicStateT gs bs Identity Source #
The basic LogicVar monad, for performing backtracking computations
returning values of type a
newtype LogicStateT gs bs m a Source #
A monad transformer for performing backtracking computations
layered over another monad m
, with propagation of global and backtracking state, e.g. resp. for freshness/uniqueness and maintaining variable mappings.
LogicStateT | |
|
Instances
Monad m => MonadLogicState (,) gs bs m (LogicStateT gs bs m) Source # | |
Defined in Control.Monad.LogicState backtrackWithRoll :: (gs -> bs -> bs -> m bs) -> LogicStateT gs bs m a -> LogicStateT gs bs m (LogicStateT gs bs m a) Source # backtrack :: LogicStateT gs bs m a -> LogicStateT gs bs m (LogicStateT gs bs m a) Source # | |
MonadReader r m => MonadReader r (LogicStateT gs bs m) Source # | |
Defined in Control.Monad.LogicState ask :: LogicStateT gs bs m r # local :: (r -> r) -> LogicStateT gs bs m a -> LogicStateT gs bs m a # reader :: (r -> a) -> LogicStateT gs bs m a # | |
MonadTrans (LogicStateT gs bs) Source # | |
Defined in Control.Monad.LogicState lift :: Monad m => m a -> LogicStateT gs bs m a # | |
TransLogicState (gs, bs) (LogicStateT gs bs) Source # | |
Defined in Control.Monad.LogicState observeT :: Monad m => (gs, bs) -> LogicStateT gs bs m a -> m a Source # observeAllT :: Monad m => (gs, bs) -> LogicStateT gs bs m a -> m [a] Source # observeStateAllT :: Monad m => (gs, bs) -> LogicStateT gs bs m a -> m ([a], (gs, bs)) Source # observeManyT :: Monad m => (gs, bs) -> Int -> LogicStateT gs bs m a -> m [a] Source # observeStateManyT :: Monad m => (gs, bs) -> Int -> LogicStateT gs bs m a -> m ([a], (gs, bs)) Source # liftWithState :: Monad m => ((gs, bs) -> m (a, (gs, bs))) -> LogicStateT gs bs m a Source # | |
Monad m => MonadState (gs, bs) (LogicStateT gs bs m) Source # | |
Defined in Control.Monad.LogicState get :: LogicStateT gs bs m (gs, bs) # put :: (gs, bs) -> LogicStateT gs bs m () # state :: ((gs, bs) -> (a, (gs, bs))) -> LogicStateT gs bs m a # | |
Monad (LogicStateT gs bs m) Source # | |
Defined in Control.Monad.LogicState (>>=) :: LogicStateT gs bs m a -> (a -> LogicStateT gs bs m b) -> LogicStateT gs bs m b # (>>) :: LogicStateT gs bs m a -> LogicStateT gs bs m b -> LogicStateT gs bs m b # return :: a -> LogicStateT gs bs m a # fail :: String -> LogicStateT gs bs m a # | |
Functor (LogicStateT gs bs f) Source # | |
Defined in Control.Monad.LogicState fmap :: (a -> b) -> LogicStateT gs bs f a -> LogicStateT gs bs f b # (<$) :: a -> LogicStateT gs bs f b -> LogicStateT gs bs f a # | |
Applicative (LogicStateT gs bs f) Source # | |
Defined in Control.Monad.LogicState pure :: a -> LogicStateT gs bs f a # (<*>) :: LogicStateT gs bs f (a -> b) -> LogicStateT gs bs f a -> LogicStateT gs bs f b # liftA2 :: (a -> b -> c) -> LogicStateT gs bs f a -> LogicStateT gs bs f b -> LogicStateT gs bs f c # (*>) :: LogicStateT gs bs f a -> LogicStateT gs bs f b -> LogicStateT gs bs f b # (<*) :: LogicStateT gs bs f a -> LogicStateT gs bs f b -> LogicStateT gs bs f a # | |
MonadIO m => MonadIO (LogicStateT gs bs m) Source # | |
Defined in Control.Monad.LogicState liftIO :: IO a -> LogicStateT gs bs m a # | |
Alternative (LogicStateT gs bs f) Source # | |
Defined in Control.Monad.LogicState empty :: LogicStateT gs bs f a # (<|>) :: LogicStateT gs bs f a -> LogicStateT gs bs f a -> LogicStateT gs bs f a # some :: LogicStateT gs bs f a -> LogicStateT gs bs f [a] # many :: LogicStateT gs bs f a -> LogicStateT gs bs f [a] # | |
MonadPlus (LogicStateT gs bs m) Source # | |
Defined in Control.Monad.LogicState mzero :: LogicStateT gs bs m a # mplus :: LogicStateT gs bs m a -> LogicStateT gs bs m a -> LogicStateT gs bs m a # | |
Monad m => MonadLogic (LogicStateT gs bs m) Source # | |
Defined in Control.Monad.LogicState msplit :: LogicStateT gs bs m a -> LogicStateT gs bs m (Maybe (a, LogicStateT gs bs m a)) # interleave :: LogicStateT gs bs m a -> LogicStateT gs bs m a -> LogicStateT gs bs m a # (>>-) :: LogicStateT gs bs m a -> (a -> LogicStateT gs bs m b) -> LogicStateT gs bs m b # ifte :: LogicStateT gs bs m a -> (a -> LogicStateT gs bs m b) -> LogicStateT gs bs m b -> LogicStateT gs bs m b # once :: LogicStateT gs bs m a -> LogicStateT gs bs m a # |