alexbruf/elm-table/1.0.0

Table.AggregationFn

Built-in aggregation functions, ported from row-aggregation/aggregationFns.ts.

An AggregationFn folds the values of a column over a group's leaf rows. Some also know how to merge the results of child groups, which lets nested groups avoid re-reading every leaf.

Type

A fold over leaf values plus an optional merge of child results.

Built-ins

Sum of Number values; other values count as zero.

Smallest Number or Date; Null when there is none.

Largest Number or Date; Null when there is none.

List [ min, max ], or List [ Null, Null ] when there is no value of a comparable kind.

Arithmetic mean of numeric values; Null when there is none.

Median of Number values; Null when there is none.

Distinct values in first-seen order, as a List.

Number of distinct values.

Number of rows.

First row's value, Null for no rows.

Last row's value, Null for no rows.

Building your own

Build an aggregation from a fold over leaf values.

Add a merge step for child-group results.

Applying

Fold leaf values.

merge : AggregationFn -> Maybe (List Value -> Value)

The merge step, if the aggregation has one.