ihb2032/MoonFrame/types does not have a README file

    DataError

    pub(all) suberror DataError {
    ColumnNotFound(String)
    DuplicateColumn(String)
    TypeMismatch(TypeMismatchDetail)
    LengthMismatch(Int, Int)
    IndexOutOfBounds(Int)
    ParseError(ParseErrorDetail)
    InvalidOperation(String)
    IoError(String)
    Unsupported(String)
    NullInNonNullable(String)
    } derive(Eq,
    Debug
    )

    Unified error type for all MoonFrame operations.

    The diagnostic shapes it carries — ParseErrorDetail, TypeMismatchDetail — are #non_exhaustive: a new shape is not a breaking change, and a caller matching those details carries a .. arm for the shapes it does not know. DataError itself stays exhaustive: #non_exhaustive is not supported on a suberror (MoonBit v0.10.14), so a new error kind remains a deliberate, breaking change under the enum-surface lock.
    impl Show for DataError

    DataError::equal

    fn DataError::equal(DataError, DataError) -> Bool

    DataError::message

    fn DataError::message(self : DataError) -> String

    Human-readable message describing the error.

    DataError::not_equal

    fn DataError::not_equal(x : DataError, y : DataError) -> Bool

    DataError::output

    fn DataError::output(self : DataError, logger : &Logger) -> Unit

    DataError::to_string

    fn DataError::to_string(self : DataError) -> String

    CellParseLocation

    pub(all) enum CellParseLocation {
    Row
    Record
    Line
    } derive(Eq,
    Debug
    )

    Identifies how a typed cell's 1-based source position is reported. Row is used by CSV, Record by JSON arrays, and Line by NDJSON.

    CellParseLocation::equal

    CellParseLocation::not_equal

    fn CellParseLocation::not_equal(x : CellParseLocation, y : CellParseLocation) -> Bool

    ClosedInterval

    pub(all) enum ClosedInterval {
    Both
    Left
    Right
    None
    } derive(Eq,
    Debug
    )

    Which endpoints an is_between range includes. Both (the default) is lo <= x <= hi; Left / Right open the other end; None excludes both (lo < x < hi).

    ClosedInterval::equal

    ClosedInterval::not_equal

    fn ClosedInterval::not_equal(x : ClosedInterval, y : ClosedInterval) -> Bool

    DataType

    pub(all) enum DataType {
    Int
    Float
    Bool
    String
    Date
    Timestamp
    Decimal
    Duration
    Null
    } derive(Eq,
    Debug
    )

    Logical data type for a column.

    Null is the dtype of a missing value, not of a column: it is what Scalar::Null.dtype() reports, and so what a TypeMismatch's "expected T, got Null" names when a null cell reaches a typed read. A hand-built Schema may also carry it, but nothing materialises a column on it — DataFrame::empty raises Unsupported for such a field, cast refuses it as a target, and no reader infers it: an all-null probe window falls back to String. Concrete columns always carry one of the other variants.

    A logical dtype is more than its variant: its display name, the physical buffer its columns ride, and its numericity are registered in the dtype registry, whose per-dtype rows are the compile-forced registration point for a dtype added here.
    impl Show for DataType

    DataType::equal

    fn DataType::equal(DataType, DataType) -> Bool

    DataType::is_numeric

    fn DataType::is_numeric(self : DataType) -> Bool

    true for Int and Float — both are usable in numeric reductions. Reads the registry's numeric flag, so an I64-riding dtype like Date is correctly not numeric.

    DataType::is_summable

    fn DataType::is_summable(self : DataType) -> Bool

    Whether the reduction sum accepts the dtype — the registry row it reads states why this is wider than is_numeric for exactly one dtype: a Decimal column folds through the engine's value arithmetic (NaN propagates, an overflow is ±∞), while the approximate statistics stay behind the numeric gate.

    DataType::not_equal

    fn DataType::not_equal(x : DataType, y : DataType) -> Bool

    DataType::output

    fn DataType::output(self : DataType, logger : &Logger) -> Unit

    DataType::to_repr

    DataType::to_string

    fn DataType::to_string(self : DataType) -> String

    Dec128

    pub struct Dec128 {
    // private fields
    } derive(
    Debug
    )

    An IEEE 754 decimal128 value. The fields are the representation, not the API: build values with the constructors (of_int64, parse_opt, …) and read them with the predicates and conversions — neg is the sign bit (true = negative; on NaN it carries nothing), kind names the exceptional shapes (0 finite, 1 infinity, 2 NaN), limbs is the little-endian base-10^9 coefficient, and exp the quantum exponent (the value is ±(Σ limbs[i]·BASE^i)·10^exp).
    impl Eq for Dec128
    impl Show for Dec128
    impl Shrink for Dec128

    Dec128::abs

    fn Dec128::abs(self : Dec128) -> Dec128

    Absolute value — the sign cleared; NaN unchanged.

    Dec128::add

    fn Dec128::add(self : Dec128, other : Dec128) -> Dec128

    Addition. NaN dominates; a like-signed infinity absorbs (opposing ones make the NaN); a zero operand keeps the addends' finer exponent (the preferred exponent) and the round-to-nearest zero sign. Finite pairs align at 33 digits below the coarser exponent — every digit a 34-digit sum can read, one spare for the carry — the digits that fall below the alignment folded into the sticky bit. An exact sum refines to the addends' finer exponent while the format's 34 digits hold.

    Dec128::adjusted_exponent

    fn Dec128::adjusted_exponent(self : Dec128) -> Int?

    The adjusted exponent — exponent + significant digits − 1, the power of ten the leading digit sits at (the ordering magnitude); a zero has no leading digit and answers one below its quantum, and the exceptionals answer None.

    Dec128::canonical

    fn Dec128::canonical(self : Dec128) -> Dec128

    The cohort's canonical member — trailing zeros stripped (a zero keeps an empty coefficient and its sign), so value-equal decimals hash and key alike. The exceptionals are their own canonical shapes.

    Dec128::cmp_total

    fn Dec128::cmp_total(self : Dec128, other : Dec128) -> Int

    The total order the sort and order-statistics read — the decimal twin of the Float stack's: NaN past everything (one NaN bucket), −∞ < finite < +∞, −0 and +0 equal (they are value-equal, and a stable sort keeps their input order), magnitudes ascending.

    Dec128::coefficient_digits

    fn Dec128::coefficient_digits(self : Dec128) -> Array[Int]?

    The coefficient's decimal digits, most significant first, trailing zeros kept — the cohort's own spelling ("150" at exponent −2 is 1.50, not 1.5). Empty for a zero; None on the exceptionals.

    Dec128::div

    fn Dec128::div(self : Dec128, other : Dec128) -> Dec128

    Division. 0/0 and ∞/∞ are the NaN; a nonzero over a zero the signed infinity; a zero over a nonzero the signed zero; an infinity over a finite (or the mirror) the fitting extreme. The finite quotient carries 35 digits before its one rounding (the 35th is the guard a tie reads), and an exact quotient's guard scaling shifts back out toward the preferred exponent — dividend exponent minus divisor exponent.

    Dec128::equal

    fn Dec128::equal(self : Dec128, other : Dec128) -> Bool

    Dec128::exponent

    fn Dec128::exponent(self : Dec128) -> Int?

    The quantum exponent — the power of ten the coefficient scales by; None on the exceptionals (their exponent is not part of the value). A cohort's members differ in exactly this and the coefficient's trailing zeros.

    Dec128::from_double

    fn Dec128::from_double(d : Double) -> Dec128

    A Double as a decimal — the double's shortest round-trip spelling, read back exactly and rounded once into 34 digits; the exceptional doubles map to the exceptional decimals.

    Dec128::ge

    fn Dec128::ge(self : Dec128, other : Dec128) -> Bool

    IEEE greater-or-equal — false whenever either side is NaN.

    Dec128::gt

    fn Dec128::gt(self : Dec128, other : Dec128) -> Bool

    IEEE greater-than — false whenever either side is NaN.

    Dec128::infinity

    fn Dec128::infinity(neg? : Bool) -> Dec128

    An infinity — infinity(neg=true) is −∞.

    Dec128::is_finite

    fn Dec128::is_finite(self : Dec128) -> Bool

    A finite value — the zeroes and the subnormals among them.

    Dec128::is_infinite

    fn Dec128::is_infinite(self : Dec128) -> Bool

    ±∞.

    Dec128::is_nan

    fn Dec128::is_nan(self : Dec128) -> Bool

    NaN — the value that equals nothing, itself included.

    Dec128::is_negative

    fn Dec128::is_negative(self : Dec128) -> Bool

    The sign bit — negative for the negative finite values, −0, and −∞; false on NaN (its sign carries nothing).

    Dec128::is_zero

    fn Dec128::is_zero(self : Dec128) -> Bool

    A zero coefficient — +0 or −0 (never true on the exceptionals).

    Dec128::le

    fn Dec128::le(self : Dec128, other : Dec128) -> Bool

    IEEE less-or-equal — false whenever either side is NaN.

    Dec128::lt

    fn Dec128::lt(self : Dec128, other : Dec128) -> Bool

    IEEE less-than — false whenever either side is NaN.

    Dec128::mul

    fn Dec128::mul(self : Dec128, other : Dec128) -> Dec128

    Multiplication. NaN dominates, an infinity times a zero is the NaN, an infinity times anything else the signed infinity. The finite product is exact in the workspace (68 digits), rounded once, an exact one keeping the operands' exponents' sum — the preferred exponent, cohort trailing zeros and all.

    Dec128::nan

    fn Dec128::nan() -> Dec128

    The NaN — one quiet NaN; the payload the format allows carries nothing a value layer can read.

    Dec128::neg

    fn Dec128::neg(self : Dec128) -> Dec128

    Negation — the sign flipped on the finite values and the zeroes (−0 stays a value); NaN unchanged (its sign carries nothing).

    Dec128::not_equal

    fn Dec128::not_equal(x : Dec128, y : Dec128) -> Bool

    Dec128::of_int64

    fn Dec128::of_int64(v : Int64) -> Dec128

    An integer as a decimal — exact, at exponent zero.

    Dec128::of_int64_scale

    fn Dec128::of_int64_scale(v : Int64, scale~ : Int) -> Dec128

    v × 10^-scale as a decimal — the fixed-point spellings' lift (a parquet DECIMAL cell, an unscaled magnitude under a scale). The value rounds into the format like every finite one.

    Dec128::output

    fn Dec128::output(self : Dec128, logger : &Logger) -> Unit

    Dec128::parse_opt

    fn Dec128::parse_opt(s : String) -> Dec128?

    Parse a decimal spelling — the render's own forms read back exactly: an optional sign, digits with an optional point (.5 among them), an optional decimal exponent [eE][+-]?digits, and the exceptional spellings inf / +inf / -inf / NaN. The significant digits accumulate into the workspace and round once (a hundred-digit literal is a value past 34 significant digits, not a refusal); None for any other shape.

    Dec128::quantize

    fn Dec128::quantize(self : Dec128, places~ : Int) -> Dec128

    Round to places decimal places — the round verb's quantum arithmetic: the result's exponent is exactly −places, the value rounded half-to-even into it (NaN and ±∞ pass through). A finite value whose coefficient cannot hold that exponent (past 34 digits there) is the quantize-invalid shape, a NaN.

    Dec128::shrink

    fn Dec128::shrink(self : Dec128) -> Iter[Dec128]

    Dec128::sub

    fn Dec128::sub(self : Dec128, other : Dec128) -> Dec128

    Subtraction — the subtrahend negated, cohort and sign carried.

    Dec128::to_double

    fn Dec128::to_double(self : Dec128) -> Double

    The value as a Double — the decimal spelling read by the double parser (a correctly-rounded conversion), the exceptionals mapped across, an overflowing finite magnitude to ±∞.

    Dec128::to_int64

    fn Dec128::to_int64(self : Dec128) -> Int64?

    The value as an Int64 — exact when every digit is an integer digit, None otherwise (a fraction, a magnitude past Int64, or an exceptional).

    Dec128::to_repr

    Dec128::to_string

    fn Dec128::to_string(self : Dec128) -> String

    Dec128::trunc

    fn Dec128::trunc(self : Dec128) -> Dec128

    Truncate toward zero — the integer part with the fraction dropped, the magnitude's own digits kept (no rounding); NaN and ±∞ pass through, and a value in (−1, 0) keeps its sign on the zero (IEEE trunc's own −0). The Float → Int cast reads this before its range check, the decimal twin of the double's truncating conversion.

    Dec128::zero

    fn Dec128::zero(neg? : Bool) -> Dec128

    The zeroes — zero() is +0, zero(neg=true) the negative zero the format keeps a sign for.

    Field

    pub struct Field {
    // private fields
    } derive(Eq,
    Debug
    )

    Column metadata: a name, the column's logical DataType, and a declared nullable flag.

    nullable = false is a declared constraint that DataFrame::from_rows enforces: row data placing a Scalar::Null in such a column raises NullInNonNullable(name). (DataFrame::empty builds 0-row columns, so it can never violate the constraint.) The flag is never inferred from a column's contents: the constructor's nullable default — and so DataFrame::DataFrame and the IO readers — always sets nullable = true, so a nullable = false field only ever originates from an explicit Field::Field(..., nullable=false) in a caller-supplied schema.

    Once declared, it travels with the cells it describes. Every operation that moves a column carries its field rather than re-deriving one: Field::rename (and so DataFrame::rename / rename_with, which change nothing but the name), Schema::select / Schema::rename, the row-only frame transforms that reuse their input's schema verbatim (head / tail / slice / filter / sort / unique / fill_null / …), and the projections: a select or with_columns entry that is a bare col("x") (or an aliased one, which carries the field renamed), every column drop or select leaves in place, and the counter-prepending with_row_index. A column replaced through with_columns takes the field of whichever column now supplies its cells.

    An operation that computes cells derives a fresh field instead, with the constructor default: arithmetic, aggregations, cast, fill_null as an expression, group_by(...).agg(...), join (an outer one introduces nulls), and the summary frames (describe / null_count / sum / …). The declaration was made about the input's cells, not about these.

    That split is what keeps the flag honest without ever inspecting a column: it is validated once, by from_rows, and thereafter only accompanies cells it was validated against — the operations that carry it drop, reorder or rename, and never introduce a value.

    The fields are priv, so the struct is opaque outside this package: build one through Field::Field(...) and read it through name() / dtype() / nullable(). That is what actually keeps a future field additive — a readable field is also matchable, and MoonBit requires a struct pattern to name every field or carry .., so a public field's arrival would break a caller's pattern exactly as a new pub(all) enum variant breaks a match.
    impl Show for Field

    Field::Field

    fn Field::Field(name : String, dtype : DataType, nullable? : Bool) -> Field

    Build a field. nullable defaults to true, the common setting for inferred CSV / JSON columns; pass nullable=false to declare the constraint DataFrame::from_rows enforces.

    Field::dtype

    fn Field::dtype(self : Field) -> DataType

    The column's logical DataType.

    Field::equal

    fn Field::equal(Field, Field) -> Bool

    Field::name

    fn Field::name(self : Field) -> String

    The column's name.

    Field::not_equal

    fn Field::not_equal(x : Field, y : Field) -> Bool

    Field::nullable

    fn Field::nullable(self : Field) -> Bool

    The declared nullable flag. DataFrame::from_rows enforces it, raising on a null in a non-nullable column.

    Field::output

    fn Field::output(self : Field, logger : &Logger) -> Unit

    Field::rename

    fn Field::rename(self : Field, new_name : String) -> Field

    Return a copy of this field with a new name.

    Field::to_repr

    Field::to_string

    fn Field::to_string(self : Field) -> String

    ParseErrorDetail

    pub(all) enum ParseErrorDetail {
    Message(String)
    Cell(CellParseLocation, String, Int, DataType, String)
    } derive(Eq,
    Debug
    )

    Structured details carried by DataError::ParseError. #non_exhaustive: a new diagnostic shape here is not a breaking change — a caller matching these details carries a .. arm for the shapes it does not know (the contract the DataError variants naming them inherit).

    ParseErrorDetail::equal

    ParseErrorDetail::not_equal

    fn ParseErrorDetail::not_equal(x : ParseErrorDetail, y : ParseErrorDetail) -> Bool

    RankMethod

    pub(all) enum RankMethod {
    Average
    Min
    Max
    Dense
    Ordinal
    } derive(Eq,
    Debug
    )

    How rank numbers a tie. Over the m sorted non-null cells, a tie group spanning sorted positions [a, b]:

    • Average (the default) — every member gets the mean of a+1 … b+1, a Float rank ([3, 6, 1, 1, 6] ranks 3.0, 4.5, 1.5, 1.5, 4.5);
    • Min — every member gets a+1, competition ranking (gaps follow ties);
    • Max — every member gets b+1;
    • Dense — like Min but the next tie group starts one past the previous group's rank, no gaps;
    • Ordinal — no tie sharing: cells rank 1 … m in input order among equals.

    Null cells stay null under every method (only non-null cells rank). No seeded-random tie-break method exists: its output would be seeded randomness, out of place in a library whose every other verb is deterministic.

    RankMethod::equal

    fn RankMethod::equal(RankMethod, RankMethod) -> Bool

    RankMethod::not_equal

    fn RankMethod::not_equal(x : RankMethod, y : RankMethod) -> Bool

    Scalar

    pub(all) enum Scalar {
    Int(Int64)
    Float(Double)
    Bool(Bool)
    String(String)
    Date(Int64)
    Timestamp(Int64)
    Decimal(Dec128)
    Duration(Int64)
    Null
    } derive(Eq,
    Debug
    )

    A single cell value in a DataFrame.

    Null represents a missing value. The as_* conversions raiseTypeMismatch(Expected(expected, got, "")) on a wrong dtype (got = Null for a nullcell). Comparisons between cells are column-level — an expression'seq / lt / gt` verbs — and their dtype matrix lives on the comparison kernel, not here.

    The Float variant carries a 64-bit Double; the Int variant carries a 64-bit Int64. Use as_float for explicit access; Int is also accepted via numeric promotion to Double. The Date variant carries whole days since the Unix epoch (1970-01-01 = day 0), rendering as an ISO YYYY-MM-DD string.
    impl Show for Scalar

    Scalar::as_bool

    fn Scalar::as_bool(self : Scalar) -> Bool raise DataError

    Bool cells return their value; other concrete variants and Null raise TypeMismatch(Expected(...)).

    Scalar::as_float

    fn Scalar::as_float(self : Scalar) -> Double raise DataError

    Float cells return their Double; Int cells are promoted to Double; other concrete variants and Null raise TypeMismatch(Expected(...)).

    Scalar::as_int

    fn Scalar::as_int(self : Scalar) -> Int64 raise DataError

    Int cells return their Int64; other concrete variants and Null raise TypeMismatch(Expected(...)).

    Scalar::as_string

    fn Scalar::as_string(self : Scalar) -> String raise DataError

    String cells return their value; other concrete variants and Null raise TypeMismatch(Expected(...)).

    Scalar::dtype

    fn Scalar::dtype(self : Scalar) -> DataType

    The DataType corresponding to this value's variant.

    Scalar::equal

    fn Scalar::equal(Scalar, Scalar) -> Bool

    Scalar::is_null

    fn Scalar::is_null(self : Scalar) -> Bool

    true only for the Null (missing-value) variant.

    Scalar::not_equal

    fn Scalar::not_equal(x : Scalar, y : Scalar) -> Bool

    Scalar::output

    fn Scalar::output(self : Scalar, logger : &Logger) -> Unit

    Scalar::to_repr

    Scalar::to_string

    fn Scalar::to_string(self : Scalar) -> String

    Value-style rendering: Int(42) → "42", String("ab") → "ab", Date(0) → "1970-01-01", Null → "". Use the Show impl for the variant-form rendering.

    Schema

    pub struct Schema {
    // private fields
    } derive(Eq,
    Debug
    )

    Ordered list of Fields describing a DataFrame's columns.

    Construction always validates uniqueness of names; once built, a Schema is guaranteed to have no duplicate column names.

    The fields array is priv: build a schema with Schema::Schema and read a copy via fields() / field_names(). External code cannot reach or mutate the backing array, so a validated schema stays valid.

    index is the name→position map behind index_of, and through it field / select / rename. It is derived from fields and built in lock-step with it, never separately: the constructors are the only writers, and each one builds both. Uniqueness is what makes it total — every name maps to exactly the position that carries it — so it is the same validation pass that establishes both. A schema is immutable, so one scan at construction replaces a scan per lookup: resolving c names against a c-column schema was O(c²) while every resolution walked the array, which is the shape a wide select or rename hits.
    impl Show for Schema

    Schema::Schema

    fn Schema::Schema(fields : Array[Field]) -> Schema raise DataError

    Build a schema from a list of fields. raise DuplicateColumn(name) on the first repeated name.

    The input array is copied, so mutating fields after construction cannot alter the schema or break the validated no-duplicates invariant.

    The type's own constructor, like Field::Field — the spelling every canonically-constructed type in MoonFrame uses.

    Schema::equal

    fn Schema::equal(Schema, Schema) -> Bool

    Schema::field

    fn Schema::field(self : Schema, name : String) -> Field raise DataError

    Return the Field for name, or raise ColumnNotFound(name).

    Schema::field_at

    fn Schema::field_at(self : Schema, i : Int) -> Field raise DataError

    Return the Field at position i, or raise IndexOutOfBounds(i).

    Schema::field_names

    fn Schema::field_names(self : Schema) -> Array[String]

    Column names in declaration order.

    Schema::fields

    fn Schema::fields(self : Schema) -> Array[Field]

    Return a snapshot of the schema's fields.

    A fresh array is returned so callers cannot mutate the schema in place and break the "no duplicate names" invariant enforced by Schema::Schema.

    Schema::index_of

    fn Schema::index_of(self : Schema, name : String) -> Int raise DataError

    The index of the column named name, or raise ColumnNotFound(name). O(1) — the name index is built once, when the schema is.

    Schema::is_empty

    fn Schema::is_empty(self : Schema) -> Bool

    true when the schema has no columns.

    Schema::iter2

    fn Schema::iter2(self : Schema) -> Iter2[String, DataType]

    Iterate the fields as (name, dtype) pairs, in declaration order — the for name, dtype in schema spelling. The pairing a field-by-field walk needs without indexing fields() twice per field; the declared nullable flag is a Field-level detail and stays off this face (fields() carries it). The iterator is lazy and yields fresh pairs as the loop advances — a name walked this way is a copy, not the field vector handed out.

    Schema::len

    fn Schema::len(self : Schema) -> Int

    Number of columns in the schema.

    Schema::not_equal

    fn Schema::not_equal(x : Schema, y : Schema) -> Bool

    Schema::output

    fn Schema::output(self : Schema, logger : &Logger) -> Unit

    Schema::rename

    fn Schema::rename(self : Schema, old_name : String, new_name : String) -> Schema raise DataError

    Rename old_name to new_name. Raises if old_name is missing or new_name collides with another existing column.

    Schema::select

    fn Schema::select(self : Schema, names : Array[String]) -> Schema raise DataError

    Project a sub-schema by name, preserving the order of names. Missing names raise ColumnNotFound(name); duplicates inside names raise DuplicateColumn(name).

    Schema::to_repr

    Schema::to_string

    fn Schema::to_string(self : Schema) -> String

    TypeMismatchDetail

    pub(all) enum TypeMismatchDetail {
    Message(String)
    Expected(DataType, DataType, String)
    Operation(String, DataType, DataType)
    } derive(Eq,
    Debug
    )

    Structured details carried by DataError::TypeMismatch. #non_exhaustive: a new diagnostic shape here is not a breaking change — a caller matching these details carries a .. arm for the shapes it does not know (the contract the DataError variants naming them inherit).

    TypeMismatchDetail::equal

    TypeMismatchDetail::not_equal