// ets_tracing: off import * as Tp from "../Collections/Immutable/Tuple/index.js" import { pipe } from "../Function/index.js" import { suspend } from "./core.js" import * as D from "./do.js" import type { Effect } from "./effect.js" import * as map from "./map.js" /** * Summarizes a effect by computing some value before and after execution, and * then combining the values to produce a summary, together with the result of * execution. */ export function summarized_( self: Effect, summary: Effect, f: (start: B, end: B) => C, __trace?: string ): Effect> { return suspend( () => pipe( D.do, D.bind("start", () => summary), D.bind("value", () => self), D.bind("end", () => summary), map.map((s) => Tp.tuple(f(s.start, s.end), s.value)) ), __trace ) } /** * Summarizes a effect by computing some value before and after execution, and * then combining the values to produce a summary, together with the result of * execution. * * @ets_data_first summarized_ */ export function summarized( summary: Effect, f: (start: B, end: B) => C, __trace?: string ) { return (self: Effect): Effect> => summarized_(self, summary, f, __trace) }