summary refs log tree commit diff stats
path: root/tests/concepts/tvectorspace.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/concepts/tvectorspace.nim')
-rw-r--r--tests/concepts/tvectorspace.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/concepts/tvectorspace.nim b/tests/concepts/tvectorspace.nim
new file mode 100644
index 000000000..7a18c1762
--- /dev/null
+++ b/tests/concepts/tvectorspace.nim
@@ -0,0 +1,19 @@
+discard """
+  joinable: false
+"""
+
+type VectorSpace[K] = concept x, y
+  x + y is type(x)
+  zero(type(x)) is type(x)
+  -x is type(x)
+  x - y is type(x)
+  var k: K
+  k * x is type(x)
+
+proc zero(T: typedesc): T = 0
+
+static:
+  assert float is VectorSpace[float]
+  # assert float is VectorSpace[int]
+  # assert int is VectorSpace
+