HORIZON HASKELLDocslts/ghc-9.14.x99ffbb82026-10-19Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 99ffbb8 · 2026-10-19

Modulemachines-0.7.4Haskell2010

Data.Machine.Plan

Contents
  1. Plans
Synopsis
  • Packagemachines-0.7.4
  • Exports9
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourcePlan.hs

Plans

typetype Plan (k :: Type -> Type) o a = forall (m :: Type -> Type). PlanT k o m a

A Plan k o a is a specification for a pure Machine, that reads inputs selected by k with types based on i, writes values of type o, and has intermediate results of type a.

A Plan k o a can be used as a PlanT k o m a for any Monad m.

It is perhaps easier to think of Plan in its un-cps'ed form, which would look like:

data Plan k o a
  = Done a
  | Yield o (Plan k o a)
  | forall z. Await (z -> Plan k o a) (k z) (Plan k o a)
  | Fail
newtypenewtype PlanT (k :: Type -> Type) o (m :: Type -> Type) a

You can construct a Plan (or PlanT), turning it into a Machine (or MachineT).

Constructors

  • PlanT
    • runPlanT :: forall r. (a -> m r) -> (o -> m r -> m r) -> (forall z. (z -> m r) -> k z -> m r -> m r) -> m r -> m r
Instances12MonadError, MonadReader, MonadState, MonadWriter, MonadTrans, Monad, …
valueexhaust :: Monad m => m (Maybe a) -> PlanT k a m ()

Run a monadic action repeatedly yielding its results, until it returns Nothing.