tmonoid.nim 434 B

1234567891011121314151617181920212223242526
  1. discard """
  2. output: '''true'''
  3. """
  4. # bug #3686
  5. type Monoid = concept x, y
  6. x + y is type(x)
  7. type(z(type(x))) is type(x)
  8. proc z(x: typedesc[int]): int = 0
  9. echo(int is Monoid)
  10. # https://github.com/nim-lang/Nim/issues/8126
  11. type AdditiveMonoid* = concept x, y, type T
  12. x + y is T
  13. # some redundant checks to test an alternative approaches:
  14. type TT = type(x)
  15. x + y is type(x)
  16. x + y is TT
  17. doAssert(1 is AdditiveMonoid)