package soteria

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Reversible.Make_effectful

Effectful reversible computation for a value of type t. Note that this module is a functor, so that we can create any amount, we are not limited to a unique reversible effect.

I.e. one can do

module Rev1 = Make_effectful (struct
  type t = int
end)

module Rev2 = Make_effectful (struct
  type t = string
end)

let computation () =
  Rev1.save ();
  Rev2.save ();
  Rev1.backtrack ()

let () = Rev1.run ~init:0 @@ fun () -> Rev2.run ~init:"x" @@ computation

Parameters

module M : sig ... end

Signature

type t = M.t
type Effect.t +=
  1. | Backtrack_n : int -> unit Effect.t
  2. | Save : unit Effect.t
  3. | Update : (M.t -> 'a * M.t) -> 'a Effect.t
val backtrack_n : int -> unit

Remove the last n checkpoints.

val save : unit -> unit

Save the current state as a new checkpoint.

val wrap : (M.t -> 'a * M.t) -> unit -> 'a

Apply f to the current state, updating it with the result.

val wrap_read : (M.t -> 'a) -> unit -> 'a

Apply f to the current state without modifying it.

val run : init:M.t -> (unit -> 'a) -> 'a

Execute the effectful computation f with initial state init, handling backtrack, save, and update effects.