Skip to content

metagn/knot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

knot

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

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}

About

tie compile-time values to types under names

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages