knot

tie compile-time values to types under names

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

Summary

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

Authors

  • metagn

Installation

nimble install knot
choosenim install knot
git clone https://github.com/metagn/knot

OS Compatibility

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

Dependencies

Package Version Optional
nim >= 1.0.0 No

Source

Repository https://github.com/metagn/knot
Homepage https://github.com/metagn/knot
Registry Source nimble_official

README

knot

Associate compile-time values with a type under a name.

Not developed anymore in favor of the more general library ketin.

import knot

type Foo = object

const bar {.tie: Foo.} = 123

assert Foo.pick(bar) == 123

tie Foo:
  proc baz(x: int): string = "int " & $x
  proc baz(x: float): string = "float " & $x

assert Foo.choice(baz)(123) == "int 123"
assert Foo.choice(baz)(1.23) == "float 1.23"

Foo.tie collection, 1
Foo.tie collection, 2
Foo.tie collection, 3

assert Foo.unravel(collection, []) == [1, 2, 3]
assert Foo.unravel(collection, {}) == {1, 2, 3}

See tests for example uses.