úÎBƒ@?      Safe-Inferred6A recursive variant of the prompt monad transformer. )A higher-kinded Either, used in defining . 6Prompt can also be used to define monad transformers. You will notice the lack of a Monad m constraint; this is allowed because Prompt doesn'+t use the underlying monad at all; instead 4the observation function (generally implemented via ) will have the constraint. 9 is for prompts which are dependent on the prompt monad. For example, a  MonadPlus prompt:  data PromptPlus m a where  PromptZero :: PromptPlus m a - PromptPlus :: m a -> m a -> PromptPlus m a  0instance MonadPlus (RecPrompt PromptPlus) where  mzero = prompt PromptZero & mplus x y = prompt (PromptPlus x y) >You can construct a monad very simply with prompt, by putting Call of its effects as terms in a GADT, like the following example:   data PromptState s a where ! Put :: s -> PromptState s ()  Get :: PromptState s s  You then use   to access effects:   :postIncrement :: MonadPrompt (PromptState Int) m => m Int postIncrement =  do x < - prompt Get  prompt (Put (x+1))  return x <The advantage of Prompt over implementing effects directly:  = Prompt is pure; it is only through the observation function * runPromptC that you can cause effects.  You don'/t have to worry about the monad laws; they are 6 correct by construction and you cannot break them. > You can implement several observation functions for the same  type. See, for example,  #http://paste.lisp.org/display/53766 ? where a guessing game is implemented with an IO observation > function for the user, and an AI observation function that ! plays the game automatically. >In these ways Prompt is similar to Unimo, but bind and return <are inlined into the computation, whereas in Unimo they are handled as a term calculus. See  0http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=89  4 is the observation function for prompts. It takes two functions as arguments:   ret: will be called with the final result of the computation, % to convert it to the answer type.  prm7 will be called if there are any effects; it is passed 8 a prompt and a continuation function. prm can apply A the effect requested by the prompt and call the continuation. :In some cases prm can return the answer type directly; it <may be useful to abort the remainder of the computation, or @save off the continuation to be called later. There is a great Eexample of using this to implement a UI for peg solitaire in Bertram  Felgenhauer's post to Haskell-Cafe at  Fhttp://www.haskell.org/pipermail/haskell-cafe/2008-January/038301.html  ; takes a way of converting prompts to an element in a pure 1fashion and calculates the result of the prompt  is similar to  5 but allows the computation to happen in any monad. 8Runs a recursive prompt computation. This is similar to  #, but for recursive prompt types. ARun a recursive prompt computation in a pure fashion, similar to  . ERun a recursive prompt computation in an arbitrary monad, similar to . # runs a prompt monad transformer. îYou can also lift any Prompt computation into a PromptT (or more generally, any appropriate MonadPrompt instance). This is the kind of place where the advantage of being able to use multiple observation functions on Prompt really shows. +Run a recursive prompt monad transformer. ,  -handler when there is no further computation handler for prompts a prompt-based computation answer -handler when there is no further computation handler for prompts a prompt-based computation answer -handler when there is no further computation handler for prompts  handler for lifted computations a prompt-based computation answer -handler when there is no further computation handler for prompts  handler for lifted computations a prompt-based computation answer  !"#$%&'()*+  !    !"#$%&'()*+,       !"#$%&'()MonadPrompt-1.0.0.3Control.Monad.Prompt RecPromptT unRecPromptTLiftEffectPromptT unPromptT RecPrompt unRecPromptPrompt MonadPromptprompt runPromptC runPrompt runPromptM runRecPromptC runRecPrompt runRecPromptM runPromptTliftP runRecPromptTrunP$fMonadTransRecPromptT$fMonadPromptpRecPromptT$fApplicativeRecPromptT$fFunctorRecPromptT$fMonadRecPromptT$fMonadTransPromptT$fMonadPromptpPromptT$fApplicativePromptT$fFunctorPromptT$fMonadPromptT$fMonadPromptpRecPrompt$fApplicativeRecPrompt$fFunctorRecPrompt$fMonadRecPrompt$fMonadPromptpPrompt$fApplicativePrompt$fFunctorPrompt $fMonadPrompt