string_builder

Functions

arg_int

pub fn arg_int(
  previous: fn(fn(String) -> fn(Int) -> a) -> b,
) -> fn(fn(String) -> a) -> b

Add a placeholder for an Int

Example

let formatter =
  sb.new
  |> sb.arg_int
  |> ...

arg_int_formatter

pub fn arg_int_formatter(
  callback: fn(String) -> a,
) -> fn(Int) -> a

A placeholder for an Int To be used in conjunction with compose

arg_int_list

pub fn arg_int_list(
  previous: fn(fn(String) -> fn(List(Int)) -> a) -> b,
) -> fn(fn(String) -> a) -> b

Add a placeholder for a List(Int)

Example

let formatter =
  sb.new
  |> sb.arg_int_list
  |> ...

arg_int_list_formatter

pub fn arg_int_list_formatter(
  callback: fn(String) -> a,
) -> fn(List(Int)) -> a

A placeholder for a List(Int) To be used in conjunction with compose

arg_string

pub fn arg_string(
  previous: fn(fn(String) -> fn(String) -> a) -> b,
) -> fn(fn(String) -> a) -> b

Add a placeholder for a string

Example

let formatter =
  sb.new
  |> sb.arg_string
  |> ...

arg_string_formatter

pub fn arg_string_formatter(
  callback: fn(String) -> a,
) -> fn(String) -> a

A placeholder for a string To be used in conjunction with compose

compose

pub fn compose(
  previous: fn(fn(String) -> a) -> b,
  next: fn(fn(String) -> c) -> a,
) -> fn(fn(String) -> c) -> b

Compose formatters

Example

let formatter =
  sb.new
  |> sb.string("The current state is ")
  |> sb.compose(custom_state_formatter)

end0

pub fn end0(formatter: fn(fn(a) -> a) -> b) -> fn() -> b

End a formatter with 0 arguments

Example

let formatter =
  sb.new
  |> sb.string("Hello")
  |> sb.end0

end1

pub fn end1(formatter: fn(fn(a) -> a) -> b) -> b

End a formatter with 1 argument

Example

let formatter =
  sb.new
  |> sb.string("Hello ")
  |> sb.arg_string
  |> sb.end1

end2

pub fn end2(
  formatter: fn(fn(a) -> a) -> fn(b) -> fn(c) -> d,
) -> fn(b, c) -> d

End a formatter with 2 arguments

Example

let formatter =
  sb.new
  |> sb.string("Hello ")
  |> sb.arg_string
  |> sb.arg_int
  |> sb.end2

end3

pub fn end3(
  formatter: fn(fn(a) -> a) -> fn(b) -> fn(c) -> fn(d) -> e,
) -> fn(b, c, d) -> e

End a formatter with 3 arguments

Example

let formatter =
  sb.new
  |> sb.string("Hello ")
  |> sb.arg_string
  ...
  |> sb.end3

end4

pub fn end4(
  formatter: fn(fn(a) -> a) ->
    fn(b) -> fn(c) -> fn(d) -> fn(e) -> f,
) -> fn(b, c, d, e) -> f

End a formatter with 4 arguments

Example

let formatter =
  sb.new
  |> sb.string("Hello ")
  |> sb.arg_string
  ...
  |> sb.end4

end5

pub fn end5(
  formatter: fn(fn(a) -> a) ->
    fn(b) -> fn(c) -> fn(d) -> fn(e) -> fn(f) -> g,
) -> fn(b, c, d, e, f) -> g

End a formatter with 5 arguments

Example

let formatter =
  sb.new
  |> sb.string("Hello ")
  |> sb.arg_string
  ...
  |> sb.end5

identity

pub fn identity(s: a) -> a

The identity function This is used when calling a formatter using the curried form

int

pub fn int(
  previous: fn(fn(String) -> a) -> b,
  n: Int,
) -> fn(fn(String) -> a) -> b

Add an Int

Example

let formatter =
  sb.new
  |> sb.int(12)
  |> ...

int_formatter

pub fn int_formatter(n: Int) -> fn(fn(String) -> a) -> a

Format an Int To be used in conjunction with compose

int_list

pub fn int_list(
  previous: fn(fn(String) -> a) -> b,
  l: List(Int),
) -> fn(fn(String) -> a) -> b

Add a List(Int)

Example

let formatter =
  sb.new
  |> sb.int_list([1,2,3])
  |> ...

int_list_formatter

pub fn int_list_formatter(
  l: List(Int),
) -> fn(fn(String) -> a) -> a

Format a List(Int) To be used in conjunction with compose

new

pub fn new(callback: fn(String) -> a) -> a

Start a new formatter

Example

let formatter =
  sb.new
  ...

string

pub fn string(
  previous: fn(fn(String) -> a) -> b,
  str: String,
) -> fn(fn(String) -> a) -> b

Add a string

Example

let formatter =
  sb.new
  |> sb.string("Hello ")

string_formatter

pub fn string_formatter(str: String) -> fn(fn(String) -> a) -> a

Format a String To be used in conjunction with compose