!"      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~       !Safe&'-.=>?@AHSUVX% extensible-effects'The MSplit primitive from LogicT paper.extensible-effects The laws for  are:71] msplit mzero == return Nothing 2] msplit (return a " m) == return (Just(a, m))extensible-effectsEmbed a pure value into MSplitextensible-effectsiSoft-cut: non-deterministic if-then-else, aka Prolog's *-> Declaratively, ifte t th el = (t >>= th) " ((not t) >> el) However, t is evaluated only once. In other words, ifte t th el is equivalent to t >>= th if t has at least one solution. If t fails, ifte t th el is the same as el.VLaws: 1] ifte (return a) th el == th a 2] ifte mzero th el == el 3] ifte (return a " m) th el == th a " (m >>= th)extensible-effects_Another pruning operation (ifte is the other). This selects one solution out of possibly many.extensible-effectsNegation as failureextensible-effectsIFair (i.e., avoids starvation) disjunction. It obeys the following laws:41] interleave mzero m == m 2] interleave (return a " m1) m2 == return a " (interleave m2 m1)%corollary: interleave m mzero == mextensible-effectsIFair (i.e., avoids starvation) conjunction. It obeys the following laws:&1] mzero >>- k == mzero 2] (return a "' m) >>- k == interleave (k a) (m >>- k) extensible-effects,Collect all solutions. This is from Hinze's BacktrJ monad class. Unsurprisingly, this can be implemented in terms of msplit.*TODO: use a more efficient data structure.   Safe&'-.=>?@AHSUVX-#extensible-effectsLeft-edge deconstruction$extensible-effectsMNon-empty tree. Deconstruction operations make it more and more left-leaning%extensible-effectsThere is no tempty: use (tsingleton return), which works just the same. The names are chosen for compatibility with FastTCQueue&extensible-effectssnoc: clearly constant-time'extensible-effectsappend: clearly constant-time(extensible-effects$Process the Left-edge deconstruction#$%&'() Trustworthy&',-.=>?@ACHSUVXG extensible-effects3This class is used for emulating monad transformers*extensible-effectsRUsing overlapping instances here is OK since this class is private to this module+extensible-effects!Find an index of an element in a list The element must exist This is essentially a compile-time computation. Using overlapping instances here is OK since this class is private to this module extensible-effects9A useful operator for reducing boilerplate in signatures.#The following lines are equivalent. A(Member (Exc e) r, Member (State s) r) => ... [ Exc e, State s ]  ::r = ... extensible-effects#Typeclass that asserts that effect t& is contained inside the effect-list r.The FindElemr typeclass is an implementation detail and not required for using the effect list or implementing custom effects.extensible-effects/The data constructors of Union are not exportedStrong Sum (Existential with the evidence) is an open union t is can be a GADT and hence not necessarily a Functor. Int is the index of t in the list r; that is, the index of t in the universe rextensible-effectswExplicit type-level equality condition is a dirty hack to eliminate the type annotation in the trivial case, such as run (runReader () get).2There is no ambiguity when finding instances for Member t (a ': b ': r)(, which the second instance is selected.-The only case we have to concerned about is  Member t '[s]. But, in this case, values of definition is the same (if present), and the first one is chosen according to GHC User Manual, since the latter one is incoherent. This is the optimal choice.     Trustworthy&',-.=>?@AHPSUVXk3%extensible-effectsYou need this when using catches.extensible-effectsSame as  but with additional , constraintextensible-effectsA convenient alias to 'SetMember Lift (Lift m) r', which allows us to assert that the lifted type occurs ony once in the effect list. extensible-effects%Lifting: emulating monad transformers#extensible-effectsRespond to requests of type t.%extensible-effectsAbstract the recursive &+ pattern, i.e., "somebody else's problem".'extensible-effects8The monad that all effects in this library are based on.KAn effectful computation is a value of type `Eff r a`. In this signature, rs is a type-level list of effects that are being requested and need to be handled inside an effectful computation. a5 is the computation's result similar to other monads.0A computation's result can be retrieved via the >h function. However, all effects used in the computation need to be handled by the use of the effects' run*{ functions before unwrapping the final result. For additional details, see the documentation of the effects you are using.*extensible-effectsAn effectful function from a to bi that is a composition of one or more effectful functions. The paremeter r describes the overall effect.lThe composition members are accumulated in a type-aligned queue. Using a newtype here enables us to define Category and Arrow instances.+extensible-effectsQEffectful arrow type: a function from a to b that also does effects denoted by r-extensible-effectsCconvert single effectful arrow into composable type. i.e., convert + to */extensible-effectsOApplication to the `generalized effectful function' Arrs r b w, i.e., convert * to +0extensible-effectsSyntactic sugar for /1extensible-effectsLift a function to an arrow2extensible-effectsThe identity arrow3extensible-effectsArrow composition4extensible-effectsCommon pattern: append + to *5extensible-effectsCase analysis for ' datatype. If the value is ( a apply the first function to a ; if it is ) u q, apply the second function.-extensible-effects The usual -D fnuction with arguments flipped. This is a common pattern for Eff.6extensible-effects*Case analysis for impure computations for ' datatype. This uses .7extensible-effects*Case analysis for impure computations for ' datatype. This uses .8extensible-effects:Compose effectful arrows (and possibly change the effect!):extensible-effectsmCompose and then apply to function. This is a common pattern when processing requests. Different options of f: allow us to handle or relay the request and continue on.;extensible-effects:Compose effectful arrows (and possibly change the effect!)=extensible-effectsMSend a request and wait for a reply (resulting in an effectful computation).>extensible-effects&Get the result from a pure computationA pure computation has type  Eff '[] aN. The empty effect-list indicates that no further effects need to be handled.?extensible-effectspA convenient pattern: given a request (in an open union), either handle it (using default Handler) or relay it.Handle# implies that all requests of type t are dealt with, i.e., k" (the response type) doesn't have t" as part of its effect list. The  Relay k r constraint ensures that k/ is an effectful computation (with effectlist r).MNote that we can only handle the leftmost effect type (a consequence of the  OpenUnion implementation.@extensible-effectsEA less commonly needed variant with an explicit handler (instead of  Handle t k constraint).Aextensible-effectsOIntercept the request and possibly respond to it, but leave it unhandled. The  Relay k r constraint ensures that k/ is an effectful computation (with effectlist r). As such, the effect type t# will show up in the response type k.Bextensible-effects-A less common variant which uses the default $ from the  Handle t kl instance (in general, we may need to define new datatypes to call respond_relay with the default handler).Cextensible-effectsEmbeds a less-constrained '2 into a more-constrained one. Analogous to MTL's D.Dextensible-effects*embed an operation of type `m a` into the ' monad when Lift m" is in a part of the effect-list.Eextensible-effectsThe handler of Lift requests. It is meant to be terminal: we only allow a single Lifted Monad. Note, too, how this is different from other handlers.Fextensible-effects4Catching of dynamic exceptions See the problem in 4http://okmij.org/ftp/Haskell/misc.html#catch-MonadIOGextensible-effectsCatch multiple dynamic exceptions. The implementation follows that in Control.Exception almost exactly. Not yet tested. Could this be useful for control with cut?.extensible-effectsAs the name suggests, * also has an Arrow instance./extensible-effects*- can be composed and have a natural identity.0extensible-effects3Handle lifted requests by running them sequentially?extensible-effectsreturn@extensible-effectsreturnextensible-effectshandler. !"#$%&'()*1+,-./012345-6789:;<=>?@ABCDEFGSafe&'-.=>?@AHSUVX3   !"#$%&')(*+,-./0123456789:;<=>?@ABCDEFG3')(>576 !"DEFG  #$%&?@ABC=+*,-/012348;<.9:Safe&'-.=>?@AHSUVX  !"'>DEFG>'DEFG !" Safe&'-.=>?@AHSUVXtHextensible-effectsThe Writer monadIn MTL's Writer monad, the told value must have a |Monoid| type. Our writer has no such constraints. If we write a |Writer|-like interpreter to accumulate the told values in a monoid, it will have the |Monoid w| constraint thenJextensible-effectsOHow to interpret a pure value in a writer context, given the value for mempty.Kextensible-effectsWrite a new value.Lextensible-effects#Transform the state being produced.Mextensible-effectsjHandle Writer requests, using a user-provided function to accumulate values, hence no Monoid constraints.Nextensible-effects:Handle Writer requests, using a List to accumulate values.Oextensible-effectsEHandle Writer requests, using a Monoid instance to accumulate values.Pextensible-effects:Handle Writer requests by taking the first value provided.Qextensible-effects6Handle Writer requests by overwriting previous values.Rextensible-effectszHandle Writer requests, using a user-provided function to accumulate values and returning the final accumulated values.Sextensible-effectshHandle Writer requests, using a List to accumulate values and returning the final accumulated values.Textensible-effectssHandle Writer requests, using a Monoid instance to accumulate values and returning the final accumulated values.Uextensible-effectslHandle Writer requests by taking the first value provided and and returning the final accumulated values.Vextensible-effectsdHandle Writer requests by overwriting previous values and returning the final accumulated values.Xextensible-effects_Given a value to write, and a callback (which includes empty and append), respond to requests.HIJKLMNOPQRSTUVHIJKLMPQNORUVSTSafe&'-.=>?@AHSUVXkYextensible-effectsThe Writer monadIn MTL's Writer monad, the told value must have a |Monoid| type. Our writer has no such constraints. If we write a |Writer|-like interpreter to accumulate the told values in a monoid, it will have the |Monoid w| constraint then[extensible-effectsOHow to interpret a pure value in a writer context, given the value for mempty.\extensible-effectsWrite a new value.]extensible-effects#Transform the state being produced.^extensible-effectsjHandle Writer requests, using a user-provided function to accumulate values, hence no Monoid constraints._extensible-effects:Handle Writer requests, using a List to accumulate values.`extensible-effectsEHandle Writer requests, using a Monoid instance to accumulate values.aextensible-effects:Handle Writer requests by taking the first value provided.bextensible-effects6Handle Writer requests by overwriting previous values.cextensible-effectszHandle Writer requests, using a user-provided function to accumulate values and returning the final accumulated values.dextensible-effectshHandle Writer requests, using a List to accumulate values and returning the final accumulated values.eextensible-effectssHandle Writer requests, using a Monoid instance to accumulate values and returning the final accumulated values.fextensible-effectslHandle Writer requests by taking the first value provided and and returning the final accumulated values.gextensible-effectsdHandle Writer requests by overwriting previous values and returning the final accumulated values.iextensible-effects_Given a value to write, and a callback (which includes empty and append), respond to requests.YZ[\]^_`abcdefgYZ[\]^ab_`cfgdeSafe&'-.4=>?@AHSUVXjextensible-effectsTrace effect for debugginglextensible-effects#Embed a pure value in Trace contextmextensible-effectsPrint a string as a trace.nextensible-effectsSRun a computation producing Traces. The handler for IO request: a terminal handleroextensible-effects+Given a callback and request, respond to itjklmnjklmnSafe&'-.=>?@AHSUVXkpextensible-effectsThe Reader monadThe request for a value of type e from the current environment This can be expressed as a GADT because the type of values returned in response to a (Reader e a) request is not any a; we expect in reply the value of type eM, the value from the environment. So, the return type is restricted: 'a ~ e'One can also define this as $data Reader e v = (e ~ v) => Reader 9^ without GADTs, using explicit coercion as is done here. #newtype Reader e v = Reader (e->v) ^ In the latter case, when we make the request, we make it as Reader id. So, strictly speaking, GADTs are not really necessary.rextensible-effects1How to interpret a pure value in a reader contextsextensible-effectsgGet the current value from a Reader. The signature is inferred (when using NoMonomorphismRestriction).textensible-effectsbThe handler of Reader requests. The return type shows that all Reader requests are fully handled.uextensible-effectsLocally rebind the value in the dynamic environment This function is like a relay; it is both an admin for Reader requests, and a requestor of them.vextensible-effects>Request the environment value using a transformation function.xextensible-effectsCGiven a value to read, and a callback, how to respond to requests.pqrstuvpqrsuvt Trustworthy&'-.=>?@AHSUVXk yextensible-effectsAn encapsulated State handler, for transactional semantics The global state is updated only if the transactionState finished successfully{extensible-effects State, strictInitial design: The state request carries with it the state mutator function We can use this request both for mutating and getting the state. But see below for a better design! 3data State s v where State :: (s->s) -> State s sIn this old design, we have assumed that the dominant operation is modify. Perhaps this is not wise. Often, the reader is most nominant.ASee also below, for decomposing the State into Reader and Writer! The conventional design of State~extensible-effectsEmbed a pure value in a stateful computation, i.e., given an initial state, how to interpret a pure value in a stateful computation.extensible-effectsBReturn the current value of the state. The signatures are inferredextensible-effectsWrite a new value of the state.extensible-effectsRun a State effectextensible-effects$Transform the state with a function.extensible-effects/Run a State effect, discarding the final state.extensible-effects.Run a State effect and return the final state.extensible-effects8Embed Transactional semantics to a stateful computation.extensible-effects9Confer transactional semantics on a stateful computation.extensible-effectsA different representation of State: decomposing State into mutation (Writer) and Reading. We don't define any new effects: we just handle the existing ones. Thus we define a handler for two effects together.extensible-effectsHandle 'State s' requestsextensible-effects Initial stateextensible-effectsEffect incorporating Stateextensible-effects0Effect containing final state and a return valueyz{}|~{}|~yz Safe&'-.=>?@AHSUVXk!extensible-effectsThe Reader monadThe request for a value of type e from the current environment This can be expressed as a GADT because the type of values returned in response to a (Reader e a) request is not any a; we expect in reply the value of type eM, the value from the environment. So, the return type is restricted: 'a ~ e'One can also define this as $data Reader e v = (e ~ v) => Reader 9^ without GADTs, using explicit coercion as is done here. #newtype Reader e v = Reader (e->v) ^ In the latter case, when we make the request, we make it as Reader id. So, strictly speaking, GADTs are not really necessary.extensible-effects1How to interpret a pure value in a reader contextextensible-effectsgGet the current value from a Reader. The signature is inferred (when using NoMonomorphismRestriction).extensible-effectsbThe handler of Reader requests. The return type shows that all Reader requests are fully handled.extensible-effectsLocally rebind the value in the dynamic environment This function is like a relay; it is both an admin for Reader requests, and a requestor of them.extensible-effects>Request the environment value using a transformation function.extensible-effectsCGiven a value to read, and a callback, how to respond to requests.  Trustworthy&'-.=>?@AHSUVXk?extensible-effectsAn encapsulated State handler, for transactional semantics The global state is updated only if the transactionState finished successfullyextensible-effects State, lazyInitial design: The state request carries with it the state mutator function We can use this request both for mutating and getting the state. But see below for a better design! 3data State s v where State :: (s->s) -> State s sIn this old design, we have assumed that the dominant operation is modify. Perhaps this is not wise. Often, the reader is most nominant.ASee also below, for decomposing the State into Reader and Writer! The conventional design of Stateextensible-effectsEmbed a pure value in a stateful computation, i.e., given an initial state, how to interpret a pure value in a stateful computation.extensible-effectsBReturn the current value of the state. The signatures are inferredextensible-effectsWrite a new value of the state.extensible-effects$Run a state effect. compared to the runStateL function, this is implemented naively and is expected to perform slower.extensible-effectsCRun a State effect. This variant is a bit optimized compared to  runState'.extensible-effects$Transform the state with a function.extensible-effects/Run a State effect, discarding the final state.extensible-effects.Run a State effect and return the final state.extensible-effects8Embed Transactional semantics to a stateful computation.extensible-effects9Confer transactional semantics on a stateful computation.extensible-effectsA different representation of State: decomposing State into mutation (Writer) and Reading. We don't define any new effects: we just handle the existing ones. Thus we define a handler for two effects together.extensible-effectsHandle 'State s' requestsextensible-effects Initial stateextensible-effectsEffect incorporating Stateextensible-effects0Effect containing final state and a return value  Trustworthy&'-.=>?@AHSUVX\ extensible-effectsState, lazy (i.e., on-demand)Extensible effects make it clear that where the computation is delayed (which I take as an advantage) and they do maintain the degree of extensibility (the delayed computation must be effect-closed, but the whole computation does not have to be).extensible-effectsBReturn the current value of the state. The signatures are inferredextensible-effectsWrite a new value of the state.extensible-effectsRun a State effectextensible-effects$Transform the state with a function.extensible-effects/Run a State effect, discarding the final state.extensible-effects.Run a State effect and return the final state.extensible-effectsA different representation of State: decomposing State into mutation (Writer) and Reading. We don't define any new effects: we just handle the existing ones. Thus we define a handler for two effects together.extensible-effectsBackwards state The overall state is represented with two attributes: the inherited getAttr and the synthesized putAttr. At the root node, putAttr becomes getAttr, tying the knot. As usual, the inherited attribute is the argument (i.e., the  environment?) and the synthesized is the result of the handler |go| below.extensible-effectsA different notion of  backwards9 is realized if we change the Put handler slightly. How?Another implementation, exploring Haskell's laziness to make putAttr also technically inherited, to accumulate the sequence of updates. This implementation is compatible with deep handlers, and lets us play with different notions of  backwardnessextensible-effects)Given a continuation, respond to requestsextensible-effects Initial stateextensible-effectsEffect incorporating Stateextensible-effects0Effect containing final state and a return value Safe&'-.=>?@AEHSUVXcextensible-effectsGeneral form of an interpreterextensible-effectsELift values to an effect. You can think this is a generalization of Lift.extensible-effectsEmbed a pure valueextensible-effectsLift a value to a monad.extensible-effects2Convert values using given interpreter to effects.extensible-effects0Given a continuation and a program, interpret it Safe&'-.=>?@AHSUVXfextensible-effectsDefine data using GADTs.extensible-effects7Then, implements interpreters from the data to effects.Safe&'-.=>?@AHSUVXyG extensible-effectsIA different implementation, more directly mapping to MonadPlus interfaceextensible-effects6How to embed a pure value in non-deterministic contextextensible-effectsThe left branchextensible-effectsThe right branchextensible-effectsAn interpreter The following is very simple, but leaks a lot of memory The cause probably is mapping every failure to empty It takes then a lot of timne and space to store those emptyextensible-effectsA different implementation, more involved but faster and taking much less (100 times) less memory. The benefit of the effect framework is that we can have many interpreters.extensible-effects_Same as makeChoiceA, except it has the type hardcoded. Required for MonadBaseControl instance.extensible-effectsRA different implementation, more involved. Unclear whether this is faster or not.extensible-effectsWe actually implement LogicT, the non-determinism reflection, of which soft-cut is one instance. Straightforward implementation using A*. See the LogicT paper for an explanation.extensible-effects5Given a callback and NdetEff requests respond to them Safe&'-.4=>?@AHSUVXSextensible-effects Create unique Enumerable values.extensible-effectsaEmbed a pure value. Note that this is a specialized form of State's and we could have reused it.extensible-effects6Produce a value that has not been previously produced.extensible-effects&Run an effect requiring unique values.extensible-effects2Given a continuation and requests, respond to themSafe&'-.=>?@AHSUVXextensible-effects Exceptions'exceptions of the type e; no resumptionextensible-effectsEmbed a pure valueextensible-effectsThrow an errorextensible-effectsEThrow an exception in an effectful computation. The type is inferred.extensible-effectsThrow an exception in an effectful computation. The type is unit, which suppresses the ghc-mod warning "A do-notation statement discarded a result of type"extensible-effects?Makes an effect fail, preventing future effects from happening.extensible-effects2Run a computation that might produce an exception.extensible-effects<Runs a failable effect, such that failed computation return 2 , and 3 the return value on success.extensible-effectsRun a computation that might produce exceptions, and give it a way to deal with the exceptions that come up. The handler is allowed to rethrow the exceptionextensible-effectssAdd a default value (i.e. failure handler) to a fallible computation. This hides the fact that a failure happened.extensible-effectsiRun a computation until it produces an exception, and convert and throw that exception in a new context.extensible-effects6Treat Lefts as exceptions and Rights as return values.extensible-effects in a lifted Monadextensible-effectsLift a maybe into the ! effect, causing failure if it's 2.extensible-effects in a lifted Monadextensible-effectsIgnores a failure event. Since the event can fail, you cannot inspect its return type, because it has none on failure. To inspect it, use .extensible-effectsGiven a callback, and an  request, respond to it.extensible-effectsThe fallible computation.extensible-effects"The computation to run on failure.Safe&'-.=>?@AHSUVX extensible-effects-an effectful function that can throw an error @tooBig i = do when (i > 100) $ throwError $ show i return i extensible-effectsrun the tooBig effect based on a provided Int. (runTooBig i = run . runError $ tooBig i  runTooBig 1Right 1 runTooBig 200 Left "200"extensible-effects:an effectul computation using state. The state is of type [Int]. This function takes the head off the list, if it is there and return it. If state is the empty list, then it stays the same and returns Nothing. |popState = do stack <- get case stack of [] -> return Nothing (x : xs) -> do put xs return $ Just x extensible-effectsqrun the popState effectful computation based on initial state. The result-type is the result of the computation  Maybe Int8 together with the state at the end of the computation [Int] .runPopState xs = run . runState xs $ popState runPopState [1, 2, 3](Just 1,[2,3])runPopState [] (Nothing,[])extensible-effects7an effect that returns a number one more than the given noneMore = do x <- ask -- query the environment return $ x + 1 -- add one to the asked value and return it extensible-effectsRun the oneMore1 effectful function by giving it a value to read. +runOneMore i = run . runReader i $ oneMore  runOneMore 12extensible-effects/An effectful computation with multiple effects:A value gets read2an error can be thrown depending on the read valuestate gets read and transformed)All these effects are composed using the Eff- monad using the corresponding Effect types. something = do readValue :: Float <- ask -- read a value from the environment when (readValue < 0) $ throwError readValue -- if the value is negative, throw an error modify (l -> (round readValue :: Integer) : l) -- add the rounded read element to the list currentState :: [Integer] <- get -- get the state after the modification return $ sum currentState -- sum the elements in the list and return that extensible-effectsRun the someting effectful computation given in the previous function. The handlers apply from bottom to top - so this is the reading direction. runSomething1 initialState newValue = run . -- run the Eff-monad with no effects left runError . -- run the error part of the effect. This introduces the Either in the result. runState initialState . -- handle the state-effect providing an initial state giving back a pair. runReader newValue $ -- provide the computation with the dynamic value to read/ask for something -- the computation - function runSomething1 [] (-0.5) Left (-0.5)runSomething1 [2] 1.3Right (3,[1,2])extensible-effectsRun the  something] effectful computation given above. This has an alternative ordering of the effect-handlers.QThe used effect-handlers are the same are used in slightly different order: The runState and runErrorR methods are swapped, which results in a different output type and run-semantics. runSomething1 initialState newValue = run . runState initialState . runError . runReader newValue $ something -- the computation - function runSomething2 [4] (-2.4)(Left (-2.4),[4])runSomething2 [4] 5.9(Right 10,[6,4])3 Safe&',-.=>?@AHSUVXv extensible-effectsJThe datatype for the example from the paper. See the tests for the exampleextensible-effects0specialization to tell the type of the exceptionextensible-effectsMultiple Reader effectsextensible-effects2Write the elements of a list of numbers, in order.extensible-effects+Add a list of numbers to the current state.extensible-effects:Write a list of numbers and add them to the current state.extensible-effectsSum a list of numbers.extensible-effectsaSafely get the last element of a list. Nothing for empty lists; Just the last element otherwise.extensible-effects&Get the last element and sum of a listSafe&'-.4=>?@AHSUVX%extensible-effectsStatus of a thread: done or reporting the value of the type a (For simplicity, a co-routine reports a value but accepts unit)Type parameter r# is the effect we're yielding from.Type parameter a is the type that is yielded.Type parameter wO is the type of the value returned from the coroutine when it has completed. extensible-effectsQCo-routines The interface is intentionally chosen to be the same as in transf.hsq| The yield request: reporting a value of type e and suspending the coroutine. Resuming with the value of type b extensible-effects2Yield a value of type a and suspend the coroutine.extensible-effectsReturn a pure valueextensible-effects%Launch a thread and report its statusextensible-effects1Given a continuation and a request, respond to it          Safe&'-.=>?@AHSUVXextensible-effectsNon-determinism (choice)choose lst non-deterministically chooses one value from the lst choose [] thus corresponds to failure Unlike Reader, Choose is not a GADT because the type of values returned in response to a (Choose a) request is just a, without any constraints.extensible-effectsEmbed a pure valueextensible-effectsfchoose lst non-deterministically chooses one value from the lst choose [] thus corresponds to failureextensible-effects3MonadPlus-like operators are expressible via chooseextensible-effects3MonadPlus-like operators are expressible via chooseextensible-effects4Run a nondeterministic effect, returning all values.extensible-effects3MonadPlus-like operators are expressible via chooseextensible-effects9Given a continuation and a Choose request, respond to it. Safe&'-.=>?@AHSUVX extensible-effectsProlog cutD, taken from Hinze 2000 (Deriving backtracking monad transformers).!extensible-effectsThe interpreter -- it is like reify . reflect with a twist. Compare this implementation with the huge implementation of call in Hinze 2000 (Figure 9). Each clause corresponds to the axiom of call or cutfalse. All axioms are covered.The code clearly expresses the intuition that call watches the choice points of its argument computation. When it encounteres a cutfalse request, it discards the remaining choicepoints. It completely handles CutFalse effects but not non-determinism ! !4 !"#$%&'()*+,-./012345567889:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno_`abcdefghijklmnoppqrstuvwxyz{n|}}~n u v w x y z { n |  } } ~   n     n        nnnnA1extensible-effects-4.0.0.0-IGpSFLObmCI6B8ZN7NjXaDControl.Eff.LogicData.OpenUnionControl.Eff.ExtendControl.Eff.Writer.StrictControl.Eff.Writer.LazyControl.Eff.TraceControl.Eff.Reader.StrictControl.Eff.State.StrictControl.Eff.Reader.LazyControl.Eff.State.LazyControl.Eff.State.OnDemandControl.Eff.OperationalControl.Eff.Operational.ExampleControl.Eff.NdetEffControl.Eff.FreshControl.Eff.ExceptionControl.Eff.QuickStartControl.Eff.ExampleControl.Eff.CoroutineControl.Eff.ChooseControl.Eff.Cut Data.FTCQueueControl.Eff.Internal Control.EffMSplitmsplit withMSplitreflectifteoncegnot interleave>>-sols SetMember<::MemberinjprjUniondecompweaken$fFindElem[]t[]$fFindElem[]t:$fFindElem[]t:0 $fMembertr $fMembert: $fEQUkBoolabp$fEQUkBoolaaTrue$fMemberU'kFalsetagt:$fMemberU'kTruetagtag:$fSetMemberktagt1: HandlerDynE LiftedBaseLiftedLiftunLiftHandlehandleRelayrelayEffValEArrsArrfirstsingleK~^qApp^$arridentcomp^|>eff impureDecomp impurePrjqCompqThenandThenqComps^|$^sendrun handle_relay handle_relay' respond_relayrespond_relay'raiseliftrunLift catchDynE catchesDynEWriterTell withWritertellcensor runWriter runListWriterrunMonoidWriterrunFirstWriter runLastWriter execWriterexecListWriterexecMonoidWriterexecFirstWriterexecLastWriter$fMonadBaseControlmEff$fHandleWriter->Trace withTracetracerunTrace$fHandleTraceIOReaderAsk withReaderask runReaderlocalreader$fHandleReader->TxStateStateGetPut withStategetput runState'runStatemodify evalState execState withTxStatetransactionState runStateR$fHandleState->TxStateT OnDemandStateDelayonDemand runStateBack0 runStateBack$fHandleOnDemandState->Intrprtr runIntrprtrProgram SingletonwithOperational singleton runProgram$fHandleProgram->JailPrintScanprogadventIO adventPureNdetEff withNdetEffleftright makeChoiceA0 makeChoiceA makeChoiceLstmsplit1 $fMSplitEff$fMonadPlusEff$fAlternativeEff$fHandleNdetEffmFresh withFreshfresh runFresh'$fHandleFresh->FailExc withExceptionexc throwError throwError_dierunErrorrunFail catchErroronFail rethrowError liftEither liftEitherM liftMaybe liftMaybeM ignoreFail $fHandleExcmtooBig runTooBigpopState runPopStateoneMore runOneMore something runSomething1 runSomething2MoveTooBig runErrBigsum2writeAllsumAll writeAndAddsumEfflastEff lastAndSumhandUphandDown $fEqTooBig $fShowTooBigYDoneYieldyield withCoroutinerunC$fHandleYieldEffChoose withChoosechoosemzero'mplus' makeChoice$fHandleChoosemCutFalsecutfalse!callbaseGHC.BasemplusViewLFTCQueue tsingleton|>><viewlMaptviewlEQUFindElem,monad-control-1.0.2.3-7nkbYj3vGDkFaD9mDe8p7yControl.Monad.Trans.ControlMonadBaseControlbind $fArrowArrs$fCategoryTYPEArrs $fHandleLiftm GHC.MaybeNothingJust