Link Search Menu Expand Document

HasPow overview

Added in v1.0.0


Table of contents


utils

HasPow (interface)

The class of values which support exponentiation

Signature

export interface HasPow<A> {
  /**
   * Exponentiates a value
   *
   * ```ts
   * import { Int } from 'fp-ts'
   *
   * const actual = Int.pow(Int(3), Int(3))
   * const expected = Int(2,7)
   *
   * expect(actual).toBe(expected)
   *
   * ```
   */
  readonly pow: (n: A, exponent: A) => A
}

Added in v1.0.0

toPowOf

Pipeable version of [[HasPow.pow]]. Exponentiates a value.

import { Int } from 'fp-ts'

const actual = pipe(Int(3), toPowOf(Int)(3))
const expected = Int(2, 7)

expect(actual).toBe(expected)

Signature

export declare function toPowOf<A>(T: HasPow<A>): (exponent: A) => (n: A) => A

Added in v1.0.0