title: How to get the type of a value as string?
body: <p>I would like to know if it is possible to get the type (int32 / float64 / string) from a value in Nim at runtime?</p>
  
  <p>I thought this would be possible with the "typeinfo" library but I can't figure it out!</p>
  
  <p>EDIT: Got an answer and made this real quick:</p>
  
  <pre><code>import typetraits
  
  type
      MyObject = object
          a, b: int
          s: string
  
  let obj = MyObject(a: 3, b: 4, s: "abc")
  
  proc dump_var[T: object](x: T) =
      echo x.type.name, " ("
      for n, v in fieldPairs(x):
          echo("    ", n, ": ", v.type.name, " = ", v)
      echo ")"
  
  dump_var obj
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>MyObject (
      a: int = 3
      b: int = 4
      s: string = abc
  )
  </code></pre>