prospect-0.1.0.0: Explore continuations with trepidation

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Prospect

Contents

Synopsis

Prospecting of free monads

prospect :: (Functor f, Generic1 f, GExplore f (Rep1 f)) => Free f a -> (Maybe a, [f ()]) Source #

Perform a best-effort analysis of a free monad by automatically exploreing it.

survey Source #

Arguments

:: Functor f 
=> (forall b. f (Free f b) -> Free f b)

The following function. Consider using explore to get an automatic implementation for this.

-> Free f a 
-> (Maybe a, [f ()]) 

Perform a best-effort analysis of a free monad.

explore :: forall f a. (Generic1 f, GExplore f (Rep1 f)) => f a -> a Source #

An automatically generated (and unsafe) f-algebra capable of tearing down any functor f with a Generic1 instance. explore will guess its way through any continuations it discovers.

Guesswork

guess :: a Source #

A guess is a bottom whose evaluation can be caught by way of verify or given. It can be used to follow continuations in a free monad until it branches.

given :: Alternative f => (a -> f b) -> a -> f b Source #

Strictly attempt a function application, returning empty if the argument was a guess.

verify :: Alternative f => a -> f a Source #

Attempt to evaluate the pure value a, returning empty if it was a guess.

ensure :: (Alternative f, NFData a) => a -> f a Source #

Like verify, but much stricter.

proceed :: (Alternative f, NFData a) => (a -> f b) -> a -> f b Source #

Like given, but much stricter.

data Guess Source #

The underlying machinery of guess.

Constructors

Guess 
Instances
Eq Guess Source # 
Instance details

Defined in Control.Monad.Prospect

Methods

(==) :: Guess -> Guess -> Bool #

(/=) :: Guess -> Guess -> Bool #

Show Guess Source # 
Instance details

Defined in Control.Monad.Prospect

Methods

showsPrec :: Int -> Guess -> ShowS #

show :: Guess -> String #

showList :: [Guess] -> ShowS #

Exception Guess Source # 
Instance details

Defined in Control.Monad.Prospect