Table of contents


Endomorphism (interface)

Signature

export interface Endomorphism<A> {
  (a: A): A
}

Added in v2.0.0

FunctionN (interface)

Signature

export interface FunctionN<A extends Array<unknown>, B> {
  (...args: A): B
}

Example

import { FunctionN } from 'fp-ts/lib/function'

export const sum: FunctionN<[number, number], number> = (a, b) => a + b

Added in v2.0.0

Lazy (interface)

A thunk

Signature

export interface Lazy<A> {
  (): A
}

Added in v2.0.0

Predicate (interface)

Signature

export interface Predicate<A> {
  (a: A): boolean
}

Added in v2.0.0

Refinement (interface)

Signature

export interface Refinement<A, B extends A> {
  (a: A): a is B
}

Added in v2.0.0

unsafeCoerce (constant)

Signature

export const unsafeCoerce: <A, B>(a: A) => B = ...

Added in v2.0.0

absurd (function)

Signature

export function absurd<A>(_: never): A { ... }

Added in v2.0.0

constFalse (function)

A thunk that returns always false

Signature

export const constFalse = (): boolean => ...

Added in v2.0.0

constNull (function)

A thunk that returns always null

Signature

export const constNull = (): null => ...

Added in v2.0.0

constTrue (function)

A thunk that returns always true

Signature

export const constTrue = (): boolean => ...

Added in v2.0.0

constUndefined (function)

A thunk that returns always undefined

Signature

export const constUndefined = (): undefined => ...

Added in v2.0.0

constVoid (function)

A thunk that returns always void

Signature

export const constVoid = (): void => ...

Added in v2.0.0

constant (function)

Signature

export function constant<A>(a: A): Lazy<A> { ... }

Added in v2.0.0

decrement (function)

Signature

export function decrement(n: number): number { ... }

Added in v2.0.0

flip (function)

Flips the order of the arguments of a function of two arguments.

Signature

export function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C { ... }

Added in v2.0.0

flow (function)

Function composition (from left to right).

Signature

export function flow<A extends Array<unknown>, B>(ab: (...a: A) => B): (...a: A) => B
export function flow<A extends Array<unknown>, B, C>(ab: (...a: A) => B, bc: (b: B) => C): (...a: A) => C
export function flow<A extends Array<unknown>, B, C, D>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D
): (...a: A) => D
export function flow<A extends Array<unknown>, B, C, D, E>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E
): (...a: A) => E
export function flow<A extends Array<unknown>, B, C, D, E, F>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F
): (...a: A) => F
export function flow<A extends Array<unknown>, B, C, D, E, F, G>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G
): (...a: A) => G
export function flow<A extends Array<unknown>, B, C, D, E, F, G, H>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H
): (...a: A) => H
export function flow<A extends Array<unknown>, B, C, D, E, F, G, H, I>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I
): (...a: A) => I
export function flow<A extends Array<unknown>, B, C, D, E, F, G, H, I, J>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J
): (...a: A) => J { ... }

Example

import { flow } from 'fp-ts/lib/function'

const len = (s: string): number => s.length
const double = (n: number): number => n * 2

const f = flow(len, double)

assert.strictEqual(f('aaa'), 6)

Added in v2.0.0

identity (function)

Signature

export function identity<A>(a: A): A { ... }

Added in v2.0.0

increment (function)

Signature

export function increment(n: number): number { ... }

Added in v2.0.0

not (function)

Signature

export function not<A>(predicate: Predicate<A>): Predicate<A> { ... }

Added in v2.0.0

tuple (function)

Signature

export function tuple<T extends Array<any>>(...t: T): T { ... }

Added in v2.0.0