diff options
Diffstat (limited to 'tests/concepts/tmonoid.nim')
-rw-r--r-- | tests/concepts/tmonoid.nim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/concepts/tmonoid.nim b/tests/concepts/tmonoid.nim new file mode 100644 index 000000000..e0e19adbc --- /dev/null +++ b/tests/concepts/tmonoid.nim @@ -0,0 +1,25 @@ +discard """ + output: '''true''' +""" + +# bug #3686 + +type Monoid = concept x, y + x + y is type(x) + type(z(type(x))) is type(x) + +proc z(x: typedesc[int]): int = 0 + +echo(int is Monoid) + +# https://github.com/nim-lang/Nim/issues/8126 +type AdditiveMonoid* = concept x, y, type T + x + y is T + + # some redundant checks to test an alternative approaches: + type TT = type(x) + x + y is type(x) + x + y is TT + +doAssert(1 is AdditiveMonoid) + |