Skip to content

Logged

Logged<L, A> = WithValue<A> & WithLog<L>

Defined in: Core/Logged.ts:28

A value paired with an accumulated log.

Logged<W, A> pairs a result A with a sequence of log entries W. When you sequence two Logged computations with chain, the logs are automatically concatenated — you never have to thread the log array through your code manually.

L

A

const program = pipe(
  Logged.make<string, number>(0),
  Logged.chain(n => pipe(
    Logged.tell("start"),
    Logged.map(() => n + 1),
  )),
  Logged.chain(n => pipe(
    Logged.tell("done"),
    Logged.map(() => n * 10),
  )),
);

Logged.run(program); // [10, ["start", "done"]]