Hyperlinkv0.8.0-beta.28

Newtype

Newtype.makeCombinerconsteffect/Newtype.ts:282
<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
constructorsmakeReducer
Source effect/Newtype.ts:2823 lines
export const makeCombiner: <N extends Newtype.Any>(
  combiner: Combiner.Combiner<Newtype.Carrier<N>>
) => Combiner.Combiner<N> = cast