Abstract

Simple functional combinators.

Synopsis

val |> ^a ^b : (x: a) -> (f: a -> b) -> b
val <| ^a ^b : (f: a -> b) -> (x: a) -> b
val >-> ^a ^b ^c : (f: a -> b) -> (g: b -> c) -> (x: a) -> c
val <-< ^a ^b ^c : (g: b -> c) -> (f: a -> b) -> (x: a) -> c
val flip ^a ^b ^c : (f: a -> b -> c) -> (b: b) -> (a: a) -> c
val curry ^a ^b ^c : (f: (a, b) -> c) -> (a: a) -> (b: b) -> c
val uncurry ^a ^b ^c : (f: a -> b -> c) -> (a, b) -> c
val const ^a ^b : (x: a) -> b -> a
val id ^a : (x: a) -> a
val iterate a : (n: i32) -> (f: a -> a) -> (x: a) -> a
val iterate_until a : (p: a -> bool) -> (f: a -> a) -> (x: a) -> a
val iterate_while a : (p: a -> bool) -> (f: a -> a) -> (x: a) -> a

Description

val |> ^a ^b: (x: a) -> (f: a -> b) -> b

Left-to-right application. Particularly useful for describing computation pipelines:

x |> f |> g |> h
val <| ^a ^b: (f: a -> b) -> (x: a) -> b

Right to left application.

val >-> ^a ^b ^c: (f: a -> b) -> (g: b -> c) -> (x: a) -> c

Function composition, with values flowing from left to right.

val <-< ^a ^b ^c: (g: b -> c) -> (f: a -> b) -> (x: a) -> c

Function composition, with values flowing from right to left. This is the same as the operator known from mathematics.

val flip ^a ^b ^c: (f: a -> b -> c) -> (b: b) -> (a: a) -> c

Flip the arguments passed to a function.

f x y == flip f y x
val curry ^a ^b ^c: (f: (a, b) -> c) -> (a: a) -> (b: b) -> c

Transform a function taking a pair into a function taking two arguments.

val uncurry ^a ^b ^c: (f: a -> b -> c) -> (a, b) -> c

Transform a function taking two arguments in a function taking a pair.

val const ^a ^b: (x: a) -> b -> a

The constant function.

val id ^a: (x: a) -> a

The identity function.

val iterate a: (n: i32) -> (f: a -> a) -> (x: a) -> a

Apply a function some number of times.

val iterate_until a: (p: a -> bool) -> (f: a -> a) -> (x: a) -> a

Keep applying f until p returns true for the input value. May apply zero times. Note: may not terminate.

val iterate_while a: (p: a -> bool) -> (f: a -> a) -> (x: a) -> a

Keep applying f while p returns true for the input value. May apply zero times. Note: may not terminate.