All files / src/typeclass Dual.ts

66.66% Statements 2/3
100% Branches 0/0
0% Functions 0/1
66.66% Lines 2/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241x                                         1x    
import {Monoid as MO} from '@effect/typeclass'
import type {TypeLambda} from 'effect/HKT'
 
/**
 * @category type lambda
 */
export interface DualTypeLambda extends TypeLambda {
  readonly type: Dual<this['Target']>
}
 
/**
 * A [Monoid](https://github.com/Effect-TS/effect/blob/main/packages/typeclass/src/Monoid.ts)
 * with the `combine` arguments flipped.
 * @category typeclass
 */
export interface Dual<A> extends MO.Monoid<A> {}
 
/**
 * Build the `Dual<A>` of a `Monoid<A>`.
 * @category typeclass
 */
export const fromMonoid = <A>(monoid: MO.Monoid<A>): Dual<A> =>
  MO.reverse(monoid)