ghc-8.2.2: The GHC API

Copyright | (c) Dan Doel
License | BSD3
Maintainer | dan.doel@gmail.com
Stability | experimental
Portability | non-portable (multi-parameter type classes)
Safe Haskell | Safe
Language | Haskell2010

ListT

Description

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/ListT-icfp2005.pdf).

Synopsis

- newtype ListT m a = ListT {
  - unListT :: forall r. (a -> m r -> m r) -> m r -> m r
  }
- runListT :: ListT m a -> (a -> m r -> m r) -> m r -> m r
- select :: Monad m => [a] -> ListT m a
- fold :: ListT m a -> (a -> m r -> m r) -> m r -> m r

# Documentation

newtype ListT m a #

A monad transformer for performing backtracking computations layered over another monad `m`

Constructors

ListT |

Fields

- unListT :: forall r. (a -> m r -> m r) -> m r -> m r

Instances

Monad (ListT m) # |
Methods (>>=) :: ListT m a -> (a -> ListT m b) -> ListT m b Source # (>>) :: ListT m a -> ListT m b -> ListT m b Source # return :: a -> ListT m a Source # fail :: String -> ListT m a Source #
Functor (ListT f) # |
Methods fmap :: (a -> b) -> ListT f a -> ListT f b Source # (<$) :: a -> ListT f b -> ListT f a Source #
Applicative (ListT f) # |
Methods pure :: a -> ListT f a Source # (<*>) :: ListT f (a -> b) -> ListT f a -> ListT f b Source # liftA2 :: (a -> b -> c) -> ListT f a -> ListT f b -> ListT f c Source # (*>) :: ListT f a -> ListT f b -> ListT f b Source # (<*) :: ListT f a -> ListT f b -> ListT f a Source #
Alternative (ListT f) # |
Methods empty :: ListT f a Source # (<|>) :: ListT f a -> ListT f a -> ListT f a Source # some :: ListT f a -> ListT f [a] Source # many :: ListT f a -> ListT f [a] Source #
MonadPlus (ListT m) # |
Methods mzero :: ListT m a Source # mplus :: ListT m a -> ListT m a -> ListT m a Source #

runListT :: ListT m a -> (a -> m r -> m r) -> m r -> m r #

Runs a ListT computation with the specified initial success and failure continuations.

select :: Monad m => [a] -> ListT m a #

fold :: ListT m a -> (a -> m r -> m r) -> m r -> m r #