logict-state-0.1.0.4: 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
LanguageHaskell2010

Control.Monad.LogicState

Contents

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

MonadReader r m => MonadReader r (LogicStateT gs bs m) Source # 

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 # 

Methods

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

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

Methods

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 # 

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 #

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

Methods

backtrack :: LogicStateT gs bs m a -> LogicStateT gs bs m (LogicStateT gs bs m a) Source #

Monad (LogicStateT gs bs m) Source # 

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 #

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

Functor (LogicStateT gs bs f) Source # 

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 #

Applicative (LogicStateT gs bs f) Source # 

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 #

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

Methods

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

Alternative (LogicStateT gs bs f) Source # 

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

MonadPlus (LogicStateT gs bs m) Source # 

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 # 

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 #

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 #