astar-monad-0.2.1.0

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.AStar.Class

Synopsis

Documentation

class MonadPlus m => MonadAStar w r m | m -> r, m -> w where Source #

A class which represents the ability to do A* search.

The laws aren't completely pinned down yet, but these should probably hold:

It should short-circuit on 'done'
done a >> mx == done a
done a <|> mx == done a

It should fail a branch using `empty`.
empty >> mx == empty
empty <|> mx == mx

It should branch respecting costs using `<|>` from its 'Alternative' instance.
(updateCost 2 >> mx) <|> (updateCost 1 >> my) == mx <|> my

Methods

updateCost :: w -> m () Source #

Update the cost estimate of the current branch and re-evaluate available branches, switching to a cheaper one when appropriate.

done :: r -> m a Source #

Return a solution and short-circuit any remaining branches.

Instances
(Ord w, Monad m) => MonadAStar w r (AStarT s w r m) Source # 
Instance details

Defined in Control.Monad.AStar

Methods

updateCost :: w -> AStarT s w r m () Source #

done :: r -> AStarT s w r m a Source #

branch :: MonadAStar w r m => m a -> m a -> m a Source #

Branch the search.

branch == (<|>)

failure :: MonadAStar w r m => m a Source #

Fail the current branch.

branch == empty