records
Operations on tuples as heterogeneous record types a la Relational Algebra
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:25 |
Tags
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 objectt1 ==~ t2: check if two tuples are equal regardless of orderto(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 orderlen,hasKey,[],[]=: operations that treat a tuple similar to aTable[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 inkeysconcat(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", ...})