<N extends Newtype.Any>(
combiner: Combiner.Combiner<Newtype.Carrier<N>>
): Combiner.Combiner<N>Lifts a Combiner for the carrier type into a Combiner for the newtype.
When to use
Use when you need to combine newtype-wrapped values with the carrier's combining logic, without manually unwrapping.
Details
The returned combiner delegates to the provided carrier combiner.
Example (Combining newtypes)
import { Combiner, Newtype } from "effect"
interface Amount extends Newtype.Newtype<"Amount", number> {}
const sum = Combiner.make<number>((a, b) => a + b)
const combiner = Newtype.makeCombiner<Amount>(sum)
const iso = Newtype.makeIso<Amount>()
const total = combiner.combine(iso.set(10), iso.set(20))
Newtype.value(total) // 30export const const makeCombiner: <
N extends Newtype.Any
>(
combiner: Combiner.Combiner<Newtype.Carrier<N>>
) => Combiner.Combiner<N>
Lifts a Combiner for the carrier type into a Combiner for the newtype.
When to use
Use when you need to combine newtype-wrapped values with the carrier's
combining logic, without manually unwrapping.
Details
The returned combiner delegates to the provided carrier combiner.
Example (Combining newtypes)
import { Combiner, Newtype } from "effect"
interface Amount extends Newtype.Newtype<"Amount", number> {}
const sum = Combiner.make<number>((a, b) => a + b)
const combiner = Newtype.makeCombiner<Amount>(sum)
const iso = Newtype.makeIso<Amount>()
const total = combiner.combine(iso.set(10), iso.set(20))
Newtype.value(total) // 30
makeCombiner: <function (type parameter) N in <N extends Newtype.Any>(combiner: Combiner.Combiner<Newtype.Carrier<N>>): Combiner.Combiner<N>N extends Newtype.type Newtype<in out Key extends string, out Carrier>.Any = Newtype<any, unknown>A type that matches any Newtype, useful as a generic constraint:
<N extends Newtype.Any>.
When to use
Use as a generic constraint when a type parameter can be any Newtype.
Any>(
combiner: Combiner.Combiner<Newtype.Carrier<N>>(parameter) combiner: {
combine: (self: A, that: A) => A;
}
combiner: import CombinerCombiner.interface Combiner<A>Represents a strategy for combining two values of the same type A. A
Combiner contains a single combine method that takes two values and
returns a merged result. It does not include an identity/empty value; use
Reducer when you need one.
When to use
Use when you need to describe how two values of the same type
merge, pass a reusable combining strategy to library functions like
Struct.makeCombiner or Option.makeCombinerFailFast, or define the
combining step for a Reducer.
Example (Combining numbers with addition)
import { Combiner } from "effect"
const Sum = Combiner.make<number>((self, that) => self + that)
console.log(Sum.combine(3, 4))
// Output: 7
Combiner<Newtype.type Newtype<in out Key extends string, out Carrier>.Carrier<N extends Newtype.Any> = N extends Newtype<infer _Key extends string, infer Carrier> ? Carrier : neverExtracts the carrier (underlying) type from a newtype.
When to use
Use when you need to refer to the wrapped type in generic utilities.
Carrier<function (type parameter) N in <N extends Newtype.Any>(combiner: Combiner.Combiner<Newtype.Carrier<N>>): Combiner.Combiner<N>N>>
) => import CombinerCombiner.interface Combiner<A>Represents a strategy for combining two values of the same type A. A
Combiner contains a single combine method that takes two values and
returns a merged result. It does not include an identity/empty value; use
Reducer when you need one.
When to use
Use when you need to describe how two values of the same type
merge, pass a reusable combining strategy to library functions like
Struct.makeCombiner or Option.makeCombinerFailFast, or define the
combining step for a Reducer.
Example (Combining numbers with addition)
import { Combiner } from "effect"
const Sum = Combiner.make<number>((self, that) => self + that)
console.log(Sum.combine(3, 4))
// Output: 7
Combiner<function (type parameter) N in <N extends Newtype.Any>(combiner: Combiner.Combiner<Newtype.Carrier<N>>): Combiner.Combiner<N>N> = const cast: <A, B>(a: A) => BReturns the input value with a different static type.
When to use
Use when you need an explicit type-level cast and accept that the value is
returned unchanged at runtime.
Gotchas
This is a type-level cast only; it performs no runtime validation or
conversion.
cast