summary refs log blame commit diff stats
path: root/tests/concepts/tvectorspace.nim
blob: 7a18c1762bad4a283ba916435a06bc59ecffaf66 (plain) (tree)
1
2
3
4



                 














                                    
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