Logged
Logged:
object
Defined in: Core/Logged.ts:29
Type Declaration
Section titled “Type Declaration”apply: <
L2,A>(arg) => <B,L1>(logged) =>Logged<L2|L1,B>
Applies a function wrapped in a Logged container to an argument wrapped in a Logged container,
concatenating both logs in order.
Type Parameters
Section titled “Type Parameters”L2 = never
A = unknown
Parameters
Section titled “Parameters”Logged<L2, A>
Returns
Section titled “Returns”<B, L1>(logged) => Logged<L2 | L1, B>
- Logged.chain to sequence dependent computations.
- Logged.map to transform values with a plain un-wrapped function.
Example
Section titled “Example”assign
Section titled “assign”assign: <
K,L2,A,B>(key,transform) => <L1>(logged) =>Logged<L2|L1,A&{ [P in string]: B }>
Evaluates a new Logged computation using the current accumulator object and attaches the result to a new key.
Type Parameters
Section titled “Type Parameters”K extends string
L2
A
B
Parameters
Section titled “Parameters”K
transform
Section titled “transform”(value) => Logged<L2, B>
Returns
Section titled “Returns”<L1>(logged) => Logged<L2 | L1, A & { [P in string]: B }>
Logged.assignTo to initiate the accumulator object.
Example
Section titled “Example”assignTo
Section titled “assignTo”assignTo: <
K>(key) => <A,L>(logged) =>Logged<L,{ [P in string]: A }>
Wraps a Logged value in an accumulator record with a single specified key. Initiates the pipeline accumulator object.
Type Parameters
Section titled “Type Parameters”K extends string
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”<A, L>(logged) => Logged<L, { [P in string]: A }>
Logged.assign to attach subsequent values to the accumulator object.
Example
Section titled “Example”chain: <
A,L2,B>(transform) => <L1>(logged) =>Logged<L2|L1,B> =chainLogged
Sequences two Logged computations, concatenating their logs in order.
The value from the first computation is passed to transform.
Type Parameters
Section titled “Type Parameters”A
L2
B
Parameters
Section titled “Parameters”transform
Section titled “transform”(value) => Logged<L2, B>
Returns
Section titled “Returns”<L1>(logged) => Logged<L2 | L1, B>
- Logged.map to transform values without appending new log entries.
- Logged.apply to combine independent computations wrapped in Logged containers.
Example
Section titled “Example”focus: <
S,A>(lens) => <L2,B>(transform) => <L1>(logged) =>Logged<L2|L1,S>
Focuses a Logged computation on a sub-field of a data structure using a Lens, updating the focused property while accumulating any logs generated during the sub-computation.
Type Parameters
Section titled “Type Parameters”S
A
Parameters
Section titled “Parameters”Lens<S, A>
Returns
Section titled “Returns”<L2, B>(transform) => <L1>(logged) => Logged<L2 | L1, S>
- Lens for constructing composable property focus optics.
- Logged.chain to sequence transformations at the root container level.
Example
Section titled “Example”from:
object
from.entry
Section titled “from.entry”entry: <
L>(logEntry) =>Logged<L,undefined> =makeEntry
Creates a Logged container that records a single log entry and sets the value to undefined.
Use this to append to the log inside a chain step.
Type Parameters
Section titled “Type Parameters”L
Parameters
Section titled “Parameters”logEntry
Section titled “logEntry”L
Returns
Section titled “Returns”Logged<L, undefined>
- Logged.make to create a value with an initial log.
- Logged.to.Pair to extract value and log at the boundary.
Example
Section titled “Example”make: <
L,A>(value,log) =>Logged<L,A>
Creates a Logged container with a value and an optional initial log array.
Type Parameters
Section titled “Type Parameters”L = never
A = unknown
Parameters
Section titled “Parameters”A
readonly L[] = []
Returns
Section titled “Returns”Logged<L, A>
- Logged.from.entry to record a single log entry without a value.
- Logged.to.Pair to extract value and logs at the system boundary.
Example
Section titled “Example”map: <
A,B>(transform) => <L>(logged) =>Logged<L,B> =mapLogged
Transforms the value inside a Logged container while preserving accumulated logs.
Type Parameters
Section titled “Type Parameters”A
B
Parameters
Section titled “Parameters”transform
Section titled “transform”(value) => B
Returns
Section titled “Returns”<L>(logged) => Logged<L, B>
- Logged.chain to sequence operations that also produce logs.
- Logged.mapLog to transform the accumulated log entries instead.
Example
Section titled “Example”mapLog
Section titled “mapLog”mapLog: <
L1,L2>(transform) => <A>(logged) =>Logged<L2,A>
Transforms all accumulated log entries with a mapping function while preserving the value.
Type Parameters
Section titled “Type Parameters”L1
L2
Parameters
Section titled “Parameters”transform
Section titled “transform”(logEntry) => L2
Returns
Section titled “Returns”<A>(logged) => Logged<L2, A>
- Logged.map to transform the contained value instead.
- Logged.tapLog to inspect logs without changing them.
Example
Section titled “Example”tap: <
A>(sideEffect) => <L>(logged) =>Logged<L,A>
Runs a side effect on the value without modifying the value or the log.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”sideEffect
Section titled “sideEffect”(value) => void
Returns
Section titled “Returns”<L>(logged) => Logged<L, A>
Logged.tapLog to inspect accumulated logs instead.
Example
Section titled “Example”tapLog
Section titled “tapLog”tapLog: <
L>(sideEffect) => <A>(logged) =>Logged<L,A>
Runs a side effect on the accumulated logs without modifying the value or the log.
Type Parameters
Section titled “Type Parameters”L
Parameters
Section titled “Parameters”sideEffect
Section titled “sideEffect”(log) => void
Returns
Section titled “Returns”<A>(logged) => Logged<L, A>
- Logged.tap to inspect the value instead.
- Logged.mapLog to transform log entries instead.
Example
Section titled “Example”to:
object
to.Pair
Section titled “to.Pair”Pair: <
L,A>(logged) =>Pair<A, readonlyL[]>
Extracts the contained value and accumulated log entries as a Pair<A, ReadonlyArray<L>>.
Type Parameters
Section titled “Type Parameters”L
A
Parameters
Section titled “Parameters”logged
Section titled “logged”Logged<L, A>
Returns
Section titled “Returns”Pair<A, readonly L[]>
- Logged.make to construct a Logged container.
- Logged.from.entry to record standalone entries.