summary refs log blame commit diff stats
path: root/tests/concepts/tvectorspace.nim
blob: 74423e0d25fa9ec2c04e22d4d88fce760d91f899 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                    
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