summary refs log tree commit diff stats
path: root/tests/concepts/t5983.nim
blob: e696474483201c33c2b21870de5792968dfac72b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
discard """
  output: "20.0 USD"
"""

import typetraits

const currencies = ["USD", "EUR"] # in real code 120 currencies

type USD* = distinct float # in real code 120 types generates using macro
type EUR* = distinct float

type CurrencyAmount = concept c
  type t = c.type
  const name = c.type.name
  name in currencies

proc `$`(x: CurrencyAmount): string =
  $float(x) & " " & x.name

let amount = 20.USD
echo amount