trellis

Types

A type representing a formatted table with headers and rows of data

Example

let table = 
  table([user1, user2, user3])
  |> with("Name", Left, { 
    use user <- param
    user.name 
  })
  |> with("Age", Right, {
    use user <- param
    user.age |> int.to_string
  })
pub type Table(value) {
  Table(
    columns: List(Column(value)),
    rows: List(value),
    style: style.Style,
  )
}

Constructors

  • Table(
      columns: List(Column(value)),
      rows: List(value),
      style: style.Style,
    )

Functions

pub fn param(f: fn(a) -> b) -> fn(a) -> b

Helper function to wrap a function for use in column definitions

This is a utility function that can make column definitions more readable when used with partial application

pub fn style(
  table table: Table(a),
  style style: Style,
) -> Table(a)

Set the style of the table

pub fn table(data rows: List(a)) -> Table(a)

Creates a new table with the given rows of data

pub fn to_string(table: Table(a)) -> String

Converts the table to a formatted string representation

Creates a string with Unicode box-drawing characters, properly aligned content, and separators between header and rows

pub fn with(
  table table: Table(a),
  column column: Column(a),
) -> Table(a)

Adds a new column to the table definition

Search Document