gxyz/function

Values

pub fn freeze(value: a) -> fn() -> a

freezes a value as an arity 0 function freezes a value as an arity 0 function

: let x = function.freeze(1)
: assert x() == 1
: assert x() == 1
pub fn freeze1(fun: fn(a) -> b, a: a) -> fn() -> b

freezes an arity 1 function and it’s arg as an arity 0 function

pub fn freeze2(fun: fn(a, b) -> c, a: a, b: b) -> fn() -> c

freezes an arity 2 function and it’s arg as an arity 0 function

pub fn freeze3(
  fun: fn(a, b, c) -> d,
  a: a,
  b: b,
  c: c,
) -> fn() -> d

freezes an arity 3 function and it’s arg as an arity 0 function

pub fn freeze4(
  fun: fn(a, b, c, d) -> e,
  a: a,
  b: b,
  c: c,
  d: d,
) -> fn() -> e

freezes an arity 4 function and it’s arg as an arity 0 function

pub fn freeze5(
  fun: fn(a, b, c, d, e) -> f,
  a: a,
  b: b,
  c: c,
  d: d,
  e: e,
) -> fn() -> f

freezes an arity 5 function and it’s arg as an arity 0 function

pub fn iff(condition: Bool, f: fn() -> a, default: a) -> a

calls an arity 0 function if the condition is True, otherwise returns the default value

pub fn iff_nil(condition: Bool, f: fn() -> Nil) -> Nil

calls an arity 0 function if the condition is True, and returns Nil

pub fn ignore_result(
  condition: Bool,
  f: fn() -> Result(a, b),
) -> Nil

calls an arity 0 function if the condition is True, ignores the Result and returns Nil

Search Document