-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Monad transformer for evaluating to a fixpoint
--
-- Monad transformer for evaluating to a fixpoint.
@package transformers-fix
@version 1.0
-- | Monad transformer for evaluating to a fixpoint.
--
-- The idea is that some transforms need to be run multiple times.
-- Deciding whether to run a transform again can be somewhat tedious
-- though, as you cannot necessarily just run some transform f
-- on x until f x == x.
--
-- This might not be ideal for a few reasons:
--
--
-- - x might not implement Eq;
-- - x might implement Eq, but could contain floats
-- of NaN, in which case NaN /= NaN; or
-- - checking equality can be expensive.
--
--
-- Instead, this provides a function called progress, with the
-- same type as return, that marks the current transform as
-- having "made progress": that is, it should be re-run again. Then you
-- can call fixpoint with a function of type a -> FixT m
-- a, which will be re-run until no progress is made.
module Control.Monad.Trans.Fix
-- | Fixpoint monad transformer.
newtype FixT m a
FixT :: m (a, Progress) -> FixT m a
[runFixT] :: FixT m a -> m (a, Progress)
-- | Have we made progress?
data Progress
RunAgain :: Progress
NoProgress :: Progress
-- | Apply the transform until it no longer makes progress
fixpoint :: Monad m => (a -> FixT m a) -> a -> m a
-- | Run a FixT once, regardless of whether it believes it makes progress
-- or not
once :: Monad m => FixT m a -> m a
-- | Take a function that returns Just on progress and
-- Nothing on completion.
fixOfMaybe :: Monad m => (a -> m (Maybe a)) -> a -> FixT m a
-- | Return a value and proclaim: "it might be worth running again"
progress :: Monad m => a -> FixT m a
instance GHC.Show.Show Control.Monad.Trans.Fix.Progress
instance GHC.Classes.Ord Control.Monad.Trans.Fix.Progress
instance GHC.Classes.Eq Control.Monad.Trans.Fix.Progress
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Fix.FixT m)
instance GHC.Base.Monad m => GHC.Base.Functor (Control.Monad.Trans.Fix.FixT m)
instance GHC.Base.Monad m => GHC.Base.Applicative (Control.Monad.Trans.Fix.FixT m)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Fix.FixT