Copyright | Oleg Kiselyov Sebastian Fischer David A Roberts |
---|---|

License | BSD3 |

Maintainer | David A Roberts <d@vidr.cc> |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe-Inferred |

Language | Haskell2010 |

This Haskell library provides an implementation of the MonadPlus type class that enumerates results of a non-deterministic computation by interleaving subcomputations in a way that has usually much better memory performance than other strategies with the same termination properties.

By using supensions in strategic positions, the user can ensure that the search does not diverge if there are remaining non-deterministic results.

More information is available on the author's website: http://okmij.org/ftp/Computation/monads.html#fair-bt-stream

Warning: `Stream`

is only a monad when the results of `observeAll`

are interpreted as a multiset, i.e., a valid transformation
according to the monad laws may change the order of the results.

## Synopsis

- data StreamT m a
- type Stream = StreamT Identity
- suspended :: Monad m => StreamT m a -> StreamT m a
- runStream :: Stream a -> [a]
- observe :: Stream a -> a
- observeT :: MonadFail m => StreamT m a -> m a
- observeAll :: Stream a -> [a]
- observeAllT :: Monad m => StreamT m a -> m [a]
- observeMany :: Int -> Stream a -> [a]
- observeManyT :: Monad m => Int -> StreamT m a -> m [a]
- module Control.Monad.Logic.Class

# Documentation

Results of non-deterministic computations of type `StreamT m a`

can be
enumerated efficiently.

#### Instances

suspended :: Monad m => StreamT m a -> StreamT m a Source #

Suspensions can be used to ensure fairness.

runStream :: Stream a -> [a] Source #

Deprecated: use observeAll

The function `runStream`

enumerates the results of a
non-deterministic computation.

observeAll :: Stream a -> [a] Source #

observeAllT :: Monad m => StreamT m a -> m [a] Source #

observeMany :: Int -> Stream a -> [a] Source #

module Control.Monad.Logic.Class