Function — Function Combinators

Part of the std module. Available via import std.

Standard function combinators.

Combinators

identity

identity: x:a. a
  x

The identity function. Returns its argument unchanged. Also known as the I combinator.

const

const: x:a. y:b. a
  x

Returns the first argument, ignoring the second. Also known as the Kestrel (K combinator).

flip

flip: f:(a. b. c). b:b. a:a. c
  f a b

Swap the order of a function’s first two arguments.

starling

starling: f:(t. a. b). g:(t. a). t:t. b
  f t (g t)

The S combinator. Applies f to t and the result of g t.

apply

apply: f:(a. b). x:a. b
  f x

Apply a function to a value. Also known as the A combinator or $ in Haskell.

ylppa

ylppa: x:a. f:(a. b). b
  f x

Apply a value to a function (reversed apply). Also known as the Thrush (T combinator) or & in Haskell.

applyBinary

applyBinary: f:(a. b. c). x:a. y:b. c
  f x y

Apply two arguments to a binary function.

curry

curry: f:(a. b. c). x:a. (b. c)
  y. f x y

Partially apply the first argument of a binary function, returning a unary function.

uncurry

uncurry: f:(a. (b. c)). x:a. y:b. c
  f x y

Convert a curried function to take both arguments.

compose

compose: f:(a. b). g:(b. c). a:a. c
  g (f a)

Compose two functions. Applies f first, then g.