package algaeff

  1. Overview
  2. Docs

Useful helper functions for deep handlers.

val finally : ('a, 'b) Algaeff__.StdlibShim.Effect.Deep.continuation -> (unit -> 'a) -> 'b

finally f runs the thunk f and calls continue if a value is returned and discontinue if an exception is raised. Here is an example that calls List.nth and then either returns the found element with continue or raises the exception Not_found with discontinue.

Algaeff.Fun.Deep.finally k @@ fun () -> List.nth elements n
val reperform : ('a, 'b) Algaeff__.StdlibShim.Effect.Deep.continuation -> 'a Algaeff__.StdlibShim.Effect.t -> 'b

reperform k e performs the effect e and then resumes the execution with the continuation k, in a way similar to finally. It relays the result of performing the effect e with continue or discontinue depending on whether an exception is raised.