This builds on #23 to solve the problem described in #22:
We modify the MonadLogic interface to maintain a distinction between alternatives and "cleanup operations" that need to be called when backtracking. In particular, a new pureWithCleanup method makes it possible to return a result and register a cleanup operation associated with it, and the type of msplit changes to make it possible to reify both continuations.
unwind now calls pureWithCleanup.
A new LogicT implementation in the Logic.ContUnwind module implements the intended semantics for the extended MonadLogic interface, by adapting the Logic.Cont implementation to use an extra continuation.
As a result, the Spec.Ref tests introduced in #23 pass for this implementation (only).
Feedback on whether this is the correct solution strategy would be very welcome.
This builds on #23 to solve the problem described in #22:
MonadLogic
interface to maintain a distinction between alternatives and "cleanup operations" that need to be called when backtracking. In particular, a newpureWithCleanup
method makes it possible to return a result and register a cleanup operation associated with it, and the type ofmsplit
changes to make it possible to reify both continuations.unwind
now callspureWithCleanup
.LogicT
implementation in theLogic.ContUnwind
module implements the intended semantics for the extendedMonadLogic
interface, by adapting theLogic.Cont
implementation to use an extra continuation.Spec.Ref
tests introduced in #23 pass for this implementation (only).Feedback on whether this is the correct solution strategy would be very welcome.
cc @np