logict-state-0.1.1.0: Library for logic programming based on haskell package logict
Copyright(c) Atze Dijkstra
LicenseBSD3
Maintaineratzedijkstra@gmail.com
Stabilityexperimental, (as of 20160218) under development
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.LogicState

Description

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

Documentation

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.

Constructors

LogicStateT 

Fields

Instances

Instances details
Monad m => MonadLogicState (,) gs bs m (LogicStateT gs bs m) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

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 # 
Instance details

Defined in Control.Monad.LogicState

Methods

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 # 
Instance details

Defined in Control.Monad.LogicState

Methods

lift :: Monad m => m a -> LogicStateT gs bs m a #

TransLogicState (gs, bs) (LogicStateT gs bs) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

observeT :: MonadFail 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 # 
Instance details

Defined in Control.Monad.LogicState

Methods

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 #

MonadFail (LogicStateT gs bs m) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

fail :: String -> LogicStateT gs bs m a #

MonadIO m => MonadIO (LogicStateT gs bs m) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

liftIO :: IO a -> LogicStateT gs bs m a #

Alternative (LogicStateT gs bs f) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

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] #

Applicative (LogicStateT gs bs f) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

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 #

Functor (LogicStateT gs bs f) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

fmap :: (a -> b) -> LogicStateT gs bs f a -> LogicStateT gs bs f b #

(<$) :: a -> LogicStateT gs bs f b -> LogicStateT gs bs f a #

Monad (LogicStateT gs bs m) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

(>>=) :: 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 #

MonadPlus (LogicStateT gs bs m) Source # 
Instance details

Defined in Control.Monad.LogicState

Methods

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 # 
Instance details

Defined in Control.Monad.LogicState

Methods

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 #

once :: LogicStateT gs bs m a -> LogicStateT gs bs m a #

lnot :: LogicStateT gs bs m a -> LogicStateT gs bs m () #

ifte :: LogicStateT gs bs m a -> (a -> LogicStateT gs bs m b) -> LogicStateT gs bs m b -> LogicStateT gs bs m b #