records

Operations on tuples as heterogeneous record types a la Relational Algebra

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:25

Installation

nimble install records
choosenim install records
git clone https://github.com/rotu/nim-records

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
records - - - - - - -

Source

Repository https://github.com/rotu/nim-records
Homepage https://github.com/rotu/nim-records
Registry Source nimble_official

README

Strongly typed heterogeneous record types!

Some utility functions can be found in lenientTuple:

  • target <~ source: copy all values from a tuple to another tuple or object
  • t1 ==~ t2: check if two tuples are equal regardless of order
  • to(src:tuple, T:type tuple): convert from a tuple type to another tuple type that differs only in key order
  • =~: assign from one tuple to another with the same keys, possibly in a different order
  • len,hasKey,[],[]=: operations that treat a tuple similar to a Table[static string, typed].

TupleOps has some utility methods to combine and reason about Tuples.

  • tupleKeys(t): return the field names as strings @[k0, k1, ...]
  • project(t, keys): project the tuple onto the selected keys. Returns a tuple with only the given keys.
  • reject(t, keys): reject the given keys, returning a tuple with all keys from t not in keys
  • concat(t1, t2) / &: given two tuples (positional or with non-overlapping keys), return a new tuple combining them. This will fail at compile time if the keys overlap.

Relations has an implementation of relational algebra on Nim named tuples. Viewing a relation as a seq[tuple], the following relational operators are defined:

  • Projection = project(rows, ["someKey", ...])
  • Selection = select(rows, predicate)
  • Natural join = join(rows1, rows2)
  • Rename = rename(rows, {"newKey1":"oldKey1", ...})